org.ow2.util.xmlconfig
Class XMLConfiguration

java.lang.Object
  extended by org.ow2.util.xmlconfig.XMLConfiguration

public class XMLConfiguration
extends java.lang.Object

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.

Author:
Florent Benoit

Constructor Summary
XMLConfiguration(java.io.InputStream stream, java.lang.String mappingFilename)
          Build an xml configuration with the given xml configuration file.
XMLConfiguration(java.lang.String mappingFilename)
          Initialize class fields.
XMLConfiguration(java.net.URL xmlConfigurationURL, java.lang.String mappingFilename)
          Build an xml configuration with the given xml configuration file.
XMLConfiguration(java.net.URL xmlConfigurationURL, java.lang.String mappingNS, java.lang.String mappingFilename)
          Deprecated.  
 
Method Summary
 void addConfigurationFile(java.net.URL xmlConfigurationFile)
          Add an URL pointing to an XML configuration file that will be used sequentially to configure an instance.
 void addConfigurationSource(IConfigurationSource source)
          Add a new IConfigurationSource wrapping an XML configuration content.
 void addConfigurationStream(java.lang.String name, java.io.InputStream stream)
          Add an InputStream that will be used sequentially to configure an instance.
 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, ClassMapping parentClassMapping)
          Configure the given object by looking at the element (of the configuration).
 java.util.Map<java.lang.String,java.lang.Object> getContextualInstances()
           
 IPropertyResolver getPropertyResolver()
           
 boolean isElementMapping(java.lang.String name, ClassMapping classMapping)
          Is that the given name should be considered as an XML element (and read the value of this element).
 boolean isListElement(java.lang.String name, ClassMapping classMapping)
          Is that the given name should be used with a list.
protected  void setAttributes(org.w3c.dom.Element node, java.lang.Object object, ClassMapping classMapping)
          Sets the attributes on the given object.
 void setContextualInstances(java.util.Map<java.lang.String,java.lang.Object> contextualInstances)
          Set the contextual instances Map.
 void setPropertyResolver(IPropertyResolver propertyResolver)
          Set the property resolver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLConfiguration

@Deprecated
public XMLConfiguration(java.net.URL xmlConfigurationURL,
                                   java.lang.String mappingNS,
                                   java.lang.String mappingFilename)
Deprecated. 

Build an xml configuration with the given xml configuration file.

Parameters:
xmlConfigurationURL - the given xml configuration file
mappingFilename - per-Package mapping file name
mappingNS - the namespace of the mapping

XMLConfiguration

public XMLConfiguration(java.net.URL xmlConfigurationURL,
                        java.lang.String mappingFilename)
Build an xml configuration with the given xml configuration file.

Parameters:
xmlConfigurationURL - the given xml configuration file
mappingFilename - per-Package mapping file name

XMLConfiguration

public XMLConfiguration(java.io.InputStream stream,
                        java.lang.String mappingFilename)
Build an xml configuration with the given xml configuration file.

Parameters:
stream - the given xml configuration file
mappingFilename - per-Package mapping file name

XMLConfiguration

public XMLConfiguration(java.lang.String mappingFilename)
Initialize class fields.

Parameters:
mappingFilename - per-Package mapping file name
Method Detail

addConfigurationFile

public void addConfigurationFile(java.net.URL xmlConfigurationFile)
Add an URL pointing to an XML configuration file that will be used sequentially to configure an instance.

Parameters:
xmlConfigurationFile - URL pointing to an XML configuration file

addConfigurationStream

public void addConfigurationStream(java.lang.String name,
                                   java.io.InputStream stream)
Add an InputStream that will be used sequentially to configure an instance.

Parameters:
name - Stream's name
stream - the InputStream wrapping an XML configuration

addConfigurationSource

public void addConfigurationSource(IConfigurationSource source)
Add a new IConfigurationSource wrapping an XML configuration content.

Parameters:
source - the configuration's source

configure

public void configure(java.lang.Object object)
               throws XMLConfigurationException
Configure the given object with the configuration that was analyzed.

Parameters:
object - the object to configure.
Throws:
XMLConfigurationException - if configuration fails

isElementMapping

public boolean isElementMapping(java.lang.String name,
                                ClassMapping classMapping)
Is that the given name should be considered as an XML element (and read the value of this element).

Parameters:
name - the given name
classMapping - the mapping used to get the info
Returns:
true if the name should be read from the XML element.

isListElement

public boolean isListElement(java.lang.String name,
                             ClassMapping classMapping)
Is that the given name should be used with a list.

Parameters:
name - the given name
classMapping - the mapping used to get the info
Returns:
true if the name should be used as a list.

configure

public void configure(java.lang.Object object,
                      org.w3c.dom.Element element,
                      ClassMapping parentClassMapping)
               throws XMLConfigurationException
Configure the given object by looking at the element (of the configuration).

Parameters:
object - the given object to configure.
element - the element that contains configuration.
parentClassMapping - the parent class mapping
Throws:
XMLConfigurationException - if configuration fails

setAttributes

protected void setAttributes(org.w3c.dom.Element node,
                             java.lang.Object object,
                             ClassMapping classMapping)
                      throws XMLConfigurationException
Sets the attributes on the given object.

Parameters:
node - the XML element object
object - the object to configure
classMapping - the mapping data
Throws:
XMLConfigurationException - if the attributes cannot be set

getPropertyResolver

public IPropertyResolver getPropertyResolver()
Returns:
the property resolver

setPropertyResolver

public void setPropertyResolver(IPropertyResolver propertyResolver)
Set the property resolver.

Parameters:
propertyResolver - the property resolver

getContextualInstances

public java.util.Map<java.lang.String,java.lang.Object> getContextualInstances()
Returns:
the contextual instances Map

setContextualInstances

public void setContextualInstances(java.util.Map<java.lang.String,java.lang.Object> contextualInstances)
Set the contextual instances Map.

Parameters:
contextualInstances - the contextual instances Map


Copyright © 2007-2009 OW2 Consortium. All Rights Reserved.