BEA Systems, Inc.

com.beasys.commerce.foundation.property
Class DirectPropertyManagerBean

java.lang.Object
  |
  +--com.beasys.commerce.foundation.property.DirectPropertyManagerBean

public class DirectPropertyManagerBean
extends java.lang.Object
implements javax.ejb.SessionBean

A session bean that provides ConfigurableEntity functionality with minimal access through entity beans. This is accomplished by accessing the EntityPropertyManager directly, and reduces ejb locks so that there is less of a risk of deadlock.

See Also:
Serialized Form

Field Summary
static java.lang.String DIRECT_PROPERTY_MANAGER
           
static java.lang.String ENTITY_PROPERTY_MANAGER_HOME
           
static java.lang.String GROUP_JNDI_HOME_NAME
           
static java.lang.String USER_JNDI_HOME_NAME
           
 
Constructor Summary
DirectPropertyManagerBean()
           
 
Method Summary
 void ejbActivate()
          This method is required by the EJB Specification, but is not used by this class.
 void ejbCreate()
          Creates the session bean.
 void ejbPassivate()
          This method is required by the EJB Specification, but is not used by this class.
 void ejbRemove()
          This method is required by the EJB Specification, but is not used by this class.
 java.lang.Object getDefaultValue(java.lang.String propertySet, java.lang.String propertyName)
          Retrieves the default value of a property
 ConfigurableEntity getEntity(java.lang.String profileKey, java.lang.String profileType)
          Instantiates a ConfigurableEntity based on the pk and profileType, and returns it cast as a ConfigurableEntity.
 long getEntityId(java.lang.String pk, java.lang.String profileType)
          Retrieves the unique numeric id of a configurable entity
 java.lang.Object getExplicitProperty(java.lang.String profileKey, java.lang.String profileType, java.lang.String propertyName)
          Retrieve an explicit property from a configurable entity, if it exists.
 java.util.Map getProperties(java.lang.String pk, java.lang.String profileType, java.lang.String successorPk, java.lang.String successorProfileType)
          Retrieve all set properties for a particular ConfigurableEntity, following the successor chains as necessary.
 java.lang.Object getProperty(java.lang.String pk, java.lang.String profileType, java.lang.String successorPk, java.lang.String successorProfileType, java.lang.String propertySet, java.lang.String propertyName, java.lang.Object defaultValue)
          Retrieve a property from a configurable entity.
protected  java.lang.Object getProperty(java.lang.String pk, java.lang.String profileType, java.lang.String successorPk, java.lang.String successorProfileType, java.lang.String propertySet, java.lang.String propertyName, java.lang.Object defaultValue, boolean useDefault)
          Just like the public direct property except it takes an extra parameter to determine whether or not to return the property's default value, if there is one.
 java.lang.Object getPropertyFromCache(java.lang.String profileKey, java.lang.String profileType, java.lang.String propertyName)
          Get a value out of the cache
protected  java.lang.Object getPropertyFromSuccessorHandle(PersistableHandle handle, java.lang.String propertySet, java.lang.String propertyName)
          Try to retrieve a property from a ConfigurableEntity that is referred to by a PersistableHandle
protected  com.beasys.commerce.foundation.property.external.SharedProperty getSharedProperty(java.lang.String pk, java.lang.String propertySet, java.lang.String propertyName)
          Try to retrieve a property from a shared profile provider.
protected  java.util.Map mergeWithSuccessor(java.util.Map props, java.util.Map successorProps, java.lang.String propertySet)
          Merge an entity's properties with its successor's properties.
protected  java.util.Map mergeWithSuccessorFromHandle(java.util.Map profileProperties, PersistableHandle handle, java.lang.String scopeName, java.lang.String explicitSuccessorPk, java.lang.String explicitSuccessorType)
          Get the properties for a ConfigurableEntity by calling reallyGetProperties with the information contained in the given handle, and then merge the two property maps.
protected  java.util.Map reallyGetProperties(java.lang.String pk, java.lang.String profileType, java.lang.String successorPk, java.lang.String successorProfileType)
          Recursive helper method for getProperties
 java.lang.Object removeProperty(java.lang.String pk, java.lang.String profileType, java.lang.String propertySet, java.lang.String propertyName)
          Removes the property from the given configurable entity.
 void removePropertyFromCache(java.lang.String profileKey, java.lang.String profileType, java.lang.String propertyName)
          Remove a value from the cache
 void setProperty(java.lang.String pk, java.lang.String profileType, java.lang.String propertySet, java.lang.String propertyName, java.lang.Object value)
          Sets a property for a configurable entity.
 void setPropertyIntoCache(java.lang.String profileKey, java.lang.String profileType, java.lang.String propertyName, java.lang.Object value)
          Set a value into a cache
 void setSessionContext(javax.ejb.SessionContext ctx)
          Sets the session context.
