cuba.wired.ddread
Class WiredJarReader

java.lang.Object
  extended by cuba.wired.ddread.XmlReader
      extended by cuba.wired.ddread.WiredJarReader

public class WiredJarReader
extends XmlReader

XML reader for the descriptor of a wired JAR module

Author:
Jan Lessner

Field Summary
protected  org.w3c.dom.Element jardd
           
static java.lang.String WIRED_DD_DIR
           
static java.lang.String WIRED_DD_FILE
           
 
Fields inherited from class cuba.wired.ddread.XmlReader
REVISION_ID
 
Constructor Summary
WiredJarReader(java.lang.String jarFileName)
          Create a new WiredJarReader for the specified JAR file
 
Method Summary
protected  void checkEnvironmentType(java.lang.Class interfaceType)
           
protected  java.lang.Class getClass(org.w3c.dom.Node node, java.lang.String key)
          Get a Class by name from a descriptor node
protected  java.lang.Class getClass(java.lang.String className)
          Get a Class by name from the system class loader
protected  ComponentRefMap getComponentRefs(org.w3c.dom.Node comp)
          Collect a component's local references to other components
protected  EnvironmentRefMap getEnvironmentRefs(org.w3c.dom.Node comp)
          Collect a component's local environment references
protected  ResourceRefMap getResourceRefs(org.w3c.dom.Node comp)
          Collect a component's local references to external resources
protected  boolean getTransactionManagementType(org.w3c.dom.Node comp)
          Check for type of transaction control of a component description.
protected  java.lang.Object parseEnvironmentValue(java.lang.String rawValue, java.lang.Class resultType)
          Make a value type out of a string representation, basically by applying the expected result type's static valueOf method (via Java reflection API).
protected  void registerComponent(org.w3c.dom.Node comp, ComponentMap componentMap)
          Collect a component's name, type, wired adapter, and references and register it in the passed component map
 void registerComponents(ComponentMap componentMap)
          Collect all components from the module JAR file's descriptor and register them in the passed component map.
 
Methods inherited from class cuba.wired.ddread.XmlReader
getAttribute, getChild, getChildNode, getElementName, getJarEntry, getMandatoryAttribute, getMandatoryChild, getMandatoryChildNode, getMandatoryFirstChildValue, getResource, getRootElement, getRootElement, getSystemResource, getURL, setXmlParser, setXmlParserType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WIRED_DD_DIR

public static final java.lang.String WIRED_DD_DIR
See Also:
Constant Field Values

WIRED_DD_FILE

public static final java.lang.String WIRED_DD_FILE
See Also:
Constant Field Values

jardd

protected org.w3c.dom.Element jardd
Constructor Detail

WiredJarReader

public WiredJarReader(java.lang.String jarFileName)
               throws InitException
Create a new WiredJarReader for the specified JAR file

Parameters:
jarFileName - the name of the JAR file to read the descriptor from. Must not by null.
Throws:
InitException - if the JAR file does not exist, if it is not valid, if it doesn't contain a descriptor META-INF/wired-jar.xml or if the descriptor could not be process as an XML file.
Method Detail

getClass

protected java.lang.Class getClass(java.lang.String className)
                            throws InitException
Get a Class by name from the system class loader

Parameters:
className - the fully qualified class name. Must not be null.
Returns:
The loaded Class
Throws:
InitException - if the class could not be loaded.

getClass

protected java.lang.Class getClass(org.w3c.dom.Node node,
                                   java.lang.String key)
                            throws InitException
Get a Class by name from a descriptor node

Parameters:
node - The parent element node for the class name retrieval
key - The name of the direct child tag to retrieve the class name from
Returns:
The loaded Class
Throws:
InitException - if the class could not be loaded

getComponentRefs

protected ComponentRefMap getComponentRefs(org.w3c.dom.Node comp)
                                    throws InitException
Collect a component's local references to other components

Parameters:
comp - The node in the descriptor representing the component of interest
Returns:
A ComponentRefMap holding the collected references
Throws:
InitException - if any of the referenced component interfaces cannot be loaded from the system class loader

getResourceRefs

protected ResourceRefMap getResourceRefs(org.w3c.dom.Node comp)
                                  throws InitException
Collect a component's local references to external resources

Parameters:
comp - The node in the descriptor representing the component of interest
Returns:
A ResourceRefMap holding the collected references
Throws:
InitException - if any of the references refers to an unsupported resource interface type. Currently the is only DataSource supported.

checkEnvironmentType

protected void checkEnvironmentType(java.lang.Class interfaceType)
                             throws InitException
Throws:
InitException

parseEnvironmentValue

protected java.lang.Object parseEnvironmentValue(java.lang.String rawValue,
                                                 java.lang.Class resultType)
                                          throws InitException
Make a value type out of a string representation, basically by applying the expected result type's static valueOf method (via Java reflection API).

Parameters:
rawValue - the string value to make the object from
resultType - the expected result value type
Returns:
an object of type resultType if the passed string was successfully converted, or null if rawValue was null.
Throws:
InitException - if the resultType has no static valueOf() method, or if it cannot be invoked successfully (especially non-suitable string value).

getEnvironmentRefs

protected EnvironmentRefMap getEnvironmentRefs(org.w3c.dom.Node comp)
                                        throws InitException
Collect a component's local environment references

Parameters:
comp - The node in the descriptor representing the component of interest
Returns:
A EnvironmentRefMap holding the collected references
Throws:
InitException - if any of the references refers to an unsupported value type or if the specified value is not suitable to construct an object of the requested type. Currently there are the following types supported:
  • java.lang.String
  • java.lang.Boolean
  • java.lang.Byte
  • java.lang.Short
  • java.lang.Integer
  • java.lang.Long
  • java.lang.Float
  • java.lang.Double

getTransactionManagementType

protected boolean getTransactionManagementType(org.w3c.dom.Node comp)
                                        throws InitException
Check for type of transaction control of a component description.

Parameters:
comp - The node in the descriptor representing the component of interest
Returns:
true if the component uses container-managed transactions
Throws:
InitException - if the transaction management attribute is missing in the transaction tag of the component

registerComponent

protected void registerComponent(org.w3c.dom.Node comp,
                                 ComponentMap componentMap)
                          throws InitException
Collect a component's name, type, wired adapter, and references and register it in the passed component map

Parameters:
comp - The node in the descriptor representing the component of interest
componentMap - The ComponentMap to register the component in.
Throws:
InitException - if the component's description is invalid

registerComponents

public void registerComponents(ComponentMap componentMap)
                        throws InitException
Collect all components from the module JAR file's descriptor and register them in the passed component map.

Parameters:
componentMap - The ComponentMap to register the components in.
Throws:
InitException - if any of the components' descriptions is invalid