Revert cached services map to be local to configuration class
authorCherian Mathew <c.mathew@bgbm.org>
Mon, 23 Nov 2015 09:39:22 +0000 (10:39 +0100)
committerCherian Mathew <c.mathew@bgbm.org>
Mon, 23 Nov 2015 09:39:22 +0000 (10:39 +0100)
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/taxeditor/httpinvoker/CdmRemoteSourceTest.java

index a1ce7e4..26f6889 100644 (file)
@@ -106,7 +106,7 @@ public class CdmApplicationRemoteConfiguration implements ICdmApplicationConfigu
 \r
     private ICdmRemoteSource remoteSource;\r
 \r
-    private static Map serviceMap = new HashMap<Class<IService>, IService>();\r
+    private Map serviceMap = new HashMap<Class<IService>, IService>();\r
 \r
     private ICdmEntitySessionManager cdmEntitySessionManager;\r
 \r
@@ -120,7 +120,7 @@ public class CdmApplicationRemoteConfiguration implements ICdmApplicationConfigu
 \r
     public CdmApplicationRemoteConfiguration(ICdmRemoteSource remoteSource) {\r
         this.remoteSource = remoteSource;\r
-        serviceMap.clear();\r
+\r
     }\r
 \r
     public void setRemoteSource(ICdmRemoteSource remoteSource) {\r
@@ -128,13 +128,19 @@ public class CdmApplicationRemoteConfiguration implements ICdmApplicationConfigu
     }\r
 \r
     private Object getService(Class<?> clazz, String serviceSuffix, CdmAuthenticatedHttpInvokerRequestExecutor executor) {\r
-        return getService(clazz, serviceSuffix, remoteSource, executor);\r
-    }\r
-\r
-    public static Object getService(Class<?> clazz, String serviceSuffix, ICdmRemoteSource remoteSource, CdmAuthenticatedHttpInvokerRequestExecutor executor) {\r
         if(serviceMap.containsKey(clazz)) {\r
             return serviceMap.get(clazz);\r
         }\r
+        Object service = getService(clazz, serviceSuffix, remoteSource, executor);\r
+        serviceMap.put(clazz,  service);\r
+        return service;\r
+    }\r
+\r
+    public static Object getService(Class<?> clazz,\r
+            String serviceSuffix,\r
+            ICdmRemoteSource remoteSource,\r
+            CdmAuthenticatedHttpInvokerRequestExecutor executor) {\r
+\r
         String baseUrl;\r
         if(remoteSource.getContextPath() == null || remoteSource.getContextPath().equals("")) {\r
             baseUrl = "http://" + remoteSource.getServer() + ":" + String.valueOf(remoteSource.getPort());\r
@@ -149,9 +155,7 @@ public class CdmApplicationRemoteConfiguration implements ICdmApplicationConfigu
             proxy.setHttpInvokerRequestExecutor(executor);\r
         }\r
         proxy.afterPropertiesSet();\r
-        Object service = proxy.getObject();\r
-        serviceMap.put(clazz,  service);\r
-        return service;\r
+        return proxy.getObject();\r
     }\r
 \r
     // ****************************** APPLICATION CONTEXT *************************************************/\r
index b3225b9..945d5c6 100644 (file)
@@ -32,7 +32,7 @@ public class CdmRemoteSourceTest extends BaseRemotingTest {
                        contextPath,
                        NomenclaturalCode.ICNAFP);
                try {
-                       inactiveCrs.getDbSchemaVersion();
+                       String dbSchemaVersion = inactiveCrs.getDbSchemaVersion();
                        Assert.fail("getDbSchemaVersion() on inactive cdm server should have thrown RemoteAccessException");
                } catch(CdmSourceException cse) {
                        Assert.fail("getDbSchemaVersion() on inactive cdm server should have thrown RemoteAccessException and not CdmSourceException");
@@ -61,11 +61,6 @@ public class CdmRemoteSourceTest extends BaseRemotingTest {
        }
 
        @Test
-       public void whenConnectingToAnActiveServerWithServicesBlockedThenFailToAccessServices() {
-
-       }
-
-       @Test
        public void whenConnectingToAnActiveServerThenConnectSuccessfully() {
                // check if active server throws the right exception
                CdmRemoteSource activeCrs = CdmRemoteSource.NewInstance(sourceName,