static java.lang.String upcaseFirst(java.lang.String s)
          Make the first letter of a string uppercase
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USER_JNDI_HOME_NAME

public static final java.lang.String USER_JNDI_HOME_NAME

GROUP_JNDI_HOME_NAME

public static final java.lang.String GROUP_JNDI_HOME_NAME

DIRECT_PROPERTY_MANAGER

public static final java.lang.String DIRECT_PROPERTY_MANAGER

ENTITY_PROPERTY_MANAGER_HOME

public static final java.lang.String ENTITY_PROPERTY_MANAGER_HOME
Constructor Detail

DirectPropertyManagerBean

public DirectPropertyManagerBean()
Method Detail

getDefaultValue

public java.lang.Object getDefaultValue(java.lang.String propertySet,
                                        java.lang.String propertyName)
                                 throws java.rmi.RemoteException
Retrieves the default value of a property
Parameters:
propertySet - the property set to look in
propertyName - the name of the property
Returns:
the property's default value

getProperties

public java.util.Map getProperties(java.lang.String pk,
                                   java.lang.String profileType,
                                   java.lang.String successorPk,
                                   java.lang.String successorProfileType)
                            throws java.rmi.RemoteException
Retrieve all set properties for a particular ConfigurableEntity, following the successor chains as necessary. The successor passed into this method will be treated as the explicit successor, and properties for each property set will be retrieved from the successor for that property set if necessary. The results from this call will be the same as if getProperty was called separately for each available property with this explicit successor.
The only properties that will not come back from this call are explicit properties, which should be retrieved through getExplicitProperty(), and properties that were not set for this entity or any of its successors, for which the default value should be retrieved through getDefaultValue().
Parameters:
pk - the profile key of the entity
profileType - the profile type of the entity
successorPk - the profile key of an explicit successor to use (can be null)
successorProfileType - the profile type for an explicity successor (can be null)
Returns:
a map of PropertyMapKey->Object pairs

reallyGetProperties

protected java.util.Map reallyGetProperties(java.lang.String pk,
                                            java.lang.String profileType,
                                            java.lang.String successorPk,
                                            java.lang.String successorProfileType)
                                     throws java.rmi.RemoteException
Recursive helper method for getProperties

mergeWithSuccessorFromHandle

protected java.util.Map mergeWithSuccessorFromHandle(java.util.Map profileProperties,
                                                     PersistableHandle handle,
                                                     java.lang.String scopeName,
                                                     java.lang.String explicitSuccessorPk,
                                                     java.lang.String explicitSuccessorType)
                                              throws java.rmi.RemoteException
Get the properties for a ConfigurableEntity by calling reallyGetProperties with the information contained in the given handle, and then merge the two property maps. If the handle turns out to point to the same entity as the explicit successor, it does nothing.
Parameters:
profileProperties - the current set of properties, to merge into
handle - the handle representing a successor
scopeName - the scope to stay within (can be null for all scopes)
explicitSuccessorPk - the key of the explicit successor
explicitSuccessorType - the type of the explicit successor

mergeWithSuccessor

protected java.util.Map mergeWithSuccessor(java.util.Map props,
                                           java.util.Map successorProps,
                                           java.lang.String propertySet)
Merge an entity's properties with its successor's properties. This will check each property in the successor's map against the entity's map, and if it is not there (after checking the original scope, default scope, and reserved scope), will enter it. If a propertySet is provided, only properties from that set will be merged. The maps are pairs of PropertyMapKey->value entries.
Parameters:
props - the entity's properties
successorProps - the successor's properties
propertySet - the propertySet to stay within (can be null for all sets)
Returns:
the merged map

getProperty

public java.lang.Object getProperty(java.lang.String pk,
                                    java.lang.String profileType,
                                    java.lang.String successorPk,
                                    java.lang.String successorProfileType,
                                    java.lang.String propertySet,
                                    java.lang.String propertyName,
                                    java.lang.Object defaultValue)
                             throws java.rmi.RemoteException
Retrieve a property from a configurable entity. This will follow the standard successor search that the ConfigurableEntity object itself will follow, except that it will not retrieve an actual ConfigurableEntity unless it is necessary. This will reduce the number of EJB locks and potential deadlock situations.
Parameters:
pk - the profile key of the entity
profileType - the profile type of the entity
successorPk - the profile key of the explicit successor
successorProfileType - the type of the explicit successor
propertySet - the property set to look in
propertyName - the name of the property to retrieve
defaultValue - a value to return if none is found
Returns:
the value of the property

getPropertyFromCache

public java.lang.Object getPropertyFromCache(java.lang.String profileKey,
                                             java.lang.String profileType,
                                             java.lang.String propertyName)
Get a value out of the cache

