Project

General

Profile

« Previous | Next » 

Revision 6548ea8a

Added by Cherian Mathew almost 9 years ago

  • corrected recursive autowiring
  • changed application context loading to be more performant

View differences:

eu.etaxonomy.taxeditor.cdmlib/.classpath
128 128
	<classpathentry exported="true" kind="lib" path="lib/org.osgi.core-1.0.0.jar"/>
129 129
	<classpathentry exported="true" kind="lib" path="lib/org.springframework.aop-3.2.2.RELEASE.jar"/>
130 130
	<classpathentry exported="true" kind="lib" path="lib/org.springframework.aspects-3.2.2.RELEASE.jar"/>
131
	<classpathentry exported="true" kind="lib" path="lib/org.springframework.beans-3.2.2.RELEASE.jar"/>
132
	<classpathentry exported="true" kind="lib" path="lib/org.springframework.context-3.2.2.RELEASE.jar"/>
131
	<classpathentry exported="true" kind="lib" path="lib/org.springframework.beans-3.2.2.RELEASE.jar" sourcepath="/home/cmathew/.m2/repository/org/springframework/org.springframework.beans/3.2.2.RELEASE/org.springframework.beans-3.2.2.RELEASE-sources.jar"/>
132
	<classpathentry exported="true" kind="lib" path="lib/org.springframework.context-3.2.2.RELEASE.jar" sourcepath="/home/cmathew/.m2/repository/org/springframework/org.springframework.context/3.2.2.RELEASE/org.springframework.context-3.2.2.RELEASE-sources.jar"/>
133 133
	<classpathentry exported="true" kind="lib" path="lib/org.springframework.core-3.2.2.RELEASE.jar"/>
134 134
	<classpathentry exported="true" kind="lib" path="lib/org.springframework.expression-3.2.2.RELEASE.jar"/>
135 135
	<classpathentry exported="true" kind="lib" path="lib/org.springframework.jdbc-3.2.2.RELEASE.jar" sourcepath="lib/org.springframework.jdbc-3.2.2.RELEASE-sources.jar"/>
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java
13 13

  
14 14
import org.apache.log4j.Logger;
15 15
import org.hibernate.SessionFactory;
16
import org.springframework.beans.BeansException;
16 17
import org.springframework.beans.factory.annotation.Autowired;
18
import org.springframework.context.ApplicationContext;
19
import org.springframework.context.ApplicationContextAware;
20
import org.springframework.orm.hibernate4.HibernateTransactionManager;
21
import org.springframework.security.authentication.ProviderManager;
22
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
23
import org.springframework.security.core.Authentication;
24
import org.springframework.security.core.context.SecurityContext;
25
import org.springframework.security.core.context.SecurityContextHolder;
17 26
import org.springframework.stereotype.Component;
18 27
import org.springframework.transaction.PlatformTransactionManager;
19 28
import org.springframework.transaction.TransactionStatus;
20 29

  
21 30
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
22 31
import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
32
import eu.etaxonomy.cdm.api.service.IAgentService;
33
import eu.etaxonomy.cdm.api.service.IClassificationService;
34
import eu.etaxonomy.cdm.api.service.ICollectionService;
35
import eu.etaxonomy.cdm.api.service.ICommonService;
36
import eu.etaxonomy.cdm.api.service.IDatabaseService;
37
import eu.etaxonomy.cdm.api.service.IDescriptionService;
38
import eu.etaxonomy.cdm.api.service.IEntityConstraintViolationService;
39
import eu.etaxonomy.cdm.api.service.IEntityValidationService;
40
import eu.etaxonomy.cdm.api.service.IFeatureNodeService;
41
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
42
import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService;
43
import eu.etaxonomy.cdm.api.service.IGroupService;
44
import eu.etaxonomy.cdm.api.service.IIdentificationKeyService;
45
import eu.etaxonomy.cdm.api.service.ILocationService;
46
import eu.etaxonomy.cdm.api.service.IMediaService;
47
import eu.etaxonomy.cdm.api.service.INameService;
48
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
49
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
50
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
51
import eu.etaxonomy.cdm.api.service.IReferenceService;
52
import eu.etaxonomy.cdm.api.service.IService;
53
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
54
import eu.etaxonomy.cdm.api.service.ITaxonService;
55
import eu.etaxonomy.cdm.api.service.ITermService;
56
import eu.etaxonomy.cdm.api.service.IUserService;
57
import eu.etaxonomy.cdm.api.service.IVocabularyService;
58
import eu.etaxonomy.cdm.api.service.IWorkingSetService;
59
import eu.etaxonomy.cdm.api.service.molecular.IAmplificationService;
60
import eu.etaxonomy.cdm.api.service.molecular.IPrimerService;
61
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
23 62
import eu.etaxonomy.cdm.ext.geo.IEditGeoService;
63
import eu.etaxonomy.cdm.model.common.CdmBase;
64
import eu.etaxonomy.cdm.persistence.hibernate.permission.ICdmPermissionEvaluator;
24 65
import eu.etaxonomy.taxeditor.service.ICachedCommonService;
25 66
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
26 67

  
......
31 72
 *
32 73
 */
