Project

General

Profile

« Previous | Next » 

Revision a735bbbf

Added by Andreas Kohlbecker about 7 years ago

  • ID a735bbbfccc284e24f355551d2496cd15e790243
  • Parent a1dac6b2

ref #5285 attempt to avoid using the CdmSpringContextHelper
using DI to get rid of CdmSpringContextHelper, but got stuck due to the complexity and variety of the 'design patterns' that have been used.

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/util/CdmSpringContextHelper.java
14 14
import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
15 15
import com.vaadin.server.VaadinServlet;
16 16

  
17
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
18
import eu.etaxonomy.cdm.api.service.IClassificationService;
19
import eu.etaxonomy.cdm.api.service.ICommonService;
20
import eu.etaxonomy.cdm.api.service.IDescriptionService;
21
import eu.etaxonomy.cdm.api.service.INameService;
22
import eu.etaxonomy.cdm.api.service.IReferenceService;
23
import eu.etaxonomy.cdm.api.service.IService;
24 17
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
25
import eu.etaxonomy.cdm.api.service.ITaxonService;
26
import eu.etaxonomy.cdm.api.service.ITermService;
27
import eu.etaxonomy.cdm.api.service.IVocabularyService;
28 18

  
29 19
/**
30
 * This helper relates to the problem that in the Vaadin framework it is
20
 * This helper was related to the problem that in the Vaadin framework it was
31 21
 * not possible to autowire beans from the underlying application context
32
 * as Vaadin prevents this possibility. To overcome this problem, this singleton
33
 * helper class has
34
 * been written to retrieve the beans given the bean name.
22
 * as Vaadin preventes this possibility. To overcome this problem, this singleton
23
 * helper class has been written to retrieve the beans given the bean name.
24
 * <p>
25
 * Now that <code>vaadin-spring</code> is being used this class is in principle
26
 * no longer needed. It never the less been kept for some time to continue
27
 * provide the J2EEConnectionPool. Once a clear concept exist about to handle and
28
 * inject it in a proper way this class can be removed completely.
35 29
 *
36 30
 * @author c.mathew
37 31
 *
38
 * TODO This class may no longer needed in a couple of cases since vaadin-spring
32
 * TODO This class may no longer needed in a couple of cases since <code>vaadin-spring</code>
39 33
 * is being used and spring beans can be injected now.
40 34
 *
41 35
 */
......
76 70

  
77 71
    }
78 72

  
79
    public Object getBean(final String beanRef) {
73
    private Object getBean(final String beanRef) {
80 74
        return context.getBean(beanRef);
81 75
    }
82

  
83
    public Object getBean(Class clazz) {
84
        return context.getBean(clazz);
85
    }
86

  
87
    public <T extends IService> T getService(Class<T> clazz) {
76
    
77
    private Object getBean(Class clazz) {
88 78
        return context.getBean(clazz);
89 79
    }
90 80

  
......
104 94
//        return new J2EEConnectionPool(getCurrent().getDataSource());
105 95
//    }
106 96

  
107

  
108

  
109 97
    public static Connection getConnection() throws SQLException {
110 98
        return getCurrent().getDataSource().getConnection();
111 99
    }
......
119 107
        return databaseMetaData;
120 108
    }
121 109

  
122
    public static ICdmApplicationConfiguration getApplicationConfiguration() {
123
        return (ICdmApplicationConfiguration) getCurrent().getBean("cdmApplicationDefaultConfiguration");
124
    }
125
    public static ITaxonService getTaxonService() {
126
        return (ITaxonService)getCurrent().getBean(ITaxonService.class);
127
    }
128

  
110
    @Deprecated
129 111
    public static ITaxonNodeService getTaxonNodeService() {
130 112
        return (ITaxonNodeService)getCurrent().getBean(ITaxonNodeService.class);
131 113
    }
132

  
133
    public static IReferenceService getReferenceService() {
134
        return (IReferenceService)getCurrent().getBean(IReferenceService.class);
135
    }
136

  
137
    public static INameService getNameService() {
138
        return (INameService)getCurrent().getBean(INameService.class);
139
    }
140

  
141
    public static ICommonService getCommonService() {
142
        return (ICommonService)getCurrent().getBean(ICommonService.class);
143
    }
144

  
145
    public static IClassificationService getClassificationService() {
146
        return (IClassificationService)getCurrent().getBean(IClassificationService.class);
147
    }
148

  
149
    public static IVocabularyService getVocabularyService() {
150
        return (IVocabularyService)getCurrent().getBean(IVocabularyService.class);
151
    }
152

  
153
    public static ITermService getTermService() {
154
        return (ITermService)getCurrent().getBean(ITermService.class);
155
    }
156

  
157
    public static IDescriptionService getDescriptionService() {
158
        return (IDescriptionService)getCurrent().getBean(IDescriptionService.class);
159
    }
160

  
161

  
162

  
163 114
}

Also available in: Unified diff