© 2002 BEA Systems, Inc.


com.bea.p13n.property
Class AbstractConfigurableEntity

java.lang.Object
  |
  +--com.bea.p13n.property.AbstractConfigurableEntity
Direct Known Subclasses:
AbstractHierarchicalEntity, ConfigurableEntityImpl, Event

public abstract class AbstractConfigurableEntity
extends java.lang.Object
implements ConfigurableEntity, java.io.Serializable

Abstract base class for ConfigurableEntity implementations. This class provides the basic CE functionality, including explicit properties, but does not persist properties in any way. It also does not use Property Sets for property validation or default value retrieval, as it does not have a consistent way to access the Property Set Manager. Any classes that wish to use the ConfigurableEntity functionality in a lightweight object should extend this.

See Also:
Serialized Form

Field Summary
protected static java.lang.String CE_METHOD_CACHE
          cache name for CE explicit methods
protected  java.lang.Class instanceClass
          The actual implementation class of this entity
protected static java.lang.String PREFIX_GET
          prefix to find accessor methods via reflection
protected static java.lang.String PREFIX_SET
          prefix to find mutator methods via reflection
protected  EntityPropertyCache propertyCache
          internal store of properties
protected static com.bea.p13n.i18n.PropertyExceptionTextFormatter textFormatter
          Exception class
 
Constructor Summary
AbstractConfigurableEntity()
           
 
Method Summary
static PropertyMapKey createMapKey(java.lang.String propertySet, java.lang.String propertyName)
          Helper function that will allocate a PropertyMapKey from a property set name and property name.
 java.lang.Object getCachedProperty(java.lang.String propertySet, java.lang.String propertyName)
          Retrieve the value associated with the key from the object cache
protected  java.lang.Object getExplicitProperty(java.lang.String propertyName)
          Find and invoke the explicit accessor method for the given property in the implementation class of the entity.
protected  java.lang.reflect.Method getExplicitSetter(java.lang.String propertyName, java.lang.Object value)
          Search for a setter method for the given property name and value object.
protected  java.lang.Object getImplicitProperty(java.lang.String propertySet, java.lang.String propertyName)
          Look for a value for the given property in the standard database tables.
 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.
 java.lang.String getPropertyAsString(java.lang.String propertySet, java.lang.String propertyName)
          Convenience method to return a property as a String.
 EntityPropertyCache getPropertyCache()
          Allocate the property map and load it using the EntityPropertyManager.
 java.lang.Object getPropertyNoDefault(java.lang.String propertySet, java.lang.String propertyName)
          Retrieve the value associated with the named key in the specified property set, but does not return a default value from the property's PropertyDefinition if a value was not persisted for this entity.
 long getUniqueId()
          Retrieve the unique identifier generated for this ConfigurableEntity.
protected  boolean hasExplicitGetter(java.lang.String propertyName)
          Determine if an explicit getter method exists for the given property in the implementation class of the entity.
protected  boolean hasExplicitSetter(java.lang.String propertyName, java.lang.Object value)
          Determine if an explicit setter method exists for the given property in the implementation class of the entity.
protected  void removeExplicitProperty(java.lang.String propertyName, java.lang.Object prototypeValue)
           
 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.
protected  void setExplicitProperty(java.lang.String propertyName, java.lang.Object value)
          Set a property on the entity using the explicit set.
 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.
protected  java.lang.String upcaseFirst(java.lang.String s)
          Make the first letter of the string upper cased.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREFIX_SET

protected static final java.lang.String PREFIX_SET
prefix to find mutator methods via reflection

PREFIX_GET

protected static final java.lang.String PREFIX_GET
prefix to find accessor methods via reflection

instanceClass

protected java.lang.Class instanceClass
The actual implementation class of this entity

propertyCache

protected transient EntityPropertyCache propertyCache
internal store of properties

textFormatter

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

CE_METHOD_CACHE

protected static final java.lang.String CE_METHOD_CACHE
cache name for CE explicit methods
Constructor Detail

AbstractConfigurableEntity

public AbstractConfigurableEntity()
Method Detail

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.
Specified by:
getProperty in interface ConfigurableEntity

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

getPropertyAsString

public java.lang.String getPropertyAsString(java.lang.String propertySet,
                                            java.lang.String propertyName)
                                     throws java.rmi.RemoteException
Convenience method to return a property as a String.
Specified by:
getPropertyAsString in interface ConfigurableEntity

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 as a String, or null if all searches failed