33 74
@Component
34
public class CdmApplicationRemoteConfiguration extends CdmApplicationDefaultConfiguration {
75
public class CdmApplicationRemoteConfiguration implements ICdmApplicationConfiguration, ApplicationContextAware  {
35 76

  
36 77
    @SuppressWarnings("unused")
37 78
    private static final Logger logger = Logger.getLogger(CdmApplicationRemoteConfiguration.class);
38 79

  
80
    protected ApplicationContext applicationContext;
81

  
82
    @Autowired
83
    //@Qualifier("nameService")
84
    private INameService nameService;
85
    @Autowired
86
    //@Qualifier("taxonService")
87
    private ITaxonService taxonService;
88
    @Autowired
89
    //@Qualifier("classificationService")
90
    private IClassificationService classificationService;
91
    @Autowired
92
    //@Qualifier("referenceService")
93
    private IReferenceService referenceService;
94
    @Autowired
95
    //@Qualifier("agentService")
96
    private IAgentService agentService;
97
    @Autowired
98
    //@Qualifier("databaseService")
99
    private IDatabaseService databaseService;
100
    @Autowired
101
    //@Qualifier("termService")
102
    private ITermService termService;
103
    //@Autowired
104
    private HibernateTransactionManager transactionManager;
105
    @Autowired
106
    //@Qualifier("descriptionService")
107
    private IDescriptionService descriptionService;
108
    @Autowired
109
    //@Qualifier("occurrenceService")
110
    private IOccurrenceService occurrenceService;
111
    @Autowired
112
    //@Qualifier("primerService")
113
    private IPrimerService primerService;
114
    @Autowired
115
    //@Qualifier("amplificationService")
116
    private IAmplificationService amplificationService;
117
    @Autowired
118
    //@Qualifier("sequenceService")
119
    private ISequenceService sequenceService;
120
    @Autowired
121
    //@Qualifier("mediaService")
122
    private IMediaService mediaService;
123
    @Autowired
124
    //@Qualifier("commonService")
125
    private ICommonService commonService;
126
    @Autowired
127
    private ILocationService locationService;
128
    //@Autowired
129
    private SessionFactory sessionFactory;
130
    //@Autowired
131
    private DataSource dataSource;
132
    @Autowired
133
    private ProviderManager authenticationManager;
134
    @Autowired
135
    private IUserService userService;
136
    @Autowired
137
    private IGrantedAuthorityService grantedAuthorityService;
138
    @Autowired
139
    private IGroupService groupService;
140
    @Autowired
141
    private ICollectionService collectionService;
142
    @Autowired
143
    private IFeatureTreeService featureTreeService;
144
    @Autowired
145
    private IFeatureNodeService featureNodeService;
146
    @Autowired
147
    private IVocabularyService vocabularyService;
39 148
    @Autowired
40
    IEditGeoService editGeoService;
149
    private ITaxonNodeService taxonNodeService;
150
    @Autowired
151
    private IIdentificationKeyService identificationKeyService;
152
    @Autowired
153
    private IPolytomousKeyService polytomousKeyService;
154
    @Autowired
155
    private IPolytomousKeyNodeService polytomousKeyNodeService;
156
    @Autowired
157
    private IEntityValidationService entityValidationService;
158
    @Autowired
159
    private IEntityConstraintViolationService entityConstraintViolationService;
160
    @Autowired
161
    private ICdmPermissionEvaluator permissionEvaluator;
41 162

  
163

  
164

  
165
    @Autowired
166
    private IEditGeoService editGeoService;
42 167
    @Autowired
43 168
    private ICachedCommonService cachedCommonService;
44 169

  
170
    @Autowired
171
    private IWorkingSetService workingSetService;
45 172

  
46 173
    @Autowired
47 174
    protected ICdmEntitySessionManager cdmEntitySessionManager;
48 175

  
49
    public CdmApplicationRemoteConfiguration() {
176
    private IService<CdmBase> mainService;
177

  
178
    public CdmApplicationRemoteConfiguration() {}
179

  
180
    // ****************************** APPLICATION CONTEXT *************************************************/
181

  
182
    @Override
183
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException{
184
        this.applicationContext = applicationContext;
50 185
    }
51 186

  
52 187
    /* (non-Javadoc)
......
58 193
    }
59 194

  
60 195

  
61
    /* (non-Javadoc)
62
     * @see eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration#startTransaction()
196

  
197
    /**
198
     * @return
199
     */
200
    public IEditGeoService getEditGeoService() {
201
        return this.editGeoService;
202
    }
203

  
204
    /**
205
     * @return
63 206
     */
207
    public ICachedCommonService getCachedCommonService(){
208
        return this.cachedCommonService;
209
    }
210

  
211

  
212
    public ICdmEntitySessionManager getCdmEntitySessionManager() {
213
        return this.cdmEntitySessionManager;
214
    }
215

  
216

  
217

  
218

  
219

  
220

  
221
 // ****************************** GETTER *************************************************/
222

  
64 223
    @Override
65
    public TransactionStatus startTransaction() throws UnsupportedOperationException {
66
        throw new UnsupportedOperationException("startTransaction is not implemented for CdmApplicationRemoteConfiguration");
224
    public final Object getBean(String name){
225
        return this.applicationContext.getBean(name);
67 226
    }
68 227

  
228
    @Override
229
    public IAgentService getAgentService(){
230
        return this.agentService;
231
    }
69 232

  
70
    /* (non-Javadoc)
71
     * @see eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration#startTransaction()
72
     */
73 233
    @Override
74
    public TransactionStatus startTransaction(Boolean readOnly) throws UnsupportedOperationException {
75
        throw new UnsupportedOperationException("startTransaction is not implemented for CdmApplicationRemoteConfiguration");
234
    public IDatabaseService getDatabaseService(){
235
        return this.databaseService;
76 236
    }
77 237

  
238
    @Override
239
    public INameService getNameService(){
240
        return this.nameService;
241
    }
78 242

  
79
    /* (non-Javadoc)
80
     * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#commitTransaction(org.springframework.transaction.TransactionStatus)
81
     */
82 243
    @Override
83
    public void commitTransaction(TransactionStatus txStatus) throws UnsupportedOperationException {
84
        throw new UnsupportedOperationException("commitTransaction is not implemented for CdmApplicationRemoteConfiguration");
244
    public IReferenceService getReferenceService(){
245
        return this.referenceService;
246
    }
247

  
248
    @Override
249
    public ITaxonService getTaxonService(){
250
        return this.taxonService;
251
    }
252

  
253
    @Override
254
    public IClassificationService getClassificationService(){
255
        return this.classificationService;
256
    }
257

  
258
    @Override
259
    public ITaxonNodeService getTaxonNodeService(){
260
        return this.taxonNodeService;
261
    }
262

  
263
    @Override
264
    public IDescriptionService getDescriptionService(){
265
        return this.descriptionService;
266
    }
267

  
268
    @Override
269
    public IOccurrenceService getOccurrenceService(){
270
        return this.occurrenceService;
85 271
    }
86 272

  
87
    /* (non-Javadoc)
88
     * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#NewConversation()
89
     */
273
    @Override
274
    public IPrimerService getPrimerService(){
275
        return this.primerService;
276
    }
277

  
278
    @Override
279
    public IAmplificationService getAmplificationService(){
280
        return this.amplificationService;
281
    }
282

  
283
    @Override
284
    public ISequenceService getSequenceService(){
285
        return this.sequenceService;
286
    }
287

  
288
    @Override
289
    public IMediaService getMediaService(){
290
        return this.mediaService;
291
    }
292

  
293
    @Override
294
    public ITermService getTermService(){
295
        return this.termService;
296
    }
297

  
298
    @Override
299
    public ICommonService getCommonService(){
300
        return this.commonService;
301
    }
302

  
303
    @Override
304
    public ILocationService getLocationService(){
305
        return this.locationService;
306
    }
307

  
308
    @Override
309
    public IUserService getUserService(){
310
        return this.userService;
311
    }
312

  
313
    @Override
314
    public IGrantedAuthorityService getGrantedAuthorityService(){
315
        return this.grantedAuthorityService;
316
    }
317

  
318
    @Override
319
    public IService<CdmBase> getMainService(){
320
        return this.mainService;
321
    }
322

  
323

  
324
    @Override
325
    public ProviderManager getAuthenticationManager(){
326
        return this.authenticationManager;
327
    }
328

  
329

  
90 330
    @Override
91 331
    public ConversationHolder NewConversation() {
92 332
        return new ConversationHolderMock();
93 333
    }
94 334

  
95
    /**
96
     * @return
97
     */
98
    public IEditGeoService getEditGeoService() {
99
        return this.editGeoService;
335
    @Override
336
    public ICollectionService getCollectionService(){
337
        return collectionService;
100 338
    }
101 339

  
102
    /**
103
     * @return
104
     */
105
    public ICachedCommonService getCachedCommonService(){
106
        return this.cachedCommonService;
340
    @Override
341
    public IFeatureTreeService getFeatureTreeService(){
342
        return featureTreeService;
107 343
    }
108 344

  
345
    @Override
346
    public IFeatureNodeService getFeatureNodeService(){
347
        return featureNodeService;
348
    }
109 349

  
110
    public ICdmEntitySessionManager getCdmEntitySessionManager() {
111
        return this.cdmEntitySessionManager;
350
    @Override
351
    public IVocabularyService getVocabularyService(){
352
        return vocabularyService;
112 353
    }
113 354

  
114
    /* (non-Javadoc)
115
     * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#setDataSource(javax.sql.DataSource)
116
     */
117 355
    @Override
118
    public void setDataSource(DataSource dataSource) {
356
    public IIdentificationKeyService getIdentificationKeyService(){
357
        return identificationKeyService;
119 358
    }
120 359

  
121
    /* (non-Javadoc)
122
     * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#setTransactionManager(org.springframework.transaction.PlatformTransactionManager)
123
     */
124 360
    @Override
125
    public void setTransactionManager(PlatformTransactionManager transactionManager) {
361
    public IPolytomousKeyService getPolytomousKeyService(){
362
        return polytomousKeyService;
363
    }
364

  
365

  
366
    @Override
367
    public IPolytomousKeyNodeService getPolytomousKeyNodeService(){
368
        return polytomousKeyNodeService;
369
    }
370

  
371
    @Override
372
    public IWorkingSetService getWorkingSetService(){
373
        return workingSetService;
374
    }
375

  
376
    @Override
377
    public IGroupService getGroupService(){
378
        return groupService;
379
    }
380

  
381

  
382
    @Override
383
    public IEntityValidationService getEntityValidationService(){
384
        return entityValidationService;
385
    }
386

  
387

  
388
    @Override
389
    public IEntityConstraintViolationService getEntityConstraintViolationService(){
390
        return entityConstraintViolationService;
391
    }
392

  
393
    @Override
394
    public ICdmPermissionEvaluator getPermissionEvaluator(){
395
        return permissionEvaluator;
396
    }
397

  
398

  
399
    @Override
400
    public TransactionStatus startTransaction() throws UnsupportedOperationException {
401
        throw new UnsupportedOperationException("startTransaction is not implemented for CdmApplicationRemoteConfiguration");
402
    }
403

  
404
    @Override
405
    public TransactionStatus startTransaction(Boolean readOnly) throws UnsupportedOperationException {
406
        throw new UnsupportedOperationException("startTransaction is not implemented for CdmApplicationRemoteConfiguration");
407
    }
408

  
409

  
410
    @Override
411
    public void commitTransaction(TransactionStatus txStatus) throws UnsupportedOperationException {
412
        throw new UnsupportedOperationException("commitTransaction is not implemented for CdmApplicationRemoteConfiguration");
126 413
    }
127 414

  
128
    /* (non-Javadoc)
129
     * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#setSessionFactory(org.hibernate.SessionFactory)
130
     */
131 415
    @Override
132
    public void setSessionFactory(SessionFactory sessionFactory) {
416
    public void authenticate(String username, String password){
417
        UsernamePasswordAuthenticationToken tokenForUser = new UsernamePasswordAuthenticationToken(username, password);
418
        Authentication authentication = this.getAuthenticationManager().authenticate(tokenForUser);
419
        SecurityContext context = SecurityContextHolder.getContext();
420
        context.setAuthentication(authentication);
133 421
    }
134 422
}
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteController.java
1 1
/**
2
* Copyright (C) 2014 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
2
 * Copyright (C) 2014 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9 9

  
10 10

  
11 11
package eu.etaxonomy.cdm.api.application;
......
16 16
import org.apache.log4j.Logger;
17 17
import org.hibernate.collection.internal.AbstractPersistentCollection;
18 18
import org.hibernate.proxy.AbstractLazyInitializer;
19
import org.springframework.beans.MutablePropertyValues;
20
import org.springframework.beans.factory.config.BeanDefinition;
21 19
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
22 20
import org.springframework.context.ApplicationListener;
21
import org.springframework.context.support.GenericApplicationContext;
23 22
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
24 23
import org.springframework.core.io.ClassPathResource;
25 24
import org.springframework.core.io.Resource;
26 25

  
27
import eu.etaxonomy.cdm.api.application.CdmApplicationController;
28
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration;
29
import eu.etaxonomy.cdm.api.application.RemotingMonitoredGenericApplicationContext;
30 26
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
31 27
import eu.etaxonomy.cdm.common.monitor.NullProgressMonitor;
32
import eu.etaxonomy.cdm.common.monitor.SubProgressMonitor;
33 28
import eu.etaxonomy.taxeditor.remoting.cache.CdmModelCacher;
34 29
import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
35
import eu.etaxonomy.taxeditor.session.CdmEntitySessionManager;
36 30
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
37 31

  
38 32
/**
......
47 41

  
48 42
    private static final Logger logger = Logger.getLogger(CdmApplicationRemoteController.class);
49 43

  
50
	
44

  
51 45
    public static final Resource DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE =
52
    		new ClassPathResource("/eu/etaxonomy/cdm/remotingApplicationContext.xml");
46
            new ClassPathResource("/eu/etaxonomy/cdm/remotingApplicationContext.xml");
53 47
    private final Resource applicationContextResource;
54 48
    private final IProgressMonitor progressMonitor;
55 49

  
56
    
50

  
57 51
    /**
58 52
     * Creates new instance of CdmApplicationRemoteController
59 53
     *
......
65 59
     * @return
66 60
     */
67 61
    public static CdmApplicationRemoteController NewInstance(Resource applicationContextResource,
68
			ICdmRemoteSource remoteSource,
69
			boolean omitTermLoading,
70
			IProgressMonitor progressMonitor,
71
			List<ApplicationListener> listeners) {
72
    	return new CdmApplicationRemoteController(applicationContextResource,
73
    			remoteSource,
74
    			omitTermLoading,
75
    			progressMonitor,
76
				listeners);
62
            ICdmRemoteSource remoteSource,
63
            boolean omitTermLoading,
64
            IProgressMonitor progressMonitor,
65
            List<ApplicationListener> listeners) {
66
        return new CdmApplicationRemoteController(applicationContextResource,
67
                remoteSource,
68
                omitTermLoading,
69
                progressMonitor,
70
                listeners);
77 71

  
78 72
    }
79 73
    /**
......
87 81
     * @return
88 82
     */
89 83
    public static CdmApplicationRemoteController NewInstance(ICdmRemoteSource remoteSource,
90
			boolean omitTermLoading,
91
			IProgressMonitor progressMonitor,
92
			List<ApplicationListener> listeners) {
84
            boolean omitTermLoading,
85
            IProgressMonitor progressMonitor,
86
            List<ApplicationListener> listeners) {
93 87

  
94
    	return new CdmApplicationRemoteController(DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE,
95
    			remoteSource,
96
    			omitTermLoading,
97
    			progressMonitor,
98
				listeners);
88
        return new CdmApplicationRemoteController(DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE,
89
                remoteSource,
90
                omitTermLoading,
91
                progressMonitor,
92
                listeners);
99 93

  
100 94
    }
101 95

  
102
	/**
103
	 * Constructs CdmApplicationRemoteController
104
	 *
105
	 * @param applicationContextResource
106
	 * @param remoteSource
107
	 * @param omitTermLoading
108
	 * @param progressMonitor
109
	 * @param listeners
110
	 */
111
	private CdmApplicationRemoteController(Resource applicationContextResource,
112
				ICdmRemoteSource remoteSource,
113
				boolean omitTermLoading,
114
				IProgressMonitor progressMonitor,
115
				List<ApplicationListener> listeners){
116
		logger.info("Start CdmApplicationRemoteController with remote source: " + remoteSource.getName());
96
    /**
97
     * Constructs CdmApplicationRemoteController
98
     *
99
     * @param applicationContextResource
100
     * @param remoteSource
101
     * @param omitTermLoading
102
     * @param progressMonitor
103
     * @param listeners
104
     */
105
    private CdmApplicationRemoteController(Resource applicationContextResource,
106
            ICdmRemoteSource remoteSource,
107
            boolean omitTermLoading,
108
            IProgressMonitor progressMonitor,
109
            List<ApplicationListener> listeners){
110
        logger.info("Start CdmApplicationRemoteController with remote source: " + remoteSource.getName());
117 111
        this.applicationContextResource =
118
        		applicationContextResource != null ? applicationContextResource : DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE;
112
                applicationContextResource != null ? applicationContextResource : DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE;
119 113
        this.progressMonitor = progressMonitor != null ? progressMonitor : new NullProgressMonitor();
120 114

  
121 115
        setNewRemoteSource(remoteSource, omitTermLoading, listeners);
122 116

  
123
	}
117
    }
124 118

  
125 119

  
126 120

  
......
134 128
     * @return
135 129
     */
136 130
    protected boolean setNewRemoteSource(ICdmRemoteSource remoteSource,
137
    		boolean omitTermLoading,
138
    		List<ApplicationListener> listeners){
131
            boolean omitTermLoading,
132
            List<ApplicationListener> listeners){
139 133

  
140 134
        logger.info("Connecting to '" + remoteSource.getName() + "'");
141 135

  
142
        RemotingMonitoredGenericApplicationContext applicationContext =  new RemotingMonitoredGenericApplicationContext();
143
        int refreshTasks = 45;
144
        int nTasks = 5 + refreshTasks;
136
        GenericApplicationContext applicationContext
137
            = generateApplicationContext(applicationContextResource, listeners, progressMonitor, false);
145 138

  
146
        progressMonitor.beginTask("Connecting to '" + remoteSource.getName() + "'", nTasks);
147 139

  
148
        progressMonitor.subTask("Registering remote source.");
149 140
        PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
150 141
        Properties properties = new Properties();
151 142
        properties.setProperty("remoteServer", remoteSource.getServer());
......
153 144
        properties.setProperty("remoteContext", remoteSource.getContextPath());
154 145
        pspc.setProperties(properties);
155 146
        applicationContext.addBeanFactoryPostProcessor(pspc);
147
        //progressMonitor.beginTask("Connecting to '" + remoteSource.getName() + "'", nTasks);
148
        applicationContext.refresh();
149
        applicationContext.start();
150

  
151

  
152
        progressMonitor.subTask("Cleaning up.");
153
        setApplicationContext(applicationContext);
154
        progressMonitor.worked(1);
155

  
156
        progressMonitor.done();
157
        return true;
158
    }
159

  
160
    public static GenericApplicationContext generateApplicationContext(Resource applicationContextResource,
161
            List<ApplicationListener> listeners,
162
            IProgressMonitor progressMonitor,
163
            boolean validateXml) {
164
        RemotingMonitoredGenericApplicationContext applicationContext =  new RemotingMonitoredGenericApplicationContext();
165
        int refreshTasks = 45;
166
        int nTasks = 5 + refreshTasks;
167

  
168
        progressMonitor.subTask("Registering remote source.");
156 169
        applicationContext.getEnvironment().setActiveProfiles("remoting");
157 170
        progressMonitor.worked(1);
158 171

  
159 172
        XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(applicationContext);
160
        //xmlReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
173
        if(!validateXml) {
174
            xmlReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
175
        }
161 176
        progressMonitor.subTask("Registering resources.");
162 177
        xmlReader.loadBeanDefinitions(applicationContextResource);
163 178
        progressMonitor.worked(1);
164 179

  
165
        //omitTerms
166
        if (omitTermLoading == true){
167
            String initializerName = "persistentTermInitializer";
168
            BeanDefinition beanDef = applicationContext.getBeanDefinition(initializerName);
169
            MutablePropertyValues values = beanDef.getPropertyValues();
170
            values.addPropertyValue("omit", omitTermLoading);
171
        }
172

  
173 180
        if (listeners != null){
174 181
            for(ApplicationListener listener : listeners){
175 182
                applicationContext.addApplicationListener(listener);
176 183
            }
177 184
        }
178 185

  
179

  
180
        applicationContext.refresh(new SubProgressMonitor(progressMonitor, refreshTasks));
181
        applicationContext.start();
182

  
183
        progressMonitor.subTask("Cleaning up.");
184
        setApplicationContext(applicationContext);
185
        progressMonitor.worked(1);
186

  
187
        progressMonitor.done();
188
        return true;
186
        return applicationContext;
189 187
    }
190 188

  
191 189
    /* (non-Javadoc)
......
194 192
    @Override
195 193
    protected void init(){
196 194
        configuration = (ICdmApplicationConfiguration)applicationContext.getBean("cdmApplicationRemoteConfiguration");
197
		AbstractLazyInitializer.setConfiguration((CdmApplicationRemoteConfiguration)configuration);
198
		AbstractPersistentCollection.setConfiguration((CdmApplicationRemoteConfiguration)configuration);
199
		
200
		CdmModelCacher cmdmc = new CdmModelCacher();
201
		cmdmc.cacheGetterFields();
195
        AbstractLazyInitializer.setConfiguration((CdmApplicationRemoteConfiguration)configuration);
196
        AbstractPersistentCollection.setConfiguration((CdmApplicationRemoteConfiguration)configuration);
197

  
198
        CdmModelCacher cmdmc = new CdmModelCacher();
199
        cmdmc.cacheGetterFields();
202 200

  
203 201
    }
204 202

  
205 203
    public ICdmEntitySessionManager getCdmEntitySessionManager() {
206
    	return ((CdmApplicationRemoteConfiguration)configuration).getCdmEntitySessionManager();
204
        return ((CdmApplicationRemoteConfiguration)configuration).getCdmEntitySessionManager();
207 205
    }
208 206
}
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/RemotingMonitoredGenericApplicationContext.java
9 9
*/
10 10
package eu.etaxonomy.cdm.api.application;
11 11

  
12
import java.util.concurrent.CancellationException;
12
import java.io.Serializable;
13 13

  
14 14
import org.apache.log4j.Logger;
15
import org.springframework.beans.BeansException;
16 15
import org.springframework.beans.factory.annotation.QualifierAnnotationAutowireCandidateResolver;
17
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
16
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
18 17
import org.springframework.context.support.GenericApplicationContext;
19 18
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
20 19

  
21
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
22
import eu.etaxonomy.cdm.common.monitor.SubProgressMonitor;
23

  
24 20
/**
25 21
 * {@link GenericApplicationContext Generic application context} which allows progress monitoring.
26 22
 * @author a.mueller
27 23
 * @date 29.09.2011
28 24
 *
29 25
 */
30
public class RemotingMonitoredGenericApplicationContext extends GenericApplicationContext{
26
public class RemotingMonitoredGenericApplicationContext extends GenericApplicationContext implements Serializable {
31 27
    @SuppressWarnings("unused")
32
    private static final Logger logger = Logger.getLogger(CdmApplicationController.class);
28
    private static final Logger logger = Logger.getLogger(RemotingMonitoredGenericApplicationContext.class);
33 29

  
34 30
    final int countInvokeBeanFactoryPostProcessors = 10;
35 31
    final int countFinishBeanFactoryInitialization = 90;
36 32
    private final int countTasks = countInvokeBeanFactoryPostProcessors + countFinishBeanFactoryInitialization;
37
    private IProgressMonitor currentMonitor;
33
   // private IProgressMonitor currentMonitor;
38 34

  
39 35

  
40 36

  
......
42 38
     * Constructor.
43 39
     * @param progressMonitor
44 40
     */
41
//    public RemotingMonitoredGenericApplicationContext() {
42
////		MonitoredListableBeanFactory beanFactory =
43
//        super(new RemotingMonitoredListableBeanFactory());
44
//        //taken from empty constructor of GenericApplicationContext
45
//        ((RemotingMonitoredListableBeanFactory)getBeanFactory()).setSerializationId(getId());
46
//        ((RemotingMonitoredListableBeanFactory)getBeanFactory()).setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());
47
//        ((RemotingMonitoredListableBeanFactory)getBeanFactory()).setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
48
//    }
49

  
45 50
    public RemotingMonitoredGenericApplicationContext() {
46
//		MonitoredListableBeanFactory beanFactory =
47
        super(new RemotingMonitoredListableBeanFactory());
51
//      MonitoredListableBeanFactory beanFactory =
52
        super();
48 53
        //taken from empty constructor of GenericApplicationContext
49
        ((RemotingMonitoredListableBeanFactory)getBeanFactory()).setSerializationId(getId());
50
        ((RemotingMonitoredListableBeanFactory)getBeanFactory()).setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());
51
        ((RemotingMonitoredListableBeanFactory)getBeanFactory()).setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
54
        ((DefaultListableBeanFactory)getBeanFactory()).setSerializationId(getId());
55
        ((DefaultListableBeanFactory)getBeanFactory()).setParameterNameDiscoverer(new LocalVariableTableParameterNameDiscoverer());
56
        ((DefaultListableBeanFactory)getBeanFactory()).setAutowireCandidateResolver(new QualifierAnnotationAutowireCandidateResolver());
52 57
    }
53 58

  
54 59

  
55
    public int countTasks(){
56
        return countTasks;
57
    }
58

  
59
    protected void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory beanFactory){
60
        String task = "Invoke bean factory post processors";
61
        checkMonitorCancelled(currentMonitor);
62
        currentMonitor.subTask(task);
63
        super.invokeBeanFactoryPostProcessors(beanFactory);
64
        currentMonitor.worked(countInvokeBeanFactoryPostProcessors);
65
        checkMonitorCancelled(currentMonitor);
66
    }
60
//    public int countTasks(){
61
//        return countTasks;
62
//    }
63
//
64
//    @Override
65
//    protected void invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory beanFactory){
66
//        String task = "Invoke bean factory post processors";
67
////        checkMonitorCancelled(currentMonitor);
68
////        currentMonitor.subTask(task);
69
//        super.invokeBeanFactoryPostProcessors(beanFactory);
70
////        currentMonitor.worked(countInvokeBeanFactoryPostProcessors);
71
////        checkMonitorCancelled(currentMonitor);
72
//    }
73
//
74
//    @Override
75
//    protected void finishBeanFactoryInitialization(ConfigurableListableBeanFactory beanFactory){
76
////        checkMonitorCancelled(currentMonitor);
77
//        String task = "Finish bean factory initialization";
78
////        currentMonitor.subTask(task);
79
////        IProgressMonitor subMonitor	= new SubProgressMonitor(currentMonitor, countFinishBeanFactoryInitialization);
80
////        getMyBeanFactory().setCurrentMonitor(subMonitor);
81
//        super.finishBeanFactoryInitialization(beanFactory);
82
////        checkMonitorCancelled(currentMonitor);
83
//
84
//    }
85

  
86
//    /**
87
//     * @param progressMonitor the progressMonitor to set
88
//     */
89
//    public void setCurrentMonitor(IProgressMonitor monitor) {
90
////        this.currentMonitor = monitor;
91
//    }
92
//
93
//    /**
94
//     *
95
//     */
96
//    public IProgressMonitor getCurrentMonitor() {
97
////        return currentMonitor;
98
//        return null;
99
//    }
100

  
101

  
102
//    /* (non-Javadoc)
103
//     * @see org.springframework.context.support.AbstractApplicationContext#refresh()
104
//     */
105
//    @Override
106
//    public void refresh() throws BeansException, IllegalStateException {
107
//        //checkMonitorCancelled(monitor);
108
//        String message = "Refresh application context. This might take a while ...";
109
////        currentMonitor = monitor;
110
//        beginTask(message, countTasks);
111
//        super.refresh();
112
//        taskDone();
113
//        //checkMonitorCancelled(monitor);
114
//    }
67 115

  
68
    protected void finishBeanFactoryInitialization(ConfigurableListableBeanFactory beanFactory){
69
        checkMonitorCancelled(currentMonitor);
70
        String task = "Finish bean factory initialization";
71
        currentMonitor.subTask(task);
72
        IProgressMonitor subMonitor	= new SubProgressMonitor(currentMonitor, countFinishBeanFactoryInitialization);
73
        getMyBeanFactory().setCurrentMonitor(subMonitor);
74
        super.finishBeanFactoryInitialization(beanFactory);
75
        checkMonitorCancelled(currentMonitor);
76

  
77
    }
78

  
79
    /**
80
     * @param progressMonitor the progressMonitor to set
81
     */
82
    public void setCurrentMonitor(IProgressMonitor monitor) {
83
        this.currentMonitor = monitor;
84
    }
85 116

  
86 117
    /**
87 118
     *
88 119
     */
89
    public IProgressMonitor getCurrentMonitor() {
90
        return currentMonitor;
91
    }
92

  
93

  
94
    /* (non-Javadoc)
95
     * @see org.springframework.context.support.AbstractApplicationContext#refresh()
96
     */
97
    public void refresh(IProgressMonitor monitor) throws BeansException, IllegalStateException {
98
        checkMonitorCancelled(monitor);
99
        String message = "Refresh application context. This might take a while ...";
100
        currentMonitor = monitor;
101
        beginTask(message, countTasks);
102
        super.refresh();
103
        taskDone();
104
        checkMonitorCancelled(monitor);
105
    }
106

  
107

  
108
    /**
109
     *
110
     */
111
    private void taskDone() {
112
        if (currentMonitor != null){
113
            currentMonitor.done();
114
        }
115
    }
116

  
117

  
118
    /**
119
     * @param monitor
120
     * @param message
121
     */
122
    private void beginTask(String message, int countTasks) {
123
        if (currentMonitor != null){
124
            currentMonitor.beginTask(message, countTasks);
125
        }
126
    }
127

  
128

  
129
    private RemotingMonitoredListableBeanFactory getMyBeanFactory(){
130
        return (RemotingMonitoredListableBeanFactory)getBeanFactory();
131
    }
132

  
133

  
134
    private void checkMonitorCancelled(IProgressMonitor monitor) {
135
        if (monitor != null && monitor.isCanceled()){
136
            throw new CancellationException();
137
        }
138
    }
120
//    private void taskDone() {
121
////        if (currentMonitor != null){
122
////            currentMonitor.done();
123
////        }
124
//    }
125

  
126

  
127
//    /**
128
//     * @param monitor
129
//     * @param message
130
//     */
131
//    private void beginTask(String message, int countTasks) {
132
////        if (currentMonitor != null){
133
////            currentMonitor.beginTask(message, countTasks);
134
////        }
135
//    }
136

  
137

  
138
//    private RemotingMonitoredListableBeanFactory getMyBeanFactory(){
139
//        return (RemotingMonitoredListableBeanFactory)getBeanFactory();
140
//    }
141
//
142
//
143
//    private void checkMonitorCancelled(IProgressMonitor monitor) {
144
//        if (monitor != null && monitor.isCanceled()){
145
//            throw new CancellationException();
146
//        }
147
//    }
139 148
}
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/RemotingMonitoredListableBeanFactory.java
1 1
// $Id$
2 2
/**
3 3
* Copyright (C) 2009 EDIT
4
* European Distributed Institute of Taxonomy 
4
* European Distributed Institute of Taxonomy
5 5
* http://www.e-taxonomy.eu
6
* 
6
*
7 7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8 8
* See LICENSE.TXT at the top of this package for the full license terms.
9 9
*/
......
30 30
public class RemotingMonitoredListableBeanFactory extends DefaultListableBeanFactory {
31 31
	@SuppressWarnings("unused")
32 32
	private static final Logger logger = Logger.getLogger(RemotingMonitoredListableBeanFactory.class);
33
	
33

  
34 34
	private boolean isInitializingBeans = false;
35 35
	private IProgressMonitor currentMonitor;
36
	
36

  
37 37
	private static List<String> beansToMonitor = Arrays.asList("sessionFactory","defaultBeanInitializer","persistentTermInitializer");
38
	private Set<String> alreadyMonitoredBeans = new HashSet<String>();
38
	private final Set<String> alreadyMonitoredBeans = new HashSet<String>();
39 39

  
40 40
	public RemotingMonitoredListableBeanFactory(){
41 41
	}
42
	
42

  
43 43
//	@Override
44 44
//	protected RootBeanDefinition getMergedLocalBeanDefinition(String beanName) throws BeansException {
45 45
//		if (registeredBeanNames.contains(beanName)){
46 46
//			return super.getMergedLocalBeanDefinition(beanName);
47
//				
47
//
48 48
//		}
49 49
////		String message = "Handle bean '%s'";
50 50
////		message = String.format(message, beanName);
......
54 54
////		registeredBeanNames.add(beanName);
55 55
//		return result;
56 56
//	}
57
	
58
	public void preInstantiateSingletons() throws BeansException {
57

  
58
	@Override
59
    public void preInstantiateSingletons() throws BeansException {
59 60
		isInitializingBeans = true;
60 61
		checkMonitorCancelled(currentMonitor);
61 62
		int countBeans = 0;
......
86 87
//		}
87 88
//		return result;
88 89
//	}
89
	
90
	protected Object createBean(final String name, final RootBeanDefinition mbd, final Object[] args){
90

  
91
	@Override
92
    protected Object createBean(final String name, final RootBeanDefinition mbd, final Object[] args){
91 93
		boolean doMonitor = isInitializingBeans && beansToMonitor.contains(name) && !alreadyMonitoredBeans.contains(name);
92 94
		checkMonitorCancelled(currentMonitor);
93 95
		if (doMonitor){
......
111 113
		return result;
112 114
	}
113 115

  
114
	
116

  
115 117
	/**
116 118
	 * @param mainMonitor the mainMonitor to set
117 119
	 */
118 120
	public void setCurrentMonitor(IProgressMonitor monitor) {
119 121
		this.currentMonitor = monitor;
120 122
	}
121
	
123

  
122 124
	private void checkMonitorCancelled(IProgressMonitor monitor) {
123 125
		if (monitor != null && monitor.isCanceled()){
124 126
			throw new CancellationException();
125
		}	
127
		}
126 128
	}
127
		
129

  
128 130
}
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/cache/CdmServiceCacher.java
16 16
import eu.etaxonomy.taxeditor.remoting.cache.CdmTransientEntityCacher;
17 17
import eu.etaxonomy.taxeditor.service.TermServiceRequestExecutor;
18 18
import eu.etaxonomy.taxeditor.session.CdmEntitySession;
19
import eu.etaxonomy.taxeditor.session.CdmEntitySessionManager;
20 19
import eu.etaxonomy.taxeditor.session.ICdmEntitySession;
20
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
21
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManagerObserver;
21 22

  
22 23
/**
23 24
 * Class which uses CDM services to cache cdm entities
......
31 32
 * @param <T>
32 33
 */
33 34
@Component
34
public class CdmServiceCacher extends CdmCacher {
35
public class CdmServiceCacher extends CdmCacher  implements ICdmEntitySessionManagerObserver {
35 36

  
36 37
    @Autowired
37 38
    ITermService termService;
38 39

  
39
    @Autowired
40
    private CdmEntitySessionManager cdmEntitySessionManager;
40

  
41
    private ICdmEntitySessionManager cdmEntitySessionManager;
41 42

  
42 43
    private CdmTransientEntityCacher cdmTransientEntityCacher;
43 44

  
......
85 86
        return false;
86 87
    }
87 88

  
88
    public void setActiveSession(ICdmEntitySession cdmEntitySession) {
89

  
90
    public void setCdmEntitySessionManager(ICdmEntitySessionManager cdmEntitySessionManager) {
91
        this.cdmEntitySessionManager = cdmEntitySessionManager;
92
        if(cdmEntitySessionManager != null) {
93
            cdmEntitySessionManager.addSessionObserver(this);
94
        }
95
    }
96

  
97
    public CdmTransientEntityCacher getCurrentCacher() {
98
        ICdmEntitySession cdmEntitySession = cdmEntitySessionManager.getActiveSession();
89 99
        if(cdmEntitySession != null && cdmEntitySession instanceof CdmEntitySession) {
90
            this.cdmTransientEntityCacher = ((CdmEntitySession) cdmEntitySession).getCacher();
91
        } else {
92
            this.cdmTransientEntityCacher = null;
100
            return ((CdmEntitySession) cdmEntitySession).getCacher();
93 101
        }
102
        return null;
94 103
    }
95 104

  
96 105
    @Override
......
122 131
        return cachedCdmEntity;
123 132
    }
124 133

  
134
    /* (non-Javadoc)
135
     * @see eu.etaxonomy.taxeditor.session.ICdmEntitySessionManagerObserver#changed()
136
     */
137
    @Override
138
    public void changed() {
139
        ICdmEntitySession cdmEntitySession = cdmEntitySessionManager.getActiveSession();
140
        if(cdmEntitySession != null && cdmEntitySession instanceof CdmEntitySession) {
141
            this.cdmTransientEntityCacher = ((CdmEntitySession) cdmEntitySession).getCacher();
142
        } else {
143
            this.cdmTransientEntityCacher = null;
144
        }
145
    }
146

  
125 147

  
126 148
}
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CdmModelCacher.java
74 74
			String mappedClassName = mappedClass.getName();
75 75

  
76 76
			CdmModelFieldPropertyFromClass cmgmfc = new CdmModelFieldPropertyFromClass(mappedClassName);
77
			addGetters(persistentClass, cmgmfc);
78 77
			logger.info("Adding class : " + mappedClassName + " to cache");
79

  
78
			addGetters(persistentClass, cmgmfc);
80 79
			cache.put(new Element(mappedClassName, cmgmfc));
81 80

  
82 81
		}
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/CdmEntitySession.java
191 191
    public void bind() {
192 192
        logger.info("Binding session with owner " + sessionOwner.toString());
193 193
        cdmEntitySessionManager.bind(sessionOwner);
194
        cdmEntitySessionManager.notifyObservers();
194

  
195 195
    }
196 196

  
197 197
    /* (non-Javadoc)
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/session/CdmEntitySessionManager.java
18 18
import java.util.Set;
19 19

  
20 20
import org.apache.log4j.Logger;
21
import org.springframework.beans.factory.annotation.Autowired;
22 21
import org.springframework.stereotype.Component;
23 22

  
24
import eu.etaxonomy.cdm.api.cache.CdmServiceCacher;
25 23
import eu.etaxonomy.cdm.model.common.CdmBase;
26 24
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeEvent.EventType;
27 25

  
......
41 39

  
42 40
    private ICdmEntitySession activeSession;
43 41

  
44
    @Autowired
45
    private CdmServiceCacher cdmServiceCacher;
42

  
46 43

  
47 44
    @Override
48 45
    public ICdmEntitySession newSession(ICdmEntitySessionEnabled sessionOwner, boolean setAsActive) {
......
68 65

  
69 66
    private void setActiveSession(ICdmEntitySession activeSession) {
70 67
        this.activeSession = activeSession;
71
        cdmServiceCacher.setActiveSession(activeSession);
68
        notifyObservers();
72 69
    }
73 70

  
74 71

  
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/httpInvokerServiceClients.xml
1 1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans default-lazy-init="true" xmlns="http://www.springframework.org/schema/beans"
2
<beans xmlns="http://www.springframework.org/schema/beans"
3 3
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4 4
  xmlns:tx="http://www.springframework.org/schema/tx"
5 5
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
......
450 450
    </property>
451 451
  </bean>
452 452

  
453
  <bean id="providerManager"
453
  <bean id="authenticationManager"
454 454
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
455 455
    <property name="serviceUrl">
456 456
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/authenticationManager.service</value>
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remotingApplicationContext.xml
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<beans xmlns="http://www.springframework.org/schema/beans"
3
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
4
	xmlns:context="http://www.springframework.org/schema/context"
5
	xmlns:tx="http://www.springframework.org/schema/tx"
6
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
3
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
4
  xmlns:tx="http://www.springframework.org/schema/tx"
5
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
7 6
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
8 7
    http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-2.5.xsd">
9 8

  
10 9

  
11
	<!-- <bean id="remoteTermInitializer" class="eu.etaxonomy.cdm.remote.service.RemoteTermInitializer"/> -->
10
  <!-- <bean id="remoteTermInitializer" class="eu.etaxonomy.cdm.remote.service.RemoteTermInitializer"/> -->
12 11

  
13
	<context:annotation-config />
12
  <context:annotation-config />
14 13

  
15
	<import resource="classpath:/eu/etaxonomy/cdm/httpInvokerServiceClients.xml" />
14
  <import resource="classpath:/eu/etaxonomy/cdm/httpInvokerServiceClients.xml" />
16 15

  
17
	<context:component-scan base-package="eu/etaxonomy/taxeditor/session" />
18 16

  
19
	<bean id="cdmApplicationRemoteConfiguration"
20
		class="eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration" />
21 17

  
22
	<import resource="classpath:/eu/etaxonomy/cdm/remoting_services_security.xml" />
18
  <!-- <context:component-scan base-package="eu/etaxonomy/taxeditor/session" 
19
    /> -->
20
  <bean id="cdmEntitySessionManager"  class="eu.etaxonomy.taxeditor.session.CdmEntitySessionManager" />
23 21

  
24
	<context:component-scan base-package="eu.etaxonomy.cdm.api.cache">
25
		<!-- FIXME:Remoting Temp workaround to make remoting work -->
26
		<context:exclude-filter type="regex"
27
			expression="eu\.etaxonomy\.cdm\.api\.cache\.CdmTermCacher" />
28
	</context:component-scan>
22
  <bean id="cdmApplicationRemoteConfiguration" 
23
    class="eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration" />
29 24

  
30
	<context:component-scan base-package="eu.etaxonomy.taxeditor.service"/>
31

  
32
	
33
	<!-- EditGeoService was moved to ext. Therefore it will not be found by 
34
		the default component scan. We added it here because the Editor needs it. 
35
		However, this is only a temporary solution. In the future we want to pass 
36
		in an application context with the editor. -->
25
  <!-- <import resource="classpath:/eu/etaxonomy/cdm/remoting_services_security.xml" 
26
    /> -->
27

  
28
<!--   <context:component-scan base-package="eu.etaxonomy.taxeditor.service" /> -->
29
  
30
  <bean id="cdmServiceRequestExecutor"
31
    class="eu.etaxonomy.taxeditor.service.CdmServiceRequestExecutor" />
32
    
33
  <bean id="cachedCommonService" 
34
    class="eu.etaxonomy.taxeditor.service.CachedCommonServiceImpl" />
35
  
36
  <bean id="accessDecisionManager" 
37
    class="eu.etaxonomy.cdm.persistence.hibernate.permission.UnanimousBasedUnrevokable">
38
    
39
    <property name="decisionVoters">
40
      <list>
41
        <bean
42
          class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.GrantAlwaysVoter" />
43
        <bean
44
          class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.TaxonNodeVoter" />
45
        <bean
46
          class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.TaxonBaseVoter" />
47
        <bean
48
          class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.DescriptionBaseVoter" />
49
        <bean
50
          class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.DescriptionElementVoter" />
51
      </list>
52
    </property>
53
  </bean>
54

  
55
  <!-- CdmPermissionEvaluator.hasPermissions() evaluates the CdmPermissions 
56
    like TAXONNODE.UPDATE{20c8f083-5870-4cbd-bf56-c5b2b98ab6a7} -->
57
  <bean id="cdmPermissionEvaluator"
58
    class="eu.etaxonomy.cdm.persistence.hibernate.permission.CdmPermissionEvaluator">
59
    <property name="accessDecisionManager" ref="accessDecisionManager" />
60
  </bean>
61

  
62
  <!-- The CdmSecurityHibernateInterceptor checks onSave() and on flushDirty() 
63
    if the currently authenticated principal or token has sufficient permissions 
64
    on the entity to be persisted -->
65
  <bean id="securityHibernateInterceptor"
66
    class="eu.etaxonomy.cdm.persistence.hibernate.CdmSecurityHibernateInterceptor">
67
    <property name="permissionEvaluator" ref="cdmPermissionEvaluator" />
68
  </bean>
69

  
70
<!--   <bean id="authenticationManager" -->
71
<!--     class="org.springframework.security.authentication.ProviderManager"> -->
72
<!--     <property name="providers"> -->
73
<!--       <list> -->
74
<!--         <ref local="daoAuthenticationProvider" /> -->
75
<!--       </list> -->
76
<!--     </property> -->
77
<!--   </bean> -->
78

  
79
<!--   <bean id="daoAuthenticationProvider" -->
80
<!--     class="org.springframework.security.authentication.dao.DaoAuthenticationProvider"> -->
81
<!--     <property name="userDetailsService" ref="userService" /> -->
82
<!--     <property name="saltSource" ref="saltSource" /> -->
83
<!--     <property name="passwordEncoder" ref="passwordEncoder" /> -->
84
<!--   </bean> -->
85

  
86
<!--   <bean id="passwordEncoder" -->
87
<!--     class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" /> -->
88

  
89
<!--   <bean id="saltSource" -->
90
<!--     class="org.springframework.security.authentication.dao.ReflectionSaltSource"> -->
91
<!--     <property name="userPropertyToUse" value="getUsername" /> -->
92
<!--   </bean> -->
93

  
94

  
95
  <context:component-scan base-package="eu.etaxonomy.cdm.api.cache">
96
    <!-- FIXME:Remoting Temp workaround to make remoting work -->
97
    <context:exclude-filter type="regex"
98
      expression="eu\.etaxonomy\.cdm\.api\.cache\.CdmTermCacher" />
99
  </context:component-scan>
37 100

  
38 101

  
39
	<!-- <bean id="conversationHolder" class="eu.etaxonomy.cdm.api.conversation.ConversationHolder" 
40
		scope="prototype"/> -->
41 102

  
42
	<!-- TODO move to io -->
43
	<!-- <context:component-scan base-package="eu/etaxonomy/cdm/io"> <context:exclude-filter 
44
		type="regex" expression="eu\.etaxonomy\.cdm\.io\.berlinModel.*" /> </context:component-scan> -->
45
	<!-- enable the configuration of transactional behavior based on annotations -->
46
	<!-- <tx:annotation-driven transaction-manager="transactionManager"/> -->
47 103

  
48 104
</beans>
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_services_security.xml
15 15
          security specific configuration
16 16
        ======================================================================
17 17
     -->
18
    <security:global-method-security pre-post-annotations="enabled" run-as-manager-ref="runAsManager" >
19
        <security:expression-handler ref="expressionHandler" />
20
    </security:global-method-security>
18
<!--     <security:global-method-security pre-post-annotations="enabled" run-as-manager-ref="runAsManager" > -->
19
<!--         <security:expression-handler ref="expressionHandler" /> -->
20
<!--     </security:global-method-security> -->
21 21

  
22 22
    <!--
23 23
        To use "hasPermission()" in the Spring EL method annotations like @PreAuthorize we explicitly configure the permissionEvaluator
24 24
        the cdmPermissionEvaluator is already defined in the persistence security context
25 25
    -->
26
    <bean id="expressionHandler" class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler">
27
        <property name="permissionEvaluator" ref="cdmPermissionEvaluator" />
28
    </bean>
26
<!--     <bean id="expressionHandler" class="org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler"> -->
27
<!--         <property name="permissionEvaluator" ref="cdmPermissionEvaluator" /> -->
28
<!--     </bean> -->
29 29

  
30 30
    <bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager">
31 31
        <property name="providers">
......
53 53

  
54 54
        the key must match FirstDataInserter.RUN_AS_KEY
55 55
     -->
56
    <bean id="runAsManager"
57
        class="org.springframework.security.access.intercept.RunAsManagerImpl">
58
      <property name="key" value="TtlCx3pgKC4l"/>
59
    </bean>
56
<!--     <bean id="runAsManager" -->
57
<!--         class="org.springframework.security.access.intercept.RunAsManagerImpl"> -->
58
<!--       <property name="key" value="TtlCx3pgKC4l"/> -->
59
<!--     </bean> -->
60 60

  
61 61

  
62 62
</beans>
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/application/CdmApplicationRemoteControllerTest.java
1
// $Id$
2
/**
3
* Copyright (C) 2015 EDIT
4
* European Distributed Institute of Taxonomy
5
* http://www.e-taxonomy.eu
6
*
7
* The contents of this file are subject to the Mozilla Public License Version 1.1
8
* See LICENSE.TXT at the top of this package for the full license terms.
9
*/
10
package eu.etaxonomy.taxeditor.application;
11

  
12
/**
13
 * @author cmathew
14
 * @date 26 May 2015
15
 *
16
 */
17
public class CdmApplicationRemoteControllerTest {
18

  
19

  
20

  
21

  
22
}

Also available in: Unified diff