com.ca.commons.jndi.beans
Interface DirContextFactory

All Known Implementing Classes:
FailureSimulateDirContextFactory, FixedDirContextFactory, MappingDummyDirContextFactory, ResilientDirContextFactory, StandardDirContextFactory

public interface DirContextFactory

A factory interface for creating DirContext instances. An object implementing this interface can be passed to the JNDIBeanStoreFactory.newBeanStore(DirContextFactory) method, which creates a new JNDIBeanStore instance. The JNDIBeanStore will then use the provided DirContextFactory whenever it needs a DirContext. Factories are usually configured in JavaBeans style. Therefore, implementations of this interface should provide a public no-arg constructor, along with property setter methods to allow the instance to be configured. These property setters must be used to configure factories before passing them to the JNDIBeanStoreFactory.newBeanStore method.

Within a single instance of JNDIBeanStore, calls to the getContext and returnContext methods will always be paired. Therefore, getContext is called first, and is always followed by a later call to returnContext. The close method is called by the JNDIBeanStore.close() method, and can be used by a factory to perform cleanup.

Note that this interface is not designed with concurrent access in mind. Therefore, a factory instance should only ever be used with a single JNDIBeanStore instance. Implementations of this interface should expect to only be called by one thread at a time.

See Also:
JNDIBeanStoreFactory, JNDIBeanStore, DirContext

Method Summary
 void close()
          Indicates that the JNDIBeanStore using this factory has been closed down.
 DirContext getContext()
          Returns a DirContext instance that is ready for use.
 void returnContext(DirContext ctx)
          Called to indicate that a DirContext previously provided by this factory is no longer needed.
 

Method Detail

getContext

DirContext getContext()
                      throws NamingException
Returns a DirContext instance that is ready for use. The object returned by this method will always be passed back as a parameter to the returnContext method.

Throws:
NamingException - If a DirContext could not be established for any reason.
See Also:
returnContext(javax.naming.directory.DirContext)

returnContext

void returnContext(DirContext ctx)
                   throws NamingException
Called to indicate that a DirContext previously provided by this factory is no longer needed.

Parameters:
ctx - The DirContext previously returned by the getContext method.
Throws:
NamingException - If there was a problem cleaning up the context.
See Also:
getContext()

close

void close()
           throws NamingException
Indicates that the JNDIBeanStore using this factory has been closed down. An implementation should free up any resources it is using.

Throws:
NamingException - If there was a problem when freeing resources.
See Also:
JNDIBeanStore.close()


Created 2011-07-14 13:27 EST