getPropertyNoDefault

public java.lang.Object getPropertyNoDefault(java.lang.String propertySet,
                                             java.lang.String propertyName)
                                      throws java.rmi.RemoteException
Retrieve the value associated with the named key in the specified property set, but does not return a default value from the property's PropertyDefinition if a value was not persisted for this entity. 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.
Specified by:
getPropertyNoDefault in interface ConfigurableEntity

Parameters:
propertySet - The name of the property set
propertyName - The name of the property to retrieve.
Returns:
the value for this property, or null if all searches failed

setProperty

public void setProperty(java.lang.String propertySet,
                        java.lang.String propertyName,
                        java.lang.Object value)
                 throws PropertyValidationException,
                        java.rmi.RemoteException
Associate the specified value with the named key in the specified property set.
Specified by:
setProperty in interface ConfigurableEntity

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

removeProperty

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

Specified by:
removeProperty in interface ConfigurableEntity

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.

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.
Specified by:
getUniqueId in interface ConfigurableEntity

Returns:
this entity's unique id

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.
Specified by:
getPkString in interface ConfigurableEntity

Returns:
the primary key string identifier for this entity

getJndiName

public java.lang.String getJndiName()
                             throws java.rmi.RemoteException
Retrieve the jndi name for an entity. A combination of pk string and jndi name is always unique between entities.
Specified by:
getJndiName in interface ConfigurableEntity

Returns:
the jndi name for this entity

getImplicitProperty

protected java.lang.Object getImplicitProperty(java.lang.String propertySet,
                                               java.lang.String propertyName)
                                        throws java.rmi.RemoteException
Look for a value for the given property in the standard database tables.

Parameters:
propertySet - the property set to look in
propertyName - the name of the property
Returns:
the property value, or null if it was not found

getCachedProperty

public java.lang.Object getCachedProperty(java.lang.String propertySet,
                                          java.lang.String propertyName)
                                   throws java.rmi.RemoteException
Retrieve the value associated with the key from the object cache

Parameters:
propertySet - The property set to look in
propertyName - The name of the property
Returns:
the property's value, or null if it was not found

hasExplicitGetter

protected boolean hasExplicitGetter(java.lang.String propertyName)
Determine if an explicit getter method exists for the given property in the implementation class of the entity.

Parameters:
propertyName - the name of the property to look for
Returns:
true if an explicit accessor exists, false otherwise

getExplicitProperty

protected java.lang.Object getExplicitProperty(java.lang.String propertyName)
Find and invoke the explicit accessor method for the given property in the implementation class of the entity.

Parameters:
propertyName - the name of the property to look for
Returns:
the value returned from the accessor, or null if the accessor was not found

getExplicitSetter

protected java.lang.reflect.Method getExplicitSetter(java.lang.String propertyName,
                                                     java.lang.Object value)
Search for a setter method for the given property name and value object. This will look in the current CE impl class for a setter of the form set which takes as its argument an object of the same type as the value object, or a superclass, or an interface that the value object implements.

Returns:
the setter method, or null if none exists.

hasExplicitSetter

protected boolean hasExplicitSetter(java.lang.String propertyName,
                                    java.lang.Object value)
Determine if an explicit setter method exists for the given property in the implementation class of the entity.

Parameters:
propertyName - the name of the property to look for
value - a value that represents the property type to look for
Returns:
true if an explicit mutator exists, false otherwise

setExplicitProperty

protected void setExplicitProperty(java.lang.String propertyName,
                                   java.lang.Object value)
Set a property on the entity using the explicit set.

Parameters:
propertyName - the name of the property to set
value - the value to pass to the mutator method

removeExplicitProperty

protected void removeExplicitProperty(java.lang.String propertyName,
                                      java.lang.Object prototypeValue)


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

createMapKey

public static PropertyMapKey createMapKey(java.lang.String propertySet,
                                          java.lang.String propertyName)
Helper function that will allocate a PropertyMapKey from a property set name and property name.

Parameters:
propertySet - the property set name to use
propertyName - the property name to use
Returns:
a PropertyMapKey representing that property

upcaseFirst

protected final java.lang.String upcaseFirst(java.lang.String s)
Make the first letter of the string upper cased.

Parameters:
s - the string to process
Returns:
the processed string

© 2002 BEA Systems, Inc.

Copyright © 2002 BEA Systems, Inc. All Rights Reserved