views:

28

answers:

1

I have a class

class ObjFactory {
 MyObject getObject() {...}
 void returnObject() {...}
}

How can we configure Tomcat so that it would provide this factory through JNDI and manages this factory?

Say, one web app should get access to this factory and it must exist only 1 factory in Tomcat, every copy of a web app references the same object.

  1. What are specific rules to design this factory class? Maybe it should implement some interface to work with Tomcat, JNDI in the way I described?

  2. How to glue this class, tomcat and webapp (what should be written in what file, web.xml, context.xml, etc)?

+1  A: 

If you are using Tomcat 5.5, this is a good place to start: JNDI Resources HOW-TO.

Scroll down to the 'Adding Custom Resource Factories' section for a step-by-step explanation.

Eric Eijkelenboom