From bf0cb7b356f8a2d564d8089c2ba1781dbd4ecaa1 Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Wed, 22 Jun 2011 14:30:58 +0000 Subject: [PATCH] throwing an exception if the application context is built twice. SVN: 21821 --- .../openbis/dss/generic/shared/ServiceProvider.java | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 8acc1bc783d..7ed45efefe2 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 @@ -39,6 +39,8 @@ public class ServiceProvider // applicationContex it lazily initialized private static BeanFactory applicationContext = null; + + private static boolean buildingApplicationContext; /** * @deprecated This method should only be used from {@link ServiceProviderTestWrapper} to avoid @@ -64,8 +66,16 @@ public class ServiceProvider { if (applicationContext == null) { + if (buildingApplicationContext) + { + throw new IllegalStateException("Building application context. " + + "Application context hasn't been built completely. " + + "Beans should access other beans lazily."); + } + buildingApplicationContext = true; applicationContext = new ClassPathXmlApplicationContext(new String[] { "dssApplicationContext.xml" }, true); + buildingApplicationContext = false; } } } -- GitLab