|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bankframe.ejb.EEntityBean
com.bankframe.ei.ldap.LDAPEntityBean
public abstract class LDAPEntityBean
This class is the base class for Bean Managed EJB's that persist to/from an LDAP data source All bankframe entities that need to access LDAP data should derive from this class.
The derived class must implement the abstract getRdnAttributeName() method, In ldap terms the rdn ( Relative Distinguished Name ) is an entity's primary key.
The derived class can set and get attribute values using the put() and get() methods. Multi-valued attributes should be put and got using the putMultiple() and getMultiple() methods which expect the multiple values to be passed/returned as enumerations
The derived class can specifiy its LDAP objectclass(es) using the putObjectClass() method. The object's attributes and objectclasses MUST be
specified before a call to the LDAPEntityBean.ejbCreate() method is called.The derived class's ejbCreate() method(s) should return an instance of the LDAPEntityBeanPK class or sub-class
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import com.bankframe.ei.ldap.LDAPEntityBean;
public class ExampleLDAPBean extends LDAPEntityBean {
private final String RDN_ATTRIBUTE_NAME="cn";
// ejb creation method
public LDAPEntityBeanPK ejbCreate(String commonName) throws CreateException {
this.putObjectClass("container");
this.put(this.RDN_ATTRIBUTE_NAME,commonName);
return super.ejbCreate();
}
// required method
public void ejbPostCreate(String commonName) throws RemoteException, CreateException {
}
// required method
public String getRdnAttributeName() {
return this.RDN_ATTRIBUTE_NAME;
}
// EntityBean attribute getter
public String getCommonName() {
return this.get(this.RDN_ATTRIBUTE_NAME);
}
public LDAPEntityBeanPK ejbFindByPrimaryKey(LDAPEntityBeanPK primaryKey) throws FinderException {
return (LDAPEntityBeanPK)super.ldapFindByPrimaryKey(primaryKey);
}
public Enumeration ejbFindAll() throws FinderException {
return super.ldapFindAll(LDAPEntityBeanPK.class);
}
}
import com.bankframe.ei.ldap.LDAPPrimaryKey;
public class ExamplePK implements LDAPrimaryKey {
public String attribute1;
ExamplePK() {};
ExamplePK(String attribute1) { this.attribute1 = attribute1; }
// LDAPPrimaryKey required methods
public String getRdnAttributeValue() { return this.attribute1; }
public void setRdnAttributeValue(String value) { this.attribute1 = value ;}
public boolean equals( Object o ) {
if ( o instanceof ExamplePK ) {
ExamplePK otherKey = (ExamplePK)o;
return this.attribute1.equals(otherKey.attribute1)
}
return false;
}
public int hashCode() { return attribute1.hashCode(); }
}
The example EJB above would need to be adapted as follows to use this primary key class:
public ExamplePK ejbCreate(String commonName) throws CreateException {
this.putObjectClass("container");
this.put(this.RDN_ATTRIBUTE_NAME,commonName);
super.ldapCreate();
// create the primary key ourselves
return new ExamplePK(commonName);
}
public ExamplePK ejbFindByPrimaryKey(ExamplePK primaryKey) throws FinderException {
return (ExamplePK)super.ldapFindByPrimaryKey(primaryKey);
}
public Enumeration ejbFindAll() throws FinderException {
return super.ldapFindAll(ExamplePK.class);
}
Field Summary | |
---|---|
static String |
LDAP_SERVER_CONTEXT_ALIAS
|
Constructor Summary | |
---|---|
LDAPEntityBean()
|
Method Summary | |
---|---|
void |
ejbActivate()
This method is called by the EJB Container when this entity instance is activated, i.e. |
void |
ejbLoad()
This method is called by the EJB Container when this entity instance must referesh its instance data from the data source |
void |
ejbPassivate()
This method is called by the EJB Container when this entity instance is about to be passivated, i.e. |
void |
ejbRemove()
This method is called by the EJB Container when this entity instance is about to be removed, the data in the LDAP server should be deleted |
void |
ejbStore()
This method is called by the EJB Container when this entity instance should be persisted to the LDAP server |
Object |
get(String key)
This method retireves the specified ldap attribute |
Enumeration |
getMultiple(String key)
This method retrieves an ldap attribute that contains more than one value |
LDAPPrimaryKey |
getPrimaryKey()
This method gets the Primary Key for this entity bean |
abstract String |
getRdnAttributeName()
This method must be implemented by all derived classes. |
LDAPEntityBeanPK |
ldapCreate()
This method initialises the bean, create the entry on the ldap server and create a primary key instance |
void |
put(String key,
Object value)
This method stores the specified ldap attribute |
void |
putMultiple(String key,
Enumeration values)
This method stores multiple values in an attribute |
void |
putObjectClass(String objectClass)
This method stores the ldap object's objectclass. |
void |
setEntityContext(EntityContext ctx)
This method is called by the EJB Container to store the entity's context |
DataPacket |
toDataPacket()
This method provides a default implementation of toDataPacket() by copying the values of each of the attributes to the dataPacket |
void |
unsetEntityContext()
This method is called by the EJB Container when this entity bean instance is about to returned to the free bean pool. |
Methods inherited from class com.bankframe.ejb.EEntityBean |
---|
toString, validate |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String LDAP_SERVER_CONTEXT_ALIAS
Constructor Detail |
---|
public LDAPEntityBean()
Method Detail |
---|
public void ejbActivate()
ejbActivate
in interface EntityBean
ejbActivate
in class EEntityBean
public void ejbLoad()
ejbLoad
in interface EntityBean
ejbLoad
in class EEntityBean
public void ejbPassivate()
ejbPassivate
in interface EntityBean
ejbPassivate
in class EEntityBean
public void ejbRemove()
ejbRemove
in interface EntityBean
ejbRemove
in class EEntityBean
public void ejbStore()
ejbStore
in interface EntityBean
ejbStore
in class EEntityBean
public Object get(String key)
key
- String of the attribute to retrieve
public Enumeration getMultiple(String key)
key
- String of the attribute to retrieve
public LDAPPrimaryKey getPrimaryKey()
public abstract String getRdnAttributeName()
public LDAPEntityBeanPK ldapCreate() throws CreateException
CreateException
- if the entry cannot be createdpublic void put(String key, Object value)
key
- Name of the attributevalue
- The data to storepublic void putMultiple(String key, Enumeration values)
key
- Name of the attributevalues
- The data to storepublic void putObjectClass(String objectClass)
public void setEntityContext(EntityContext ctx) throws RemoteException
setEntityContext
in interface EntityBean
setEntityContext
in class EEntityBean
ctx
- - the context of the entity.
RemoteException
public DataPacket toDataPacket()
toDataPacket
in class EEntityBean
public void unsetEntityContext() throws RemoteException
unsetEntityContext
in interface EntityBean
unsetEntityContext
in class EEntityBean
RemoteException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |