de.ispsoft.jaxme
Class JMManagerFactoryImpl

java.lang.Object
  extended byde.ispsoft.jaxme.jaxb.JAXBContext
      extended byde.ispsoft.jaxme.JMManagerFactoryImpl
All Implemented Interfaces:
JMManagerFactory
Direct Known Subclasses:
JMManagerFactoryLIImpl

public class JMManagerFactoryImpl
extends JAXBContext
implements JMManagerFactory

A default implementation for a JMManagerFactory. This implementation is immediately instantiating all the managers listed in configuration file. The obvious advantage is that the accessor methods need not be synchronized at the cost of a slower startup. If you don't like this, you might prefer to use the JMManagerFactoryLIImpl which implements lazy instantiation of managers.

Author:
Jochen Wiedmann

Field Summary
static java.lang.String CONFIGURATION_NAME
          The local name of the element with the list of configurations.
protected  java.util.Map configurations
           
protected  org.w3c.dom.Element defaults
           
static java.lang.String DEFAULTS_NAME
          The local name of the defaults element.
static java.lang.String LOCAL_NAME
          The local name of the JMManagerFactory configuration.
static java.lang.String LOCALNAME_ATTRIBUTE
          The local name of the attribute localName.
static java.lang.String MANAGER_CLASS_NAME
          The local name of the ManagerClass element.
protected  java.util.Map managers
           
static java.lang.String NAMESPACE_URI
          The namespace for the JMManagerFactory configuration.
static java.lang.String NAMESPACE_URI_ATTRIBUTE
          The local name of the attribute namespaceURI.
protected  java.lang.String schemaPath
           
 
Fields inherited from class de.ispsoft.jaxme.jaxb.JAXBContext
JAXB_CONTEXT_FACTORY
 
Constructor Summary
JMManagerFactoryImpl()
          Creates a new instance of JMManagerFactoryImpl.
 
Method Summary
 Marshaller createMarshaller()
          Create a Marshaller object that can be used to convert a java content tree into XML data.
 Unmarshaller createUnmarshaller()
          Create an Unmarshaller object that can be used to convert XML data into a java content tree.
 Validator createValidator()
          Create a Validator object that can be used to validate a java content tree against its source schema.
 org.w3c.dom.Element getConfiguration(java.lang.String pNamespaceURI, java.lang.String pLocalName)
          Returns a Configuration element with the JMManager's configuration for a given namespace and local name or null, if there is no such element.
 org.w3c.dom.Element getDefaults()
          Returns a Defaults element with the JMManagerFactory's default settings.
protected  boolean getLazyInstantiation()
          Returns whether the factory has lazy instantiation.
 JMManager getManager(java.lang.String pNamespaceURI, java.lang.String pLocalName)
          Deprecated. Use getManager(UriName) instead.
 JMManager getManager(UriName pUriName)
          Returns a JMManager responsible for handling the given document type.
static java.lang.String getNodeText(org.w3c.dom.Node pNode)
          Returns the text contained in a given node.
 java.lang.String getSchemaPath()
          Returns the path previously set by JaxbContextFactoryImpl.createContext(schemaPath).
 void init(org.xml.sax.InputSource pSource)
          Initializes the JMManagerFactoryImpl by parsing a configuration from the given InputSource.
protected  void parseConfiguration(org.w3c.dom.Element pConfigFile)
          Parses a configuration.
protected  void setLazyInstantiation(boolean pLazyInstantiation)
          Sets whether the factory has lazy instantiation.
 void setSchemaPath(java.lang.String pPath)
          Called by JaxbContextFactoryImpl.createContext(schemaPath).
 void setURI(java.lang.String pURI)
          Initializes the factory to read resources from the given URI.
 
Methods inherited from class de.ispsoft.jaxme.jaxb.JAXBContext
newInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configurations

protected java.util.Map configurations

managers

protected java.util.Map managers

defaults

protected org.w3c.dom.Element defaults

schemaPath

protected java.lang.String schemaPath

NAMESPACE_URI

public static final java.lang.String NAMESPACE_URI

The namespace for the JMManagerFactory configuration.

See Also:
Constant Field Values

LOCAL_NAME

public static final java.lang.String LOCAL_NAME

The local name of the JMManagerFactory configuration.

See Also:
Constant Field Values

DEFAULTS_NAME

public static final java.lang.String DEFAULTS_NAME

The local name of the defaults element.

See Also:
Constant Field Values

CONFIGURATION_NAME

public static final java.lang.String CONFIGURATION_NAME

The local name of the element with the list of configurations.

See Also:
Constant Field Values

LOCALNAME_ATTRIBUTE

public static final java.lang.String LOCALNAME_ATTRIBUTE

The local name of the attribute localName.

See Also:
Constant Field Values

NAMESPACE_URI_ATTRIBUTE

public static final java.lang.String NAMESPACE_URI_ATTRIBUTE

The local name of the attribute namespaceURI.

See Also:
Constant Field Values

MANAGER_CLASS_NAME

public static final java.lang.String MANAGER_CLASS_NAME

The local name of the ManagerClass element.

See Also:
Constant Field Values
Constructor Detail

JMManagerFactoryImpl

public JMManagerFactoryImpl()

Creates a new instance of JMManagerFactoryImpl. The instance cannot be used until one of the init() methods or setURI() is called.

Method Detail

parseConfiguration

protected void parseConfiguration(org.w3c.dom.Element pConfigFile)
                           throws org.xml.sax.SAXException

Parses a configuration. Returns an element of defaults.

Throws:
org.xml.sax.SAXException

setLazyInstantiation

protected void setLazyInstantiation(boolean pLazyInstantiation)

Sets whether the factory has lazy instantiation. Defaults to false.


getLazyInstantiation

protected boolean getLazyInstantiation()

Returns whether the factory has lazy instantiation. Defaults to false.


setURI

public void setURI(java.lang.String pURI)
            throws org.xml.sax.SAXException

Initializes the factory to read resources from the given URI. Possible values are:

http://...
https://...
ftp://...
file:...
The value is interpreted using new java.net.URL(value) and an XML file is read from the given URL.
resource:... The String resource: is removed and the remainder is taken as a resource name. The resource is located through the context class loader and an XML file is read from the given URL.
Any other value The value is taken as a file name and the given XML file is loaded.

Specified by:
setURI in interface JMManagerFactory
Throws:
org.xml.sax.SAXException

init

public void init(org.xml.sax.InputSource pSource)
          throws org.xml.sax.SAXException

Initializes the JMManagerFactoryImpl by parsing a configuration from the given InputSource.

Throws:
org.xml.sax.SAXException

getManager

public JMManager getManager(java.lang.String pNamespaceURI,
                            java.lang.String pLocalName)
                     throws org.xml.sax.SAXException
Deprecated. Use getManager(UriName) instead.

Returns a JMManager responsible for handling the given document type.

Specified by:
getManager in interface JMManagerFactory
Throws:
org.xml.sax.SAXException

getManager

public JMManager getManager(UriName pUriName)
                     throws org.xml.sax.SAXException

Returns a JMManager responsible for handling the given document type.

Throws:
org.xml.sax.SAXException

getConfiguration

public org.w3c.dom.Element getConfiguration(java.lang.String pNamespaceURI,
                                            java.lang.String pLocalName)

Returns a Configuration element with the JMManager's configuration for a given namespace and local name or null, if there is no such element.

Specified by:
getConfiguration in interface JMManagerFactory

getDefaults

public org.w3c.dom.Element getDefaults()

Returns a Defaults element with the JMManagerFactory's default settings.

Specified by:
getDefaults in interface JMManagerFactory

getNodeText

public static java.lang.String getNodeText(org.w3c.dom.Node pNode)

Returns the text contained in a given node.


createMarshaller

public Marshaller createMarshaller()
Description copied from class: JAXBContext
Create a Marshaller object that can be used to convert a java content tree into XML data.

Specified by:
createMarshaller in class JAXBContext
Returns:
a Marshaller object

createUnmarshaller

public Unmarshaller createUnmarshaller()
Description copied from class: JAXBContext
Create an Unmarshaller object that can be used to convert XML data into a java content tree.

Specified by:
createUnmarshaller in class JAXBContext
Returns:
an Unmarshaller object

createValidator

public Validator createValidator()
Description copied from class: JAXBContext
Create a Validator object that can be used to validate a java content tree against its source schema.

Specified by:
createValidator in class JAXBContext
Returns:
a Validator object

setSchemaPath

public void setSchemaPath(java.lang.String pPath)

Called by JaxbContextFactoryImpl.createContext(schemaPath).


getSchemaPath

public java.lang.String getSchemaPath()

Returns the path previously set by JaxbContextFactoryImpl.createContext(schemaPath).