Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.hivemind.parse
Class DescriptorParser  view DescriptorParser download DescriptorParser.java

java.lang.Object
  extended byorg.xml.sax.helpers.DefaultHandler
      extended byorg.apache.hivemind.parse.AbstractParser
          extended byorg.apache.hivemind.parse.DescriptorParser
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public final class DescriptorParser
extends AbstractParser

Used to parse HiveMind module deployment descriptors.

TODO: The parser ignores element content except inside <contribution> and <invoke-factory> ... it probably should forbid non-whitespace content.


Nested Class Summary
 
Nested classes inherited from class org.apache.hivemind.parse.AbstractParser
 
Field Summary
private  java.util.Map _attributes
          Temporary storage of the current org.xml.sax.Attributes.
private  java.util.Map _compiledPatterns
           
private  org.apache.oro.text.regex.Perl5Compiler _compiler
           
private  java.util.Map _elementParseInfo
          Built from DescriptorParser.properties.
private  org.apache.hivemind.ErrorHandler _errorHandler
           
private  org.apache.oro.text.regex.Perl5Matcher _matcher
           
private  ModuleDescriptor _moduleDescriptor
           
private  org.apache.hivemind.ClassResolver _resolver
           
private  java.util.Map _ruleMap
          Map of Rule keyed on class name, used with <custom> rules.
private static java.lang.String DEFAULT_SERVICE_MODEL
           
static java.lang.String ID_PATTERN
          Format for configuration point ids, service point ids and schema ids.
private static org.apache.commons.logging.Log LOG
           
static java.lang.String MODULE_ID_PATTERN
          Module ids are a sequence of simple ids seperated by periods.
private  java.util.Map OCCURS_MAP
           
private static java.lang.String SIMPLE_ID
           
private static int STATE_COLLECT_SERVICE_PARAMETERS
          Used with <invoke-factory> and <interceptor> to collect parameters that will be passed to the implementation or interceptor factory service.
private static int STATE_CONFIGURATION_POINT
           
private static int STATE_CONTRIBUTION
           
private static int STATE_CONVERSION
          Used with the <conversion> element (an alternative to using <rules>.
private static int STATE_CREATE_INSTANCE
           
private static int STATE_ELEMENT
           
private static int STATE_IMPLEMENTATION
           
private static int STATE_LWDOM
          Represents building Element hierarchy as a light-wieght DOM.
private static int STATE_MODULE
           
private static int STATE_NO_CONTENT
          Special state for elements that are not allowed to contain any other elements.
private static int STATE_RULES
           
private static int STATE_SCHEMA
          Used for both <schema&;gt; within a <extension-point>, and for <parameters-schema> within a <service>.
private static int STATE_SERVICE_POINT
           
private static int STATE_START
          States used while parsing the document.
static java.lang.String VERSION_PATTERN
           
private  java.util.Map VISIBILITY_MAP
           
 
Fields inherited from class org.apache.hivemind.parse.AbstractParser
 
Constructor Summary
DescriptorParser(org.apache.hivemind.ErrorHandler errorHandler)
           
 
Method Summary
 void begin(java.lang.String elementName, java.util.Map attributes)
          Invoked when an element's start tag is recognized.
private  void beginCollectServiceParameters(java.lang.String elementName)
          Very similar to beginContribution(String) 55 , in that it creates an org.apache.hivemind.impl.ElementImpl, adds it as a parameter to the AbstractServiceInvocationDescriptor, then enters STATE_LWDOM to fill in its attributes and content.
private  void beginConfigurationPoint(java.lang.String elementName)
          Invoked when a new element starts within STATE_CONFIGURATION_POINT.
private  void beginContribution(java.lang.String elementName)
           
private  void beginConversion(java.lang.String elementName)
           
private  void beginElement(java.lang.String elementName)
           
private  void beginImplementation(java.lang.String elementName)
           
private  void beginLWDom(java.lang.String elementName)
           
private  void beginModule(java.lang.String elementName)
          Invoked when a new element occurs while in STATE_MODULE.
private  void beginRules(java.lang.String elementName)
           
private  void beginSchema(java.lang.String elementName)
           
private  void beginServicePoint(java.lang.String elementName)
           
private  void beginStart(java.lang.String elementName)
          begin outermost element, expect "module".
private  org.apache.hivemind.impl.ElementImpl buildLWDomElement(java.lang.String elementName)
           
private  void checkAttributes()
           
private  void checkAttributes(java.lang.String elementName)
          Checks that only known attributes are specified.
 void end(java.lang.String elementName)
          Invoked when an element's close tag is recognized.
private  void endConversion()
           
private  void endLWDom()
           
private  void endSchema()
           
private  void enterAttribute(java.lang.String elementName)
           
private  void enterConfigurationPoint(java.lang.String elementName)
           
private  void enterContribution(java.lang.String elementName)
           
private  void enterConversion(java.lang.String elementName)
           
private  void enterCreateInstance(java.lang.String elementName)
           
private  void enterCreateObject(java.lang.String elementName)
           
private  void enterCustom(java.lang.String elementName)
           
private  void enterDependency(java.lang.String elementName)
           
private  org.apache.hivemind.schema.ElementModel enterElement(java.lang.String elementName)
          Pushes STATE_ELEMENT onto the stack and creates and returns the org.apache.hivemind.schema.impl.ElementModelImpl it creates.
private  void enterEmbeddedConfigurationPointSchema(java.lang.String elementName)
           
private  void enterImplementation(java.lang.String elementName)
           
private  void enterInterceptor(java.lang.String elementName)
           
private  void enterInvokeFactory(java.lang.String elementName)
           
private  void enterInvokeParent(java.lang.String elementName)
           
private  void enterParametersSchema(java.lang.String elementName)
           
private  void enterPushAttribute(java.lang.String elementName)
           
private  void enterPushContent(java.lang.String elementName)
           
private  void enterReadAttribute(java.lang.String elementName)
           
private  void enterReadContent(java.lang.String elementName)
           
private  void enterRules(java.lang.String elementName)
           
private  void enterSchema(java.lang.String elementName)
           
private  void enterServicePoint(java.lang.String elementName)
           
private  void enterSetModule(java.lang.String elementName)
           
private  void enterSetParent(java.lang.String elementName)
           
private  void enterSetProperty(java.lang.String elementName)
           
private  void enterSubModule(java.lang.String elementName)
           
private  java.lang.String getAttribute(java.lang.String name)
           
private  java.lang.String getAttribute(java.lang.String name, java.lang.String defaultValue)
           
private  boolean getBooleanAttribute(java.lang.String name, boolean defaultValue)
           
private  org.apache.hivemind.schema.Rule getCustomRule(java.lang.String ruleClassName)
           
private  java.lang.Object getEnumAttribute(java.lang.String name, java.util.Map translations)
          Gets the value for the attribute and uses the Map to translate it to an object value.
private  int getIntAttribute(java.lang.String name)
           
 ModuleDescriptor getModuleDescriptor()
           
private  java.lang.String getValidatedAttribute(java.lang.String name, java.lang.String pattern, java.lang.String formatKey)
           
 void initialize(org.apache.hivemind.Resource resource, org.apache.hivemind.ClassResolver resolver)
           
private  void initializeFromProperties(java.util.Properties p)
           
private  void initializeFromPropertiesFile()
          Invoked from the constructor to read the properties file that defines certain aspects of the operation of the parser.
private  void initializeFromProperty(java.lang.String key, java.lang.String value)
           
private  void initializeRequired(java.lang.String key, java.lang.String value)
           
private  org.apache.hivemind.schema.Rule instantiateRule(java.lang.String ruleClassName)
           
protected  void push(java.lang.String elementName, java.lang.Object object, int state)
          Enters a new state, pushing an object onto the stack.
 void reset()
           
private  boolean validateFormat(java.lang.String input, java.lang.String pattern)
           
 
Methods inherited from class org.apache.hivemind.parse.AbstractParser
characters, endElement, error, fatalError, getElementPath, getLocation, getResource, getState, initializeParser, peekContent, peekElementName, peekObject, pop, push, resetParser, setDocumentLocator, setState, startElement, unexpectedElement, updateObject, warning
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SERVICE_MODEL

private static final java.lang.String DEFAULT_SERVICE_MODEL
See Also:
Constant Field Values

LOG

private static final org.apache.commons.logging.Log LOG

STATE_START

private static final int STATE_START
States used while parsing the document. Most states correspond to a particular XML element in the document. STATE_START is the initial state, before the <module> element is reached.

See Also:
Constant Field Values

STATE_MODULE

private static final int STATE_MODULE
See Also:
Constant Field Values

STATE_CONFIGURATION_POINT

private static final int STATE_CONFIGURATION_POINT
See Also:
Constant Field Values

STATE_CONTRIBUTION

private static final int STATE_CONTRIBUTION
See Also:
Constant Field Values

STATE_SERVICE_POINT

private static final int STATE_SERVICE_POINT
See Also:
Constant Field Values

STATE_CREATE_INSTANCE

private static final int STATE_CREATE_INSTANCE
See Also:
Constant Field Values

STATE_IMPLEMENTATION

private static final int STATE_IMPLEMENTATION
See Also:
Constant Field Values

STATE_SCHEMA

private static final int STATE_SCHEMA
Used for both <schema&;gt; within a <extension-point>, and for <parameters-schema> within a <service>.

See Also:
Constant Field Values

STATE_ELEMENT

private static final int STATE_ELEMENT
See Also:
Constant Field Values

STATE_RULES

private static final int STATE_RULES
See Also:
Constant Field Values

STATE_COLLECT_SERVICE_PARAMETERS

private static final int STATE_COLLECT_SERVICE_PARAMETERS
Used with <invoke-factory> and <interceptor> to collect parameters that will be passed to the implementation or interceptor factory service.

See Also:
Constant Field Values

STATE_CONVERSION

private static final int STATE_CONVERSION
Used with the <conversion> element (an alternative to using <rules>. Finds <map> elements.

See Also:
Constant Field Values

STATE_LWDOM

private static final int STATE_LWDOM
Represents building Element hierarchy as a light-wieght DOM.

See Also:
Constant Field Values

STATE_NO_CONTENT

private static final int STATE_NO_CONTENT
Special state for elements that are not allowed to contain any other elements.

See Also:
Constant Field Values

SIMPLE_ID

private static final java.lang.String SIMPLE_ID
See Also:
Constant Field Values

ID_PATTERN

public static final java.lang.String ID_PATTERN
Format for configuration point ids, service point ids and schema ids. Consists of an optional leading underscore, followed by alphanumerics and underscores. Normal naming convention is to use a single CamelCase word, like a Java class name.

See Also:
Constant Field Values

MODULE_ID_PATTERN

public static final java.lang.String MODULE_ID_PATTERN
Module ids are a sequence of simple ids seperated by periods. In practice, they look like Java package names.

See Also:
Constant Field Values

VERSION_PATTERN

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

_attributes

private java.util.Map _attributes
Temporary storage of the current org.xml.sax.Attributes.


_elementParseInfo

private java.util.Map _elementParseInfo
Built from DescriptorParser.properties. Key is element name, value is an instance of ElementParseInfo.


_moduleDescriptor

private ModuleDescriptor _moduleDescriptor

_errorHandler

private org.apache.hivemind.ErrorHandler _errorHandler

_resolver

private org.apache.hivemind.ClassResolver _resolver

_compiler

private org.apache.oro.text.regex.Perl5Compiler _compiler

_matcher

private org.apache.oro.text.regex.Perl5Matcher _matcher

_compiledPatterns

private java.util.Map _compiledPatterns

_ruleMap

private final java.util.Map _ruleMap
Map of Rule keyed on class name, used with <custom> rules.


OCCURS_MAP

private final java.util.Map OCCURS_MAP

VISIBILITY_MAP

private final java.util.Map VISIBILITY_MAP
Constructor Detail

DescriptorParser

public DescriptorParser(org.apache.hivemind.ErrorHandler errorHandler)
Method Detail

begin

public void begin(java.lang.String elementName,
                  java.util.Map attributes)
Description copied from class: AbstractParser
Invoked when an element's start tag is recognized. The element and attributes are provided to the subclass for further processing.

Specified by:
begin in class AbstractParser

beginCollectServiceParameters

private void beginCollectServiceParameters(java.lang.String elementName)
Very similar to beginContribution(String) 55 , in that it creates an org.apache.hivemind.impl.ElementImpl, adds it as a parameter to the AbstractServiceInvocationDescriptor, then enters STATE_LWDOM to fill in its attributes and content.


beginConfigurationPoint

private void beginConfigurationPoint(java.lang.String elementName)
Invoked when a new element starts within STATE_CONFIGURATION_POINT.


beginContribution

private void beginContribution(java.lang.String elementName)

beginConversion

private void beginConversion(java.lang.String elementName)

beginElement

private void beginElement(java.lang.String elementName)

beginImplementation

private void beginImplementation(java.lang.String elementName)

beginLWDom

private void beginLWDom(java.lang.String elementName)

beginModule

private void beginModule(java.lang.String elementName)
Invoked when a new element occurs while in STATE_MODULE.


beginRules

private void beginRules(java.lang.String elementName)

beginSchema

private void beginSchema(java.lang.String elementName)

beginServicePoint

private void beginServicePoint(java.lang.String elementName)

beginStart

private void beginStart(java.lang.String elementName)
begin outermost element, expect "module".


push

protected void push(java.lang.String elementName,
                    java.lang.Object object,
                    int state)
Description copied from class: AbstractParser
Enters a new state, pushing an object onto the stack. Invokes AbstractParser.push(String, Object, int, boolean) 55 , and ignores character data within the element.

Overrides:
push in class AbstractParser

buildLWDomElement

private org.apache.hivemind.impl.ElementImpl buildLWDomElement(java.lang.String elementName)

checkAttributes

private void checkAttributes()

checkAttributes

private void checkAttributes(java.lang.String elementName)
Checks that only known attributes are specified. Checks that all required attribute are specified.


end

public void end(java.lang.String elementName)
Description copied from class: AbstractParser
Invoked when an element's close tag is recognized. The element is provided. The content of the element (the unparsed whitespace within the element's tags) is available via AbstractParser.peekContent() 55 .

Specified by:
end in class AbstractParser

endSchema

private void endSchema()

endConversion

private void endConversion()

endLWDom

private void endLWDom()

enterAttribute

private void enterAttribute(java.lang.String elementName)

enterConfigurationPoint

private void enterConfigurationPoint(java.lang.String elementName)

enterContribution

private void enterContribution(java.lang.String elementName)

enterConversion

private void enterConversion(java.lang.String elementName)

enterCreateInstance

private void enterCreateInstance(java.lang.String elementName)

enterCreateObject

private void enterCreateObject(java.lang.String elementName)

enterCustom

private void enterCustom(java.lang.String elementName)

enterElement

private org.apache.hivemind.schema.ElementModel enterElement(java.lang.String elementName)
Pushes STATE_ELEMENT onto the stack and creates and returns the org.apache.hivemind.schema.impl.ElementModelImpl it creates.


enterEmbeddedConfigurationPointSchema

private void enterEmbeddedConfigurationPointSchema(java.lang.String elementName)

enterParametersSchema

private void enterParametersSchema(java.lang.String elementName)

enterImplementation

private void enterImplementation(java.lang.String elementName)

enterInterceptor

private void enterInterceptor(java.lang.String elementName)

enterInvokeFactory

private void enterInvokeFactory(java.lang.String elementName)

enterInvokeParent

private void enterInvokeParent(java.lang.String elementName)

enterReadAttribute

private void enterReadAttribute(java.lang.String elementName)

enterReadContent

private void enterReadContent(java.lang.String elementName)

enterRules

private void enterRules(java.lang.String elementName)

enterSchema

private void enterSchema(java.lang.String elementName)

enterServicePoint

private void enterServicePoint(java.lang.String elementName)

enterSetModule

private void enterSetModule(java.lang.String elementName)

enterSetParent

private void enterSetParent(java.lang.String elementName)

enterSetProperty

private void enterSetProperty(java.lang.String elementName)

enterPushAttribute

private void enterPushAttribute(java.lang.String elementName)

enterPushContent

private void enterPushContent(java.lang.String elementName)

enterSubModule

private void enterSubModule(java.lang.String elementName)

enterDependency

private void enterDependency(java.lang.String elementName)

getAttribute

private java.lang.String getAttribute(java.lang.String name)

getAttribute

private java.lang.String getAttribute(java.lang.String name,
                                      java.lang.String defaultValue)

getValidatedAttribute

private java.lang.String getValidatedAttribute(java.lang.String name,
                                               java.lang.String pattern,
                                               java.lang.String formatKey)

validateFormat

private boolean validateFormat(java.lang.String input,
                               java.lang.String pattern)

getBooleanAttribute

private boolean getBooleanAttribute(java.lang.String name,
                                    boolean defaultValue)

getCustomRule

private org.apache.hivemind.schema.Rule getCustomRule(java.lang.String ruleClassName)

getEnumAttribute

private java.lang.Object getEnumAttribute(java.lang.String name,
                                          java.util.Map translations)
Gets the value for the attribute and uses the Map to translate it to an object value. Returns the object value if succesfully translated. Returns null if unsuccesful. If a value is provided that isn't a key of the map, and error is logged and null is returned.


getIntAttribute

private int getIntAttribute(java.lang.String name)

initializeFromProperties

private void initializeFromProperties(java.util.Properties p)

initializeFromPropertiesFile

private void initializeFromPropertiesFile()
Invoked from the constructor to read the properties file that defines certain aspects of the operation of the parser.


initializeFromProperty

private void initializeFromProperty(java.lang.String key,
                                    java.lang.String value)

initializeRequired

private void initializeRequired(java.lang.String key,
                                java.lang.String value)

instantiateRule

private org.apache.hivemind.schema.Rule instantiateRule(java.lang.String ruleClassName)

initialize

public void initialize(org.apache.hivemind.Resource resource,
                       org.apache.hivemind.ClassResolver resolver)
Since:
1.1

getModuleDescriptor

public ModuleDescriptor getModuleDescriptor()
Since:
1.1

reset

public void reset()
Since:
1.1