| 
 | |||||||||||
| 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
              |
              +--org.sape.carbon.core.config.format.jdom.JDOMConfigurationProxy
This is an extension of an AbstractConfigurationProxy
 that is backed by a JDOM Document data structure.
 
| Field Summary | |
| protected  Map | attributeCacheMap for caching previously accessed attributes | 
| static String | MAP_KEY_ATTRIBUTEKey attribute for a map element. | 
| protected  ConfigurationTypeService | typeServiceHolds the type service for configuration. | 
| Fields inherited from class org.sape.carbon.core.config.format.AbstractConfigurationProxy | 
| document, documentType, element, name, REF_PREFIX, REF_PREFIX_LENGTH | 
| Fields inherited from class org.sape.carbon.core.util.reflection.GenericProxy | 
|  | 
| Constructor Summary | |
| JDOMConfigurationProxy(Class configurationClass)Constructs a JDOMConfigurationProxy for the specified class type. | |
| JDOMConfigurationProxy(org.jdom.Document document,
                       Class configurationClass)Constructs a JDOMConfigurationProxy for the specified class type. | |
| JDOMConfigurationProxy(org.jdom.Element element,
                       Class configurationClass)Constructs a JDOMConfigurationProxy for the specified class type. | |
| Method Summary | |
| protected  org.jdom.Element | addAttribute(org.jdom.Element element,
             String attributeName,
             Class type,
             Object obj)Adds an attribute. | 
|  org.jdom.Element | addAttribute(String attributeName,
             Class type,
             Object obj)This method should add a child entity to this configuration entity | 
|  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. | 
|  Object | clone()This method clones this Configuration object through a deep-copy of it's underlying datastructure. | 
| protected  org.jdom.Element | configurationToElement(Configuration config)Converts a configuration to its jdom representation. | 
| protected  org.jdom.Element | constructElement(String entityName,
                 Class type,
                 Object obj)Constructs a jdom element from the given object by calling the ConfigurationTypeService | 
| protected  Object | formatContainedElement(org.jdom.Element element,
                       String name,
                       String key,
                       Class type)Converts the element to its object representation. | 
| protected  Object | formatElement(org.jdom.Element element,
              String name,
              Class type)Converts the element to its object representation. | 
|  Object | getArray(String attributeName,
         Class componentType)Retrieves an array of objects of the specified type that have the specified name. | 
| protected  Configuration | getChildConfiguration(Class requiredInterface,
                      org.jdom.Element element,
                      String name)Builds a new implementation of the specified configuration class by using a JDOMConfigurationProxy as the InvocationHandler for a Dynamic Proxy. | 
| protected  org.jdom.Element | getCollectionElement(String attributeName,
                     Class type)Gets the element containing either an array or Map object. | 
|  Map | getMap(String tagName,
       Class contentType)Retrieves a java.util.Map of objects of the specified type that have the specified name. | 
|  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  void | preLoadAttributeCache()This method is not in use as of carbon 1.1. | 
|  String | proxyToString(Object proxy)This method overrides the base proxy's toStringimplementation so that useful data is printed out when toString is
 called. | 
|  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 | setConfigurationReadOnly()Sets whether this configuration may be altered. | 
|  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.config.format.AbstractConfigurationProxy | 
| getArrayValue, getChildType, getCollectionComponentType, getConfigurationInterface, getConfigurationInterface, getConfigurationName, getDataStructure, getDocumentType, getRootElement, getSimpleClassName, handleInvoke, isChildConfiguration, isConfigurationWritable, isMapAttribute, isReference, lookupDefaultAttributeValue, proxyEquals, proxyHashCode, setConfigurationName | 
| Methods inherited from class org.sape.carbon.core.util.reflection.GenericProxy | 
| invoke | 
| Methods inherited from class java.lang.Object | 
| equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
protected final ConfigurationTypeService typeService
protected Map attributeCache
public static final String MAP_KEY_ATTRIBUTE
| Constructor Detail | 
public JDOMConfigurationProxy(Class configurationClass)
Configuration object.
configurationClass - The type of Configuration object that should be
  returned
public JDOMConfigurationProxy(org.jdom.Document document,
                              Class configurationClass)
Configuration object.
 The supplied document is used as the backing store for
 this configuration object's data.
document - The JDOM Document object representing a configurations
   dataconfigurationClass - The type of configuration to be implemented
public JDOMConfigurationProxy(org.jdom.Element element,
                              Class configurationClass)
Configuration object.
 The supplied Element is used as the backing datastore
 for this configuration object and it's document object
 will be modified when this object is modified.
element - The JDOM element object representing to root node
  of this configuration objectconfigurationClass - The type of configuration object that will be
   implemented| Method Detail | 
public String proxyToString(Object proxy)
This method overrides the base proxy's toString
 implementation so that useful data is printed out when toString is
 called.
 
proxyToString in class GenericProxyproxy - the proxy to print
public Object clone()
This method clones this Configuration object through a deep-copy of it's underlying datastructure. The resulting configuration object is a new object and can be altered without affecting the original.
clone in interface Configurationclone in class AbstractConfigurationProxyObject.clone()
public Object lookupAttribute(String attributeName,
                              Class returnType)