setPropertyIntoCache

public void setPropertyIntoCache(java.lang.String profileKey,
                                 java.lang.String profileType,
                                 java.lang.String propertyName,
                                 java.lang.Object value)
Set a value into a cache

removePropertyFromCache

public void removePropertyFromCache(java.lang.String profileKey,
                                    java.lang.String profileType,
                                    java.lang.String propertyName)
Remove a value from the cache

getExplicitProperty

public java.lang.Object getExplicitProperty(java.lang.String profileKey,
                                            java.lang.String profileType,
                                            java.lang.String propertyName)
                                     throws java.rmi.RemoteException
Retrieve an explicit property from a configurable entity, if it exists. This method will actually create an instance of the entity based on the profileType, look for a getter method for the given property, and call it.
Parameters:
profileKey - the profile key of the entity
profileType - the profile type of the entity
propertyName - the name of the property to retrieve
Returns:
the value returned by the getter method, or null if none was found

getSharedProperty

protected com.beasys.commerce.foundation.property.external.SharedProperty getSharedProperty(java.lang.String pk,
                                                                                            java.lang.String propertySet,
                                                                                            java.lang.String propertyName)
Try to retrieve a property from a shared profile provider. Uses the SharedProfileProvider implementation class specified by the property sharedProfile.provider.

getProperty

protected java.lang.Object getProperty(java.lang.String pk,
                                       java.lang.String profileType,
                                       java.lang.String successorPk,
                                       java.lang.String successorProfileType,
                                       java.lang.String propertySet,
                                       java.lang.String propertyName,
                                       java.lang.Object defaultValue,
                                       boolean useDefault)
                                throws java.rmi.RemoteException
Just like the public direct property except it takes an extra parameter to determine whether or not to return the property's default value, if there is one. The public version just delegates to this one. This gets called recursively to climb the successor chain.

getPropertyFromSuccessorHandle

protected java.lang.Object getPropertyFromSuccessorHandle(PersistableHandle handle,
                                                          java.lang.String propertySet,
                                                          java.lang.String propertyName)
                                                   throws java.rmi.RemoteException
Try to retrieve a property from a ConfigurableEntity that is referred to by a PersistableHandle

setProperty

public void setProperty(java.lang.String pk,
                        java.lang.String profileType,
                        java.lang.String propertySet,
                        java.lang.String propertyName,
                        java.lang.Object value)
                 throws java.rmi.RemoteException
Sets a property for a configurable entity. This call actually retrieves a ConfigurableEntity object based on the given pk and profile type, and calls setProperty on it. This will ensure that the correct explicit properties will be set, and any cached values in the ConfigurableEntity will stay updated
Parameters:
pk - the key of the entity to update
profileType - the profile type of the entity
propertySet - the property set of the property to set
propertyName - the name of the property to set
value - the value to set

removeProperty

public java.lang.Object removeProperty(java.lang.String pk,
                                       java.lang.String profileType,
                                       java.lang.String propertySet,
                                       java.lang.String propertyName)
                                throws java.rmi.RemoteException
Removes the property from the given configurable entity.
Parameters:
pk - the key of the entity to update
profileType - the profile type of the entity
propertySet - the property set of the property to set
propertyName - the name of the property to set
Returns:
the removed value

getEntityId

public long getEntityId(java.lang.String pk,
                        java.lang.String profileType)
                 throws java.rmi.RemoteException
Retrieves the unique numeric id of a configurable entity
Parameters:
pk - the key of the entity
profileType - the type of entity
Returns:
the entity's unique numeric id

getEntity

public ConfigurableEntity getEntity(java.lang.String profileKey,
                                    java.lang.String profileType)
                             throws java.rmi.RemoteException
Instantiates a ConfigurableEntity based on the pk and profileType, and returns it cast as a ConfigurableEntity.
Parameters:
pk - the key of the entity to retrieve
profileType - the type to retrieve it as
Returns:
the retrieved configurable entity

upcaseFirst

public static java.lang.String upcaseFirst(java.lang.String s)
Make the first letter of a string uppercase

ejbCreate

public void ejbCreate()
Creates the session bean.

ejbActivate

public void ejbActivate()
This method is required by the EJB Specification, but is not used by this class.
Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbRemove

public void ejbRemove()
This method is required by the EJB Specification, but is not used by this class.
Specified by:
ejbRemove in interface javax.ejb.SessionBean

ejbPassivate

public void ejbPassivate()
This method is required by the EJB Specification, but is not used by this class.
Specified by:
ejbPassivate in interface javax.ejb.SessionBean

setSessionContext

public final void setSessionContext(javax.ejb.SessionContext ctx)
Sets the session context.
Specified by:
setSessionContext in interface javax.ejb.SessionBean
Parameters:
ctx - Context for session

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved