BEA Systems, Inc.

com.beasys.commerce.foundation
Class ConfigurableEntityImpl

java.lang.Object
  |
  +--com.beasys.commerce.foundation.EntityImpl
        |
        +--com.beasys.commerce.foundation.ConfigurableEntityImpl
Direct Known Subclasses:
ContentImpl, GroupImpl, UserImpl

public abstract class ConfigurableEntityImpl
extends EntityImpl
implements PropertyCache, javax.ejb.EntityBean

This is the implementation of the Configurable Entity that combines the pluggable method features of Business Policy, Runtime Configuration, and Persistence. For each remote interface that is derived from the ConfigurableEntity, there must be an equivalent ConfigurableEntityImpl that mirrors its methods.

See Also:
ConfigurableEntity, Serialized Form

Field Summary
protected static java.lang.String DEFAULT_ENTITY_PROPERTY_MANAGER_HOME
           
protected static java.lang.String DEFAULT_SCHEMA_GROUP_NAME
           
protected static java.lang.String ENTITY_PROPERTY_MANAGER_HOME
          The Entity Property Manager is used to persist the properties.
protected  java.util.HashMap propertyMap
          This is the map that contains the cache of runtime properties associated with this entity.
protected static java.lang.String SCHEMA_GROUP_NAME
          The Shema Group provides an additional mechanism by which the deployer can subdivide the namespace of properties.
 
Fields inherited from class com.beasys.commerce.foundation.EntityImpl
__classIdentifier, __containingEntity, __mapKey, __sequenceNumber, _ctx, _environmentNamingContext, _environmentPropertyCache, _isDirty, _smartBMP
 
Constructor Summary
ConfigurableEntityImpl()
          Default constructor.
 
Method Summary
 void addBusinessPolicy(java.lang.String policyKey, BusinessPolicy policy)
          Set the named policy on the object.
 void addCachedPropertyMapped(java.lang.String scope, java.lang.String key, java.lang.String mapKey, java.lang.Object value)
          Add the specified value to the cache.
 void addCachedPropertyValue(java.lang.String scope, java.lang.String key, java.lang.Object value)
          Add the specified value to the cache.
 void addPropertyValue(java.lang.String scopeName, java.lang.String key, java.lang.Object propertyValue)
          Add a Property to a collection associated with the property.
 void addPropertyValueMapped(java.lang.String scopeName, java.lang.String propertyKey, java.lang.String mappedKey, java.lang.Object propertyValue)
           
 java.lang.String buildPolicyKey(java.lang.String policyKey)
          Build policy key is a helper function that builds a property name for the business policy that will not collide with user specified keys.
static PropertyMapKey createMapKey(java.lang.String scopeName, java.lang.String key)
          Helper function that will allocate a PropertyMapKey from a scope name and property name.
 void ejbActivate()
          ejbActivate method.
 SmartKey ejbCreate(SmartKey key)
          ejbCreate method.
 void ejbLoad()
          ejbLoad method.
 void ejbPassivate()
          ejbPassivate method.
 void ejbPostCreate(SmartKey key)
          ejbPostCreate method.
 void ejbRemove()
          ejbRemove method.
 void ejbStore()
          ejbStore method.
 BusinessPolicy getBusinessPolicy(java.lang.String policyKey)
          Get the named policy from the object.
 java.lang.Object getCachedProperty(java.lang.String scope, java.lang.String key)
          Retrieve the value associated with the key from the object cache
protected  java.lang.Object getImplicitProperty(java.lang.String scope, java.lang.String key, ConfigurableEntity explicitSuccessor, boolean useDefault)
          Search for the runtime property.
 PersistableHandle getPersistableHandle()
          This method is used to create a long lived handle to an EJB object that can be persisted into a database.
