Project

General

Profile

« Previous | Next » 

Revision d0fbe90d

Added by Cherian Mathew about 10 years ago

comments and javadoc

View differences:

eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java
1
// $Id: CdmApplicationDefaultConfiguration.java 11680 2011-04-04 17:07:39Z a.mueller $
2 1
/**
3
* Copyright (C) 2007 EDIT
2
* Copyright (C) 2014 EDIT
4 3
* European Distributed Institute of Taxonomy 
5 4
* http://www.e-taxonomy.eu
6 5
* 
......
25 24
import eu.etaxonomy.cdm.api.service.IDatabaseService;
26 25
import eu.etaxonomy.cdm.ext.geo.IEditGeoService;
27 26

  
27

  
28 28
/**
29
 * @author a.mueller
30
 * @created 21.05.2008
31
 * @version 1.0
32
 */
33
/**
34
 * @author a.mueller
35
 * @author j.koch
29
 * CDM Application Configuration class which manages the configuration for remoting
30
 * clients
31
 *
36 32
 */
37
// FIXME:Remoting This bean naming is a hack to make remoting work, in conjunction with the
38
// exclude filter in the application package set in the remotingApplicationContext 
33
//FIXME:Remoting This bean naming is a hack to make remoting work, in conjunction with the
34
//exclude filter in the application package set in the remotingApplicationContext 
39 35
//@Component("cdmApplicationDefaultConfiguration")
40 36
public class CdmApplicationRemoteConfiguration extends CdmApplicationDefaultConfiguration {
41 37
	
......
48 44
	public CdmApplicationRemoteConfiguration() {
49 45
	}
50 46
	
51
	@Override
52
	public IDatabaseService getDatabaseService() throws UnsupportedOperationException {
53
		throw new UnsupportedOperationException("getDatabaseService is not implemented for CdmApplicationRemoteConfiguration");
54
	}
55

  
56
	
47
    /* (non-Javadoc)
48
     * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#getTransactionManager()
49
     */
57 50
    @Override
58 51
    public PlatformTransactionManager getTransactionManager() throws UnsupportedOperationException {
59 52
		throw new UnsupportedOperationException("getTransactionManager is not implemented for CdmApplicationRemoteConfiguration");
......
78 71
	}
79 72

  
80 73

  
74
    /* (non-Javadoc)
75
     * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#commitTransaction(org.springframework.transaction.TransactionStatus)
76
     */
81 77
    @Override
82 78
    public void commitTransaction(TransactionStatus txStatus) throws UnsupportedOperationException {
83 79
		throw new UnsupportedOperationException("commitTransaction is not implemented for CdmApplicationRemoteConfiguration");
84 80
	}
85 81
			
82
	/* (non-Javadoc)
83
	 * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#NewConversation()
84
	 */
86 85
	@Override
87
	public ConversationHolder NewConversation() {
88
		// TODO Auto-generated method stub
86
	public ConversationHolder NewConversation() {		
89 87
		return new ConversationHolderMock();
90 88
	}
91 89
	
90
	/**
91
	 * @return
92
	 */
92 93
	public IEditGeoService getEditGeoService() {
93 94
		return this.editGeoService;
94 95
	}
95 96
	
97
	/* (non-Javadoc)
98
	 * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#setDataSource(javax.sql.DataSource)
99
	 */
96 100
	@Override
97
	public void setDataSource(DataSource dataSource) {        
101
	public void setDataSource(DataSource dataSource) {        		
98 102
    }
99 103
	
104
	/* (non-Javadoc)
105
	 * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#setTransactionManager(org.springframework.transaction.PlatformTransactionManager)
106
	 */
100 107
	@Override
101 108
	public void setTransactionManager(PlatformTransactionManager transactionManager) {        
102 109
    }
103 110
	
111
	/* (non-Javadoc)
112
	 * @see eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration#setSessionFactory(org.hibernate.SessionFactory)
113
	 */
104 114
	@Override
105 115
    public void setSessionFactory(SessionFactory sessionFactory) {    	
106 116
    }
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteController.java
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
*/
9

  
10

  
1 11
package eu.etaxonomy.cdm.api.application;
2 12

  
3 13
import java.util.List;
......
17 27
import eu.etaxonomy.cdm.common.monitor.SubProgressMonitor;
18 28
import eu.etaxonomy.cdm.remote.ICdmRemoteSource;
19 29

  
30
/**
31
 * CDM Application Controller class for remoting clients
32
 * FIXME:Remoting extending {@link CdmApplicationController} is a temporary workaround.
33
 * The {@link CdmApplicationController} should be split into a CdmApplicationControllerBase
34
 * class with {@link CdmApplicationController} and this class as subclasses
35
 *
36
 */
20 37
public class CdmApplicationRemoteController  extends CdmApplicationController {
21 38
	
22 39
    private static final Logger logger = Logger.getLogger(CdmApplicationRemoteController.class);
......
25 42
    private final Resource applicationContextResource;
26 43
    private final IProgressMonitor progressMonitor;
27 44
    
45
    /**
46
     * Creates new instance of CdmApplicationRemoteController
47
     * 
48
     * @param applicationContextResource
49
     * @param remoteSource
50
     * @param omitTermLoading
51
     * @param progressMonitor
52
     * @param listeners
53
     * @return
54
     */
28 55
    public static CdmApplicationRemoteController NewInstance(Resource applicationContextResource, 
29 56
			ICdmRemoteSource remoteSource, 				
30 57
			boolean omitTermLoading, 
......
38 65
    	
39 66
    }
40 67
    
68
	/**
69
	 * Constructs CdmApplicationRemoteController
70
	 * 
71
	 * @param applicationContextResource
72
	 * @param remoteSource
73
	 * @param omitTermLoading
74
	 * @param progressMonitor
75
	 * @param listeners
76
	 */
41 77
	private CdmApplicationRemoteController(Resource applicationContextResource, 
42 78
				ICdmRemoteSource remoteSource, 				
43 79
				boolean omitTermLoading, 
......
52 88
	}
53 89
	
54 90
    /**
91
     * Returns classpath resource for application context config file
92
     * 
55 93
     * @return
56 94
     */
57 95
    protected static ClassPathResource getClasspathResource() {
58 96
        return new ClassPathResource(DEFAULT_APPLICATION_CONTEXT_RESOURCE);
59 97
    }
98
    
99
    
60 100
    /**
61
     * Sets the application context to a new spring ApplicationContext by using the according data source and initializes the Controller.
62
     * @param dataSource
101
     * Creates and starts a new spring application context
102
     * 
103
     * @param remoteSource object for connecting to an http-invoker server
104
     * @param omitTermLoading
105
     * @param listeners
106
     * @return
63 107
     */
64 108
    protected boolean setNewRemoteSource(ICdmRemoteSource remoteSource, 
65 109
    		boolean omitTermLoading, 
......
82 126
        pspc.setProperties(properties);
83 127
        applicationContext.addBeanFactoryPostProcessor(pspc);
84 128
        progressMonitor.worked(1);
85
        
86
//        BeanDefinition remoteSourceBean = remoteSource.getRemoteSourceBean();
87
//        remoteSourceBean.setAttribute("isLazy", false);
88
//        applicationContext.registerBeanDefinition("dataSource", remoteSourceBean);
89

  
90 129

  
91 130
        XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(applicationContext);
92 131
        progressMonitor.subTask("Registering resources.");
......
119 158
        return true;
120 159
    }
121 160
    
161
    /* (non-Javadoc)
162
     * @see eu.etaxonomy.cdm.api.application.CdmApplicationController#init()
163
     */
122 164
    @Override
123
    protected void init(){
124
        logger.debug("Init " +  this.getClass().getName() + " ... ");
125
        if (logger.isDebugEnabled()){for (String beanName : applicationContext.getBeanDefinitionNames()){ logger.debug(beanName);}}
126
        //TODO delete next row (was just for testing)
127
        if (logger.isInfoEnabled()){
128
            logger.info("Registered Beans: ");
129
            String[] beanNames = applicationContext.getBeanDefinitionNames();
130
            for (String beanName : beanNames){
131
                logger.info(beanName);
132
            }
133
        }
165
    protected void init(){    
134 166
        configuration = (ICdmApplicationConfiguration)applicationContext.getBean("cdmApplicationRemoteConfiguration");
135 167

  
136 168
    }
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/remote/CdmPersistentRemoteSource.java
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
*/
9

  
1 10
package eu.etaxonomy.cdm.remote;
2 11

  
3 12
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
4 13

  
14
/**
15
 * Class representing a CDM remote source which can be persisted to a source config file
16
 *
17
 */
5 18
public class CdmPersistentRemoteSource extends CdmRemoteSourceBase {
6 19
	
20
	/**
21
	 * Creates a new instance of CdmPersistentRemoteSource
22
	 * 
23
	 * @param name
24
	 * @param server
25
	 * @param port
26
	 * @param contextPath
27
	 * @param nomenclaturalCode
28
	 * @return
29
	 */
7 30
	public CdmPersistentRemoteSource NewInstance(String name, String server, int port, String contextPath, NomenclaturalCode nomenclaturalCode) {
8 31
		return new CdmPersistentRemoteSource(name, server, port, contextPath, nomenclaturalCode);
9 32
	}
10 33
	
34
	/**
35
	 * Creates a new CdmPersistentRemoteSource
36
	 * 
37
	 * @param name
38
	 * @param server
39
	 * @param port
40
	 * @param contextPath
41
	 * @param nomenclaturalCode
42
	 */
11 43
	private CdmPersistentRemoteSource(String name, String server, int port, String contextPath, NomenclaturalCode nomenclaturalCode) { 
12 44
		super(name, server, port, contextPath, nomenclaturalCode);
13 45
		
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/remote/CdmRemoteSource.java
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
*/
1 9
package eu.etaxonomy.cdm.remote;
2 10

  
3
import org.springframework.beans.factory.config.BeanDefinition;
4

  
5 11
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
6 12

  
13
/**
14
 * Class representing a CDM remote source 
15
 *
16
 */
7 17
public class CdmRemoteSource extends CdmRemoteSourceBase {
8 18
	
9 19
	
20
	/**
21
	 * Creates a new instance of CdmRemoteSource
22
	 * 
23
	 * @param name
24
	 * @param server
25
	 * @param port
26
	 * @param contextPath
27
	 * @param nomenclaturalCode
28
	 * @return
29
	 */
10 30
	public static CdmRemoteSource NewInstance(String name, String server, int port, String contextPath, NomenclaturalCode nomenclaturalCode) {
11 31
		return new CdmRemoteSource(name, server, port, contextPath, nomenclaturalCode);
12 32
	}
13 33
	
34
	/**
35
	 * Creates a new CdmRemoteSource
36
	 * 
37
	 * @param name
38
	 * @param server
39
	 * @param port
40
	 * @param contextPath
41
	 * @param nomenclaturalCode
42
	 */
14 43
	private CdmRemoteSource(String name, String server, int port, String contextPath, NomenclaturalCode nomenclaturalCode) { 
15 44
		super(name, server, port, contextPath, nomenclaturalCode);
16 45
		
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/remote/CdmRemoteSourceBase.java
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
*/
1 9
package eu.etaxonomy.cdm.remote;
2 10

  
3
import org.springframework.remoting.RemoteConnectFailureException;
4 11
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;
5 12

  
6 13
import eu.etaxonomy.cdm.api.service.IDatabaseService;
......
8 15
import eu.etaxonomy.cdm.config.CdmSourceException;
9 16
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
10 17

  
18
/**
19
 * Base class representing a CDM remote source. 
20
 * This class handles all the configuration relating to the remoting aspect of
21
 * a CDM source.
22
 *
23
 */
11 24
public class CdmRemoteSourceBase extends CdmSource implements ICdmRemoteSource {
12 25

  
13 26
	private String contextPath;
......
15 28
	
16 29
	private IDatabaseService databaseService;
17 30
	
31
	/**
32
	 * Constructs a CdmRemoteSourceBase
33
	 * 
34
	 * @param name
35
	 * @param server
36
	 * @param port
37
	 * @param contextPath
38
	 * @param nomenclaturalCode
39
	 */
18 40
	protected CdmRemoteSourceBase(String name, String server, int port, String contextPath, NomenclaturalCode nomenclaturalCode) {
19 41
		setName(name);
20 42
		setServer(server);
......
26 48
		} else {
27 49
			setBaseUrl("http://" + server + ":" + String.valueOf(port) + "/" + contextPath);
28 50
		}
51
		// the database service needs to be initialised (before the spring
52
		// application context initialsation) since it is required to 
53
		// to make queries related to the source database
29 54
	    HttpInvokerProxyFactoryBean proxy = new HttpInvokerProxyFactoryBean();
30 55
	    proxy.setServiceInterface(IDatabaseService.class);
31 56
	    proxy.setServiceUrl(getBaseUrl() + "/remoting/database.service");
......
33 58
	    databaseService = (IDatabaseService) proxy.getObject();
34 59
	}
35 60
	
61
	/* (non-Javadoc)
62
	 * @see eu.etaxonomy.cdm.remote.ICdmRemoteSource#getBaseUrl()
63
	 */
36 64
	@Override
37 65
	public String getBaseUrl() {
38 66
		return baseUrl;
39 67
	}
40 68

  
69
	/**
70
	 * Sets the base url for the http-invoker services as listed in 
71
	 * httpInvokerServicesClients.xml.
72
	 * e.g. for 'http://127.0.0.1:8080/col/remoting/common.service', the 
73
	 * base url would be 'http://127.0.0.1:8080/col'
74
	 * 
75
	 * @param baseUrl
76
	 */
41 77
	public void setBaseUrl(String baseUrl) {
42 78
		this.baseUrl = baseUrl;
43 79
	}
44 80

  
81
	/* (non-Javadoc)
82
	 * @see eu.etaxonomy.cdm.remote.ICdmRemoteSource#getContextPath()
83
	 */
45 84
	@Override
46 85
	public String getContextPath() {
47 86
		return contextPath;
48 87
	}
49 88

  
89
	/**
90
	 * Sets the context path.
91
	 * e.g. for 'http://127.0.0.1:8080/col/remoting/common.service', the 
92
	 * context path would be 'col'
93
	 * 
94
	 * @param contextPath
95
	 */
50 96
	public void setContextPath(String contextPath) {
51 97
		this.contextPath = contextPath;
52 98
	}
53 99

  
100
	/* (non-Javadoc)
101
	 * @see eu.etaxonomy.cdm.config.CdmSource#getDbSchemaVersion()
102
	 */
54 103
	@Override
55 104
	public String getDbSchemaVersion() throws CdmSourceException {
56 105
		return databaseService.getDbSchemaVersion();
57 106

  
58 107
	}
59 108

  
109
	/* (non-Javadoc)
110
	 * @see eu.etaxonomy.cdm.config.CdmSource#isDbEmpty()
111
	 */
60 112
	@Override
61 113
	public boolean isDbEmpty() throws CdmSourceException {
62 114
		return databaseService.isDbEmpty();
63 115

  
64 116
	}
65 117

  
118
	/* (non-Javadoc)
119
	 * @see eu.etaxonomy.cdm.config.CdmSource#checkConnection()
120
	 */
66 121
	@Override
67 122
	public boolean checkConnection() throws CdmSourceException {
68 123
		// assuming that database service works implies 
69 124
		// the connection is up
70 125
		// if no exception is thrown then we assume that the 
71 126
		// connection is up
72

  
127
		// FIXME:Remoting is this really correct?
73 128
		databaseService.getDbSchemaVersion();
74 129

  
75 130
		return true;
76 131
	}
77 132

  
133
	/* (non-Javadoc)
134
	 * @see eu.etaxonomy.cdm.config.CdmSource#getConnectionMessage()
135
	 */
78 136
	@Override
79 137
	public String getConnectionMessage() {
80 138
		return "Conncting to Remote CDM Server " + getName();
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/remote/ICdmRemoteSource.java
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
*/
1 9
package eu.etaxonomy.cdm.remote;
2 10

  
3
import org.springframework.beans.factory.config.BeanDefinition;
4

  
5 11
import eu.etaxonomy.cdm.config.ICdmSource;
6 12

  
13
/**
14
 * Interface representing a CDM remote source
15
 *
16
 */
7 17
public interface ICdmRemoteSource extends ICdmSource {
8 18
	
19
	/**
20
	 * Gets the context path.
21
	 * e.g. for 'http://127.0.0.1:8080/col/remoting/common.service', the 
22
	 * context path would be 'col'
23
	 */
9 24
	public String getContextPath();
10 25
	
26
	/**
27
	 * Gets the base url for the http-invoker services as listed in 
28
	 * httpInvokerServicesClients.xml.
29
	 * e.g. for 'http://127.0.0.1:8080/col/remoting/common.service', the 
30
	 * base url would be 'http://127.0.0.1:8080/col'
31
	 */
11 32
	public String getBaseUrl();	
12 33

  
13 34
}

Also available in: Unified diff