com.mentata.l3d
Class L3DContext

java.lang.Object
  extended bycom.mentata.l3d.L3DContext
Direct Known Subclasses:
SG8Context

public class L3DContext
extends Object

An association between an available directory service and objects. Instances of this class are constructed by parsing a formatted text file named context.properties located in a package named for the context under com.mentata.l3d in the Java class hierarchy. It is defined by properties for identifying a directory server, configuring pool of connections to be used with the server, setting encryption standards for directory communication, characterizing authentication, associating a locale, and specifying an associated Java package of objects. Almost all options have defaults that work for simple situations, minimizing the need for their definition. An instance is immutable and offers limited access after its creation. A context is used for getting directory connections or instances of objects that are in an associated Java package.

Since:
0.7
Author:
Jon Roberts

Field Summary
static String CONTEXT_CLASS
          The explicit path for this parent class.
static String CONTEXT_ROOT
          The root class path for context packages.
 
Constructor Summary
L3DContext(String name)
          Constructs a context using properties defined for the given name.
 
Method Summary
 LDAPConnection getConnection()
          Returns a standard connection to the directory.
 LDAPConnection getConnection(String user, byte[] pwd)
          Returns a connection to the directory bound as the given user.
 String getLabel()
          Returns a display friendly label for the context.
 String getName()
          Returns the name of the context.
 L3DObject getObject(String classname)
          Returns an empty instance of the given object.
 L3DObject getObject(String classname, String identifier)
          Returns an instance of the object populated with the identified entry.
 L3DObject getObject(String classname, String identifier, String[] attributes)
          Returns an instance of the object populated with the identified entry and attributes.
protected  ResourceBundle getProperties()
          Returns the properties defined for the context.
 boolean isPooling()
          Indicates if the context uses an anonymous connection pool.
 void returnConnection(LDAPConnection conn)
          Returns a shared connection to the context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_ROOT

public static final String CONTEXT_ROOT
The root class path for context packages.

See Also:
Constant Field Values

CONTEXT_CLASS

public static final String CONTEXT_CLASS
The explicit path for this parent class.

See Also:
Constant Field Values
Constructor Detail

L3DContext

public L3DContext(String name)
           throws L3DException
Constructs a context using properties defined for the given name.

Parameters:
name - the name of the context
Throws:
L3DException - if the properties file is undefined
Method Detail

getName

public String getName()
Returns the name of the context.

Returns:
the name of the context

getLabel

public String getLabel()
Returns a display friendly label for the context.

Returns:
the context's label

getProperties

protected ResourceBundle getProperties()
                                throws L3DException
Returns the properties defined for the context.

Returns:
a resource bundle defining the context
Throws:
L3DException - if the properties file is undefined

isPooling

public boolean isPooling()
Indicates if the context uses an anonymous connection pool.

Returns:
whether the context uses an anonymous connection pool

getConnection

public LDAPConnection getConnection()
                             throws L3DException
Returns a standard connection to the directory.

Returns:
a pooled or fresh directory connection
Throws:
L3DException - if a pool cannot be created or a connection is unavailable

returnConnection

public void returnConnection(LDAPConnection conn)
Returns a shared connection to the context.

Parameters:
conn - a connection created by the context

getConnection

public final LDAPConnection getConnection(String user,
                                          byte[] pwd)
                                   throws L3DException
Returns a connection to the directory bound as the given user.

Parameters:
user - the identifier or RDN attribute value for a user entry
pwd - the user password as bytes
Returns:
an authenticated connection
Throws:
L3DException - if the given user cannot be found or authenticated

getObject

public final L3DObject getObject(String classname)
                          throws L3DException
Returns an empty instance of the given object.

Parameters:
classname - the class name of the object
Returns:
an empty instance of an object
Throws:
L3DException - if the object is improperly defined

getObject

public final L3DObject getObject(String classname,
                                 String identifier)
                          throws L3DException
Returns an instance of the object populated with the identified entry.

Parameters:
classname - the class name of the object
identifier - the identifier value for an entry
Returns:
a fully populated instance of an object
Throws:
L3DException - if the object is improperly defined or the identifier is incorrect

getObject

public final L3DObject getObject(String classname,
                                 String identifier,
                                 String[] attributes)
                          throws L3DException
Returns an instance of the object populated with the identified entry and attributes.

Parameters:
classname - the class name of the object
identifier - the identifier value for an entry
attributes - the attributes to populate
Returns:
a populated instance of an object
Throws:
L3DException - if the object is improperly defined or the identifier is incorrect