Overview | Package | Class | Tree | Deprecated | Index | Help
| © 2002 BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.p13n.property
Class ConfigurableEntityImpl

    java.lang.Object
      |
      +--com.bea.p13n.property.AbstractConfigurableEntity
            |
            +--com.bea.p13n.property.ConfigurableEntityImpl

Direct Known Subclasses:
  HierarchicalEntityImpl

public abstract class ConfigurableEntityImpl
extends AbstractConfigurableEntity
implements javax.ejb.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.

See Also:
  `PropertySet`, `EntityPropertyManager`, Serialized Form

Field Summary
`protected javax.ejb.EntityContext` | `_ctx` cached entity context
`protected javax.naming.Context` | `_environmentNamingContext` cached environment context
`protected static java.lang.String` | `COMMERCE_POOL` the name of the jdbc pool resource
`protected static java.lang.String` | `ENTITY_PROPERTY_MANAGER` names used to lookup ejb-refs
`protected EntityPropertyManager` | `entityPropertyManager` Cached reference to this entity's entityPropertyManager
`protected static java.lang.String` | `JNDI_NAME` variable name for JNDI lookup name
`protected static java.lang.String` | `PROPERTY_SET_MANAGER`
`protected static java.lang.String` | `PROPERTY_SET_TYPE` variable name for property set type
`protected PropertyLocator` | `propertyLocator` Cached propertyLocator for this entity; used when requesting properties from the EntityPropertyManager
`protected PropertySetManager` | `psManager` Cached reference to the PropertySetManager
`protected static com.bea.p13n.i18n.PropertyExceptionTextFormatter` | `textFormatter` Exception class
`long` | `uid` The unique numeric id of this entity

Fields inherited from class com.bea.p13n.property.AbstractConfigurableEntity
`CE_METHOD_CACHE, instanceClass, PREFIX_GET, PREFIX_SET, propertyCache, textFormatter`

Constructor Summary
`ConfigurableEntityImpl()` Default constructor

