com.primix.vlib.ejb.impl
Class AbstractEntityBean

java.lang.Object
  |
  +--com.primix.vlib.ejb.impl.AbstractEntityBean
All Implemented Interfaces:
EnterpriseBean, EntityBean, java.io.Serializable
Direct Known Subclasses:
BookBean, PersonBean, PublisherBean

public abstract class AbstractEntityBean
extends java.lang.Object
implements EntityBean

Provides basic support for the entity context, empty or minimal implementations of the required methods, and some utilties.

Version:
$Id: AbstractEntityBean.java,v 1.1 2001/06/14 15:21:23 hship Exp $
Author:
Howard Ship
See Also:
Serialized Form

Field Summary
protected  EntityContext context
          The EntityContext provided by the application server.
protected  boolean dirty
          Flag indicating that the object is 'dirty' and needs to be written back to the database.
 
Constructor Summary
AbstractEntityBean()
           
 
Method Summary
 java.lang.Integer allocateKey()
          Uses the KeyAllocator session bean to allocate a necessary key.
 void ejbActivate()
          Empty implementation; subclasses may override.
 void ejbLoad()
          Clears the dirty flag.
 void ejbPassivate()
          Empty implementation; subclasses may override.
 void ejbRemove()
          Empty implementation; subclasses may override.
 void ejbStore()
          Clears the dirty flag.
protected abstract  java.lang.String[] getAttributePropertyNames()
          Implemented in subclasses to provide a list of property names to be included in the entity attributes map.
 java.util.Map getEntityAttributes()
          Returns a Map of the properties of the bean.
protected  java.lang.Object getEnvironmentObject(java.lang.String name, java.lang.Class objectClass)
          Gets a named object from the bean's environment naming context.
 boolean isDirty()
          Returns a flag that indicates that the entity must be saved to the database.
 void setEntityContext(EntityContext context)
           
 void unsetEntityContext()
           
 void updateEntityAttributes(java.util.Map update)
          Updates the bean with property changes from the update Map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected EntityContext context
The EntityContext provided by the application server.

dirty

protected transient boolean dirty
Flag indicating that the object is 'dirty' and needs to be written back to the database. Each mutator method should set this to true.
Constructor Detail

AbstractEntityBean

public AbstractEntityBean()
Method Detail

setEntityContext

public void setEntityContext(EntityContext context)
Specified by:
setEntityContext in interface EntityBean

unsetEntityContext

public void unsetEntityContext()
Specified by:
unsetEntityContext in interface EntityBean

isDirty

public boolean isDirty()
Returns a flag that indicates that the entity must be saved to the database.

getEnvironmentObject

protected java.lang.Object getEnvironmentObject(java.lang.String name,
                                                java.lang.Class objectClass)
                                         throws java.rmi.RemoteException,
                                                NamingException
Gets a named object from the bean's environment naming context.

ejbActivate

public void ejbActivate()
                 throws EJBException,
                        java.rmi.RemoteException
Empty implementation; subclasses may override.
Specified by:
ejbActivate in interface EntityBean

ejbPassivate

public void ejbPassivate()
                  throws EJBException,
                         java.rmi.RemoteException
Empty implementation; subclasses may override.
Specified by:
ejbPassivate in interface EntityBean

ejbRemove

public void ejbRemove()
               throws EJBException,
                      java.rmi.RemoteException
Empty implementation; subclasses may override.
Specified by:
ejbRemove in interface EntityBean

ejbLoad

public void ejbLoad()
             throws EJBException,
                    java.rmi.RemoteException
Clears the dirty flag. Subclasses may invoke this implementation, or simply do so themselves.
Specified by:
ejbLoad in interface EntityBean

ejbStore

public void ejbStore()
              throws EJBException,
                     java.rmi.RemoteException
Clears the dirty flag. Subclasses may invoke this implementation, or simply do so themselves.
Specified by:
ejbStore in interface EntityBean

allocateKey

public java.lang.Integer allocateKey()
                              throws java.rmi.RemoteException
Uses the KeyAllocator session bean to allocate a necessary key.

getAttributePropertyNames

protected abstract java.lang.String[] getAttributePropertyNames()
Implemented in subclasses to provide a list of property names to be included in the entity attributes map.

getEntityAttributes

public java.util.Map getEntityAttributes()
Returns a Map of the properties of the bean. This Map is returned to the client, where it can be modified and then used to update the entity bean in a single method

The properties included in the Map are defined by the getAttributePropertyNames() method, which is implemented by concrete subclasses.


updateEntityAttributes

public void updateEntityAttributes(java.util.Map update)
Updates the bean with property changes from the update Map. Only the keys defined by getAttributePropertyNames() will be accessed (keys and values that are not in that list are ignored).

The corresponding bean property will only be updated if the key is present ... this means that the update may contain just the changed keys. Remember that a Map may store null values.