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.

Classpath support

Logging

Model bootstrapping

Version:
$Id: DefaultModelManager.java 597 2009-09-25 23:33:29Z schulte2005 $
Author:
Christian Schulte

Nested Class Summary
static interface DefaultModelManager.Listener
          Listener interface.
 
Field Summary
private static String BOOTSTRAP_CONTEXT
          JAXB context of the bootstrap schema.
private static String BOOTSTRAP_SCHEMA_LOCATION
          Classpath location of the bootstrap schema.
private  ObjectFactory bootstrapObjectFactory
          Bootstrap object factory of the instance.
private  Schema bootstrapSchema
          The bootstrap schema.
private  ClassLoader classLoader
          Class loader of the instance.
private  JAXBContext context
          The context of the instance.
private static String DEFAULT_BOOTSTRAP_DOCUMENT_LOCATION
          Classpath location searched for bootstrap documents by default.
private static String DEFAULT_CLASSPATH_MODULE_NAME
          Constant for the name of the classpath module.
private static String DEFAULT_DOCUMENT_LOCATION
          Classpath location searched for documents by default.
private static String DEFAULT_STYLESHEET_LOCATION
          Classpath location searched for style sheets by default.
private  EntityResolver entityResolver
          The entity resolver of the instance.
private  List<DefaultModelManager.Listener> listeners
          The listeners of the instance.
private static Class[] NO_CLASSES
          Empty Class array.
private static Object[] NO_OBJECTS
          Empty Object array.
private  ObjectFactory objectFactory
          Object factory of the instance.
private  Map objects
          Maps objects to Instances.
private  LSResourceResolver resourceResolver
          The L/S resolver of the instance.
private  Schema schema
          The schema of the instance.
private static String[] SCHEMA_EXTENSIONS
          Supported schema name extensions.
private  Set<URL> schemaResources
          URLs of all available classpath schema resources.
private  Schemas schemas
          Schemas of the instance.
 
Constructor Summary
DefaultModelManager()
          Creates a new DefaultModelManager instance.
 
Method Summary
private  void assertImplementationMessagesUniqueness(Implementation implementation, List<ModelException.Detail> details)
           
private  void assertImplementationPropertiesUniqueness(Implementation implementation, List<ModelException.Detail> details)
           
private  boolean checkFactoryMethod(Class clazz, Class type, String methodName)
           
private  void collectFinalSuperDependencies(Modules modules, Implementation implementation, String dependencyName, Implementations implementations, Implementations seen, boolean includeImplementation)
           
private  void collectFinalSuperImplementations(Modules modules, Implementation implementation, Implementations implementations, Implementations seen, boolean includeImplementation)
           
private  void collectFinalSuperMessages(Modules modules, Implementation implementation, String messageName, Implementations implementations, Implementations seen, boolean includeImplementation)
           
private  void collectFinalSuperProperties(Modules modules, Implementation implementation, String propertyName, Implementations implementations, Implementations seen, boolean includeImplementation)
           
private  void collectFinalSuperSpecifications(Modules modules, Implementation implementation, String specificationIdentifier, Implementations implementations, Implementations seen, boolean includeImplementation)
           
private  Implementation collectImplementation(Modules modules, Class clazz)
           
private  Implementation findInheritanceCycle(Modules modules, Implementation current, Implementation report, Implementations implementations)
           
 JAXBContext getBootstrapContext()
          Gets a new bootstrap context instance.
 String getBootstrapDocumentLocation()
          Gets the location to search for bootstrap documents.
 Marshaller getBootstrapMarshaller(boolean validating, boolean formattedOutput)
          Gets a new bootstrap Marshaller.
 ObjectFactory getBootstrapObjectFactory()
          Gets the bootstrap object factory of the instance.
 Schema getBootstrapSchema()
          Gets the bootstrap schema.
 Unmarshaller getBootstrapUnmarshaller(boolean validating)
          Gets a new bootstrap Unmarshaller.
 ClassLoader getClassLoader()
          Gets the class loader of the instance.
 Module getClasspathModule(Modules modules)
          Gets a module holding model objects resolved by inspecting the class loader of the instance.
 String getClasspathModuleName()
          Gets the classpath module name.
 Modules getClasspathModules(String location)
          Gets modules by searching the class loader of the instance for resources.
 List<Transformer> getClasspathTransformers(String location)
          Gets transformers by searching the class loader of the instance for resources.
 JAXBContext getContext()
          Gets the object management and configuration JAXBContext.
 String getDefaultDocumentLocation()
          Gets the default location to search for documents.
 String getDefaultStylesheetLocation()
          Gets the default location to search for style sheets.
 EntityResolver getEntityResolver()
          Gets the object management and configuration entity resolver.
private  Method getFactoryMethod(Class clazz, String methodName)
           
