|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.sape.carbon.core.util.reflection.GenericProxy | +--org.sape.carbon.core.config.format.AbstractConfigurationProxy
This abstract class includes basic support for configuration objects
in XML. This class implements the Dynamic Proxy
Configuration
and automatically support
reading and writing the data of that object to XML.
This abstract class implements the basic functionality for managing a
JDOM Document
. It also provides abstract method declarations
that allow a subclass to choose exactly the format for that XML and how it
is treated by a Configuration object.
Field Summary | |
protected org.jdom.Document |
document
JDOM Document object that holds the xml version of this configuration object's data. |
protected Class |
documentType
The Class of object that this configuration object is implementing. |
protected org.jdom.Element |
element
The root element of this configuration object. |
private org.apache.commons.logging.Log |
log
Provides a handle to Apache-commons logger |
protected String |
name
The fully qualified configuration name for this configuration object |
protected static String |
REF_PREFIX
Prefix for config values that reference other configs. |
protected static int |
REF_PREFIX_LENGTH
Holds the length of reference prefix. |
private static String |
ROOT_TAG
The root XML tag for configuration documnts |
private boolean |
writable
True if this object may be altered, false if it should throw exceptions when attempts are made to alter it. |
Fields inherited from class org.sape.carbon.core.util.reflection.GenericProxy |
|
Constructor Summary | |
protected |
AbstractConfigurationProxy(Class documentType)
Constructs an AbstractConfigurationProxy for the supplied document. |
protected |
AbstractConfigurationProxy(org.jdom.Document document,
org.jdom.Element root,
Class documentType)
Constructs an AbstractConfigurationProxy for the supplied document. |
Method Summary | |
abstract org.jdom.Element |
addAttribute(String entityName,
Class type,
Object obj)
This method should add a child entity to this configuration entity |
abstract void |
alterAttribute(String attributeName,
Class attributeType,
Object newValue)
Implementations of this method should provide the ability to alter an attribute within the configuration object setting its value to the provide newValue . |
abstract Object |
clone()
This method makes a deep-copy of the underlying data structure for this configuration |
abstract Object |
getArray(String attributeName,
Class componentType)
Retrieves an array of objects of the specified type that have the specified name. |
protected Object |
getArrayValue(String attributeName,
Class type,
int index)
Gets the value from an configuration array. |
Class |
getChildType(String attributeName)
Retrieves the type of a JavaBean attribute by introspecting for its retrieval method and checking its return type. |
protected Class |
getCollectionComponentType(String attrName)
Gets the type of class contained within a map. |
Class |
getConfigurationInterface()
This method returns the Class of this component's
configuration. |
protected Class |
getConfigurationInterface(org.jdom.Element element,
Class defaultInterface)
Gets the ConfigurationInterface specifed in an element. |
String |
getConfigurationName()
Retrieves this configuration object's name |
org.jdom.Document |
getDataStructure()
Returns a JDOM Document object representing the underlying data of this configuration object. |
Class |
getDocumentType()
Retrieves the primary type of this configuration |
abstract Map |
getMap(String attributeName,
Class contentType)
Retrieves a java.util.Map of objects of the specified type that have the specified name. |
org.jdom.Element |
getRootElement()
Retrieves the root element of the data being currently mapped by this configuration object. |
static String |
getSimpleClassName(Class theClass)
Returns the simple class name without the prepended package structure |
protected Object |
handleInvoke(Object proxy,
Method m,
Object[] args)
This method provides the basic implementation of invocations from the standpoint of DynamicProxies. |
boolean |
isChildConfiguration(org.jdom.Element childElement)
Checks whether or not childElement is a child configuration or not |
boolean |
isConfigurationWritable()
Is this configuration document writable or is it read-only. |
protected boolean |
isMapAttribute(String attrName)
Checks if the given attribute contains a map. |
boolean |
isReference(org.jdom.Element element)
Checks whether or not element is a reference to another configuration. |
abstract Object |
lookupAttribute(String attributeName,
Class returnType)
Implementations of this method should retrieve a value from the configuration object with the specified name and Type. |
protected Object |
lookupDefaultAttributeValue(Class type,
String attributeName,
Class returnType)
Retrieves the default value for a requested configuration attribute from an interface static variable with the same name as the requested attribute. |
protected Boolean |
proxyEquals(Object proxy,
Object other)
This method implements the standard proxyEquals method for subclassed invocation handler dynamic proxies. |
protected Integer |
proxyHashCode(Object proxy)
Implements the standard hashCode method with a simple call to System.identityHashCode(). |
abstract void |
setArrayValue(String attributeName,
Class attributeType,
int index,
Object value)
Sets the value of a specific index in an array of data in this configuration object. |
void |
setConfigurationName(String name)
Sets the name of this configuration object |
void |
setConfigurationReadOnly()
Sets whether this configuration may be altered. |
abstract void |
setMapValue(String attributeName,
Class attributeType,
Object key,
Object value)
Sets the value of a specific index in an array of data in this configuration object. |
Methods inherited from class org.sape.carbon.core.util.reflection.GenericProxy |
invoke, proxyToString |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private org.apache.commons.logging.Log log
protected static final String REF_PREFIX
protected static final int REF_PREFIX_LENGTH
protected org.jdom.Document document
protected org.jdom.Element element
protected Class documentType
protected String name
private static final String ROOT_TAG
private boolean writable
Constructor Detail |
protected AbstractConfigurationProxy(org.jdom.Document document, org.jdom.Element root, Class documentType)
document
- The JDOM document object representing the XML for this
configuration objectroot
- The root element of this configuration object, not
necessarily the root of the documentdocumentType
- the Class of object represented by the DynamicProxy
form of this objectprotected AbstractConfigurationProxy(Class documentType)
documentType
- the Class of object represented by the DynamicProxy
form of this objectMethod Detail |
public String getConfigurationName()
getConfigurationName
in interface Configuration
null
if this configuration
object has not yet been stored in the configuration servicepublic void setConfigurationName(String name)
setConfigurationName
in interface Configuration
name
- the fully qualified name of this configuration in the
configuration servicepublic Class getDocumentType()
protected Object handleInvoke(Object proxy, Method m, Object[] args) throws Throwable
This method provides the basic implementation of invocations
from the standpoint of DynamicProxies. The base proxy class,
GenericProxy
provides a default implemenetation
of an InvocationHandler and basic handling for the standad
Object
methods. Other methods are passed to this
method for invocation.
This AbstractConfigurationProxy
will handle basic
bean based calls into an object graph and utilize method name
and JavaBean based naming standards to determine the proper data
item to query.
Sublcasses of AbstractConfigurationProxy
will be able
to provide specific implementations of these methods based on what
the underlying datastore type is.
handleInvoke
in class GenericProxy
proxy
- the proxy object on which the method was calledm
- the method which was called to be executedargs
- the array of arguments to the specified method call
Throwable
- when an invoke fails with any exception -
this is cast by standard dynamic proxy functionality into an
appropriate exception for the type of method that was actually called.protected Object getArrayValue(String attributeName, Class type, int index)
attributeName
- the name of the attribute that holds the arraytype
- the type of class within the arrayindex
- the index of the value to retreive
InvalidParameterException
- indicates there was an error
accessing the give index in the array such as an
IndexOutOfBoundsExceptionprotected boolean isMapAttribute(String attrName)
attrName
- the attribute to test for being a map
protected Class getCollectionComponentType(String attrName)
attrName
- the name of the attribute to determine the
class type of
public Class getChildType(String attributeName)
attributeName
- the name of the attribute to get the type of
protected Object lookupDefaultAttributeValue(Class type, String attributeName, Class returnType)
type
- the Class of the configuration interface that may
contain a default valueattributeName
- the name of the attribute being looked forreturnType
- the return type of the method
public abstract void alterAttribute(String attributeName, Class attributeType, Object newValue)
Implementations of this method should provide the ability to alter an
attribute within the configuration object setting its value to the
provide newValue
.
attributeName
- the name of the attribute to be alteredattributeType
- the type of the attributenewValue
- the new value to change that attribute topublic abstract Object lookupAttribute(String attributeName, Class returnType)
Implementations of this method should retrieve a value from the configuration object with the specified name and Type. The Type information is gleaned from the providing configuration interface and allows the system to determine the proper mechanism for instantiating this value. This may involve the usage of the micro-level formatting for configuration values.
attributeName
- the name of the attribute to retrievereturnType
- the class type of the object that should be returned
public abstract Object getArray(String attributeName, Class componentType)
Retrieves an array of objects of the specified type that have the specified name. This might get a list of dependent objects or a list of string values.
attributeName
- the name of the array to retrievecomponentType
- the type of the objects that should be retrieved
within the array
public abstract Map getMap(String attributeName, Class contentType)
Retrieves a java.util.Map of objects of the specified type that have the specified name. This might get a list of dependent objects or a list of string values.
attributeName
- the name of the array to retrievecontentType
- the type of the objects that should be retrieved
within the Map
public abstract void setArrayValue(String attributeName, Class attributeType, int index, Object value)
Sets the value of a specific index in an array of data in this
configuration object. Implementing classes must set the specified index
of the array named by attributeName
to the specified value.
attributeName
- the name of the array to alterattributeType
- the type of the objects in the arrayindex
- the indicie of the array to altervalue
- the Object to set as the value of this indiciepublic abstract void setMapValue(String attributeName, Class attributeType, Object key, Object value)
Sets the value of a specific index in an array of data in this
configuration object. Implementing classes must set the specified index
of the array named by attributeName
to the specified value.
attributeName
- the name of the array to alterattributeType
- the type of the objects in the mapkey
- the key within the map to setvalue
- the Object to set as the value of this indiciepublic abstract org.jdom.Element addAttribute(String entityName, Class type, Object obj)
entityName
- the name of the array on which to add a particular
valuetype
- type of class of the child entityobj
- The object to be added as a configuration entity
public static String getSimpleClassName(Class theClass)
Returns the simple class name without the prepended package structure
theClass
- the class whose name is returned
public Class getConfigurationInterface()
Configuration
Class
of this component's
configuration.
getConfigurationInterface
in interface Configuration
Configuration.getConfigurationInterface()
public org.jdom.Document getDataStructure()
Configuration
getDataStructure
in interface Configuration
Document
object representing
the full data set of this configuration
documentConfiguration.getDataStructure()
public org.jdom.Element getRootElement()
getRootElement
in interface Configuration
public abstract Object clone()
Configuration
This method makes a deep-copy of the underlying data structure for this configuration
clone
in interface Configuration
clone
in class Object
Object.clone()
public boolean isChildConfiguration(org.jdom.Element childElement)
childElement
- element to be tested.
public boolean isReference(org.jdom.Element element)
element
- element to check if it is a reference
protected Class getConfigurationInterface(org.jdom.Element element, Class defaultInterface)
element
- the element to retreive the configuration element fromdefaultInterface
- the default interface if there is no
configuration interface defined by the element
protected Boolean proxyEquals(Object proxy, Object other)
GenericProxy
proxyEquals
in class GenericProxy
proxy
- the proxy object for which equals is
being handledother
- the other object being compared too
GenericProxy.proxyEquals(Object, Object)
protected Integer proxyHashCode(Object proxy)
GenericProxy
proxyHashCode
in class GenericProxy
proxy
- the object for which a hashcode should
be returned
GenericProxy.proxyHashCode(Object)
public boolean isConfigurationWritable()
isConfigurationWritable
in interface Configuration
public void setConfigurationReadOnly()
setConfigurationReadOnly
in interface Configuration
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |