|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bankframe.ejb.EEntityBean com.bankframe.ei.ldap.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 java.lang.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 |
java.lang.Object |
get(java.lang.String key)
This method retireves the specified ldap attribute |
java.util.Enumeration |
getMultiple(java.lang.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 java.lang.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(java.lang.String key,
java.lang.Object value)
This method stores the specified ldap attribute |
void |
putMultiple(java.lang.String key,
java.util.Enumeration values)
This method stores multiple values in an attribute |
void |
putObjectClass(java.lang.String objectClass)
This method stores the ldap object's objectclass. |
void |
setEntityContext(javax.ejb.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 java.lang.String LDAP_SERVER_CONTEXT_ALIAS
Constructor Detail |
public LDAPEntityBean()
Method Detail |
public void ejbActivate()
ejbActivate
in interface javax.ejb.EntityBean
ejbActivate
in class EEntityBean
public void ejbLoad()
ejbLoad
in interface javax.ejb.EntityBean
ejbLoad
in class EEntityBean
public void ejbPassivate()
ejbPassivate
in interface javax.ejb.EntityBean
ejbPassivate
in class EEntityBean
public void ejbRemove()
ejbRemove
in interface javax.ejb.EntityBean
ejbRemove
in class EEntityBean
public void ejbStore()
ejbStore
in interface javax.ejb.EntityBean
ejbStore
in class EEntityBean
public java.lang.Object get(java.lang.String key)
key
- Name of the attribute to retrievepublic java.util.Enumeration getMultiple(java.lang.String key)
key
- Name of the attribute to retrievepublic LDAPPrimaryKey getPrimaryKey()
public abstract java.lang.String getRdnAttributeName()
public LDAPEntityBeanPK ldapCreate() throws javax.ejb.CreateException
javax.ejb.CreateException
- if the entry cannot be createdpublic void put(java.lang.String key, java.lang.Object value)
key
- Name of the attributevalue
- The data to storepublic void putMultiple(java.lang.String key, java.util.Enumeration values)
key
- Name of the attributevalues
- The data to storepublic void putObjectClass(java.lang.String objectClass)
public void setEntityContext(javax.ejb.EntityContext ctx) throws java.rmi.RemoteException
setEntityContext
in interface javax.ejb.EntityBean
setEntityContext
in class EEntityBean
ctx
- - the context of the entity.
java.rmi.RemoteException
public DataPacket toDataPacket()
toDataPacket
in class EEntityBean
public void unsetEntityContext() throws java.rmi.RemoteException
unsetEntityContext
in interface javax.ejb.EntityBean
unsetEntityContext
in class EEntityBean
java.rmi.RemoteException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |