Project

General

Profile

« Previous | Next » 

Revision d02ff6c0

Added by Cherian Mathew over 8 years ago

Revert cached services map to be local to configuration class

View differences:

eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java
106 106

  
107 107
    private ICdmRemoteSource remoteSource;
108 108

  
109
    private static Map serviceMap = new HashMap<Class<IService>, IService>();
109
    private Map serviceMap = new HashMap<Class<IService>, IService>();
110 110

  
111 111
    private ICdmEntitySessionManager cdmEntitySessionManager;
112 112

  
......
120 120

  
121 121
    public CdmApplicationRemoteConfiguration(ICdmRemoteSource remoteSource) {
122 122
        this.remoteSource = remoteSource;
123
        serviceMap.clear();
123

  
124 124
    }
125 125

  
126 126
    public void setRemoteSource(ICdmRemoteSource remoteSource) {
......
128 128
    }
129 129

  
130 130
    private Object getService(Class<?> clazz, String serviceSuffix, CdmAuthenticatedHttpInvokerRequestExecutor executor) {
131
        return getService(clazz, serviceSuffix, remoteSource, executor);
132
    }
133

  
134
    public static Object getService(Class<?> clazz, String serviceSuffix, ICdmRemoteSource remoteSource, CdmAuthenticatedHttpInvokerRequestExecutor executor) {
135 131
        if(serviceMap.containsKey(clazz)) {
136 132
            return serviceMap.get(clazz);
137 133
        }
134
        Object service = getService(clazz, serviceSuffix, remoteSource, executor);
135
        serviceMap.put(clazz,  service);
136
        return service;
137
    }
138

  
139
    public static Object getService(Class<?> clazz,
140
            String serviceSuffix,
141
            ICdmRemoteSource remoteSource,
142
            CdmAuthenticatedHttpInvokerRequestExecutor executor) {
143

  
138 144
        String baseUrl;
139 145
        if(remoteSource.getContextPath() == null || remoteSource.getContextPath().equals("")) {
140 146
            baseUrl = "http://" + remoteSource.getServer() + ":" + String.valueOf(remoteSource.getPort());
......
149 155
            proxy.setHttpInvokerRequestExecutor(executor);
150 156
        }
151 157
        proxy.afterPropertiesSet();
152
        Object service = proxy.getObject();
153
        serviceMap.put(clazz,  service);
154
        return service;
158
        return proxy.getObject();
155 159
    }
156 160

  
157 161
    // ****************************** APPLICATION CONTEXT *************************************************/
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/httpinvoker/CdmRemoteSourceTest.java
32 32
		        contextPath,
33 33
		        NomenclaturalCode.ICNAFP);
34 34
		try {
35
			inactiveCrs.getDbSchemaVersion();
35
			String dbSchemaVersion = inactiveCrs.getDbSchemaVersion();
36 36
			Assert.fail("getDbSchemaVersion() on inactive cdm server should have thrown RemoteAccessException");
37 37
		} catch(CdmSourceException cse) {
38 38
			Assert.fail("getDbSchemaVersion() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
......
60 60

  
61 61
	}
62 62

  
63
	@Test
64
	public void whenConnectingToAnActiveServerWithServicesBlockedThenFailToAccessServices() {
65

  
66
	}
67

  
68 63
	@Test
69 64
	public void whenConnectingToAnActiveServerThenConnectSuccessfully() {
70 65
		// check if active server throws the right exception

Also available in: Unified diff