I would like to manage ldap connections for different openldap servers and thought about the following scenarios:
1) Create a initial directory context on a Application Scoped component with @Create and outject DirContext
This works nicely since the DirContext can be injected into other narrower scoped components.
2) Use a second, session scoped component that injects the context from 1) and has a method that creates additional context instances for other components
So any component that needs a context just calls the method in 2) e.g. getNewContext()
Would this be an appropriate solution for managing LDAP connections?
Also if I just use 1), is the DirContext thread safe? Can the DirContext be shared between all other components?
Thanks for any additional thoughts on this.