1

I have a class

 class ObjPool { MyObject getObject() {...} void returnObject() {...} int getUsedCount() {...} }

How can we use Spring framework so that it would provide only one copy of this factory to all (web) applications and so that each and every application use the same ObjPool?

I mean if app A gets an object from this ObjPool, then all other applications that invoke getUsedCount() will see that value decremented.

2
  • a container-wide Singleton? via JNDI maybe? Commented Mar 24, 2010 at 11:25
  • @josek Yes, container-wide. JNDI is possible, but they tell you can do it with Spring as well. Is that right? Commented Mar 24, 2010 at 11:27

2 Answers 2

3

In Spring each bean is a singleton by default, which means - one instance of the bean per ApplicationContext. This is NOT one per container, but one per web application.

http://blog.springsource.com/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/ gives an example of how to load an ApplicationContext at the EAR level and share across all wars.

Sign up to request clarification or add additional context in comments.

Comments

1

You could just google for "spring export to jndi"

http://maestro-lab.blogspot.com/2009/01/how-to-export-spring-managed-bean-to.html

org.springframework.jndi.JndiTemplate is a good place to start

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.