HierarchicalEntityImpl Class

com.bea.p13n.property
HierarchicalEntityImpl Class

public abstract class HierarchicalEntityImpl

    extends ConfigurableEntityImpl

HierarchicalEntity extends ConfigurableEntity by describing an interface by which Entities can be included in a hierachy of successors. The resulting hierarchy is searched upward when getting Properties. This design pattern models the Chain of Responsibility Pattern (Gamma et al).

For example, if an entity A has a successor entity B, and A is queried for a property but does not have a value persisted for that property, it will lookup entity B and query it for that property.

Also, "explicit" successors can be specified as part of a getProperty method call. These are other ConfigurableEntities that should be queried after the current entity, but before any persisted successors.

A HierarchicalEntity can have one successor persisted for each property set, as well as a "default" successor that is not associated with a property set. The default successor will be queried in the case that the current entity does not have a value, the explicit successor (if one is specified) does not have a value, and the successor for the property's property set does not have a value.


Hierarchy
Object
  AbstractConfigurableEntity
    ConfigurableEntityImpl
      HierarchicalEntityImpl
All Implemented Interfaces

ConfigurableEntity, EnterpriseBean, EntityBean, Serializable

Field Summary

protected static final String
FIND_BY_PK
finder method name
   
Fields from  com.bea.p13n.property.ConfigurableEntityImpl
_ctx, _environmentNamingContext, COMMERCE_POOL, ENTITY_PROPERTY_MANAGER, entityPropertyManager, JNDI_NAME, PROPERTY_SET_MANAGER, PROPERTY_SET_TYPE, propertyLocator, psManager, textFormatter, uid
 
Fields from  com.bea.p13n.property.AbstractConfigurableEntity
CE_METHOD_CACHE, instanceClass, PREFIX_GET, PREFIX_SET, propertyCache, textFormatter
 
Fields from interface com.bea.p13n.property.ConfigurableEntity
RESERVED_PROPERTY_SET
 

Constructor Summary

HierarchicalEntityImpl()

 

Method Summary

protected Method
getFindByPrimaryKey(Class homeClass, Class[] params)
Get the findByPrimaryKey method from a home interface.
protected Object
getImplicitProperty(String propertySet, String propertyName)
Override ConfigurableEntity.getImplicitProperty to do a successor search if the property was not found in this entity
protected Object
getImplicitProperty(String propertySet, String propertyName, ConfigurableEntity explicitSuccessor)
Search for the property value in the default database tables; first in the current entity, then in the explicit successor entity, then in the implicit successor for the property set, and finally in the default implicit successor for this entity.
public Object
getProperty(String propertySet, String propertyName, ConfigurableEntity successor)
Retrieve the value associated with the named key in the specified property set.
public String
getPropertyAsString(String propertySet, String propertyName, ConfigurableEntity successor)
Convenience method to return the property as a String.
public Object
getPropertyNoDefault(String propertySet, String propertyName, ConfigurableEntity successor)
Retrieve the value associated with the property in the specified property set, but does not return a default value from the property's PropertyDefinition if the property does not exist for the entity or in the hierarchy of successors.
public ConfigurableEntity
getSuccessor(String propertySet)
Retrieve the successor associated with this ConfigurableEntity for the specified property set.
protected ConfigurableEntity
getSuccessorFromId(Long anEntityId)
Get the entity represented by a unique entity id.
public void
removeSuccessor(String propertySet)
Remove the successor for the specified propertySet.
public void
setSuccessor(String propertySet, ConfigurableEntity successor)
This sets the successor for this object.
 
Methods from  com.bea.p13n.property.ConfigurableEntityImpl
createUniqueId, ejbActivate, ejbCreate, ejbFindByPrimaryKey, ejbLoad, ejbPassivate, ejbPostCreate, ejbRemove, ejbStore, getConnection, getDefaultSqlBundleName, getEntityContext, getEntityPropertyManager, getEnvironmentNamingContext, getEnvironmentProperty, getEnvironmentProperty, getJndiName, getPkString, getProperty, getPropertyCache, getPropertyDefault, getPropertyLocator, getPropertyLocator, getPropertySetManager, getStatement, getUniqueId, removeProperty, setEntityContext, setProperty, unsetEntityContext, useEntityPropertyManager
 
Methods from  com.bea.p13n.property.AbstractConfigurableEntity
createMapKey, getCachedProperty, getExplicitProperty, getExplicitSetter, getJndiName, getPkString, getProperty, getPropertyAsString, getPropertyCache, getPropertyNoDefault, getUniqueId, hasExplicitGetter, hasExplicitSetter, removeExplicitProperty, removeProperty, setExplicitProperty, setProperty, upcaseFirst
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   
Methods from interface com.bea.p13n.property.ConfigurableEntity
getJndiName, getPkString, getProperty, getPropertyAsString, getPropertyNoDefault, getUniqueId, removeProperty, setProperty
 
Methods from interface javax.ejb.EntityBean
ejbActivate, ejbLoad, ejbPassivate, ejbRemove, ejbStore, setEntityContext, unsetEntityContext
 

Field Detail

FIND_BY_PK

protected static final String FIND_BY_PK
finder method name

 

Constructor Detail

HierarchicalEntityImpl

public HierarchicalEntityImpl()
 

Method Detail

getFindByPrimaryKey(Class, Class[]) Method

protected Method getFindByPrimaryKey(Class homeClass, 
                                     Class[] params)
Get the findByPrimaryKey method from a home interface. This will cache the methods based on home class for faster lookups.


getImplicitProperty(String, String) Method

protected Object getImplicitProperty(String propertySet, 
                                     String propertyName)
throws RemoteException
Override ConfigurableEntity.getImplicitProperty to do a successor search if the property was not found in this entity

Overrides
AbstractConfigurableEntity.getImplicitProperty(String, String)

Parameters

propertySet
The name of the property set
propertyName
The name of the property to retrieve.

Returns

the property value, or null if it was not found

Exceptions

RemoteException

getImplicitProperty(String, String, ConfigurableEntity) Method

protected Object getImplicitProperty(String propertySet, 
                                     String propertyName, 
                                     ConfigurableEntity explicitSuccessor)
throws RemoteException
Search for the property value in the default database tables; first in the current entity, then in the explicit successor entity, then in the implicit successor for the property set, and finally in the default implicit successor for this entity.

Parameters

propertySet
The name of the property set
propertyName
The name of the property to retrieve.
explicitSuccessor
The explicit successor to use for sucessor hiearchy search if the entity does not have the property defined.

Exceptions

RemoteException

getProperty(String, String, ConfigurableEntity) Method

public Object getProperty(String propertySet, 
                          String propertyName, 
                          ConfigurableEntity successor)
throws RemoteException
Retrieve the value associated with the named key in the specified property set. If the entity does not have a value defined for that property, the property will be searched in the successor hiearchy using the explicit successor first and then the successor for the specified scope, and finally the entity's default successor. If this search does not return a value, the default value from the property set will be returned.

Parameters

propertySet
The name of the property set
propertyName
The name of the property to retrieve.
successor
The explicit successor to use for sucessor hiearchy search if the entity does not have the property defined.

Exceptions

RemoteException

getPropertyAsString(String, String, ConfigurableEntity) Method

public String getPropertyAsString(String propertySet, 
                                  String propertyName, 
                                  ConfigurableEntity successor)
throws RemoteException
Convenience method to return the property as a String. Follows the same search order as the getProperty method.

Parameters

propertySet
The name of the property set
propertyName
The name of the property to retrieve.
successor
The explicit successor to use for sucessor hiearchy search if the entity does not have the property defined.

Exceptions

RemoteException

getPropertyNoDefault(String, String, ConfigurableEntity) Method

public Object getPropertyNoDefault(String propertySet, 
                                   String propertyName, 
                                   ConfigurableEntity successor)
throws RemoteException
Retrieve the value associated with the property in the specified property set, but does not return a default value from the property's PropertyDefinition if the property does not exist for the entity or in the hierarchy of successors. This method is used by the implementation of the getProperty methods so that the search in the successor hierarchy does not return a default value from the PropertySet.

Parameters

propertySet
The name of the property set
propertyName
The name of the property to retrieve.
successor
The explicit successor to use for sucessor hiearchy search if the entity does not have the property defined.

Exceptions

RemoteException

getSuccessor(String) Method

public ConfigurableEntity getSuccessor(String propertySet)
throws RemoteException
Retrieve the successor associated with this ConfigurableEntity for the specified property set.

Parameters

propertySet
the property set to look in

Returns

this entity's successor, or null if one was not defined

Exceptions

RemoteException

getSuccessorFromId(Long) Method

protected ConfigurableEntity getSuccessorFromId(Long anEntityId)
throws RemoteException
Get the entity represented by a unique entity id.

Parameters

anEntityId
the successor's unique entity id

Returns

a reference to the successor entity, or null if it could not be found

Exceptions

RemoteException

removeSuccessor(String) Method

public void removeSuccessor(String propertySet)
Remove the successor for the specified propertySet.


setSuccessor(String, ConfigurableEntity) Method

public void setSuccessor(String propertySet, 
                         ConfigurableEntity successor)
This sets the successor for this object. This is used when resolving the getProperty.