Am 16.03.2012 08:24, schrieb Felix Schumacher:
Am 15.03.2012 21:54, schrieb Michael-O:
Hi folks,

I'd like to write a custom ldap resource factory as same as a data
source factory. The getObjectInstance method shall return
InitialDirContext object. I have written a mock factory and noticed
that the output is cached by Tomcat. So the object is created only
once (same id in Eclipse debugger).
I think you can change that behavior, but it will not be necessary in
your case.
I have found it. In http://tomcat.apache.org/tomcat-7.0-doc/config/context.html
look for "singleton". But I still believe, that you will not need it.

Regards
 Felix

Now I need to verify that the InitialDirContext is still valid (conn
timeout, etc.), same as testOnBorrow with DataSource. I won't have any
reference to it after its creation. This means that I would need to
wrap that object somehow and perform the operation myself?
This is how Tomcat JDBC Pool does.

Is my assumption correct? If yes, I would need to wrap every sing
method defined in DirContext and InitialDirContext.
If you look at the example, you gave. You will see, that the resource created a factory for you. That factory manages a pool and creates and validates
connection objects for you.

So, by using

http://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html#Generic_JavaBean_Resources
you can easily define a resource, which creates a
DirContext-factory/pool object.

That factory can be the same for the whole application, if you make
it thread safe.

The factory-method can than manage the pool and validate each
DirContext object, before it
hands it out to you. Just remember to give it back to the pool/factory.

Regards
 Felix

Thanks,

Mike


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to