Project

General

Profile

« Previous | Next » 

Revision 95b6f6f5

Added by Cherian Mathew almost 9 years ago

CdmApplicationRemoteController : refactoring code to simplify application context loading and making it performant
CdmModelCacher : removed unused method
CdmRemoteCacheManager : moved cache from disk to memory
httpInvokerServiceClients : lazy initializing all service beans
remotingApplicationContext : merged imported bean definition files into this one
CdmApplicationRemoteControllerTest : test for application controller
RemotingMonitoredGenericApplicationContext, RemotingMonitoredListableBeanFactory : removed since specific monitoring is not required in remoting
remoting_persistence_security.xml, remoting_services_security.xml : merged into remotingApplicationContext

View differences:

eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteController.java
58 58
     * @param listeners
59 59
     * @return
60 60
     */
61
    public static CdmApplicationRemoteController NewInstance(Resource applicationContextResource,
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);
71

  
72
    }
61
//    public static CdmApplicationRemoteController NewInstance(Resource applicationContextResource,
62
//            ICdmRemoteSource remoteSource,
63
//            IProgressMonitor progressMonitor,
64
//            List<ApplicationListener> listeners) {
65
//        return new CdmApplicationRemoteController(applicationContextResource,
66
//                remoteSource,
67
//                false,
68
//                progressMonitor,
69
//                listeners);
70
//
71
//    }
73 72
    /**
74 73
     * Creates new instance of CdmApplicationRemoteController
75 74
     *
......
81 80
     * @return
82 81
     */
83 82
    public static CdmApplicationRemoteController NewInstance(ICdmRemoteSource remoteSource,
84
            boolean omitTermLoading,
85 83
            IProgressMonitor progressMonitor,
86 84
            List<ApplicationListener> listeners) {
87 85

  
88 86
        return new CdmApplicationRemoteController(DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE,
89 87
                remoteSource,
90
                omitTermLoading,
88
                false,
89
                progressMonitor,
90
                listeners);
91

  
92
    }