protected  java.lang.Object getProperty(java.lang.String key)
          This is the simplest way to retrieve a property.
 java.lang.Object getProperty(java.lang.String key, java.lang.Object defaultValue)
          Retrieve the value associated with the key.
 java.lang.Object getProperty(java.lang.String scopeName, java.lang.String key, ConfigurableEntity successor, java.lang.Object defaultValue)
          Retrieve the value associated with the key.
 java.lang.String getPropertyAsString(java.lang.String key, java.lang.String defaultValue)
          Retrieve the String value associated with the key and return the result rendered as a string.
 java.lang.String getPropertyAsString(java.lang.String scopeName, java.lang.String key, ConfigurableEntity successor, java.lang.String defaultValue)
          Equivalent to getProperty except that the return value is turned into a string.
 java.lang.Object getPropertyDefault(java.lang.String scope, java.lang.String key, ConfigurableEntity explicitSuccessor)
          Retrieve the default value from the Schema for the named key and the specified scope.
 java.util.Map getPropertyMap()
          Allocate the property map and load it using the EntityPropertyManager.
 java.lang.Object getPropertyNoDefault(java.lang.String scopeName, java.lang.String key, ConfigurableEntity successor)
          Retrieve the value associated with the named key in the specified scope but does not return a default value if the property does not exist for the entity of in the hierarchy of successors.
 ConfigurableEntity getSuccessor(java.lang.String scopeName)
          Retrieve the successor associated with this ConfigurableEntity for the specified scope.
 long getUniqueId()
          Retrieve the unique identifier generated for this ConfigurableEntity.
 BusinessPolicy removeBusinessPolicy(java.lang.String policyKey)
          Remove the named policy from the object.
 void removeCachedProperties()
          Clear all the entries in the cache.
 void removeCachedProperties(java.lang.String scope)
          Clear all entries in the cache for the specified scope.
 java.lang.Object removeCachedProperty(java.lang.String scope, java.lang.String key)
          Retrieve the value associated with the key from the object cache
 java.lang.Object removeCachedPropertyMapped(java.lang.String scope, java.lang.String key, java.lang.String mapKey)
          Remove the value at the specified key from a named property that represents a map.
 void removeCachedPropertyValue(java.lang.String scope, java.lang.String key, java.lang.Object value)
          Add the specified value to the cache.
 java.lang.Object removeProperty(java.lang.String key)
          Remove the property from this ConfigurableEntity for the default scope and the specified key.
 java.lang.Object removeProperty(java.lang.String scopeName, java.lang.String key)
          Remove the property from this ConfigurableEntity for the specified scope name and key.
 java.lang.Object removePropertyValue(java.lang.String scopeName, java.lang.String key, java.lang.Object propertyValue)
          Remove the property value object from the Collection associated with the named key in the specified scope.
 java.lang.Object removePropertyValueMapped(java.lang.String scopeName, java.lang.String propertyKey, java.lang.String mappedKey)
          Remove the property value object from the Map associated with the named key in the specified scope.
 ConfigurableEntity removeSuccessor(java.lang.String scopeName)
          Remove the successor for the specified scope.
 void setCachedProperty(java.lang.String scope, java.lang.String key, java.lang.Object value)
          Add the specified value to the cache.
 void setProperty(java.lang.String key, java.lang.Object property)
          This is the the simplest way to set a property.
 void setProperty(java.lang.String scopeName, java.lang.String key, java.lang.Object property)
          Add a property to this Entity and associated it with the specified scope and key.
 void setSuccessor(java.lang.String scopeName, ConfigurableEntity successor)
          This sets the successor for this object.
static java.lang.String upcaseFirst(java.lang.String s)
           
protected  boolean useEntityPropertyManager()
          Determine if this try to use the EntityPropertyManager.
 
Methods inherited from class com.beasys.commerce.foundation.EntityImpl
bscInitializeAttributes, clearRelationalBinding, clearRelationalBinding, clearRelationalBinding, clearRelationalBinding, doRelationalBinding, doRelationalBinding, doRelationalBindingOnElement, doRelationalBindingOnElement, doRelationalBindingOnElement, doRelationalBindingOnSingleton, doRelationalBindingOnSingleton, doRelationalBindingOnSingleton, doRelationalBindingWithMapKey, doRelationalBindingWithMapKey, doRelationalBindingWithMapKey, ejbFindAll, ejbFindByPrimaryKey, enumerateRelationalBinding, enumerateRelationalBinding, get__classIdentifier, get__containingBelonging, get__containingEntity, get__containingEntityReference, get__mapKey, get__sequenceNumber, getEntityContext, getEnvironmentNamingContext, getEnvironmentProperty, getEnvironmentProperty, getEnvironmentPropertyCache, getPersistenceHelperPlugin, getSmartBMP, initSmartBMP, isModified, set__classIdentifier, set__containingBelonging, set__containingEntity, set__containingEntityReference, set__mapKey, setEntityContext, unsetEntityContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENTITY_PROPERTY_MANAGER_HOME

protected static java.lang.String ENTITY_PROPERTY_MANAGER_HOME
The Entity Property Manager is used to persist the properties. These constants identify the environment variable in the deployment descriptor that allows the deployer to define which session bean to use. The implication of using a particular EntityPropertyManager is that the deployer is deciding where the properties will be persisted.

