diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/ServiceProvider.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/ServiceProvider.java index e2bbcfb0c90ff7cfa92e3ee8f86235cdf8e0ab2a..caa44d75121d178196a9e7461a68ccfb278e49f4 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/ServiceProvider.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/ServiceProvider.java @@ -48,7 +48,7 @@ public class ServiceProvider private static final Logger operationLog = LogFactory.getLogger(LogCategory.OPERATION, ServiceProvider.class); - // applicationContex it lazily initialized + // applicationContex is lazily initialized private static BeanFactory applicationContext = null; private static boolean buildingApplicationContext; @@ -85,7 +85,12 @@ public class ServiceProvider } buildingApplicationContext = true; applicationContext = new ClassPathXmlApplicationContext(new String[] - { "dssApplicationContext.xml" }, true); + { "dssApplicationContext.xml" }, true) + { + { + setDisplayName("Application Context from { dssApplicationContext.xml }"); + } + }; buildingApplicationContext = false; } } diff --git a/screening/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DssScreeningApplicationContext.java b/screening/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DssScreeningApplicationContext.java index 4bed7de351c1fe485aafaa2615ef94b780b11ac9..2fdd09ce7d661c3598e0699d6ecc07febf7b12fa 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DssScreeningApplicationContext.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DssScreeningApplicationContext.java @@ -31,7 +31,10 @@ public class DssScreeningApplicationContext private static final String DSS_RPC_SERVICE_JSON = "data-store-rpc-service-screening-json"; - private static ApplicationContext instance; + private static ApplicationContext instance = null; + + // applicationContex is lazily initialized + private static boolean buildingApplicationContext; public static StreamSupportingHttpInvokerServiceExporter getDssRpcService() { @@ -47,8 +50,27 @@ public class DssScreeningApplicationContext { if (instance == null) { - instance = new ClassPathXmlApplicationContext(new String[] - { "screening-dssApplicationContext.xml" }, true); + synchronized (DssScreeningApplicationContext.class) + { + if (instance == null) + { + if (buildingApplicationContext) + { + throw new IllegalStateException("Building application context. " + + "Application context hasn't been built completely. " + + "Beans should access other beans lazily."); + } + buildingApplicationContext = true; + instance = new ClassPathXmlApplicationContext(new String[] + { "screening-dssApplicationContext.xml" }, true) + { + { + setDisplayName("Application Context from { screening-dssApplicationContext.xml }"); + } + }; + buildingApplicationContext = false; + } + } } return instance; }