AbstractConfigurationProxyImplementations 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.
lookupAttribute in class AbstractConfigurationProxyattributeName - the name of the attribute to retrievereturnType - the class type of the object that should be returned
AbstractConfigurationProxy.lookupAttribute(java.lang.String, java.lang.Class)
public 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.
getArray in class AbstractConfigurationProxyattributeName - the name of the array to retrievecomponentType - the type of the objects that should be retrieved
  within the array
public Map getMap(String tagName,
                  Class contentType)
AbstractConfigurationProxyRetrieves 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.
getMap in class AbstractConfigurationProxytagName - the name of the array to retrievecontentType - the type of the objects that should be retrieved
      within the Map
AbstractConfigurationProxy.getMap(java.lang.String, java.lang.Class)
public void alterAttribute(String attributeName,
                           Class attributeType,
                           Object newValue)
AbstractConfigurationProxyImplementations of this method should provide the ability to alter an
 attribute within the configuration object setting its value to the
 provide newValue.
alterAttribute in class AbstractConfigurationProxyattributeName - the name of the attribute to be alteredattributeType - the type of the attributenewValue - the new value to change that attribute toAbstractConfigurationProxy.alterAttribute(java.lang.String, java.lang.Class, java.lang.Object)
public org.jdom.Element addAttribute(String attributeName,
                                     Class type,
                                     Object obj)
AbstractConfigurationProxy
addAttribute in class AbstractConfigurationProxyattributeName - 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
AbstractConfigurationProxy.addAttribute(java.lang.String, java.lang.Class, java.lang.Object)
protected org.jdom.Element addAttribute(org.jdom.Element element,
                                        String attributeName,
                                        Class type,
                                        Object obj)
element - the element to add an attribute toattributeName - the name of the attribute to addtype - the classtype of the attributeobj - the attribute to add
public void setArrayValue(String attributeName,
                          Class attributeType,
                          int index,
                          Object value)
AbstractConfigurationProxySets 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.
 
setArrayValue in class AbstractConfigurationProxyattributeName - 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 indicieAbstractConfigurationProxy.setArrayValue(java.lang.String, java.lang.Class, int, java.lang.Object)
public 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.
 
setMapValue in class AbstractConfigurationProxyattributeName - the name of the array to alterattributeType - the component type of the value within the map.key - the key within the map to setvalue - the Object to set as the value of this indicie
protected org.jdom.Element getCollectionElement(String attributeName,
                                                Class type)
attributeName - name of the attribute to get the element fortype - the type of class contained in the array or Map
protected Object formatElement(org.jdom.Element element,
                               String name,
                               Class type)
                        throws ConfigurationFormatException
This implementation will create a new configuration proxy if the type is a subtype of Configuration or the type is complex. If it is not a configuration subtype, the type handlers will be used to convert the data to an object. If type is not a Configuration or complex type and element is null or its type handler returns null, this implementation will attempt to lookup a default via a call to lookupDefaultAttributeValue from the super class. If element is null or its type handler returns null and there is no default and type is a primitive, an exception is thrown.
element - the element to be convertedname - the name of the element, used to name the resulting
 object when it is a subtype of Configurationtype - expected type of the resulting object
ConfigurationFormatException - indicates an error
         formatting the element
protected Object formatContainedElement(org.jdom.Element element,
                                        String name,
                                        String key,
                                        Class type)
                                 throws ConfigurationFormatException
The method is the same as formatElement except that it does not look up a default for the element if it is null.
element - the element to be convertedname - the name of the element, used to name the resulting
        object when it is a subtype of Configurationkey - the accessor key of the element, used to name the resulting
        object when it is a subtype of Configurationtype - expected type of the resulting object
ConfigurationFormatException - indicates an error formatting
         the contained element
protected Configuration getChildConfiguration(Class requiredInterface,
                                              org.jdom.Element element,
                                              String name)
Builds a new implementation of the specified configuration class by using a JDOMConfigurationProxy as the InvocationHandler for a Dynamic Proxy.
If the configuration is a reference (the element text starts with "ref://"), the referenced configuraiton is fetched from the config service and returned, otherwise, a new configuration object is created.
requiredInterface - The class that will be implemented by
        the configurationelement - The root element of the configuration objectname - the name of the child configuration being retreived
protected org.jdom.Element constructElement(String entityName,
                                            Class type,
                                            Object obj)
entityName - name of the element to constructtype - type of data represented by objobj - data represented by returned element
protected org.jdom.Element configurationToElement(Configuration config)
config - configuration to be converted
public void setConfigurationReadOnly()
AbstractConfigurationProxy
setConfigurationReadOnly in interface ConfigurationsetConfigurationReadOnly in class AbstractConfigurationProxyprotected void preLoadAttributeCache()
Loads all the attributes into the attribute cache. This is used when the configuration object is switched to read-only mode to prevent concurrent reads from corrupting the cache. After this, there should never be a lookup that needs to add to the cache; the cache effectively becomes read-only.
This implementation uses the Introspector to get all the properties of the configuration interface, then looks up each property using either lookupAttribute or getArray, depending on whether or not the property is indexed.
| 
 | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||