DEFAULT_ENTITY_PROPERTY_MANAGER_HOME

protected static java.lang.String DEFAULT_ENTITY_PROPERTY_MANAGER_HOME

SCHEMA_GROUP_NAME

protected static java.lang.String SCHEMA_GROUP_NAME
The Shema Group provides an additional mechanism by which the deployer can subdivide the namespace of properties. The presence of this option makes it possible to share a schema between entities that are using an EntityPropertyManager. The reverse is also true in that it is possible for multiple entities to share an EntityPropertyManager and still have a separate name space for properties.

DEFAULT_SCHEMA_GROUP_NAME

protected static java.lang.String DEFAULT_SCHEMA_GROUP_NAME

propertyMap

protected transient java.util.HashMap propertyMap
This is the map that contains the cache of runtime properties associated with this entity. Access is only through the methods defined on the PropertyCache interface. This is protected to allow bean impls to override getPropertyMap() to avoid using the EntityPropertyManager.
Constructor Detail

ConfigurableEntityImpl

public ConfigurableEntityImpl()
Default constructor. Does nothing.
Method Detail

addBusinessPolicy

public void addBusinessPolicy(java.lang.String policyKey,
                              BusinessPolicy policy)
                       throws SystemException
Set the named policy on the object.

addCachedPropertyMapped

public void addCachedPropertyMapped(java.lang.String scope,
                                    java.lang.String key,
                                    java.lang.String mapKey,
                                    java.lang.Object value)
Add the specified value to the cache.
Specified by:
addCachedPropertyMapped in interface PropertyCache
Parameters:
scope - java.lang.String
key - java.lang.String
mapKey - java.lang.String the key into which the property will be mapped
value - java.lang.Object the value to be set.

addCachedPropertyValue

public void addCachedPropertyValue(java.lang.String scope,
                                   java.lang.String key,
                                   java.lang.Object value)
Add the specified value to the cache.
Specified by:
addCachedPropertyValue in interface PropertyCache
Parameters:
scope - java.lang.String
key - java.lang.String
value - java.lang.Object the value to be set.

addPropertyValue

public void addPropertyValue(java.lang.String scopeName,
                             java.lang.String key,
                             java.lang.Object propertyValue)
                      throws SystemException
Add a Property to a collection associated with the property.

addPropertyValueMapped

public void addPropertyValueMapped(java.lang.String scopeName,
                                   java.lang.String propertyKey,
                                   java.lang.String mappedKey,
                                   java.lang.Object propertyValue)
                            throws SystemException

buildPolicyKey

public java.lang.String buildPolicyKey(java.lang.String policyKey)
Build policy key is a helper function that builds a property name for the business policy that will not collide with user specified keys.

createMapKey

public static PropertyMapKey createMapKey(java.lang.String scopeName,
                                          java.lang.String key)
Helper function that will allocate a PropertyMapKey from a scope name and property name.
Parameters:
scope - java.lang.String
key - java.lang.String

ejbActivate

public void ejbActivate()
                 throws javax.ejb.EJBException
Description copied from class: EntityImpl
ejbActivate method.
Specified by:
ejbActivate in interface javax.ejb.EntityBean
Overrides:
ejbActivate in class EntityImpl

ejbCreate

public SmartKey ejbCreate(SmartKey key)
                   throws javax.ejb.CreateException
Description copied from class: EntityImpl
ejbCreate method.
Overrides:
ejbCreate in class EntityImpl

ejbLoad

public void ejbLoad()
             throws javax.ejb.EJBException
Description copied from class: EntityImpl
ejbLoad method.
Specified by:
ejbLoad in interface javax.ejb.EntityBean
Overrides:
ejbLoad in class EntityImpl

ejbPassivate

public void ejbPassivate()
                  throws javax.ejb.EJBException
Description copied from class: EntityImpl
ejbPassivate method.
Specified by:
ejbPassivate in interface javax.ejb.EntityBean
Overrides:
ejbPassivate in class EntityImpl

ejbPostCreate

public void ejbPostCreate(SmartKey key)
                   throws javax.ejb.CreateException
Description copied from class: EntityImpl
ejbPostCreate method.
Overrides:
ejbPostCreate in class EntityImpl

ejbRemove

public void ejbRemove()
               throws javax.ejb.RemoveException