93

  
94
    public static CdmApplicationRemoteController NewInstance(ICdmRemoteSource remoteSource,
95
            boolean validateXml,
96
            IProgressMonitor progressMonitor,
97
            List<ApplicationListener> listeners) {
98

  
99
        return new CdmApplicationRemoteController(DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE,
100
                remoteSource,
101
                validateXml,
91 102
                progressMonitor,
92 103
                listeners);
93 104

  
......
104 115
     */
105 116
    private CdmApplicationRemoteController(Resource applicationContextResource,
106 117
            ICdmRemoteSource remoteSource,
107
            boolean omitTermLoading,
118
            boolean validateXml,
108 119
            IProgressMonitor progressMonitor,
109 120
            List<ApplicationListener> listeners){
110 121
        logger.info("Start CdmApplicationRemoteController with remote source: " + remoteSource.getName());
111 122
        this.applicationContextResource =
112 123
                applicationContextResource != null ? applicationContextResource : DEFAULT_REMOTE_APPLICATION_CONTEXT_RESOURCE;
113 124
        this.progressMonitor = progressMonitor != null ? progressMonitor : new NullProgressMonitor();
114

  
115
        setNewRemoteSource(remoteSource, omitTermLoading, listeners);
125
        setNewRemoteSource(remoteSource, validateXml, listeners);
116 126

  
117 127
    }
118 128

  
......
127 137
     * @param listeners
128 138
     * @return
129 139
     */
130
    protected boolean setNewRemoteSource(ICdmRemoteSource remoteSource,
131
            boolean omitTermLoading,
140
    public boolean setNewRemoteSource(ICdmRemoteSource remoteSource,
141
            boolean validateXml,
132 142
            List<ApplicationListener> listeners){
133 143

  
134 144
        logger.info("Connecting to '" + remoteSource.getName() + "'");
135 145

  
136
        GenericApplicationContext applicationContext
137
            = generateApplicationContext(remoteSource, applicationContextResource, listeners, progressMonitor, false);
138

  
139

  
140

  
141
        //progressMonitor.beginTask("Connecting to '" + remoteSource.getName() + "'", nTasks);
142
        applicationContext.refresh();
143
        applicationContext.start();
144

  
145

  
146
        progressMonitor.subTask("Cleaning up.");
147
        setApplicationContext(applicationContext);
148
        progressMonitor.worked(1);
146
        GenericApplicationContext applicationContext =  new GenericApplicationContext();
149 147

  
150
        progressMonitor.done();
151
        return true;
152
    }
153

  
154
    public static GenericApplicationContext generateApplicationContext(ICdmRemoteSource remoteSource,
155
            Resource applicationContextResource,
156
            List<ApplicationListener> listeners,
157
            IProgressMonitor progressMonitor,
158
            boolean validateXml) {
159
        RemotingMonitoredGenericApplicationContext applicationContext =  new RemotingMonitoredGenericApplicationContext();
160
        int refreshTasks = 45;
161
        int nTasks = 5 + refreshTasks;
148
        int nTasks = 5;
162 149

  
163
        progressMonitor.subTask("Registering remote source.");
164
        applicationContext.getEnvironment().setActiveProfiles("remoting");
165
        progressMonitor.worked(1);
150
        progressMonitor.beginTask("Connecting to '" + remoteSource.getName() + "'", nTasks);
166 151

  
152
        progressMonitor.subTask("Loading context beans ...");
167 153
        PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
168 154
        Properties properties = new Properties();
169 155
        properties.setProperty("remoteServer", remoteSource.getServer());
......
171 157
        properties.setProperty("remoteContext", remoteSource.getContextPath());
172 158
        pspc.setProperties(properties);
173 159
        applicationContext.addBeanFactoryPostProcessor(pspc);
174

  
160
        applicationContext.getEnvironment().setActiveProfiles("remoting");
175 161
        XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(applicationContext);
176 162
        if(!validateXml) {
177
            xmlReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
163
            xmlReader.setValidating(false);
178 164
        }
179
        progressMonitor.subTask("Registering resources.");
180 165
        xmlReader.loadBeanDefinitions(applicationContextResource);
181
        progressMonitor.worked(1);
182

  
183 166
        if (listeners != null){
184 167
            for(ApplicationListener listener : listeners){
185 168
                applicationContext.addApplicationListener(listener);
186 169
            }
187 170
        }
171
        progressMonitor.worked(1);
188 172

  
189
        return applicationContext;
173
        progressMonitor.subTask("Refreshing / Starting context ...");
174
        applicationContext.refresh();
175
        applicationContext.start();
176
        progressMonitor.worked(1);
177

  
178
        progressMonitor.subTask("Cleaning up ...");
179
        setApplicationContext(applicationContext);
180
        progressMonitor.worked(1);
181

  
182
        return true;
190 183
    }
191 184

  
185

  
186

  
192 187
    /* (non-Javadoc)
193 188
     * @see eu.etaxonomy.cdm.api.application.CdmApplicationController#init()
194 189
     */
195 190
    @Override
196 191
    protected void init(){
192
        progressMonitor.subTask("Loading configuration ...");
197 193
        configuration = (ICdmApplicationConfiguration)applicationContext.getBean("cdmApplicationRemoteConfiguration");
198 194
        AbstractLazyInitializer.setConfiguration((CdmApplicationRemoteConfiguration)configuration);
199 195
        AbstractPersistentCollection.setConfiguration((CdmApplicationRemoteConfiguration)configuration);
196
        progressMonitor.worked(1);
200 197

  
198
        progressMonitor.subTask("Loading CDM config cache ...");
201 199
        CdmModelCacher cmdmc = new CdmModelCacher();
202 200
        cmdmc.cacheGetterFields();
201
        progressMonitor.worked(1);
203 202

  
203
        progressMonitor.done();
204 204
    }
205 205

  
206 206
    public ICdmEntitySessionManager getCdmEntitySessionManager() {
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/RemotingMonitoredGenericApplicationContext.java
1
// $Id$
2
/**
3
* Copyright (C) 2009 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.cdm.api.application;
11

  
12
import java.io.Serializable;
13

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

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

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

  
35

  
36

  
37
    /**
38
     * Constructor.
39
     * @param progressMonitor
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

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

  
59

  
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
//    }
115

  
116

  
117
    /**
118
     *
119
     */
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
//    }
148
}
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/RemotingMonitoredListableBeanFactory.java
1
// $Id$
2
/**
3
* Copyright (C) 2009 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.cdm.api.application;
11

  
12
import java.util.Arrays;
13
import java.util.HashSet;
14
import java.util.List;
15
import java.util.Set;
16
import java.util.concurrent.CancellationException;
17

  
18
import org.apache.log4j.Logger;
19
import org.springframework.beans.BeansException;
20
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
21
import org.springframework.beans.factory.support.RootBeanDefinition;
22

  
23
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
24

  
25
/**
26
 * @author a.mueller
27
 * @date 29.09.2011
28
 *
29
 */
30
public class RemotingMonitoredListableBeanFactory extends DefaultListableBeanFactory {
31
	@SuppressWarnings("unused")
32
	private static final Logger logger = Logger.getLogger(RemotingMonitoredListableBeanFactory.class);
33

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

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

  
40
	public RemotingMonitoredListableBeanFactory(){
41
	}
42

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

  
58
	@Override
59
    public void preInstantiateSingletons() throws BeansException {
60
		isInitializingBeans = true;
61
		checkMonitorCancelled(currentMonitor);
62
		int countBeans = 0;
63
		for (String beanName : getBeanDefinitionNames()) {
64
			RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName);
65
			if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit() && beansToMonitor.contains(beanName) ){
66
				countBeans++;
67
			}
68
		}
69
		String message = "preinstantiate singletons";
70
		currentMonitor.beginTask(message, countBeans);
71
		super.preInstantiateSingletons();
72
		isInitializingBeans = false;
73
		currentMonitor.done();
74
	}
75

  
76
//	protected <T> T doGetBean(final String name, final Class<T> requiredType, final Object[] args, boolean typeCheckOnly){
77
//		boolean doMonitor = isInitializingBeans && !monitoredBeanNames.contains(name);
78
//		if (doMonitor){
79
//			String message = "Handle bean '%s'";
80
//			message = String.format(message, name);
81
//			currentMonitor.subTask(message);
82
//			monitoredBeanNames.add(name);
83
//		}
84
//		T result = super.doGetBean(name, requiredType, args, typeCheckOnly);
85
//		if (doMonitor){
86
//			currentMonitor.worked(1);
87
//		}
88
//		return result;
89
//	}
90

  
91
	@Override
92
    protected Object createBean(final String name, final RootBeanDefinition mbd, final Object[] args){
93
		boolean doMonitor = isInitializingBeans && beansToMonitor.contains(name) && !alreadyMonitoredBeans.contains(name);
94
		checkMonitorCancelled(currentMonitor);
95
		if (doMonitor){
96
			String message;
97
			if (name.equals("sessionFactory")){
98
				message = "Initializing persistence context ...";
99
			}else if(name.equals("persistentTermInitializer")){
100
				message = "Loading terms ...";
101
			}else{
102
				message = "Handling '%s'";
103
				message = String.format(message, name);
104
			}
105
			currentMonitor.subTask(message);
106
			alreadyMonitoredBeans.add(name);
107
		}
108
		Object result = super.createBean(name, mbd, args);
109
		if (doMonitor){
110
			checkMonitorCancelled(currentMonitor);
111
			currentMonitor.worked(1);
112
		}
113
		return result;
114
	}
115

  
116

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

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

  
130
}
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CdmModelCacher.java
23 23

  
24 24
	private final List<CdmModelFieldPropertyFromClass> cmgmfcList = new ArrayList<CdmModelFieldPropertyFromClass>();
25 25

  
26
	public void cacheGetters() {
27

  
28
		Configuration configuration = new Configuration().configure("/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml");
29
		configuration.buildMappings();
30
		Iterator<PersistentClass> classMappingIterator = configuration.getClassMappings();
31

  
32
		Cache cache = CdmRemoteCacheManager.getInstance().getCdmModelGetMethodsCache();
33
		cache.removeAll();
34

  
35
		while(classMappingIterator.hasNext()) {
36
			PersistentClass persistentClass = classMappingIterator.next();
37
			Class mappedClass = persistentClass.getMappedClass();
38
			String mappedClassName = mappedClass.getName();
39

  
40
			CdmModelFieldPropertyFromClass cmgmfc = new CdmModelFieldPropertyFromClass(mappedClassName);
41
			Iterator propertyIt = persistentClass.getPropertyIterator();
42

  
43
			logger.info("Adding class : " + mappedClassName + " to cache");
44

  
45
			while(propertyIt.hasNext())
46
			{
47
				Property property = (Property)propertyIt.next();
48
				Getter getter = property.getGetter(mappedClass);
49
				if(getter != null && getter.getMember() != null) {
50
					Field field = (Field)getter.getMember();
51
					String getMethod = getMethodNameFromFieldName(field.getName(), field.getType().getName());
52
					logger.info(" - getMethod : " + getMethod + " for type " + field.getType().getName());
53
					cmgmfc.addGetMethods(getMethod);
54
				}
55
			}
56
			cache.put(new Element(mappedClassName, cmgmfc));
57

  
58
		}
59
		cache.flush();
60
	}
61 26

  
62 27
	public void cacheGetterFields() {
63 28

  
......
79 44
			cache.put(new Element(mappedClassName, cmgmfc));
80 45

  
81 46
		}
82
		cache.flush();
47
		//cache.flush();
83 48
	}
84 49

  
85 50
	private void addGetters(PersistentClass persistentClass, CdmModelFieldPropertyFromClass cmgmfc) {
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/remoting/cache/CdmRemoteCacheManager.java
1 1
package eu.etaxonomy.taxeditor.remoting.cache;
2 2

  
3
import java.io.File;
4 3
import java.io.InputStream;
5 4
import java.util.HashSet;
6 5
import java.util.Set;
......
8 7
import net.sf.ehcache.Cache;
9 8
import net.sf.ehcache.CacheException;
10 9
import net.sf.ehcache.CacheManager;
10
import net.sf.ehcache.config.CacheConfiguration;
11
import net.sf.ehcache.config.SizeOfPolicyConfiguration;
11 12

  
12 13
import org.springframework.core.io.ClassPathResource;
13 14
import org.springframework.core.io.Resource;
14 15

  
15
import eu.etaxonomy.cdm.common.CdmUtils;
16

  
17 16

  
18 17
public class CdmRemoteCacheManager {
19 18

  
......
26 25
    public static final Resource CDMLIB_CACHE_MANAGER_CONFIG_RESOURCE =
27 26
            new ClassPathResource("cdmlib-ehcache.xml");
28 27

  
28
    public static final String CDM_MODEL_CACHE_MGR_NAME = "cdmlibModelCacheManager";
29 29
    public static final String CDM_MODEL_CACHE_NAME = "cdmModelGetMethodsCache";
30 30

  
31 31

  
......
42 42
    }
43 43
    private CdmRemoteCacheManager() {
44 44

  
45
    	System.setProperty("ehcache.disk.store.dir", CdmUtils.getCdmHomeDir().getAbsolutePath() + File.separator + "cdmlib-model");
45

  
46 46
    	try {
47 47
    		// NOTE:Programmatically creating the cache manager may solve the problem of
48 48
    		//      recreating data written to disk on startup
49 49
    		//      see https://stackoverflow.com/questions/1729605/ehcache-persist-to-disk-issues
50 50
    		//String cacheFilePath = CDMLIB_CACHE_MANAGER_CONFIG_RESOURCE.getFile().getAbsolutePath();
51 51
    		InputStream in = this.getClass().getClassLoader().getResourceAsStream("cdmlib-ehcache.xml");
52
			cdmlibModelCacheManager = new CacheManager(in);
52

  
53
            SizeOfPolicyConfiguration sizeOfConfig = new SizeOfPolicyConfiguration();
54
            sizeOfConfig.setMaxDepth(1000);
55
            sizeOfConfig.setMaxDepthExceededBehavior("abort");
56

  
57
    		CacheConfiguration modelcc = new CacheConfiguration(CDM_MODEL_CACHE_NAME, 0)
58
            .eternal(true)
59
            .statistics(true)
60
            .sizeOfPolicy(sizeOfConfig)
61
            .overflowToOffHeap(false);
62

  
63
    		Cache modelCache = new Cache(modelcc);
64

  
65
			cdmlibModelCacheManager = CacheManager.create(CDM_MODEL_CACHE_MGR_NAME);
66
			cdmlibModelCacheManager.addCache(modelCache);
53 67

  
54 68
		} catch (CacheException e) {
55 69
			throw new CdmClientCacheException(e);
56 70
		}
57
//		} catch (IOException e) {
58
//			throw new CdmClientCacheException(e);
59
//		}
71

  
60 72
    }
61 73

  
62 74
	public Cache getCdmModelGetMethodsCache(){
......
86 98
		}
87 99
	}
88 100

  
89
	public static void checkCacheProperties() {
90
		String pathToCache = System.getProperty("ehcache.disk.store.dir");
91
		if(pathToCache == null || pathToCache.isEmpty()) {
92
			throw new CdmClientCacheException("'ehcache.disk.store.dir' property is not set");
93
		}
94
	}
95 101

  
96 102

  
97 103
}
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/taxeditor/util/Serializer.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.util;
11

  
12
import org.hibernate.cfg.Configuration;
13

  
14
/**
15
 * @author cmathew
16
 * @date 27 May 2015
17
 *
18
 */
19
public class Serializer {
20

  
21
    String HB_CONFIG_PATH= "/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml";
22

  
23
    public static void serializeHbConfig(String serializedFilePath) {
24
        Configuration configuration = new Configuration().configure("/eu/etaxonomy/cdm/mappings/hibernate.cfg.xml");
25
        configuration.buildMappings();
26
    }
27

  
28
}
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/httpInvokerServiceClients.xml
2 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
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
6
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
7
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
5
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
6
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
7
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd"
8
    default-lazy-init="true">
8 9

  
9 10

  
10
  <bean id="agentService" 
11
  <bean id="agentService" lazy-init="true"
11 12
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
12 13
    <property name="serviceUrl">
13 14
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/agent.service</value>
......
21 22
    </property>
22 23
  </bean>
23 24

  
24
  <bean id="annotationService"
25
  <bean id="annotationService" lazy-init="true"
25 26
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
26 27
    <property name="serviceUrl">
27 28
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/annotation.service</value>
......
35 36
    </property>
36 37
  </bean>
37 38

  
38
  <bean id="auditeventService"
39
  <bean id="auditeventService" lazy-init="true"
39 40
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
40 41
    <property name="serviceUrl">
41 42
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/auditevent.service</value>
......
49 50
    </property>
50 51
  </bean>
51 52

  
52
  <bean id="classificationService"
53
  <bean id="classificationService" lazy-init="true"
53 54
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
54 55
    <property name="serviceUrl">
55 56
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/classification.service</value>
......
63 64
    </property>
64 65
  </bean>
65 66

  
66
  <bean id="collectionService"
67
  <bean id="collectionService" lazy-init="true"
67 68
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
68 69
    <property name="serviceUrl">
69 70
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/collection.service</value>
......
77 78
    </property>
78 79
  </bean>
79 80

  
80
  <bean id="commonService"
81
  <bean id="commonService" lazy-init="true"
81 82
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
82 83
    <property name="serviceUrl">
83 84
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/common.service</value>
......
91 92
    </property>
92 93
  </bean>
93 94

  
94
  <bean id="descriptionService"
95
  <bean id="descriptionService" lazy-init="true"
95 96
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
96 97
    <property name="serviceUrl">
97 98
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/description.service</value>
......
105 106
    </property>
106 107
  </bean>
107 108

  
108
  <bean id="editGeoService"
109
  <bean id="editGeoService" lazy-init="true"
109 110
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
110 111
    <property name="serviceUrl">
111 112
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/editgeo.service</value>
......
119 120
    </property>
120 121
  </bean>
121 122

  
122
  <bean id="featureNodeService"
123
  <bean id="featureNodeService" lazy-init="true"
123 124
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
124 125
    <property name="serviceUrl">
125 126
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/featurenode.service</value>
......
133 134
    </property>
134 135
  </bean>
135 136

  
136
  <bean id="featureTreeService"
137
  <bean id="featureTreeService" lazy-init="true"