Method Summary
`protected long` | `createUniqueId(java.lang.Object aPK)` Use the EntityPropertyManager to create a new unique id for the entity represented by the given primary key.
`void` | `ejbActivate()` Prepare to activate this entity by resetting its naming context and EntityPropertyManager reference.
`ConfigurableEntityPk` | `ejbCreate(ConfigurableEntityPk aPK)` Creates a record for a new ConfigurableEntity using the given primary key
`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).
`void` | `ejbLoad()` Resets this entity's attributes so that it will reload from the EntityPropertyManager.
`void` | `ejbPassivate()` Prepare to passivate this entity by closing the cached naming context.
`void` | `ejbPostCreate(ConfigurableEntityPk aPK)` Post-creation method; not implemented.
`void` | `ejbRemove()` Remove the record for this entity, and all of its associated properties.
`void` | `ejbStore()` ConfigurableEntity sets properties on the fly, so there is nothing to store at the end of a transaction
`protected java.sql.Connection` | `getConnection()` Get a connection from the "jdbc/commercePool" DataSource environment entry for the EJB.
`protected java.lang.String` | `getDefaultSqlBundleName()` Return the name of the ResourceBundle which stores externalized sql strings.
`javax.ejb.EntityContext` | `getEntityContext()` Retrieve the cached entity context
`protected EntityPropertyManager` | `getEntityPropertyManager()` Find the entity property manager assigned to this ConfigurableEntity
`protected javax.naming.Context` | `getEnvironmentNamingContext()` Returns the bean's environment naming context.
`java.lang.Object` | `getEnvironmentProperty(java.lang.String propertyName)` This method returns the value of the specified environment property.
`java.lang.Object` | `getEnvironmentProperty(java.lang.String propertyName, java.lang.Object defaultValue)` This method returns the value of the specified environment property or the specified default value if the environment property is not found.
`java.lang.String` | `getJndiName()` Retrieve the jndi name for an entity.
`java.lang.String` | `getPkString()` Retrieve the pk string for an entity.
`java.lang.Object` | `getProperty(java.lang.String propertySet, java.lang.String propertyName)` Retrieve the value that was persisted for this entity for the given property, within the given property set.
`EntityPropertyCache` | `getPropertyCache()` Allocate the property map and load it using the EntityPropertyManager.
`protected java.lang.Object` | `getPropertyDefault(java.lang.String propertySet, java.lang.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(java.lang.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 java.sql.PreparedStatement` | `getStatement(java.sql.Connection conn, java.lang.String key)` Use the provided connection to prepare the SQL statement named by the provided key.
`long` | `getUniqueId()` Retrieve the unique identifier generated for this ConfigurableEntity.
`java.lang.Object` | `removeProperty(java.lang.String propertySet, java.lang.String propertyName)` Remove the property associated with the named key in the specified property set.
`void` | `setEntityContext(javax.ejb.EntityContext ctx)` Sets the entity context.
`void` | `setProperty(java.lang.String propertySet, java.lang.String propertyName, java.lang.Object value)` Associate the specified value with the named key in the specified property set.
`void` | `unsetEntityContext()` Resets the entity context.
`protected boolean` | `useEntityPropertyManager()` Determine if this class should try to use the EntityPropertyManager.

Methods inherited from class com.bea.p13n.property.AbstractConfigurableEntity
`createMapKey, getCachedProperty, getExplicitProperty, getExplicitSetter, getImplicitProperty, getPropertyAsString, getPropertyNoDefault, hasExplicitGetter, hasExplicitSetter, removeExplicitProperty, setExplicitProperty, upcaseFirst`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _ctx

    protected javax.ejb.EntityContext _ctx

  cached entity context

### _environmentNamingContext

    protected transient javax.naming.Context _environmentNamingContext

  cached environment context

### uid

    public long uid

  The unique numeric id of this entity

### ENTITY_PROPERTY_MANAGER

    protected static final java.lang.String ENTITY_PROPERTY_MANAGER

  names used to lookup ejb-refs

### PROPERTY_SET_MANAGER

    protected static final java.lang.String PROPERTY_SET_MANAGER

### PROPERTY_SET_TYPE

    protected static final java.lang.String PROPERTY_SET_TYPE

  variable name for property set type

### JNDI_NAME

    protected static final java.lang.String JNDI_NAME

  variable name for JNDI lookup name

### COMMERCE_POOL

    protected static final java.lang.String COMMERCE_POOL

  the name of the jdbc pool resource

### entityPropertyManager

    protected transient EntityPropertyManager entityPropertyManager

  Cached reference to this entity's entityPropertyManager

### psManager

    protected transient PropertySetManager psManager

  Cached reference to the PropertySetManager

### propertyLocator

    protected transient PropertyLocator propertyLocator

  Cached propertyLocator for this entity; used when requesting properties from the EntityPropertyManager

### textFormatter

    protected static final com.bea.p13n.i18n.PropertyExceptionTextFormatter textFormatter

  Exception class

Constructor Detail

### ConfigurableEntityImpl

    public ConfigurableEntityImpl()

  Default constructor

Method Detail

### ejbCreate

    public ConfigurableEntityPk ejbCreate(ConfigurableEntityPk aPK)
                                   throws javax.ejb.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

### ejbPostCreate

    public void ejbPostCreate(ConfigurableEntityPk aPK)
                       throws javax.ejb.CreateException

  Post-creation method; not implemented.

### ejbPassivate

    public void ejbPassivate()
                      throws javax.ejb.EJBException

  Prepare to passivate this entity by closing the cached naming context.
  Specified by:
    ejbPassivate in interface javax.ejb.EntityBean

### ejbActivate

    public void ejbActivate()
                     throws javax.ejb.EJBException

  Prepare to activate this entity by resetting its naming context and EntityPropertyManager reference.
  Specified by:
    ejbActivate in interface javax.ejb.EntityBean

### ejbLoad

    public void ejbLoad()
                 throws javax.ejb.EJBException

  Resets this entity's attributes so that it will reload from the EntityPropertyManager.
  Specified by:
    ejbLoad in interface javax.ejb.EntityBean

### ejbStore

    public void ejbStore()
                  throws javax.ejb.EJBException

  ConfigurableEntity sets properties on the fly, so there is nothing to store at the end of a transaction
  Specified by:
    ejbStore in interface javax.ejb.EntityBean

### ejbRemove

    public void ejbRemove()
                   throws javax.ejb.RemoveException

  Remove the record for this entity, and all of its associated properties.
  Specified by:
    ejbRemove in interface javax.ejb.EntityBean

### ejbFindByPrimaryKey

    public ConfigurableEntityPk ejbFindByPrimaryKey(ConfigurableEntityPk pk)
                                             throws javax.ejb.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
  Throws:
    javax.ejb.FinderException - if the entity is not found

### setEntityContext

    public void setEntityContext(javax.ejb.EntityContext ctx)
                          throws javax.ejb.EJBException

  Sets the entity context.
  Specified by:
    setEntityContext in interface javax.ejb.EntityBean

  Parameters:
    `ctx` - SessionContext Context for session

### unsetEntityContext

    public void unsetEntityContext()
                            throws javax.ejb.EJBException

  Resets the entity context.
  Specified by:
    unsetEntityContext in interface javax.ejb.EntityBean

### getEntityContext

    public javax.ejb.EntityContext getEntityContext()

  Retrieve the cached entity context

### getProperty

    public java.lang.Object getProperty(java.lang.String propertySet,
                                        java.lang.String propertyName)
                                 throws java.rmi.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.

  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
  Overrides:
    getProperty in class AbstractConfigurableEntity

### setProperty

    public void setProperty(java.lang.String propertySet,
                            java.lang.String propertyName,
                            java.lang.Object value)
                     throws PropertyValidationException

  Associate the specified value with the named key in the specified property set.

  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
  Throws:
    PropertyValidationException - If the property value does not match the PropertyDefinition for this property set
  Overrides:
    setProperty in class AbstractConfigurableEntity

### removeProperty

    public java.lang.Object removeProperty(java.lang.String propertySet,
                                           java.lang.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.

  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.
  Overrides:
    removeProperty in class AbstractConfigurableEntity

### getUniqueId

    public long getUniqueId()
                     throws java.rmi.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.

  Returns:
    this entity's unique id
  Overrides:
    getUniqueId in class AbstractConfigurableEntity

### getPkString

    public java.lang.String getPkString()
                                 throws java.rmi.RemoteException

  Retrieve the pk string for an entity. A combination of pk string and jndi name is always unique between entities.

  Returns:
    the primary key string identifier for this entity
  Overrides:
    getPkString in class AbstractConfigurableEntity

### getPropertyDefault

    protected java.lang.Object getPropertyDefault(java.lang.String propertySet,
                                                  java.lang.String propertyName)
                                           throws java.rmi.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

### createUniqueId

    protected long createUniqueId(java.lang.Object aPK)
                           throws ConfigurableEntityCreateException,
                                  java.rmi.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
  Throws:
    ConfigurableEntityCreateException - if there is an error
    java.rmi.RemoteException - if there is an error from the EntityPropertyManager

### useEntityPropertyManager

    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

### getPropertyCache

    public EntityPropertyCache getPropertyCache()
                                         throws java.rmi.RemoteException

  Allocate the property map and load it using the EntityPropertyManager.

  Returns:
    a full container of properties for this entity
  Overrides:
    getPropertyCache in class AbstractConfigurableEntity

### getPropertyLocator

    protected PropertyLocator getPropertyLocator()
                                          throws java.rmi.RemoteException

  Create and return a PropertyLocator to represent this entity.

### getPropertyLocator

    protected PropertyLocator getPropertyLocator(java.lang.Object aPk)
                                          throws java.rmi.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

### getJndiName

    public java.lang.String getJndiName()

  Retrieve the jndi name for an entity. A combination of pk string and jndi name is always unique between entities.

  Returns:
    the jndi name for this entity
  Overrides:
    getJndiName in class AbstractConfigurableEntity

### getEntityPropertyManager

    protected EntityPropertyManager getEntityPropertyManager()
                                                      throws java.rmi.RemoteException

  Find the entity property manager assigned to this ConfigurableEntity

  Returns:
    a reference to this entity's EntityPropertyManager

### getPropertySetManager

    protected PropertySetManager getPropertySetManager()
                                                throws java.rmi.RemoteException

  Get a reference to the PropertySetManager session bean.

### getEnvironmentProperty

    public final java.lang.Object getEnvironmentProperty(java.lang.String propertyName)
                                                  throws javax.naming.NamingException

  This method returns the value of the specified environment property.

  Throws:
    javax.naming.NamingException - - if a naming exception is encountered

### getEnvironmentProperty

    public final java.lang.Object getEnvironmentProperty(java.lang.String propertyName,
                                                         java.lang.Object defaultValue)
                                                  throws javax.naming.NamingException

  This method returns the value of the specified environment property or the specified default value if the environment property is not found.

  Throws:
    javax.naming.NamingException - - if a naming exception is encountered

### getEnvironmentNamingContext

    protected final javax.naming.Context getEnvironmentNamingContext()
                                                              throws javax.naming.NamingException

  Returns the bean's environment naming context.

  Throws:
    javax.naming.NamingException - - if a naming exception is encountered

### getConnection

    protected java.sql.Connection getConnection()

  Get a connection from the "jdbc/commercePool" DataSource environment entry for the EJB.

  Returns:
    a database connection
  Throws:
    ConfigurableEntitySystemException - if there is a problem

### getStatement

    protected java.sql.PreparedStatement getStatement(java.sql.Connection conn,
                                                      java.lang.String key)
                                               throws java.sql.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
  Throws:
    java.sql.SQLException - if an error occurs creating the statement

### getDefaultSqlBundleName

    protected java.lang.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.

Overview | Package | Class | Tree | Deprecated | Index | Help
| © 2002 BEA Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 BEA Systems, Inc. All Rights Reserved