private  Implementation getImplementation(Modules modules, Object object)
          Gets the implementation of an object.
 Instance getInstance(Modules modules, Implementation implementation, ClassLoader cl)
          Gets an instance of an implementation.
 Instance getInstance(Modules modules, Implementation implementation, Dependency dependency, ClassLoader cl)
          Gets an instance of an implementation for a dependency.
 Instance getInstance(Modules modules, Object object)
          Gets the instance of an object.
 List<DefaultModelManager.Listener> getListeners()
          Gets the list of registered listeners.
 LSResourceResolver getLSResourceResolver()
          Gets the object management and configuration L/S resolver.
 Marshaller getMarshaller(boolean validating, boolean formattedOutput)
          Gets an object management and configuration Marshaller.
private  String getMessage(String key, Object args)
           
 Object getObject(Modules modules, Specification specification, Instance instance)
          Gets the object of an instance.
 ObjectFactory getObjectFactory()
          Gets the object management and configuration ObjectFactory.
 Schema getSchema()
          Gets the object management and configuration schema.
private  Set<URL> getSchemaResources()
          Searches all available META-INF/MANIFEST.MF resources and gets a set containing URLs of entries whose name end with a known schema extension.
 Schemas getSchemas()
          Gets the schemas backing the instance.
 Unmarshaller getUnmarshaller(boolean validating)
          Gets an object management and configuration Unmarshaller.
protected  void log(Level level, String message, Throwable throwable)
          Notifies registered listeners.
private  ModelException.Detail newAbstractLocationConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, String location)
           
private  ModelException.Detail newDependencyInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Dependency dependency, Implementation finalSuperDependency)
           
private  ModelException.Detail newDependencyMultipleInheritanceContraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Dependency dependency)
           
private  ModelException.Detail newDependencyOverrideConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Dependency dependency)
           
private  ModelException.Detail newDependencyPropertiesOverrideConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Dependency dependency, Specification specification, Property property)
           
private  ModelException.Detail newDependencyPropertyReferenceDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Dependency dependency, PropertyReference reference)
           
private  ModelException.Detail newFinalModuleMessageConstraintDetail(JAXBElement<? extends ModelObject> element, Module module, Message message)
           
private  ModelException.Detail newFinalModulePropertyConstraintDetail(JAXBElement<? extends ModelObject> element, Module module, Property property)
           
private  ModelException.Detail newImplementationImplementationDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Implementation declaration)
           
private  ModelException.Detail newImplementationInheritanceCompatibilityConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Implementation superImplementation, String expectedVersion)
           
private  ModelException.Detail newImplementationInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Implementation finalSuperImplementation)
           
private  ModelException.Detail newImplementationInheritanceCycleConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Implementation cycle)
           
private  ModelException.Detail newImplementationNameConstraintDetail(JAXBElement<? extends ModelObject> element, Specification specification, Implementation implementation)
           
private  ModelException.Detail newImplementationSpecificationDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Specification specification)
           
private  ModelException.Detail newImplementationVersioningConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation declaring, Implementation implementation)
           
private  ModelException.Detail newIncompatibleDependencyDetail(JAXBElement<? extends ModelObject> element, String implementation, String implementationModule, String specification, String specificationModule, String requiredVersion, String availableVersion)
           
private  ModelException.Detail newIncompatibleImplementationDetail(JAXBElement<? extends ModelObject> element, String implementation, String implementationModule, String specification, String specificationModule, String implementedVersion, String specifiedVersion)
           
private  ModelException.Detail newMandatoryDependencyConstraintDetail(JAXBElement<? extends ModelObject> element, String implementation, String dependencyName)
           
private  ModelException.Detail newMessageInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Message message, Implementation finalSuperMessage)
           
private  ModelException.Detail newMessageInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, MessageReference reference, Implementation finalSuperMessage)
           
private  ModelException.Detail newMessageMultipleInheritanceContraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Message message)
           
private  ModelException.Detail newMessageOverrideConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Message message)
           
private  ModelException.Detail newMessageOverrideConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, MessageReference reference)
           
private  ModelException.Detail newModuleImplementationReferenceDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element, Module module, ImplementationReference reference)
           
private  ModelException.Detail newModuleMessageReferenceDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element, Module module, MessageReference reference)
           
private  ModelException.Detail newModulePropertyReferenceDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element, Module module, PropertyReference reference)
           
private  ModelException.Detail newModuleSpecificationReferenceDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element, Module module, SpecificationReference reference)
           
private  ModelException.Detail newMultiplicityConstraintDetail(JAXBElement<? extends ModelObject> element, Specification specification, Implementation implementation)
           
private  ModelException.Detail newOverrideModuleMessageConstraintDetail(JAXBElement<? extends ModelObject> element, Module module, Message message)
           
private  ModelException.Detail newOverrideModulePropertyConstraintDetail(JAXBElement<? extends ModelObject> element, Module module, Property property)
           
private  ModelException.Detail newPropertyInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Property property, Implementation finalSuperProperty)
           
private  ModelException.Detail newPropertyInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, PropertyReference reference, Implementation finalSuperProperty)
           
private  ModelException.Detail newPropertyMultipleInheritanceContraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Property property)
           
private  ModelException.Detail newPropertyOverrideConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Property property)
           
private  ModelException.Detail newPropertyOverrideConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, PropertyReference reference)
           
private  ModelException.Detail newSpecificationInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, SpecificationReference specification, Implementation finalSuperSpecification)
           
private  ModelException.Detail newSpecificationMultipleInheritanceContraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, SpecificationReference reference)
           
private  ModelException.Detail newSpecificationOverrideConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, SpecificationReference reference)
           
private  ModelException.Detail newSpecificationPropertyReferenceDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element, Specification specification, PropertyReference reference)
           
private  ModelException.Detail newSpecificationVersioningConstraintDetail(JAXBElement<? extends ModelObject> element, Implementation implementation, Specification specification)
           
private  void resolveClasspath(Modules modules, Dependencies dependencies, Module cpModule)
           
private  void resolveClasspath(Modules modules, Implementations implementations, Module cpModule)
           
private  void resolveClasspath(Modules modules, Module cpModule)
          Resolves references by inspecting the class loader of the instance.
private  void resolveClasspath(Modules modules, SpecificationReference ref, Module cpModule)
           
private  void resolveClasspath(Modules modules, Specifications references, Module cpModule)
           
private  void resolveClasspath(Specification specification, Module cpModule)
           
private  void resolveClasspath(String identifier, Module cpModule)
           
 void setClassLoader(ClassLoader value)
          Sets the class loader of the instance.
 void setContext(JAXBContext value)
          Sets the JAXB context of the instance.
 void setEntityResolver(EntityResolver value)
          Sets the entity resolver of the instance.
 void setLSResourceResolver(LSResourceResolver value)
          Sets the L/S resolver of the instance.
 void setObjectFactory(ObjectFactory value)
          Sets the object factory of the instance.
 void setSchema(Schema value)
          Sets the schema of the instance.
<T extends BootstrapObject>
T
transformBootstrapObject(JAXBElement<T> bootstrapObject, Transformer transformer)
          Transforms a given BootstrapObject with a given Transformer.
<T extends ModelObject>
T
transformModelObject(JAXBElement<T> modelObject, Transformer transformer)
          Transforms a given ModelObject with a given Transformer.
 void validateBootstrapObject(JAXBElement<? extends BootstrapObject> bootstrapObject)
          Validates a given bootstrap object.
 void validateModelObject(JAXBElement<? extends ModelObject> modelObject)
          Validates a given model object.
 void validateModules(Modules modules)
          Validates modules.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CLASSPATH_MODULE_NAME

private static final String DEFAULT_CLASSPATH_MODULE_NAME
Constant for the name of the classpath module.

See Also:
getClasspathModuleName(), Constant Field Values

DEFAULT_DOCUMENT_LOCATION

private static final String DEFAULT_DOCUMENT_LOCATION
Classpath location searched for documents by default.

See Also:
getDefaultDocumentLocation(), Constant Field Values

DEFAULT_STYLESHEET_LOCATION

private static final String DEFAULT_STYLESHEET_LOCATION
Classpath location searched for style sheets by default.

See Also:
getDefaultStylesheetLocation(), Constant Field Values

BOOTSTRAP_SCHEMA_LOCATION

private static final String BOOTSTRAP_SCHEMA_LOCATION
Classpath location of the bootstrap schema.


DEFAULT_BOOTSTRAP_DOCUMENT_LOCATION

private static final String DEFAULT_BOOTSTRAP_DOCUMENT_LOCATION
Classpath location searched for bootstrap documents by default.

See Also:
getBootstrapDocumentLocation(), Constant Field Values

BOOTSTRAP_CONTEXT

private static final String BOOTSTRAP_CONTEXT
JAXB context of the bootstrap schema.


SCHEMA_EXTENSIONS

private static final String[] SCHEMA_EXTENSIONS
Supported schema name extensions.


NO_CLASSES

private static final Class[] NO_CLASSES
Empty Class array.


NO_OBJECTS

private static final Object[] NO_OBJECTS
Empty Object array.


classLoader

private ClassLoader classLoader
Class loader of the instance.


entityResolver

private EntityResolver entityResolver
The entity resolver of the instance.


resourceResolver

private LSResourceResolver resourceResolver
The L/S resolver of the instance.


context

private JAXBContext context
The context of the instance.


schema

private Schema schema
The schema of the instance.


bootstrapSchema

private Schema bootstrapSchema
The bootstrap schema.


schemaResources

private Set<URL> schemaResources
URLs of all available classpath schema resources.


schemas

private Schemas schemas
Schemas of the instance.


objectFactory

private ObjectFactory objectFactory
Object factory of the instance.


bootstrapObjectFactory

private ObjectFactory bootstrapObjectFactory
Bootstrap object factory of the instance.


listeners

private List<DefaultModelManager.Listener> listeners
The listeners of the instance.


objects

private final Map objects
Maps objects to Instances.

Constructor Detail

DefaultModelManager

public DefaultModelManager()
Creates a new DefaultModelManager instance.

Method Detail

getObjectFactory

public ObjectFactory getObjectFactory()
Description copied from interface: ModelManager
Gets the object management and configuration ObjectFactory.

Specified by:
getObjectFactory in interface ModelManager
Returns:
The object management and configuration ObjectFactory.

getEntityResolver

public EntityResolver getEntityResolver()
Description copied from interface: ModelManager
Gets the object management and configuration entity resolver.

Specified by:
getEntityResolver in interface ModelManager
Returns:
The object management and configuration entity resolver.

getLSResourceResolver

public LSResourceResolver getLSResourceResolver()
Description copied from interface: ModelManager
Gets the object management and configuration L/S resolver.

Specified by:
getLSResourceResolver in interface ModelManager
Returns:
The object management and configuration L/S resolver.

getSchema

public Schema getSchema()
                 throws IOException,
                        SAXException,
                        JAXBException
Description copied from interface: ModelManager
Gets the object management and configuration schema.

Specified by:
getSchema in interface ModelManager
Returns:
The object management and configuration schema.
Throws:
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.

getContext

public JAXBContext getContext()
                       throws IOException,
                              SAXException,
                              JAXBException
Description copied from interface: ModelManager
Gets the object management and configuration JAXBContext.

Specified by:
getContext in interface ModelManager
Returns:
The object management and configuration JAXBContext.
Throws:
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.

getMarshaller

public Marshaller getMarshaller(boolean validating,
                                boolean formattedOutput)
                         throws IOException,
                                SAXException,
                                JAXBException
Description copied from interface: ModelManager
Gets an object management and configuration Marshaller.

Specified by:
getMarshaller in interface ModelManager
Parameters:
validating - true for a marshaller with additional schema validation support enabled; false for a marshaller without additional schema validation support enabled.
formattedOutput - true for the marshaller to produce formatted output; false for the marshaller to not apply any formatting when marshalling.
Returns:
An object management and configuration Marshaller.
Throws:
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.

getUnmarshaller

public Unmarshaller getUnmarshaller(boolean validating)
                             throws IOException,
                                    SAXException,
                                    JAXBException
Description copied from interface: ModelManager
Gets an object management and configuration Unmarshaller.

Specified by:
getUnmarshaller in interface ModelManager
Parameters:
validating - true for an unmarshaller with additional schema validation support enabled; false for an unmarshaller without additional schema validation support enabled.
Returns:
An object management and configuration Unmarshaller.
Throws:
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.

validateModelObject

public void validateModelObject(JAXBElement<? extends ModelObject> modelObject)
                         throws ModelException,
                                IOException,
                                SAXException,
                                JAXBException
Description copied from interface: ModelManager
Validates a given model object.

Specified by:
validateModelObject in interface ModelManager
Parameters:
modelObject - The object to validate.
Throws:
ModelException - if modelObject is invalid.
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.

validateModules

public void validateModules(Modules modules)
                     throws ModelException,
                            IOException,
                            SAXException,
                            JAXBException
Description copied from interface: ModelManager
Validates modules.

Specified by:
validateModules in interface ModelManager
Parameters:
modules - The modules to validate.
Throws:
ModelException - if modules is invalid.
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.

transformModelObject

public <T extends ModelObject> T transformModelObject(JAXBElement<T> modelObject,
                                                      Transformer transformer)
                                           throws IOException,
                                                  SAXException,
                                                  JAXBException,
                                                  TransformerException
Description copied from interface: ModelManager
Transforms a given ModelObject with a given Transformer.

Specified by:
transformModelObject in interface ModelManager
Type Parameters:
T - The type of modelObject.
Parameters:
modelObject - The ModelObject to transform.
transformer - The Transformer to transform modelObject with.
Returns:
modelObject transformed with transformer.
Throws:
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if binding fails.
TransformerException - if the transformation fails.

getInstance

public Instance getInstance(Modules modules,
                            Implementation implementation,
                            ClassLoader cl)
Description copied from interface: ModelManager
Gets an instance of an implementation.

Specified by:
getInstance in interface ModelManager
Parameters:
modules - The modules declaring the instance to get.
implementation - The implementation to get an instance of.
cl - The class loader of the instance to get.
Returns:
An instance of implementation or null if no instance is available.

getInstance

public Instance getInstance(Modules modules,
                            Implementation implementation,
                            Dependency dependency,
                            ClassLoader cl)
Description copied from interface: ModelManager
Gets an instance of an implementation for a dependency.

Specified by:
getInstance in interface ModelManager
Parameters:
modules - The modules declaring the instance to get.
implementation - The implementation to get an instance of.
dependency - The dependency declaring the instance to get.
cl - The class loader of the instance to get.
Returns:
An instance of implementation or null if no instance is available.

getInstance

public Instance getInstance(Modules modules,
                            Object object)
Description copied from interface: ModelManager
Gets the instance of an object.

Specified by:
getInstance in interface ModelManager
Parameters:
modules - The modules declaring the instance to get.
object - The object to get the instance of.
Returns:
The instance of object or null of nothing is known about object.

getObject

public Object getObject(Modules modules,
                        Specification specification,
                        Instance instance)
                 throws InstantiationException
Description copied from interface: ModelManager
Gets the object of an instance.

Specified by:
getObject in interface ModelManager
Parameters:
modules - The modules declaring the object to get.
specification - The specification specifying the object to get.
instance - The instance of the object to get.
Returns:
The object of instance or null if nothing is known about instance.
Throws:
InstantiationException - if instantiating the object fails.

getBootstrapObjectFactory

public ObjectFactory getBootstrapObjectFactory()
Gets the bootstrap object factory of the instance.

Returns:
The bootstrap object factory of the instance.

getBootstrapContext

public JAXBContext getBootstrapContext()
                                throws JAXBException
Gets a new bootstrap context instance.

Returns:
A new bootstrap context instance.
Throws:
JAXBException - if creating a new bootstrap context instance fails.

getBootstrapMarshaller

public Marshaller getBootstrapMarshaller(boolean validating,
                                         boolean formattedOutput)
                                  throws IOException,
                                         SAXException,
                                         JAXBException
Gets a new bootstrap Marshaller.

Parameters:
validating - true for a marshaller with additional schema validation support enabled; false for a marshaller without additional schema validation support enabled.
formattedOutput - true for the marshaller to produce formatted output; false for the marshaller to not apply any formatting when marshalling.
Returns:
A new bootstrap Marshaller.
Throws:
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.

getBootstrapUnmarshaller

public Unmarshaller getBootstrapUnmarshaller(boolean validating)
                                      throws IOException,
                                             SAXException,
                                             JAXBException
Gets a new bootstrap Unmarshaller.

Parameters:
validating - true for an unmarshaller with additional schema validation support enabled; false for an unmarshaller without additional schema validation support enabled.
Returns:
A new bootstrap Unmarshaller.
Throws:
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.

getBootstrapSchema

public Schema getBootstrapSchema()
                          throws SAXException
Gets the bootstrap schema.

Returns:
The bootstrap schema.
Throws:
SAXException - if parsing the bootstrap schema fails.

validateBootstrapObject

public void validateBootstrapObject(JAXBElement<? extends BootstrapObject> bootstrapObject)
                             throws ModelException,
                                    IOException,
                                    SAXException,
                                    JAXBException
Validates a given bootstrap object.

Parameters:
bootstrapObject - The object to validate.
Throws:
NullPointerException - if bootstrapObject is null.
ModelException - if bootstrapObject is invalid.
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.

transformBootstrapObject

public <T extends BootstrapObject> T transformBootstrapObject(JAXBElement<T> bootstrapObject,
                                                              Transformer transformer)
                                                   throws IOException,
                                                          SAXException,
                                                          JAXBException,
                                                          TransformerException
Transforms a given BootstrapObject with a given Transformer.

Type Parameters:
T - The type of bootstrapObject.
Parameters:
bootstrapObject - The BootstrapObject to transform.
transformer - The Transformer to transform bootstrapObject with.
Returns:
bootstrapObject transformed with transformer.
Throws:
NullPointerException - if bootstrapObject or transformer is null.
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if binding fails.
TransformerException - if the transformation fails.

setObjectFactory

public void setObjectFactory(ObjectFactory value)
Sets the object factory of the instance.

Parameters:
value - The new object factory of the instance or null.
See Also:
getObjectFactory()

setEntityResolver

public void setEntityResolver(EntityResolver value)
Sets the entity resolver of the instance.

Parameters:
value - The new entity resolver of the instance or null.
See Also:
getEntityResolver()

setLSResourceResolver

public void setLSResourceResolver(LSResourceResolver value)
Sets the L/S resolver of the instance.

Parameters:
value - The new L/S resolver of the instance or null.
See Also:
getLSResourceResolver()

setContext

public void setContext(JAXBContext value)
Sets the JAXB context of the instance.

Parameters:
value - The new JAXB context of the instance or null.
See Also:
getContext()

setSchema

public void setSchema(Schema value)
Sets the schema of the instance.

Parameters:
value - The new schema of the instance or null.
See Also:
getSchema()

getListeners

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

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

getBootstrapDocumentLocation

public String getBootstrapDocumentLocation()
Gets the location to search for bootstrap documents.

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

Returns:
The location to search for bootstrap documents.
See Also:
getSchemas()

getSchemas

public Schemas getSchemas()
                   throws IOException,
                          JAXBException,
                          SAXException
Gets the schemas backing the instance.

Returns:
The schemas backing the instance.
Throws:
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.
See Also:
getBootstrapDocumentLocation()

getDefaultDocumentLocation

public String getDefaultDocumentLocation()
Gets the default location to search for documents.

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

Returns:
The default location to search for documents.
See Also:
getClasspathModules(java.lang.String)

getClasspathModules

public Modules getClasspathModules(String location)
                            throws IOException,
                                   SAXException,
                                   JAXBException
Gets modules by searching the class loader of the instance for resources.

Note:
This method does not validate the modules.

Parameters:
location - The location to search at.
Returns:
All resources from the class loader of the instance matching location.
Throws:
NullPointerException - if location is null.
IOException - if reading resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.
See Also:
getDefaultDocumentLocation()

getClasspathModuleName

public String getClasspathModuleName()
Gets the classpath module name.

The classpath module name is controlled by system property org.jomc.model.DefaultModelManager.classpathModuleName holding the classpath module name. If that property is not set, the Java Classpath default is returned.

Returns:
The name of the classpath module.
See Also:
getClasspathModule(org.jomc.model.Modules)

getClasspathModule

public Module getClasspathModule(Modules modules)
Gets a module holding model objects resolved by inspecting the class loader of the instance.

This method searches the given modules for unresolved references and tries to resolve each unresolved reference by inspecting the class loader of the instance.

Parameters:
modules - The modules to resolve by inspecting the class loader of the instance.
Returns:
A module holding model objects resolved by inspecting the class loader of the instance or null if nothing could be resolved.
See Also:
getClasspathModuleName()

getDefaultStylesheetLocation

public String getDefaultStylesheetLocation()
Gets the default location to search for style sheets.

The default style sheet location is controlled by system property org.jomc.model.DefaultModelManager.defaultStylesheetLocation holding the location to search at by default. If that property is not set, the META-INF/jomc.xslt default is returned.

Returns:
The default location to search for style sheets.
See Also:
getClasspathTransformers(java.lang.String)

getClasspathTransformers

public List<Transformer> getClasspathTransformers(String location)
                                           throws IOException,
                                                  TransformerConfigurationException
Gets transformers by searching the class loader of the instance for resources.

Parameters:
location - The location to search at.
Returns:
All resources from the class loader of the instance matching location.
Throws:
NullPointerException - if location is null.
IOException - if reading resources fails.
TransformerConfigurationException - if getting the transformers fails.
See Also:
getDefaultStylesheetLocation()

getClassLoader

public ClassLoader getClassLoader()
Gets the class loader of the instance.

Returns:
The class loader of the instance.
See Also:
setClassLoader(java.lang.ClassLoader)

setClassLoader

public void setClassLoader(ClassLoader value)
Sets the class loader of the instance.

Parameters:
value - The new class loader of the instance.
See Also:
getClassLoader()

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.
See Also:
getListeners()

resolveClasspath

private void resolveClasspath(Modules modules,
                              Module cpModule)
Resolves references by inspecting the class loader of the instance.

Parameters:
modules - The modules to resolve.
cpModule - The module for resolved references.
Throws:
NullPointerException - if cpModule is null.

resolveClasspath

private void resolveClasspath(Modules modules,
                              SpecificationReference ref,
                              Module cpModule)

resolveClasspath

private void resolveClasspath(Modules modules,
                              Specifications references,
                              Module cpModule)

resolveClasspath

private void resolveClasspath(Modules modules,
                              Implementations implementations,
                              Module cpModule)

resolveClasspath

private void resolveClasspath(Modules modules,
                              Dependencies dependencies,
                              Module cpModule)

resolveClasspath

private void resolveClasspath(String identifier,
                              Module cpModule)

resolveClasspath

private void resolveClasspath(Specification specification,
                              Module cpModule)

checkFactoryMethod

private boolean checkFactoryMethod(Class clazz,
                                   Class type,
                                   String methodName)

getFactoryMethod

private Method getFactoryMethod(Class clazz,
                                String methodName)

getSchemaResources

private Set<URL> getSchemaResources()
                             throws IOException
Searches all available META-INF/MANIFEST.MF resources and gets a set containing URLs of entries whose name end with a known schema extension.

Returns:
URLs of any matching entries.
Throws:
IOException - if reading or parsing fails.

getImplementation