137 138
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
138 139
    <property name="serviceUrl">
139 140
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/featuretree.service</value>
......
147 148
    </property>
148 149
  </bean>
149 150

  
150
  <bean id="groupService"
151
  <bean id="groupService" lazy-init="true"
151 152
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
152 153
    <property name="serviceUrl">
153 154
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/group.service</value>
......
161 162
    </property>
162 163
  </bean>
163 164

  
164
  <bean id="identificationKeyService"
165
  <bean id="identificationKeyService" lazy-init="true"
165 166
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
166 167
    <property name="serviceUrl">
167 168
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/identificationkey.service</value>
......
176 177
    </property>
177 178
  </bean>
178 179

  
179
  <bean id="locationService"
180
  <bean id="locationService" lazy-init="true"
180 181
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
181 182
    <property name="serviceUrl">
182 183
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/location.service</value>
......
190 191
    </property>
191 192
  </bean>
192 193

  
193
  <bean id="markerService"
194
  <bean id="markerService" lazy-init="true"
194 195
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
195 196
    <property name="serviceUrl">
196 197
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/marker.service</value>
......
204 205
    </property>
205 206
  </bean>
206 207

  
207
  <bean id="mediaService"
208
  <bean id="mediaService" lazy-init="true"
208 209
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
209 210
    <property name="serviceUrl">
210 211
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/media.service</value>
......
218 219
    </property>
219 220
  </bean>
220 221

  
221
  <bean id="nameService"
222
  <bean id="nameService" lazy-init="true"
222 223
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
223 224
    <property name="serviceUrl">
224 225
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/name.service</value>
......
232 233
    </property>
233 234
  </bean>
234 235

  
235
  <bean id="occurrenceService"
236
  <bean id="occurrenceService" lazy-init="true"
236 237
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
237 238
    <property name="serviceUrl">
238 239
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/occurrence.service</value>
......
246 247
    </property>
247 248
  </bean>
248 249

  
249
  <bean id="polytomousKeyNodeService"
250
  <bean id="polytomousKeyNodeService" lazy-init="true"
250 251
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
251 252
    <property name="serviceUrl">
252 253
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/polytomouskeynode.service</value>
......
261 262
    </property>
262 263
  </bean>
263 264

  
264
  <bean id="polytomousKeyService"
265
  <bean id="polytomousKeyService" lazy-init="true"
265 266
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
266 267
    <property name="serviceUrl">
267 268
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/polytomouskey.service</value>
......
275 276
    </property>
276 277
  </bean>
277 278

  
278
  <bean id="referenceService"
279
  <bean id="referenceService" lazy-init="true"
279 280
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
280 281
    <property name="serviceUrl">
281 282
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/reference.service</value>
......
294 295
    </property> <property name="serviceInterface"> <value>eu.etaxonomy.cdm.api.service.IService</value> 
295 296
    </property> </bean> -->
296 297

  
297
  <bean id="taxonNodeService"
298
  <bean id="taxonNodeService" lazy-init="true"
298 299
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
299 300
    <property name="serviceUrl">
300 301
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/taxonnode.service</value>
......
308 309
    </property>
309 310
  </bean>
310 311

  
311
  <bean id="taxonService"
312
  <bean id="taxonService" lazy-init="true"
312 313
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
313 314
    <property name="serviceUrl">
314 315
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/taxon.service</value>
......
322 323
    </property>
323 324
  </bean>
324 325

  
325
  <bean id="termService"
326
  <bean id="termService" lazy-init="true"
326 327
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
327 328
    <property name="serviceUrl">
328 329
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/term.service</value>
......
335 336
    </property>
336 337
  </bean>
337 338

  
338
  <bean id="userService"
339
  <bean id="userService" lazy-init="true"
339 340
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
340 341
    <property name="serviceUrl">
341 342
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting-public/user.service</value>
......
349 350
    </property>
350 351
  </bean>
351 352

  
352
  <bean id="vocabularyService"
353
  <bean id="vocabularyService" lazy-init="true"
353 354
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
354 355
    <property name="serviceUrl">
355 356
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/vocabulary.service</value>
......
363 364
    </property>
364 365
  </bean>
365 366

  
366
  <bean id="workingSetService"
367
  <bean id="workingSetService" lazy-init="true"
367 368
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
368 369
    <property name="serviceUrl">
369 370
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/workingset.service</value>
......
377 378
    </property>
378 379
  </bean>
379 380

  
380
  <bean id="grantedAuthorityService"
381
  <bean id="grantedAuthorityService" lazy-init="true"
381 382
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
382 383
    <property name="serviceUrl">
383 384
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/grantedauthority.service</value>
......
392 393
    </property>
393 394
  </bean>
394 395

  
395
  <bean id="databaseService"
396
  <bean id="databaseService" lazy-init="true"
396 397
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
397 398
    <property name="serviceUrl">
398 399
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting-public/database.service</value>
......
406 407
    </property>
407 408
  </bean>
408 409

  
409
  <bean id="lsidAuthorityService"
410
  <bean id="lsidAuthorityService" lazy-init="true"
410 411
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
411 412
    <property name="serviceUrl">
412 413
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/lsidauthoruty.service</value>
......
421 422
    </property>
422 423
  </bean>
423 424

  
424
  <bean id="lsidMetadataService"
425
  <bean id="lsidMetadataService" lazy-init="true"
425 426
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
426 427
    <property name="serviceUrl">
427 428
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/lsidmetadata.service</value>
......
436 437
    </property>
437 438
  </bean>
438 439

  
439
  <bean id="lsiDataService"
440
  <bean id="lsiDataService" lazy-init="true"
440 441
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
441 442
    <property name="serviceUrl">
442 443
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/lsiddata.service</value>
......
450 451
    </property>
451 452
  </bean>
452 453

  
453
  <bean id="authenticationManager"
454
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
455
    <property name="serviceUrl">
456
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/authenticationManager.service</value>
457
    </property>
458
    <property name="serviceInterface">
459
      <value>org.springframework.security.authentication.AuthenticationManager
460
      </value>
461
    </property>
462
    <property name="httpInvokerRequestExecutor">
463
      <bean
464
        class="eu.etaxonomy.taxeditor.service.CdmServiceRequestExecutor" />
465
    </property>
466
  </bean>
454
<!--   <bean id="providerManager" -->
455
<!--     class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"> -->
456
<!--     <property name="serviceUrl"> -->
457
<!--       <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/authenticationManager.service</value> -->
458
<!--     </property> -->
459
<!--     <property name="serviceInterface"> -->
460
<!--       <value>org.springframework.security.authentication.AuthenticationManager -->
461
<!--       </value> -->
462
<!--     </property> -->
463
<!--     <property name="httpInvokerRequestExecutor"> -->
464
<!--       <bean -->
465
<!--         class="eu.etaxonomy.taxeditor.service.CdmServiceRequestExecutor" /> -->
466
<!--     </property> -->
467
<!--   </bean> -->
467 468

  
468
  <bean id="primerService"
469
  <bean id="primerService" lazy-init="true"
469 470
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
470 471
    <property name="serviceUrl">
471 472
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/primer.service</value>
......
480 481
    </property>
481 482
  </bean>
482 483

  
483
  <bean id="amplificationService"
484
  <bean id="amplificationService" lazy-init="true"
484 485
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
485 486
    <property name="serviceUrl">
486 487
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/amplification.service</value>
......
495 496
    </property>
496 497
  </bean>
497 498

  
498
  <bean id="sequenceService"
499
  <bean id="sequenceService" lazy-init="true"
499 500
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
500 501
    <property name="serviceUrl">
501 502
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/sequence.service</value>
......
510 511
    </property>
511 512
  </bean>
512 513

  
513
  <bean id="entityValidationService"
514
  <bean id="entityValidationService" lazy-init="true"
514 515
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
515 516
    <property name="serviceUrl">
516 517
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/entityvalidation.service</value>
......
525 526
    </property>
526 527
  </bean>
527 528

  
528
  <bean id="entityConstraintViolationService"
529
  <bean id="entityConstraintViolationService" lazy-init="true"
529 530
    class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
530 531
    <property name="serviceUrl">
531 532
      <value>http://${remoteServer}:${remotePort}/${remoteContext}/remoting/entityconstraintviolation.service</value>
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remotingApplicationContext.xml
2 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
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
6
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
7
    http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-2.5.xsd">
8

  
9

  
10
  <!-- <bean id="remoteTermInitializer" class="eu.etaxonomy.cdm.remote.service.RemoteTermInitializer"/> -->
5
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
6
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
7
    http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.1.xsd">
11 8

  
12 9
  <context:annotation-config />
13 10

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

  
16

  
17

  
18
  <!-- <context:component-scan base-package="eu/etaxonomy/taxeditor/session" 
19
    /> -->
20
  <bean id="cdmEntitySessionManager"  class="eu.etaxonomy.taxeditor.session.CdmEntitySessionManager" />
13
  <bean id="cdmEntitySessionManager"  
14
    class="eu.etaxonomy.taxeditor.session.CdmEntitySessionManager" />
21 15

  
22 16
  <bean id="cdmApplicationRemoteConfiguration" 
23 17
    class="eu.etaxonomy.cdm.api.application.CdmApplicationRemoteConfiguration" />
24 18

  
25
  <!-- <import resource="classpath:/eu/etaxonomy/cdm/remoting_services_security.xml" 
26
    /> -->
27

  
28
<!--   <context:component-scan base-package="eu.etaxonomy.taxeditor.service" /> -->
29 19
  
30
  <bean id="cdmServiceRequestExecutor"
20
  <bean id="cdmServiceRequestExecutor" 
31 21
    class="eu.etaxonomy.taxeditor.service.CdmServiceRequestExecutor" />
32 22
    
33 23
  <bean id="cachedCommonService" 
34 24
    class="eu.etaxonomy.taxeditor.service.CachedCommonServiceImpl" />
35 25
  
36 26
  <bean id="accessDecisionManager" 
37
    class="eu.etaxonomy.cdm.persistence.hibernate.permission.UnanimousBasedUnrevokable">
27
    class="eu.etaxonomy.cdm.persistence.hibernate.permission.UnanimousBasedUnrevokable" >
38 28
    
39 29
    <property name="decisionVoters">
40 30
      <list>
......
54 44

  
55 45
  <!-- CdmPermissionEvaluator.hasPermissions() evaluates the CdmPermissions 
56 46
    like TAXONNODE.UPDATE{20c8f083-5870-4cbd-bf56-c5b2b98ab6a7} -->
57
  <bean id="cdmPermissionEvaluator"
47
  <bean id="cdmPermissionEvaluator" 
58 48
    class="eu.etaxonomy.cdm.persistence.hibernate.permission.CdmPermissionEvaluator">
59 49
    <property name="accessDecisionManager" ref="accessDecisionManager" />
60 50
  </bean>
......
62 52
  <!-- The CdmSecurityHibernateInterceptor checks onSave() and on flushDirty() 
63 53
    if the currently authenticated principal or token has sufficient permissions 
64 54
    on the entity to be persisted -->
65
  <bean id="securityHibernateInterceptor"
55
  <bean id="securityHibernateInterceptor" 
66 56
    class="eu.etaxonomy.cdm.persistence.hibernate.CdmSecurityHibernateInterceptor">
67 57
    <property name="permissionEvaluator" ref="cdmPermissionEvaluator" />
68 58
  </bean>
69 59

  
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" /> -->
60
  <bean id="authenticationManager"
61
    class="org.springframework.security.authentication.ProviderManager">
62
    <property name="providers">
63
      <list>
64
        <ref local="daoAuthenticationProvider" />
65
      </list>
66
    </property>
67
  </bean>
88 68

  
89
<!--   <bean id="saltSource" -->
90
<!--     class="org.springframework.security.authentication.dao.ReflectionSaltSource"> -->
91
<!--     <property name="userPropertyToUse" value="getUsername" /> -->
92
<!--   </bean> -->
69
  <bean id="daoAuthenticationProvider" 
70
    class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
71
    <property name="userDetailsService" ref="userService" />
72
    <property name="saltSource" ref="saltSource" />
73
    <property name="passwordEncoder" ref="passwordEncoder" />
74
  </bean>
93 75

  
76
  <bean id="passwordEncoder" 
77
    class="org.springframework.security.authentication.encoding.Md5PasswordEncoder" />
94 78

  
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>
79
  <bean id="saltSource" 
80
    class="org.springframework.security.authentication.dao.ReflectionSaltSource">
81
    <property name="userPropertyToUse" value="getUsername" />
82
  </bean>
100 83

  
101 84

  
85
  <bean id="cdmServiceCacher" 
86
    class="eu.etaxonomy.cdm.api.cache.CdmServiceCacher" />
102 87

  
103 88

  
104 89
</beans>
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_persistence_security.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
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" xmlns:aop="http://www.springframework.org/schema/aop"
5
  xsi:schemaLocation="http://www.springframework.org/schema/beans
6
    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
7
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
8
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
9
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
10
    ">
11

  
12

  
13
    <!--
14
      ============================== SECURITY ==============================
15
    -->
16
    <bean id="accessDecisionManager" class="eu.etaxonomy.cdm.persistence.hibernate.permission.UnanimousBasedUnrevokable">
17
        <property name="decisionVoters">
18
            <list>
19
                <bean class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.GrantAlwaysVoter" />
20
                <bean class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.TaxonNodeVoter" />
21
                <bean class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.TaxonBaseVoter" />
22
                <bean class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.DescriptionBaseVoter" />
23
                <bean class="eu.etaxonomy.cdm.persistence.hibernate.permission.voter.DescriptionElementVoter" />
24
            </list>
25
        </property>
26
    </bean>
27

  
28
    <!--
29
        CdmPermissionEvaluator.hasPermissions() evaluates the CdmPermissions like TAXONNODE.UPDATE{20c8f083-5870-4cbd-bf56-c5b2b98ab6a7}
30
    -->
31
    <bean id="cdmPermissionEvaluator" class="eu.etaxonomy.cdm.persistence.hibernate.permission.CdmPermissionEvaluator">
32
        <property name="accessDecisionManager" ref="accessDecisionManager" />
33
    </bean>
34

  
35
    <!-- The CdmSecurityHibernateInterceptor checks onSave() and on flushDirty() if the currently authenticated principal or token  has
36
    sufficient permissions on the entity to be persisted -->
37
    <bean id="securityHibernateInterceptor" class="eu.etaxonomy.cdm.persistence.hibernate.CdmSecurityHibernateInterceptor">
38
        <property name="permissionEvaluator" ref="cdmPermissionEvaluator" />
39
    </bean>
40

  
41
</beans>
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_services_security.xml
1
<?xml version="1.0" encoding="UTF-8"?>
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:security="http://www.springframework.org/schema/security"
6
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
7
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
8
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
9
    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"
10
    >
11

  
12
    <import resource="classpath:/eu/etaxonomy/cdm/remoting_persistence_security.xml"/>
13
    <!--
14
        ======================================================================
15
          security specific configuration
16
        ======================================================================
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> -->
21

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

  
30
    <bean id="authenticationManager" class="org.springframework.security.authentication.ProviderManager">
31
        <property name="providers">
32
            <list>
33
                <ref local="daoAuthenticationProvider"/>
34
            </list>
35
        </property>
36
    </bean>
37

  
38
    <bean id="daoAuthenticationProvider" class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
39
        <property name="userDetailsService" ref="userService"/>
40
        <property name="saltSource" ref="saltSource"/>
41
        <property name="passwordEncoder" ref="passwordEncoder"/>
42
    </bean>
43

  
44
    <bean id="passwordEncoder" class="org.springframework.security.authentication.encoding.Md5PasswordEncoder"/>
45

  
46
    <bean id="saltSource" class="org.springframework.security.authentication.dao.ReflectionSaltSource">
47
        <property name="userPropertyToUse" value="getUsername"/>
48
    </bean>
49

  
50
    <!--
51
        Run-As Authentication Replacement for system operations
52
        as e.g. performed by the eu.etaxonomy.cdm.api.application.FirstDataInserter
53

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

  
61

  
62
</beans>
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientCdmRepository.java
11 11

  
12 12
import java.util.Collection;
13 13

  
14
import org.springframework.security.authentication.ProviderManager;
14
import org.springframework.security.authentication.AuthenticationManager;
15 15
import org.springframework.transaction.PlatformTransactionManager;
16 16
import org.springframework.transaction.TransactionStatus;
17 17

  
......
115 115
     * @see eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration#getAuthenticationManager()
116 116
     */
117 117
    @Override
118
    public ProviderManager getAuthenticationManager() {
118
    public AuthenticationManager getAuthenticationManager() {
119 119
        return defaultApplicationConfiguration.getAuthenticationManager();
120 120
    }
121 121

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStore.java
20 20
import org.springframework.core.io.ClassPathResource;
21 21
import org.springframework.core.io.Resource;
22 22
import org.springframework.security.access.PermissionEvaluator;
23
import org.springframework.security.authentication.ProviderManager;
23
import org.springframework.security.authentication.AuthenticationManager;
24 24
import org.springframework.security.core.Authentication;
25 25
import org.springframework.security.core.context.SecurityContext;
26 26
import org.springframework.security.core.context.SecurityContextHolder;
......
82 82
	private static SearchManager searchManager = new SearchManager();
83 83

  
84 84
	private static EditorManager editorManager = new EditorManager();
85
	
86
	private static UseObjectStore useObjectInitializer = new UseObjectStore(); 
85

  
86
	private static UseObjectStore useObjectInitializer = new UseObjectStore();
87 87

  
88 88
	private static CdmStoreConnector job;
89 89

  
......
325 325

  
326 326
		return service;
327 327
	}
328
	
328

  
329 329
	/**
330 330
	 * @see #getService(Class)
331 331
	 * As ICommonService is not extending IService we need a specific request here
......
346 346
	 *         {@link org.springframework.security.authentication.ProviderManager}
347 347
	 *         object.
348 348
	 */
349
	public static ProviderManager getAuthenticationManager() {
349
	public static AuthenticationManager getAuthenticationManager() {
350 350
		return getCurrentApplicationConfiguration().getAuthenticationManager();
351 351
	}
352 352

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/CdmStoreConnector.java
155 155
					subprogressMonitor);
156 156
		} else if(cdmSource instanceof ICdmRemoteSource) {
157 157
			return CdmApplicationRemoteController.NewInstance((ICdmRemoteSource)cdmSource,
158
							false,
159 158
							subprogressMonitor,
160 159
							null);
161 160
		} else {
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/application/CdmApplicationRemoteControllerTest.java
1 1
// $Id$
2 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
*/
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 10
package eu.etaxonomy.taxeditor.application;
11 11

  
12
import org.junit.Test;
13
import org.unitils.UnitilsJUnit4;
14

  
15
import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController;
16
import eu.etaxonomy.cdm.common.monitor.NullProgressMonitor;
17
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
18
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource;
19

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

  
19

  
25
public class CdmApplicationRemoteControllerTest extends UnitilsJUnit4 {
20 26

  
21 27

  
28
    @Test
29
    public void initApplicationControllerTest() {
30
        CdmRemoteSource crs = CdmRemoteSource.NewInstance("local-cyprus",
31
                "localhost",
32
                8080,
33
                "",
34
                NomenclaturalCode.ICNAFP);
35
        // first initialize with validation to make sure the xml is valid
36
        CdmApplicationRemoteController.NewInstance(crs,
37
                true,
38
                new NullProgressMonitor(),
39
                null);
40
    }
22 41
}
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/httpinvoker/BaseRemotingTest.java
37 37
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSourceException;
38 38
import eu.etaxonomy.taxeditor.remoting.source.ICdmRemoteSource;
39 39
import eu.etaxonomy.taxeditor.session.CdmEntitySession;
40
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
41 40
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionEnabled;
41
import eu.etaxonomy.taxeditor.session.ICdmEntitySessionManager;
42 42

  
43 43

  
44 44
/**
......
114 114
        cdmRemoteSource = CdmRemoteSource.NewInstance(sourceName, host, port, contextPath, ncode);
115 115
        remoteApplicationController =
116 116
                CdmApplicationRemoteController.NewInstance(cdmRemoteSource,
117
                        false,
118 117
                        null,
119 118
                        null);
120 119

  

Also available in: Unified diff