Description copied from class: EntityImpl
ejbRemove method.
Specified by:
ejbRemove in interface javax.ejb.EntityBean
Overrides:
ejbRemove in class EntityImpl

ejbStore

public void ejbStore()
              throws javax.ejb.EJBException
Description copied from class: EntityImpl
ejbStore method.
Specified by:
ejbStore in interface javax.ejb.EntityBean
Overrides:
ejbStore in class EntityImpl

getCachedProperty

public java.lang.Object getCachedProperty(java.lang.String scope,
                                          java.lang.String key)
                                   throws SystemException
Retrieve the value associated with the key from the object cache
Specified by:
getCachedProperty in interface PropertyCache
Parameters:
scope - java.lang.String
key - java.lang.String
Returns:
java.lang.Object

getBusinessPolicy

public BusinessPolicy getBusinessPolicy(java.lang.String policyKey)
                                 throws SystemException
Get the named policy from the object.

getImplicitProperty

protected java.lang.Object getImplicitProperty(java.lang.String scope,
                                               java.lang.String key,
                                               ConfigurableEntity explicitSuccessor,
                                               boolean useDefault)
                                        throws SystemException
Search for the runtime property.
  1. Look for the property for the specified scope and key.
  2. Look for the property in the default scope.
  3. Look for the property in the "RESERVED" scope (LDAP).
  4. Look for the property in the explicit successor (if specified).
  5. Look for the property in the successor for the specified scope.
  6. Look for the property in the default successor.
  7. Get the default value from the schema if the useDefault is true and scope is specified.

getPersistableHandle

public PersistableHandle getPersistableHandle()
This method is used to create a long lived handle to an EJB object that can be persisted into a database. It is used mainly to establish successorship relationships. It is a method on the EJB because information such as the JNDI home name is not known outside the EJB.

getProperty

protected java.lang.Object getProperty(java.lang.String key)
                                throws SystemException
This is the simplest way to retrieve a property. It provides a consolidated mechanism for the retrieval of both design time and runtime properties. The attribute is looked for in the following order:

Parameters:
key - The name under which the property is bound.

getProperty

public java.lang.Object getProperty(java.lang.String key,
                                    java.lang.Object defaultValue)
                             throws SystemException
Retrieve the value associated with the key. Return the specified default if a value cannot be found.
Parameters:
key - java.lang.String
defaultValue - java.lang.Object
See Also:
getProperty

getProperty

public java.lang.Object getProperty(java.lang.String scopeName,
                                    java.lang.String key,
                                    ConfigurableEntity successor,
                                    java.lang.Object defaultValue)
                             throws SystemException
Retrieve the value associated with the key. The fact that a scope and successor are passed implies that the caller is primarily interested in properties defined at runtime. For this reason the runtime properties are searched followed by local attributes.
Parameters:
key - java.lang.String

getPropertyAsString

public java.lang.String getPropertyAsString(java.lang.String key,
                                            java.lang.String defaultValue)
                                     throws SystemException
Retrieve the String value associated with the key and return the result rendered as a string. The specified default will be return if there is no value set on that attribute and if there is there is no default set on the schema.
Parameters:
key - java.lang.String

getPropertyAsString

public java.lang.String getPropertyAsString(java.lang.String scopeName,
                                            java.lang.String key,
                                            ConfigurableEntity successor,
                                            java.lang.String defaultValue)
                                     throws SystemException
Equivalent to getProperty except that the return value is turned into a string.
Parameters:
key - java.lang.String

getPropertyDefault

public java.lang.Object getPropertyDefault(java.lang.String scope,
                                           java.lang.String key,
                                           ConfigurableEntity explicitSuccessor)
                                    throws SystemException
Retrieve the default value from the Schema for the named key and the specified scope.

getPropertyMap

public java.util.Map getPropertyMap()
                             throws SystemException
Allocate the property map and load it using the EntityPropertyManager.

getPropertyNoDefault

public java.lang.Object getPropertyNoDefault(java.lang.String scopeName,
                                             java.lang.String key,
                                             ConfigurableEntity successor)
                                      throws SystemException
Retrieve the value associated with the named key in the specified scope but does not return a default value if the property does not exist for the entity of 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 Schema.

getSuccessor

public ConfigurableEntity getSuccessor(java.lang.String scopeName)
                                throws SystemException
Retrieve the successor associated with this ConfigurableEntity for the specified scope.

getUniqueId

public long getUniqueId()
                 throws SystemException
Retrieve the unique identifier generated for this ConfigurableEntity.

removeBusinessPolicy