private Implementation getImplementation(Modules modules,
                                         Object object)
Gets the implementation of an object.

Parameters:
modules - The modules to search for the implementation of object.
object - The object to get the implementation for.
Returns:
The implementation for object or null, if nothing is known about object.

collectImplementation

private Implementation collectImplementation(Modules modules,
                                             Class clazz)

collectFinalSuperDependencies

private void collectFinalSuperDependencies(Modules modules,
                                           Implementation implementation,
                                           String dependencyName,
                                           Implementations implementations,
                                           Implementations seen,
                                           boolean includeImplementation)

collectFinalSuperMessages

private void collectFinalSuperMessages(Modules modules,
                                       Implementation implementation,
                                       String messageName,
                                       Implementations implementations,
                                       Implementations seen,
                                       boolean includeImplementation)

collectFinalSuperProperties

private void collectFinalSuperProperties(Modules modules,
                                         Implementation implementation,
                                         String propertyName,
                                         Implementations implementations,
                                         Implementations seen,
                                         boolean includeImplementation)

collectFinalSuperSpecifications

private void collectFinalSuperSpecifications(Modules modules,
                                             Implementation implementation,
                                             String specificationIdentifier,
                                             Implementations implementations,
                                             Implementations seen,
                                             boolean includeImplementation)

collectFinalSuperImplementations

private void collectFinalSuperImplementations(Modules modules,
                                              Implementation implementation,
                                              Implementations implementations,
                                              Implementations seen,
                                              boolean includeImplementation)

findInheritanceCycle

private Implementation findInheritanceCycle(Modules modules,
                                            Implementation current,
                                            Implementation report,
                                            Implementations implementations)

getMessage

private String getMessage(String key,
                          Object args)

assertImplementationMessagesUniqueness

private void assertImplementationMessagesUniqueness(Implementation implementation,
                                                    List<ModelException.Detail> details)

assertImplementationPropertiesUniqueness

private void assertImplementationPropertiesUniqueness(Implementation implementation,
                                                      List<ModelException.Detail> details)

newIncompatibleImplementationDetail

private ModelException.Detail newIncompatibleImplementationDetail(JAXBElement<? extends ModelObject> element,
                                                                  String implementation,
                                                                  String implementationModule,
                                                                  String specification,
                                                                  String specificationModule,
                                                                  String implementedVersion,
                                                                  String specifiedVersion)

newIncompatibleDependencyDetail

private ModelException.Detail newIncompatibleDependencyDetail(JAXBElement<? extends ModelObject> element,
                                                              String implementation,
                                                              String implementationModule,
                                                              String specification,
                                                              String specificationModule,
                                                              String requiredVersion,
                                                              String availableVersion)

newImplementationNameConstraintDetail

private ModelException.Detail newImplementationNameConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                    Specification specification,
                                                                    Implementation implementation)

newMandatoryDependencyConstraintDetail

private ModelException.Detail newMandatoryDependencyConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                     String implementation,
                                                                     String dependencyName)

newMultiplicityConstraintDetail

private ModelException.Detail newMultiplicityConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                              Specification specification,
                                                              Implementation implementation)

newImplementationInheritanceConstraintDetail

private ModelException.Detail newImplementationInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                           Implementation implementation,
                                                                           Implementation finalSuperImplementation)

newSpecificationInheritanceConstraintDetail

private ModelException.Detail newSpecificationInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                          Implementation implementation,
                                                                          SpecificationReference specification,
                                                                          Implementation finalSuperSpecification)

newDependencyInheritanceConstraintDetail

private ModelException.Detail newDependencyInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                       Implementation implementation,
                                                                       Dependency dependency,
                                                                       Implementation finalSuperDependency)

newPropertyInheritanceConstraintDetail

private ModelException.Detail newPropertyInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                     Implementation implementation,
                                                                     Property property,
                                                                     Implementation finalSuperProperty)

newPropertyInheritanceConstraintDetail

private ModelException.Detail newPropertyInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                     Implementation implementation,
                                                                     PropertyReference reference,
                                                                     Implementation finalSuperProperty)

newMessageInheritanceConstraintDetail

private ModelException.Detail newMessageInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                    Implementation implementation,
                                                                    Message message,
                                                                    Implementation finalSuperMessage)

newMessageInheritanceConstraintDetail

private ModelException.Detail newMessageInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                    Implementation implementation,
                                                                    MessageReference reference,
                                                                    Implementation finalSuperMessage)

newDependencyPropertyReferenceDeclarationConstraintDetail

private ModelException.Detail newDependencyPropertyReferenceDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                                        Implementation implementation,
                                                                                        Dependency dependency,
                                                                                        PropertyReference reference)

newDependencyPropertiesOverrideConstraintDetail

private ModelException.Detail newDependencyPropertiesOverrideConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                              Implementation implementation,
                                                                              Dependency dependency,
                                                                              Specification specification,
                                                                              Property property)

newImplementationSpecificationDeclarationConstraintDetail

private ModelException.Detail newImplementationSpecificationDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                                        Implementation implementation,
                                                                                        Specification specification)

newModuleMessageReferenceDeclarationConstraintDetail

private ModelException.Detail newModuleMessageReferenceDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                                   Module module,
                                                                                   MessageReference reference)

newModulePropertyReferenceDeclarationConstraintDetail

private ModelException.Detail newModulePropertyReferenceDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                                    Module module,
                                                                                    PropertyReference reference)

newModuleImplementationReferenceDeclarationConstraintDetail

private ModelException.Detail newModuleImplementationReferenceDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                                          Module module,
                                                                                          ImplementationReference reference)

newImplementationImplementationDeclarationConstraintDetail

private ModelException.Detail newImplementationImplementationDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                                         Implementation implementation,
                                                                                         Implementation declaration)

newModuleSpecificationReferenceDeclarationConstraintDetail

private ModelException.Detail newModuleSpecificationReferenceDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                                         Module module,
                                                                                         SpecificationReference reference)

newDependencyOverrideConstraintDetail

private ModelException.Detail newDependencyOverrideConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                    Implementation implementation,
                                                                    Dependency dependency)

newMessageOverrideConstraintDetail

private ModelException.Detail newMessageOverrideConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                 Implementation implementation,
                                                                 Message message)

newMessageOverrideConstraintDetail

private ModelException.Detail newMessageOverrideConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                 Implementation implementation,
                                                                 MessageReference reference)

newPropertyOverrideConstraintDetail

private ModelException.Detail newPropertyOverrideConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                  Implementation implementation,
                                                                  Property property)

newPropertyOverrideConstraintDetail

private ModelException.Detail newPropertyOverrideConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                  Implementation implementation,
                                                                  PropertyReference reference)

newSpecificationOverrideConstraintDetail

private ModelException.Detail newSpecificationOverrideConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                       Implementation implementation,
                                                                       SpecificationReference reference)

newAbstractLocationConstraintDetail

private ModelException.Detail newAbstractLocationConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                  Implementation implementation,
                                                                  String location)

newFinalModuleMessageConstraintDetail

private ModelException.Detail newFinalModuleMessageConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                    Module module,
                                                                    Message message)

newOverrideModuleMessageConstraintDetail

private ModelException.Detail newOverrideModuleMessageConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                       Module module,
                                                                       Message message)

newFinalModulePropertyConstraintDetail

private ModelException.Detail newFinalModulePropertyConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                     Module module,
                                                                     Property property)

newOverrideModulePropertyConstraintDetail

private ModelException.Detail newOverrideModulePropertyConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                        Module module,
                                                                        Property property)

newSpecificationPropertyReferenceDeclarationConstraintDetail

private ModelException.Detail newSpecificationPropertyReferenceDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                                           Specification specification,
                                                                                           PropertyReference reference)

newSpecificationMultipleInheritanceContraintDetail

private ModelException.Detail newSpecificationMultipleInheritanceContraintDetail(JAXBElement<? extends ModelObject> element,
                                                                                 Implementation implementation,
                                                                                 SpecificationReference reference)

newDependencyMultipleInheritanceContraintDetail

private ModelException.Detail newDependencyMultipleInheritanceContraintDetail(JAXBElement<? extends ModelObject> element,
                                                                              Implementation implementation,
                                                                              Dependency dependency)

newMessageMultipleInheritanceContraintDetail

private ModelException.Detail newMessageMultipleInheritanceContraintDetail(JAXBElement<? extends ModelObject> element,
                                                                           Implementation implementation,
                                                                           Message message)

newPropertyMultipleInheritanceContraintDetail

private ModelException.Detail newPropertyMultipleInheritanceContraintDetail(JAXBElement<? extends ModelObject> element,
                                                                            Implementation implementation,
                                                                            Property property)

newImplementationInheritanceCycleConstraintDetail

private ModelException.Detail newImplementationInheritanceCycleConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                                Implementation implementation,
                                                                                Implementation cycle)

newImplementationInheritanceCompatibilityConstraintDetail

private ModelException.Detail newImplementationInheritanceCompatibilityConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                                        Implementation implementation,
                                                                                        Implementation superImplementation,
                                                                                        String expectedVersion)

newSpecificationVersioningConstraintDetail

private ModelException.Detail newSpecificationVersioningConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                         Implementation implementation,
                                                                         Specification specification)

newImplementationVersioningConstraintDetail

private ModelException.Detail newImplementationVersioningConstraintDetail(JAXBElement<? extends ModelObject> element,
                                                                          Implementation declaring,
                                                                          Implementation implementation)


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