org.jomc.model
Class DefaultModelManager

Package class diagram package DefaultModelManager
java.lang.Object
  extended by org.jomc.model.DefaultModelManager
All Implemented Interfaces:
ModelManager

public class DefaultModelManager
extends Object
implements ModelManager

Default ModelManager implementation.

Schema management

Resource management

Log management

Version:
$Id: DefaultModelManager.java 891 2009-11-02 03:40:00Z schulte2005 $
Author:
Christian Schulte

Nested Class Summary
static interface DefaultModelManager.Listener
          Listener interface.
 
Constructor Summary
DefaultModelManager()
          Creates a new DefaultModelManager instance.
 
Method Summary
 javax.xml.bind.JAXBContext getBootstrapContext()
          Gets a new bootstrap JAXB context instance.
 javax.xml.bind.Marshaller getBootstrapMarshaller()
          Gets a new bootstrap JAXB marshaller instance.
 Schema getBootstrapSchema()
          Gets a new bootstrap JAXP schema instance.
 javax.xml.bind.Unmarshaller getBootstrapUnmarshaller()
          Gets a new bootstrap JAXB unmarshaller instance.
 Modules getClasspathModules(ClassLoader classLoader, String location)
          Gets modules by searching a given class loader for resources.
 Schemas getClasspathSchemas(ClassLoader classLoader, String location)
          Gets schemas by searching a given class loader for resources.
 List<Transformer> getClasspathTransformers(ClassLoader classLoader, String location)
          Gets transformers by searching a given class loader for resources.
 javax.xml.bind.JAXBContext getContext(ClassLoader classLoader)
          Gets a new object management and configuration JAXB context instance.
static Level getDefaultLogLevel()
          Gets the default log level events are logged at.
static String getDefaultModuleLocation()
          Gets the default location searched for module resources.
static String getDefaultSchemaLocation()
          Gets the default location searched for schema resources.
static String getDefaultTransformerLocation()
          Gets the default location searched for transformer resources.
 EntityResolver getEntityResolver(ClassLoader classLoader)
          Gets a new object management and configuration entity resolver instance.
 List<DefaultModelManager.Listener> getListeners()
          Gets the list of registered listeners.
 Level getLogLevel()
          Gets the log level of the instance.
 javax.xml.bind.Marshaller getMarshaller(ClassLoader classLoader)
          Gets a new object management and configuration JAXB marshaller instance.
 LSResourceResolver getResourceResolver(ClassLoader classLoader)
          Gets a new object management and configuration L/S resource resolver instance.
 Schema getSchema(ClassLoader classLoader)
          Gets a new object management and configuration JAXP schema instance.
 javax.xml.bind.Unmarshaller getUnmarshaller(ClassLoader classLoader)
          Gets a new object management and configuration JAXB unmarshaller instance.
 boolean isLoggable(Level level)
          Checks if a message at a given level is provided to the listeners of the instance.
protected  void log(Level level, String message, Throwable throwable)
          Notifies registered listeners.
static void setDefaultLogLevel(Level value)
          Sets the default log level events are logged at.
static void setDefaultModuleLocation(String value)
          Sets the default location searched for module resources.
static void setDefaultSchemaLocation(String value)
          Sets the default location searched for schema resources.
static void setDefaultTransformerLocation(String value)
          Sets the default location searched for transformer resources.
 void setLogLevel(Level value)
          Sets the log level of the instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultModelManager

public DefaultModelManager()
Creates a new DefaultModelManager instance.

Method Detail

getEntityResolver

public EntityResolver getEntityResolver(ClassLoader classLoader)
Description copied from interface: ModelManager
Gets a new object management and configuration entity resolver instance.

Specified by:
getEntityResolver in interface ModelManager
Parameters:
classLoader - The class loader to use for resolving entities.
Returns:
A new object management and configuration entity resolver instance resolving entities using the given class loader.

getResourceResolver

public LSResourceResolver getResourceResolver(ClassLoader classLoader)
Description copied from interface: ModelManager
Gets a new object management and configuration L/S resource resolver instance.

Specified by:
getResourceResolver in interface ModelManager
Parameters:
classLoader - The class loader to use for resolving entities.
Returns:
A new object management and configuration L/S resource resolver instance resolving entities using the given class loader.

getSchema

public Schema getSchema(ClassLoader classLoader)
                 throws IOException,
                        SAXException,
                        javax.xml.bind.JAXBException
Description copied from interface: ModelManager
Gets a new object management and configuration JAXP schema instance.

Specified by:
getSchema in interface ModelManager
Parameters:
classLoader - The class loader to use for loading schema resources.
Returns:
A new object management and configuration JAXP schema instance loaded using the given class loader.
Throws:
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
javax.xml.bind.JAXBException - if unmarshalling schema resources or creating a context fails.

getContext

public javax.xml.bind.JAXBContext getContext(ClassLoader classLoader)
                                      throws IOException,
                                             SAXException,
                                             javax.xml.bind.JAXBException
Description copied from interface: ModelManager
Gets a new object management and configuration JAXB context instance.

Specified by:
getContext in interface ModelManager
Parameters:
classLoader - The class loader to create the context with.
Returns:
A new object management and configuration JAXB context instance created using the given class loader.
Throws:
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
javax.xml.bind.JAXBException - if unmarshalling schema resources or creating a context fails.

getMarshaller

public javax.xml.bind.Marshaller getMarshaller(ClassLoader classLoader)
                                        throws IOException,
                                               SAXException,
                                               javax.xml.bind.JAXBException
Description copied from interface: ModelManager
Gets a new object management and configuration JAXB marshaller instance.

Specified by:
getMarshaller in interface ModelManager
Parameters:
classLoader - The class loader to create the marshaller with.
Returns:
A new object management and configuration JAXB marshaller instance created using the given class loader.
Throws:
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
javax.xml.bind.JAXBException - if unmarshalling schema resources or creating a marshaller fails.

getUnmarshaller

public javax.xml.bind.Unmarshaller getUnmarshaller(ClassLoader classLoader)
                                            throws IOException,
                                                   SAXException,
                                                   javax.xml.bind.JAXBException
Description copied from interface: ModelManager
Gets a new object management and configuration JAXB unmarshaller instance.

Specified by:
getUnmarshaller in interface ModelManager
Parameters:
classLoader - The class loader to create the unmarshaller with.
Returns:
A new object management and configuration JAXB unmarshaller instance created using the given class loader.
Throws:
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
javax.xml.bind.JAXBException - if unmarshalling schema resources or creating an unmarshaller fails.

getListeners

public List<DefaultModelManager.Listener> getListeners()
Gets the list of registered listeners.

This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the object. This is why there is no set method for the listeners property.

Returns:
The list of registered listeners.
See Also:
log(java.util.logging.Level, java.lang.String, java.lang.Throwable)

getDefaultLogLevel

public static Level getDefaultLogLevel()
Gets the default log level events are logged at.

The default log level is controlled by system property org.jomc.model.DefaultModelManager.defaultLogLevel holding the log level to log events at by default. If that property is not set, the WARNING default is returned.

Returns:
The log level events are logged at by default.
See Also:
getLogLevel(), Level.parse(java.lang.String)

setDefaultLogLevel

public static void setDefaultLogLevel(Level value)
Sets the default log level events are logged at.

Parameters:
value - The new default level events are logged at or null.
See Also:
getDefaultLogLevel()

getLogLevel

public Level getLogLevel()
Gets the log level of the instance.

Returns:
The log level of the instance.
See Also:
getDefaultLogLevel(), setLogLevel(java.util.logging.Level), isLoggable(java.util.logging.Level)

setLogLevel

public void setLogLevel(Level value)
Sets the log level of the instance.

Parameters:
value - The new log level of the instance or null.
See Also:
getLogLevel(), isLoggable(java.util.logging.Level)

isLoggable

public boolean isLoggable(Level level)
Checks if a message at a given level is provided to the listeners of the instance.

Parameters:
level - The level to test.
Returns:
true if messages at level are provided to the listeners of the instance; false if messages at level are not provided to the listeners of the instance.
Throws:
NullPointerException - if level is null.
See Also:
getLogLevel(), setLogLevel(java.util.logging.Level)

log

protected void log(Level level,
                   String message,
                   Throwable throwable)
Notifies registered listeners.

Parameters:
level - The level of the event.
message - The message of the event or null.
throwable - The throwable of the event null.
Throws:
NullPointerException - if level is null.
See Also:
getListeners(), isLoggable(java.util.logging.Level)

getBootstrapContext

public javax.xml.bind.JAXBContext getBootstrapContext()
                                               throws javax.xml.bind.JAXBException
Gets a new bootstrap JAXB context instance.

Returns:
A new bootstrap JAXB context instance.
Throws:
javax.xml.bind.JAXBException - if creating a new bootstrap JAXB context instance fails.

getBootstrapMarshaller

public javax.xml.bind.Marshaller getBootstrapMarshaller()
                                                 throws javax.xml.bind.JAXBException
Gets a new bootstrap JAXB marshaller instance.

Returns:
A new bootstrap JAXB marshaller instance.
Throws:
javax.xml.bind.JAXBException - if creating a new bootstrap JAXB marshaller instance fails.

getBootstrapUnmarshaller

public javax.xml.bind.Unmarshaller getBootstrapUnmarshaller()
                                                     throws javax.xml.bind.JAXBException
Gets a new bootstrap JAXB unmarshaller instance.

Returns:
A new bootstrap JAXB unmarshaller instance.
Throws:
javax.xml.bind.JAXBException - if creating a new bootstrap JAXB unmarshaller instance fails.

getBootstrapSchema

public Schema getBootstrapSchema()
                          throws SAXException
Gets a new bootstrap JAXP schema instance.

Returns:
A new bootstrap JAXP schema instance.
Throws:
SAXException - if parsing the bootstrap schema fails.

getDefaultSchemaLocation

public static String getDefaultSchemaLocation()
Gets the default location searched for schema resources.

The default schema location is controlled by system property org.jomc.model.DefaultModelManager.defaultSchemaLocation holding the location to search for schema resources by default. If that property is not set, the META-INF/jomc-bootstrap.xml default is returned.

Returns:
The location searched for schema resources by default.
See Also:
getClasspathSchemas(java.lang.ClassLoader, java.lang.String)

setDefaultSchemaLocation

public static void setDefaultSchemaLocation(String value)
Sets the default location searched for schema resources.

Parameters:
value - The new default location to search for schema resources or null.
See Also:
getDefaultSchemaLocation()

getClasspathSchemas

public Schemas getClasspathSchemas(ClassLoader classLoader,
                                   String location)
                            throws IOException,
                                   javax.xml.bind.JAXBException,
                                   SAXException
Gets schemas by searching a given class loader for resources.

Parameters:
classLoader - The class loader to search for resources.
location - The location to search at.
Returns:
All schemas found at location by querying classLoader.
Throws:
NullPointerException - if classLoader or location is null.
IOException - if reading resources fails.
SAXException - if parsing schema resources fails.
javax.xml.bind.JAXBException - if unmarshalling schema resources fails.
See Also:
getDefaultSchemaLocation()

getDefaultModuleLocation

public static String getDefaultModuleLocation()
Gets the default location searched for module resources.

The default module location is controlled by system property org.jomc.model.DefaultModelManager.defaultModuleLocation holding the location to search for module resources by default. If that property is not set, the META-INF/jomc.xml default is returned.

Returns:
The location searched for module resources by default.
See Also:
getClasspathModules(java.lang.ClassLoader, java.lang.String)

setDefaultModuleLocation

public static void setDefaultModuleLocation(String value)
Sets the default location searched for module resources.

Parameters:
value - The new default location to search for module resources or null.
See Also:
getDefaultModuleLocation()

getClasspathModules

public Modules getClasspathModules(ClassLoader classLoader,
                                   String location)
                            throws IOException,
                                   SAXException,
                                   javax.xml.bind.JAXBException
Gets modules by searching a given class loader for resources.

Note:
This method does not validate the modules.

Parameters:
classLoader - The class loader to search for resources.
location - The location to search at.
Returns:
All modules found at location by querying classLoader.
Throws:
NullPointerException - if classLoader or location is null.
IOException - if reading resources fails.
SAXException - if parsing schema resources fails.
javax.xml.bind.JAXBException - if unmarshalling schema resources fails.
See Also:
getDefaultModuleLocation(), ModelObjectValidator

getDefaultTransformerLocation

public static String getDefaultTransformerLocation()
Gets the default location searched for transformer resources.

The default transformer location is controlled by system property org.jomc.model.DefaultModelManager.defaultTransformerLocation holding the location to search for transformer resources by default. If that property is not set, the META-INF/jomc.xslt default is returned.

Returns:
The location searched for transformer resources by default.
See Also:
getClasspathTransformers(java.lang.ClassLoader, java.lang.String)

setDefaultTransformerLocation

public static void setDefaultTransformerLocation(String value)
Sets the default location searched for transformer resources.

Parameters:
value - The new default location to search for transformer resources or null.
See Also:
getDefaultTransformerLocation()

getClasspathTransformers

public List<Transformer> getClasspathTransformers(ClassLoader classLoader,
                                                  String location)
                                           throws IOException,
                                                  TransformerConfigurationException
Gets transformers by searching a given class loader for resources.

Parameters:
classLoader - The class loader to search for resources.
location - The location to search at.
Returns:
All transformers found at location by querying classLoader.
Throws:
NullPointerException - if classLoader or location is null.
IOException - if reading resources fails.
TransformerConfigurationException - if getting the transformers fails.
See Also:
getDefaultTransformerLocation()


Copyright © 2005-2009 The JOMC Project. All Rights Reserved.