ConfigurableEntityImpl Class
- public abstract class ConfigurableEntityImpl
extends AbstractConfigurableEntity
implements EntityBean
Abstract base class for ConfigurableEntity EJB's.
The ConfigurableEntity provides the interface to an Entity
that can be configured at runtime by associating properties
via name-value pairs. The values are permanently associated
with the entity by use of the EntityPropertyManager.
The name to associate the value with is made of an optional
property set name and a key. Property sets define namespaces for
keys. Duplicate keys are allowed in different property sets, and not
specifying a property set means the "default" property set.
Entities that derive from ConfigurableEntity will require that the
EntityPropertyManager and PropertySetType environment variables be set in
their EJB deployment descriptors.
The EntityPropertyManager is a stateless session bean that is used
to persist the runtime properties. That bean in turn can be configured
to persist its properties in a separate set of tables.
Related Topics
PropertySet
EntityPropertyManager
-
Hierarchy
-
Object
AbstractConfigurableEntity
ConfigurableEntityImpl
-
All Implemented Interfaces
-
ConfigurableEntity, EnterpriseBean, EntityBean, Serializable
-
Direct Known Subclasses
-
HierarchicalEntityImpl
protected long |
-
createUniqueId(Object aPK)
- Use the EntityPropertyManager to create a new unique id for the
entity represented by the given primary key.
|
public void |
-
ejbActivate()
- Prepare to activate this entity by resetting its
naming context and EntityPropertyManager reference.
|
public ConfigurableEntityPk |
-
ejbCreate(ConfigurableEntityPk aPK)
- Creates a record for a new ConfigurableEntity using the
given primary key
|
public ConfigurableEntityPk |
-
ejbFindByPrimaryKey(ConfigurableEntityPk pk)
- Look for the entity in the main entity table, keyed by the pk's
identifier, and the jndi name (fully scoped with application name).
|
public void |
-
ejbLoad()
- Resets this entity's attributes so that it will reload
from the EntityPropertyManager.
|
public void |
-
ejbPassivate()
- Prepare to passivate this entity by closing the cached
naming context.
|
public void |
-
ejbPostCreate(ConfigurableEntityPk aPK)
- Post-creation method; not implemented.
|
public void |
-
ejbRemove()
- Remove the record for this entity, and all of its associated
properties.
|
public void |
-
ejbStore()
- ConfigurableEntity sets properties on the fly, so there is
nothing to store at the end of a transaction
|
protected Connection |
-
getConnection()
- Get a connection from the "jdbc/commercePool" DataSource environment
entry for the EJB.
|
protected String |
-
getDefaultSqlBundleName()
- Return the name of the ResourceBundle which stores externalized sql
strings.
|
public EntityContext |
-
getEntityContext()
- Retrieve the cached entity context
|
protected EntityPropertyManager |
-
getEntityPropertyManager()
- Find the entity property manager assigned to this ConfigurableEntity
|
protected Context |
-
getEnvironmentNamingContext()
- Returns the bean's environment naming context.
|
public Object |
-
getEnvironmentProperty(String propertyName)
- This method returns the value of the specified environment property.
|
public Object |
-
getEnvironmentProperty(String propertyName, Object defaultValue)
- This method returns the value of the specified environment property or
the specified default value if the environment property is not found.
|
public String |
-
getJndiName()
- Retrieve the jndi name for an entity.
|
public String |
-
getPkString()
- Retrieve the pk string for an entity.
|
public Object |
-
getProperty(String propertySet, String propertyName)
- Retrieve the value that was persisted for this entity for the
given property, within the given property set.
|
public EntityPropertyCache |
-
getPropertyCache()
- Allocate the property map and load it using the EntityPropertyManager.
|
protected Object |
-
getPropertyDefault(String propertySet, String propertyName)
- Retrieve the default value from the Schema for the
named key and the specified scope.
|
protected PropertyLocator |
-
getPropertyLocator()
- Create and return a PropertyLocator to represent this entity.
|
protected PropertyLocator |
-
getPropertyLocator(Object aPk)
- Create and return a PropertyLocator to represent the entity
identified by the primary key
|
protected PropertySetManager |
-
getPropertySetManager()
- Get a reference to the PropertySetManager session bean.
|
protected PreparedStatement |
-
getStatement(Connection conn, String key)
- Use the provided connection to prepare the SQL statement named
by the provided key.
|
public long |
-
getUniqueId()
- Retrieve the unique identifier generated for this ConfigurableEntity.
|
public Object |
-
removeProperty(String propertySet, String propertyName)
- Remove the property associated with the named key in the specified
property set.
|
public void |
-
setEntityContext(EntityContext ctx)
- Sets the entity context.
|
public void |
-
setProperty(String propertySet, String propertyName, Object value)
- Associate the specified value with the named key in the specified
property set.
|
public void |
-
unsetEntityContext()
- Resets the entity context.
|
protected boolean |
-
useEntityPropertyManager()
- Determine if this class should try to use the EntityPropertyManager.
|
Methods from com.bea.p13n.property.AbstractConfigurableEntity |
createMapKey, getCachedProperty, getExplicitProperty, getExplicitSetter, getImplicitProperty, getPropertyAsString, getPropertyNoDefault, hasExplicitGetter, hasExplicitSetter, removeExplicitProperty, setExplicitProperty, upcaseFirst |
Methods from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_ctx
protected EntityContext _ctx
- cached entity context
_environmentNamingContext
protected transient Context _environmentNamingContext
- cached environment context
COMMERCE_POOL
protected static final String COMMERCE_POOL
- the name of the jdbc pool resource
ENTITY_PROPERTY_MANAGER
protected static final String ENTITY_PROPERTY_MANAGER
- names used to lookup ejb-refs
entityPropertyManager
protected transient EntityPropertyManager entityPropertyManager
- Cached reference to this entity's entityPropertyManager
JNDI_NAME
protected static final String JNDI_NAME
- variable name for JNDI lookup name
PROPERTY_SET_MANAGER
protected static final String PROPERTY_SET_MANAGER
PROPERTY_SET_TYPE
protected static final String PROPERTY_SET_TYPE
- variable name for property set type
propertyLocator
protected transient PropertyLocator propertyLocator
- Cached propertyLocator for this entity; used when requesting
properties from the EntityPropertyManager
psManager
protected transient PropertySetManager psManager
- Cached reference to the PropertySetManager
textFormatter
protected static final PropertyExceptionTextFormatter textFormatter
- Exception class
uid
public long uid
- The unique numeric id of this entity
ConfigurableEntityImpl
public ConfigurableEntityImpl()
- Default constructor
createUniqueId(Object) Method
protected long createUniqueId(Object aPK)
throws ConfigurableEntityCreateException, RemoteException
Use the EntityPropertyManager to create a new unique id for the
entity represented by the given primary key.
Parameters
-
aPK
- the primary key to create
Returns
- the new entity's unique id
Exceptions
-
ConfigurableEntityCreateException
- if there is an error
-
RemoteException
- if there is an error from the EntityPropertyManager
ejbActivate() Method
public void ejbActivate()
throws EJBException
Prepare to activate this entity by resetting its
naming context and EntityPropertyManager reference.
Exceptions
-
EJBException
ejbCreate(ConfigurableEntityPk) Method
public ConfigurableEntityPk ejbCreate(ConfigurableEntityPk aPK)
throws CreateException
Creates a record for a new ConfigurableEntity using the
given primary key
Parameters
-
aPK
- the primary key to create
Returns
- the new primary key
Exceptions
-
CreateException
ejbFindByPrimaryKey(ConfigurableEntityPk) Method
public ConfigurableEntityPk ejbFindByPrimaryKey(ConfigurableEntityPk pk)
throws FinderException
Look for the entity in the main entity table, keyed by the pk's
identifier, and the jndi name (fully scoped with application name).
Subclasses can override this method to search for the entity in a
different table, if they extend the entity and it makes more sense
to do that.
Parameters
-
pk
- the primary key to look for
Returns
- the same primary key, if the entity is found
Exceptions
-
FinderException
- if the entity is not found
ejbLoad() Method
public void ejbLoad()
throws EJBException
Resets this entity's attributes so that it will reload
from the EntityPropertyManager.
Exceptions
-
EJBException
ejbPassivate() Method
public void ejbPassivate()
throws EJBException
Prepare to passivate this entity by closing the cached
naming context.
Exceptions
-
EJBException
ejbPostCreate(ConfigurableEntityPk) Method
public void ejbPostCreate(ConfigurableEntityPk aPK)
throws CreateException
Post-creation method; not implemented.
Exceptions
-
CreateException
ejbRemove() Method
public void ejbRemove()
throws RemoveException
Remove the record for this entity, and all of its associated
properties.
Exceptions
-
RemoveException
ejbStore() Method
public void ejbStore()
throws EJBException
ConfigurableEntity sets properties on the fly, so there is
nothing to store at the end of a transaction
Exceptions
-
EJBException
getConnection() Method
protected Connection getConnection()
Get a connection from the "jdbc/commercePool" DataSource environment
entry for the EJB.
Returns
- a database connection
getDefaultSqlBundleName() Method
protected String getDefaultSqlBundleName()
Return the name of the ResourceBundle which stores externalized sql
strings. This will be used to initialize the SqlBundle used in
the getStatement method.
Any subclass that uses externalized sql should override this. The
default impl returns null.
getEntityContext() Method
public EntityContext getEntityContext()
Retrieve the cached entity context
getEntityPropertyManager() Method
protected EntityPropertyManager getEntityPropertyManager()
throws RemoteException
Find the entity property manager assigned to this ConfigurableEntity
Returns
- a reference to this entity's EntityPropertyManager
Exceptions
-
RemoteException
getEnvironmentNamingContext() Method
protected Context getEnvironmentNamingContext()
throws NamingException
Returns the bean's environment naming context.
Exceptions
-
NamingException
getEnvironmentProperty(String) Method
public Object getEnvironmentProperty(String propertyName)
throws NamingException
This method returns the value of the specified environment property.
Exceptions
-
NamingException
getEnvironmentProperty(String, Object) Method
public Object getEnvironmentProperty(String propertyName,
Object defaultValue)
throws NamingException
This method returns the value of the specified environment property or
the specified default value if the environment property is not found.
Exceptions
-
NamingException
getJndiName() Method
public String getJndiName()
Retrieve the jndi name for an entity. A combination of pk string
and jndi name is always unique between entities.
-
Overrides
-
AbstractConfigurableEntity.getJndiName()
Returns
- the jndi name for this entity
getPkString() Method
public String getPkString()
throws RemoteException
Retrieve the pk string for an entity. A combination of pk string
and jndi name is always unique between entities.
-
Overrides
-
AbstractConfigurableEntity.getPkString()
Returns
- the primary key string identifier for this entity
Exceptions
-
RemoteException
getProperty(String, String) Method
public Object getProperty(String propertySet,
String propertyName)
throws RemoteException
Retrieve the value that was persisted for this entity for the
given property, within the given property set. If the entity
does not have a value persisted for this property, the default
value from the property set will be returned.
-
Overrides
-
AbstractConfigurableEntity.getProperty(String, String)
Parameters
-
propertySet
- The name of the property set to look in
-
propertyName
- The name of the property to retrieve.
Returns
- the value for this property, or null if all searches failed
Exceptions
-
RemoteException
getPropertyCache() Method
public EntityPropertyCache getPropertyCache()
throws RemoteException
Allocate the property map and load it using the EntityPropertyManager.
-
Overrides
-
AbstractConfigurableEntity.getPropertyCache()
Returns
- a full container of properties for this entity
Exceptions
-
RemoteException
getPropertyDefault(String, String) Method
protected Object getPropertyDefault(String propertySet,
String propertyName)
throws RemoteException
Retrieve the default value from the Schema for the
named key and the specified scope.
Parameters
-
propertySet
- the property set to look in
-
propertyName
- the name of the property
Returns
- the default value of the property, or null if it was not defined
Exceptions
-
RemoteException
getPropertyLocator() Method
protected PropertyLocator getPropertyLocator()
throws RemoteException
Create and return a PropertyLocator to represent this entity.
Exceptions
-
RemoteException
getPropertyLocator(Object) Method
protected PropertyLocator getPropertyLocator(Object aPk)
throws RemoteException
Create and return a PropertyLocator to represent the entity
identified by the primary key
Parameters
-
aPk
- the primary key of the entity
Returns
- a PropertyLocator object for that entity
Exceptions
-
RemoteException
getPropertySetManager() Method
protected PropertySetManager getPropertySetManager()
throws RemoteException
Get a reference to the PropertySetManager session bean.
Exceptions
-
RemoteException
getStatement(Connection, String) Method
protected PreparedStatement getStatement(Connection conn,
String key)
throws SQLException
Use the provided connection to prepare the SQL statement named
by the provided key.
Parameters
-
conn
- a valid database connection
-
key
- the key to lookup a SQL statement with
Returns
- a PreparedStatement created with the sql
Exceptions
-
SQLException
- if an error occurs creating the statement
getUniqueId() Method
public long getUniqueId()
throws RemoteException
Retrieve the unique identifier generated for this ConfigurableEntity.
The unique identifier is used by the EntityPropertyManager to
optimize the foreign keys in the persistent storage. This method may
not be implemented in a lightweight implementation of
ConfigurableEntity.
-
Overrides
-
AbstractConfigurableEntity.getUniqueId()
Returns
- this entity's unique id
Exceptions
-
RemoteException
removeProperty(String, String) Method
public Object removeProperty(String propertySet,
String propertyName)
Remove the property associated with the named key in the specified
property set.
NOTE: if an explicit setter method is found for this property, this
method will set the value to null.
-
Overrides
-
AbstractConfigurableEntity.removeProperty(String, String)
Parameters
-
propertySet
- The name of the property set.
-
propertyName
- The name of the property to remove.
Returns
- the old value of the property, or null if there was none.
setEntityContext(EntityContext) Method
public void setEntityContext(EntityContext ctx)
throws EJBException
Sets the entity context.
Parameters
-
ctx
- SessionContext Context for session
Exceptions
-
EJBException
setProperty(String, String, Object) Method
public void setProperty(String propertySet,
String propertyName,
Object value)
throws PropertyValidationException
Associate the specified value with the named key in the specified
property set.
-
Overrides
-
AbstractConfigurableEntity.setProperty(String, String, Object)
Parameters
-
propertySet
- The name of the property set.
-
propertyName
- The name of the property to assign
-
value
- The value to associate with the property name
Exceptions
-
PropertyValidationException
- If the property value does not match the PropertyDefinition for this property set
unsetEntityContext() Method
public void unsetEntityContext()
throws EJBException
Resets the entity context.
Exceptions
-
EJBException
useEntityPropertyManager() Method
protected boolean useEntityPropertyManager()
Determine if this class should try to use the EntityPropertyManager.
Subclasses can override to control this.
Returns
- true if the EntityPropertyManager defined in the entity's deployment descriptor should be used, false otherwise