public BusinessPolicy removeBusinessPolicy(java.lang.String policyKey)
                                    throws SystemException
Remove the named policy from the object.

removeCachedProperties

public void removeCachedProperties()
Clear all the entries in the cache. This is useful when all properties are to be reloaded.
Specified by:
removeCachedProperties in interface PropertyCache
Parameters:
scope - the scope for which properties are to be removed.

removeCachedProperties

public void removeCachedProperties(java.lang.String scope)
Clear all entries in the cache for the specified scope. This is useful when all properties for a scope are to be reloaded.
Specified by:
removeCachedProperties in interface PropertyCache
Parameters:
scope - the scope for which properties are to be removed.

removeCachedProperty

public java.lang.Object removeCachedProperty(java.lang.String scope,
                                             java.lang.String key)
Retrieve the value associated with the key from the object cache
Specified by:
removeCachedProperty in interface PropertyCache
Parameters:
scope - java.lang.String
key - java.lang.String
Returns:
java.lang.Object The object removed.

removeCachedPropertyValue

public void removeCachedPropertyValue(java.lang.String scope,
                                      java.lang.String key,
                                      java.lang.Object value)
Add the specified value to the cache.
Specified by:
removeCachedPropertyValue in interface PropertyCache
Parameters:
scope - java.lang.String
key - java.lang.String
value - java.lang.Object the value to be set.

removeCachedPropertyMapped

public java.lang.Object removeCachedPropertyMapped(java.lang.String scope,
                                                   java.lang.String key,
                                                   java.lang.String mapKey)
Remove the value at the specified key from a named property that represents a map.
Specified by:
removeCachedPropertyMapped in interface PropertyCache
Parameters:
scope - java.lang.String
key - java.lang.String
mapKey - java.lang.String the key into which the property will be mapped
Returns:
The object that was removed or a null if the map entry was empty.

removeProperty

public java.lang.Object removeProperty(java.lang.String key)
                                throws SystemException
Remove the property from this ConfigurableEntity for the default scope and the specified key.

removeProperty

public java.lang.Object removeProperty(java.lang.String scopeName,
                                       java.lang.String key)
                                throws SystemException
Remove the property from this ConfigurableEntity for the specified scope name and key. Note: it is not possible to remove an explicit property.

removePropertyValue

public java.lang.Object removePropertyValue(java.lang.String scopeName,
                                            java.lang.String key,
                                            java.lang.Object propertyValue)
                                     throws SystemException
Remove the property value object from the Collection associated with the named key in the specified scope.

removePropertyValueMapped

public java.lang.Object removePropertyValueMapped(java.lang.String scopeName,
                                                  java.lang.String propertyKey,
                                                  java.lang.String mappedKey)
                                           throws SystemException
Remove the property value object from the Map associated with the named key in the specified scope.

removeSuccessor

public ConfigurableEntity removeSuccessor(java.lang.String scopeName)
Remove the successor for the specified scope.

setProperty

public void setProperty(java.lang.String key,
                        java.lang.Object property)
                 throws SystemException
This is the the simplest way to set a property. If the property is an attribute of the entity it will be set directly by calling the set method. If it is a runtime property it will be set using the EntityPropertyManager.
Parameters:
key - The string to which the property will be bound
property - The value that will be bound to that name

setProperty

public void setProperty(java.lang.String scopeName,
                        java.lang.String key,
                        java.lang.Object property)
                 throws SystemException
Add a property to this Entity and associated it with the specified scope and key.
Parameters:
scopeName - The scopeName and key uniquely identify the propertyName
key -  
property - The value to associate with the property.

setSuccessor

public void setSuccessor(java.lang.String scopeName,
                         ConfigurableEntity successor)
                  throws SystemException
This sets the successor for this object. This is used when resolving the getProperty.
Parameters:
successor -  

setCachedProperty

public void setCachedProperty(java.lang.String scope,
                              java.lang.String key,
                              java.lang.Object value)
                       throws SystemException
Add the specified value to the cache. This does not have the side effect of persisting the value in the EntityPropertyManager so that persistence mechanism can also populate this map.
Specified by:
setCachedProperty in interface PropertyCache
Parameters:
scope - java.lang.String
key - java.lang.String
value - java.lang.Object the value to be set.

upcaseFirst

public static java.lang.String upcaseFirst(java.lang.String s)

useEntityPropertyManager

protected boolean useEntityPropertyManager()
Determine if this try to use the EntityPropertyManager. Subclasses can override to control this.

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved