-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Spring context and multithreading
PostPosted: Wed Jun 30, 2004 5:43 pm 
Newbie

Joined: Fri Jun 25, 2004 8:42 am
Posts: 3
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.