|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.easybeans.xmlconfig.XMLConfiguration
public class XMLConfiguration
XML configuration class that configure a given object with an xml
configuration file.
Additional information will be searched on the namespace with the resource named easybeans-mapping.xml.
Field Summary | |
---|---|
private java.util.HashMap<java.lang.String,java.lang.Object> |
configuredElements
Link between name and the objects. |
private static java.lang.String |
HTTP_NAMESPACE
Http:// namespace. |
private JLog |
logger
Logger. |
private static java.lang.String |
MAPPING_FILENAME
Per-Package mapping file name. |
private java.util.Map<java.lang.String,XMLMapping> |
mappings
Mapping between namespace and XMLMapping object. |
private boolean |
validating
Validating when parsing xml ? |
private static boolean |
VALIDATING_OFF
By default, no validation. |
private java.net.URL |
xmlConfigurationURL
URL of the configuration file. |
Constructor Summary | |
---|---|
XMLConfiguration(java.net.URL xmlConfigurationURL)
Build an xml configuration with the given xml configuration file. |
Method Summary | |
---|---|
private void |
addSetElement(java.lang.Object configuringObject,
java.lang.Object newObject)
Add or set element on the given object. |
private org.w3c.dom.Element |
analyzeXmlFile()
Gets the root element of the XML parsed file. |
void |
configure(java.lang.Object object)
Configure the given object with the configuration that was analyzed. |
void |
configure(java.lang.Object object,
org.w3c.dom.Element element)
Configure the given object by looking at the element (of the configuration). |
private XMLMapping |
createXMLMapping(java.lang.String nameSpace,
java.net.URL mappingURL)
Create the XML mapping object for the given namespace with the given XML mapping file. |
private java.lang.reflect.Method[] |
findListGetterSetterMethod(java.lang.Object configuringObject,
java.lang.Object paramObject)
Finds the get(List<Class>) and set(List<Class>) methods. |
private java.lang.reflect.Method |
findSingleGetterMethod(java.lang.Object configuringObject,
java.lang.Object paramObject)
Finds the get(Class c) method. The parameter needs to be a single entry and not a list. |
private java.lang.reflect.Method |
findSingleSetterMethod(java.lang.Object configuringObject,
java.lang.Object paramObject)
Finds the add(Class c) or set(Class c) methods. The parameter needs to be a single entry and not a list. |
private ClassMapping |
getClassMapping(java.lang.String nameSpaceURI,
java.lang.String name)
Gets the Mapping for the given nameSpaceURI and the given classname. |
private XMLMapping |
getXMLMapping(java.lang.String nameSpace)
Gets the XML mapping for the given namespace and the node name. |
private java.lang.Object |
newInstance(org.w3c.dom.Node node,
ClassMapping classMapping)
Build class instance for the given node. |
private java.lang.reflect.Method[] |
searchListGetterSetterMethod(java.lang.reflect.Method[] methods,
java.lang.String argName,
java.lang.Class parameterClass)
Search getter and setter method in the given set of methods. |
private void |
setAttribute(java.lang.Object configuringObject,
java.lang.String propertyName,
java.lang.String propertyValue,
ClassMapping classMapping)
Set attribute on the given object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String HTTP_NAMESPACE
private static final boolean VALIDATING_OFF
private static final java.lang.String MAPPING_FILENAME
private JLog logger
private boolean validating
private java.net.URL xmlConfigurationURL
private java.util.Map<java.lang.String,XMLMapping> mappings
private java.util.HashMap<java.lang.String,java.lang.Object> configuredElements
Constructor Detail |
---|
public XMLConfiguration(java.net.URL xmlConfigurationURL)
xmlConfigurationURL
- the given xml configuration fileMethod Detail |
---|
public void configure(java.lang.Object object) throws XMLConfigurationException
object
- the object to configure.
XMLConfigurationException
- if configuration failsprivate org.w3c.dom.Element analyzeXmlFile() throws XMLConfigurationException
XMLConfigurationException
- if analyze fails.public void configure(java.lang.Object object, org.w3c.dom.Element element) throws XMLConfigurationException
object
- the given object to configure.element
- the element that contains configuration.
XMLConfigurationException
- if configuration failsprivate ClassMapping getClassMapping(java.lang.String nameSpaceURI, java.lang.String name) throws XMLConfigurationException
nameSpaceURI
- the namespace of the xml elementname
- the name of the class
XMLConfigurationException
- if no configuration is foundprivate java.lang.Object newInstance(org.w3c.dom.Node node, ClassMapping classMapping) throws XMLConfigurationException
node
- the element of the xmlclassMapping
- the mapping between node name and class name
XMLConfigurationException
- if no new instance can be done.private void setAttribute(java.lang.Object configuringObject, java.lang.String propertyName, java.lang.String propertyValue, ClassMapping classMapping) throws XMLConfigurationException
configuringObject
- the object to configurepropertyName
- the name of the property (for the setter)propertyValue
- the value of the propertyclassMapping
- the mapping (if there are attributes aliasing)
XMLConfigurationException
- if attribute cannot be set.private java.lang.reflect.Method findSingleSetterMethod(java.lang.Object configuringObject, java.lang.Object paramObject)
configuringObject
- the object on which call this setter method.paramObject
- the parameter object
private java.lang.reflect.Method findSingleGetterMethod(java.lang.Object configuringObject, java.lang.Object paramObject)
configuringObject
- the object on which call this getter method.paramObject
- the parameter object
private java.lang.reflect.Method[] findListGetterSetterMethod(java.lang.Object configuringObject, java.lang.Object paramObject)
configuringObject
- the object on which call this setter method.paramObject
- the parameter object
private java.lang.reflect.Method[] searchListGetterSetterMethod(java.lang.reflect.Method[] methods, java.lang.String argName, java.lang.Class parameterClass)
methods
- the set of methods to search inargName
- the name of the argumentparameterClass
- the parameter class (for the generics on the List)
private void addSetElement(java.lang.Object configuringObject, java.lang.Object newObject) throws XMLConfigurationException
configuringObject
- the object to configurenewObject
- the object to add/set on the configuringObject object
XMLConfigurationException
- if newObject cannot be set.private XMLMapping getXMLMapping(java.lang.String nameSpace) throws XMLConfigurationException
nameSpace
- current XML namespace.
XMLConfigurationException
- if xml mapping is not found.private XMLMapping createXMLMapping(java.lang.String nameSpace, java.net.URL mappingURL) throws XMLConfigurationException
nameSpace
- the namespace of the mappingmappingURL
- the URL to the XML mapping file
XMLConfigurationException
- if no XML mapping have been created.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |