org.jbpm.wire.xml
Class WireParser

java.lang.Object
  extended by org.jbpm.xml.Parser
      extended by org.jbpm.wire.xml.WireParser
All Implemented Interfaces:
org.xml.sax.EntityResolver
Direct Known Subclasses:
EnvironmentApplicationXmlParser, EnvironmentBlockXmlParser

public class WireParser
extends Parser

parses object wiring xml and constructs a WireDefinition.

To learn the full XML syntax, check out the Bindings:

Bindings

The defaults bindings for the Wiring XML are divided in two categories:

Once a parser is created, bindings can be added, overwritten and removed to customize that parser instance.

Describing arguments

An ArgDescriptor is defined by a <arg> xml element.

This element can have an attribute "type", which specifies name of the argument's type.

This element contains one child element that defines a Descriptor. This descriptor specifies the value to give to the argument.

Example

Consider the following class:
 public class Hello {
   public static String sayHello(String name) {
     return "Hello " + name + " !";
   }
 }
The following Xml declaration will create an object 's' of class 'String' (see ObjectDescriptor). This object is created by invoking Hello.sayHello with the value world as a parameter.
 <objects>
   <object name="s" class='Hello' method='sayHello'>
     <arg>
      <string value='world' />
     </arg>
   </object>
 </objects>
The created object 's' will be a String, containing "Hello world !".

Initialization

The initialization method can be defined with the init attribute. For more details on how initialization works, see section 'Initialization' of WireContext.

The init attribute can have these values:

Author:
Tom Baeyens, Guillaume Porcher (documentation)

Field Summary
static java.lang.String CATEGORY_DESCRIPTOR
           
static java.lang.String CATEGORY_INTERCEPTOR
           
static java.lang.String CATEGORY_OPERATION
           
static java.lang.String PVM_WIRE_BINDINGS_RESOURCES
           
 
Fields inherited from class org.jbpm.xml.Parser
bindings, classLoader, documentBuilderFactory, entities
 
Constructor Summary
WireParser()
          Constructs a new WireParser with the default bindings.
 
Method Summary
static WireParser getInstance()
          Default method to get an instance of the WireParser
 java.util.List<ArgDescriptor> parseArgs(java.util.List<org.w3c.dom.Element> argElements, Parse parse)
          Parses the list of arguments of a method.
 java.lang.Object parseDocumentElement(org.w3c.dom.Element documentElement, Parse parse)
          This method builds the WireDefinition from the DOM tree.
 java.lang.Object parseElement(org.w3c.dom.Element element, Parse parse, java.lang.String category)
          This method parses an arbitrary element in the document based on the bindings in the given category.
static WireDefinition parseXmlString(java.lang.String xmlString)
          Convenience method to parse a wiring xml.
 
Methods inherited from class org.jbpm.xml.Parser
addEntity, buildDom, checkProblems, createDocumentBuilder, createParse, execute, getBinding, getBinding, getBindings, getDocumentBuilderFactory, getInputSource, importStream, newDocumentBuilderFactory, parseDocument, parseElement, resolveEntity, setBindings, setDocumentBuilderFactory, useParseEntityResolver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PVM_WIRE_BINDINGS_RESOURCES

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

CATEGORY_DESCRIPTOR

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

CATEGORY_OPERATION

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

CATEGORY_INTERCEPTOR

public static final java.lang.String CATEGORY_INTERCEPTOR
See Also:
Constant Field Values
Constructor Detail

WireParser

public WireParser()
Constructs a new WireParser with the default bindings.

Method Detail

getInstance

public static WireParser getInstance()
Default method to get an instance of the WireParser

Returns:
the static instance of WireParser

parseXmlString

public static WireDefinition parseXmlString(java.lang.String xmlString)
Convenience method to parse a wiring xml.

Parameters:
xmlString - the xml string to parse
Returns:
the WireDefinition created by parsing the xml given in input.
See Also:
parseXmlString(String)

parseDocumentElement

public java.lang.Object parseDocumentElement(org.w3c.dom.Element documentElement,
                                             Parse parse)
This method builds the WireDefinition from the DOM tree. This methods parses all child nodes of the documentElement that correspond to a Descriptor definition.

Overrides:
parseDocumentElement in class Parser
Parameters:
documentElement - the root element of the document
parse - Parse object that contains all information for the current parse operation.
Returns:
an instance of WireDefinition containing the resulting WireDefinition.
See Also:
Parser.parseDocumentElement(Element, Parse)

parseElement

public java.lang.Object parseElement(org.w3c.dom.Element element,
                                     Parse parse,
                                     java.lang.String category)
This method parses an arbitrary element in the document based on the bindings in the given category. This method calls the Parser.parseElement(Element, Parse, String) method to build the resulting object. If the resulting object is a subclass of AbstractDescriptor, the related fields are initialized.

Overrides:
parseElement in class Parser
Parameters:
element - the element to parse
parse - Parse object that contains all information for the current parse operation.
category - is the category in which the tagName should be resolved to an ElementHandler. If category is null, all the categories will be scanned for an appropriate binding in random order.
Returns:
the java object created from the DOM element

parseArgs

public java.util.List<ArgDescriptor> parseArgs(java.util.List<org.w3c.dom.Element> argElements,
                                               Parse parse)
Parses the list of arguments of a method. This method creates a list of ArgDescriptor from the given list of DOM elements

Parameters:
argElements - the list of argument DOM elements
parse - Parse object that contains all information for the current parse operation.
Returns:
the list of ArgDescriptor created from the DOM elements
See Also:
ArgDescriptor