Hi,
I am using Hibernate 2.1.4 and Spring 1.0.2. I am using Spring to manage the transaction of hibernate operations. I am using the declarative approach of Spring to configure this. The following method:
Code:
public static ApplicationContext getApplicationContext(){
if (initObj == null){
throw new IllegalStateException("Application context not initialized");
}
else if (initObj instanceof String){
String contextResourceLocation = (String) initObj;
if (cpxa==null)cpxa=new ClassPathXmlApplicationContext(contextResourceLocation);
return cpxa;
} else {
//throw new IllegalStateException("You must initialize the context with a String or ServletContext");
throw new IllegalStateException("You must initialize the context with a String");
}
}
is setting the application context. I wonder if I can use this "ClassPathXmlApplicationContext" as a singleton amongs several concurrent threads.
I know that Spring is supposed to bound a session to the current Thread but is this done at the time the context is created?
If so that would not be safe to share a single application context among several thread right?
The reason why I don