|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||

java.lang.Objectorg.jomc.model.DefaultModelManager
public class DefaultModelManager
Default ModelManager implementation.
Classpath support
getClassLoader()setClassLoader(java.lang.ClassLoader)getDefaultDocumentLocation()getClasspathModule(org.jomc.model.Modules)getClasspathModules(java.lang.String)getDefaultStylesheetLocation()getClasspathTransformers(java.lang.String)Logging
Model bootstrapping
getBootstrapContext()getBootstrapDocumentLocation()getBootstrapMarshaller(boolean, boolean)getBootstrapObjectFactory()getBootstrapSchema()getBootstrapUnmarshaller(boolean)validateBootstrapObject(javax.xml.bind.JAXBElement)transformBootstrapObject(javax.xml.bind.JAXBElement, javax.xml.transform.Transformer)
| 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 |
assertMessagesUniqueness(Messages messages,
List<ModelException.Detail> details)
|
|
private void |
assertPropertiesUniqueness(Properties properties,
List<ModelException.Detail> details)
|
|
private boolean |
checkFactoryMethod(Class clazz,
Class type,
String methodName)
|
|
private Implementation |
collectImplementation(Modules modules,
Class clazz)
|
|
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 |
newDependencyPropertyReferenceConstraintDetail(JAXBElement<? extends ModelObject> element,
Implementation implementation,
Dependency dependency)
|
|
private ModelException.Detail |
newImplementationNameConstraintDetail(JAXBElement<? extends ModelObject> element,
String specification,
String implementations,
String nonUniqueName)
|
|
private ModelException.Detail |
newImplementationSpecificationDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element,
Implementation implementation,
Specification specification)
|
|
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 |
newInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element,
Implementation child,
Implementation parent)
|
|
private ModelException.Detail |
newMandatoryDependencyConstraintDetail(JAXBElement<? extends ModelObject> element,
String implementation,
String dependencyName)
|
|
private ModelException.Detail |
newModuleSpecificationReferenceConstraintDetail(JAXBElement<? extends ModelObject> element,
Module module,
SpecificationReference reference)
|
|
private ModelException.Detail |
newMultiplicityConstraintDetail(JAXBElement<? extends ModelObject> element,
Number implementations,
String specification,
Number expected,
Multiplicity multiplicity)
|
|
private ModelException.Detail |
newPropertyOverwriteConstraintDetail(JAXBElement<? extends ModelObject> element,
Implementation implementation,
Dependency dependency,
Specification specification,
String scope)
|
|
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. |
|
|
transformBootstrapObject(JAXBElement<T> bootstrapObject,
Transformer transformer)
Transforms a given BootstrapObject with a given Transformer. |
|
|
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 |
|---|
private static final String DEFAULT_CLASSPATH_MODULE_NAME
getClasspathModuleName(),
Constant Field Valuesprivate static final String DEFAULT_DOCUMENT_LOCATION
getDefaultDocumentLocation(),
Constant Field Valuesprivate static final String DEFAULT_STYLESHEET_LOCATION
getDefaultStylesheetLocation(),
Constant Field Valuesprivate static final String BOOTSTRAP_SCHEMA_LOCATION
private static final String DEFAULT_BOOTSTRAP_DOCUMENT_LOCATION
getBootstrapDocumentLocation(),
Constant Field Valuesprivate static final String BOOTSTRAP_CONTEXT
private static final String[] SCHEMA_EXTENSIONS
private static final Class[] NO_CLASSES
Class array.
private static final Object[] NO_OBJECTS
Object array.
private ClassLoader classLoader
private EntityResolver entityResolver
private LSResourceResolver resourceResolver
private JAXBContext context
private Schema schema
private Schema bootstrapSchema
private Set<URL> schemaResources
private Schemas schemas
private ObjectFactory objectFactory
private ObjectFactory bootstrapObjectFactory
private List<DefaultModelManager.Listener> listeners
private final Map objects
Instances.
| Constructor Detail |
|---|
public DefaultModelManager()
DefaultModelManager instance.
| Method Detail |
|---|
public ObjectFactory getObjectFactory()
ModelManagerObjectFactory.
getObjectFactory in interface ModelManagerObjectFactory.public EntityResolver getEntityResolver()
ModelManager
getEntityResolver in interface ModelManagerpublic LSResourceResolver getLSResourceResolver()
ModelManager
getLSResourceResolver in interface ModelManager
public Schema getSchema()
throws IOException,
SAXException,
JAXBException
ModelManager
getSchema in interface ModelManagerIOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.
public JAXBContext getContext()
throws IOException,
SAXException,
JAXBException
ModelManagerJAXBContext.
getContext in interface ModelManagerJAXBContext.
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.
public Marshaller getMarshaller(boolean validating,
boolean formattedOutput)
throws IOException,
SAXException,
JAXBException
ModelManagerMarshaller.
getMarshaller in interface ModelManagervalidating - 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.
Marshaller.
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.
public Unmarshaller getUnmarshaller(boolean validating)
throws IOException,
SAXException,
JAXBException
ModelManagerUnmarshaller.
getUnmarshaller in interface ModelManagervalidating - true for an unmarshaller with additional schema validation support enabled;
false for an unmarshaller without additional schema validation support enabled.
Unmarshaller.
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.
public void validateModelObject(JAXBElement<? extends ModelObject> modelObject)
throws ModelException,
IOException,
SAXException,
JAXBException
ModelManager
validateModelObject in interface ModelManagermodelObject - The object to validate.
ModelException - if modelObject is invalid.
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.
public void validateModules(Modules modules)
throws ModelException,
IOException,
SAXException,
JAXBException
ModelManager
validateModules in interface ModelManagermodules - The modules to validate.
ModelException - if modules is invalid.
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.
public <T extends ModelObject> T transformModelObject(JAXBElement<T> modelObject,
Transformer transformer)
throws IOException,
SAXException,
JAXBException,
TransformerException
ModelManagerModelObject with a given Transformer.
transformModelObject in interface ModelManagerT - The type of modelObject.modelObject - The ModelObject to transform.transformer - The Transformer to transform modelObject with.
modelObject transformed with transformer.
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if binding fails.
TransformerException - if the transformation fails.
public Instance getInstance(Modules modules,
Implementation implementation,
ClassLoader cl)
ModelManager
getInstance in interface ModelManagermodules - The modules declaring the instance to get.implementation - The implementation to get an instance of.cl - The class loader of the instance to get.
implementation or null if no instance is available.
public Instance getInstance(Modules modules,
Implementation implementation,
Dependency dependency,
ClassLoader cl)
ModelManager
getInstance in interface ModelManagermodules - 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.
implementation or null if no instance is available.
public Instance getInstance(Modules modules,
Object object)
ModelManager
getInstance in interface ModelManagermodules - The modules declaring the instance to get.object - The object to get the instance of.
object or null of nothing is known about object.
public Object getObject(Modules modules,
Specification specification,
Instance instance)
throws InstantiationException
ModelManager
getObject in interface ModelManagermodules - The modules declaring the object to get.specification - The specification specifying the object to get.instance - The instance of the object to get.
instance or null if nothing is known about instance.
InstantiationException - if instantiating the object fails.public ObjectFactory getBootstrapObjectFactory()
public JAXBContext getBootstrapContext()
throws JAXBException
JAXBException - if creating a new bootstrap context instance fails.
public Marshaller getBootstrapMarshaller(boolean validating,
boolean formattedOutput)
throws IOException,
SAXException,
JAXBException
Marshaller.
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.
Marshaller.
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.
public Unmarshaller getBootstrapUnmarshaller(boolean validating)
throws IOException,
SAXException,
JAXBException
Unmarshaller.
validating - true for an unmarshaller with additional schema validation support enabled;
false for an unmarshaller without additional schema validation support enabled.
Unmarshaller.
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.
public Schema getBootstrapSchema()
throws SAXException
SAXException - if parsing the bootstrap schema fails.
public void validateBootstrapObject(JAXBElement<? extends BootstrapObject> bootstrapObject)
throws ModelException,
IOException,
SAXException,
JAXBException
bootstrapObject - The object to validate.
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.
public <T extends BootstrapObject> T transformBootstrapObject(JAXBElement<T> bootstrapObject,
Transformer transformer)
throws IOException,
SAXException,
JAXBException,
TransformerException
BootstrapObject with a given Transformer.
T - The type of bootstrapObject.bootstrapObject - The BootstrapObject to transform.transformer - The Transformer to transform bootstrapObject with.
bootstrapObject transformed with transformer.
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.public void setObjectFactory(ObjectFactory value)
value - The new object factory of the instance or null.getObjectFactory()public void setEntityResolver(EntityResolver value)
value - The new entity resolver of the instance or null.getEntityResolver()public void setLSResourceResolver(LSResourceResolver value)
value - The new L/S resolver of the instance or null.getLSResourceResolver()public void setContext(JAXBContext value)
value - The new JAXB context of the instance or null.getContext()public void setSchema(Schema value)
value - The new schema of the instance or null.getSchema()public List<DefaultModelManager.Listener> getListeners()
log(java.util.logging.Level, java.lang.String, java.lang.Throwable)public String getBootstrapDocumentLocation()
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.
getSchemas()
public Schemas getSchemas()
throws IOException,
JAXBException,
SAXException
IOException - if reading schema resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.getBootstrapDocumentLocation()public String getDefaultDocumentLocation()
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.
getClasspathModules(java.lang.String)
public Modules getClasspathModules(String location)
throws IOException,
SAXException,
JAXBException
Note:
This method does not validate the modules.
location - The location to search at.
location.
NullPointerException - if location is null.
IOException - if reading resources fails.
SAXException - if parsing schema resources fails.
JAXBException - if unmarshalling schema resources fails.getDefaultDocumentLocation()public String getClasspathModuleName()
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.
getClasspathModule(org.jomc.model.Modules)public Module getClasspathModule(Modules modules)
This method searches the given modules for unresolved references and tries to resolve each unresolved reference by inspecting the class loader of the instance.
modules - The modules to resolve by inspecting the class loader of the instance.
null if
nothing could be resolved.getClasspathModuleName()public String getDefaultStylesheetLocation()
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.
getClasspathTransformers(java.lang.String)
public List<Transformer> getClasspathTransformers(String location)
throws IOException,
TransformerConfigurationException
location - The location to search at.
location.
NullPointerException - if location is null.
IOException - if reading resources fails.
TransformerConfigurationException - if getting the transformers fails.getDefaultStylesheetLocation()public ClassLoader getClassLoader()
setClassLoader(java.lang.ClassLoader)public void setClassLoader(ClassLoader value)
value - The new class loader of the instance.getClassLoader()
protected void log(Level level,
String message,
Throwable throwable)
level - The level of the event.message - The message of the event or null.throwable - The throwable of the event null.getListeners()
private void resolveClasspath(Modules modules,
Module cpModule)
modules - The modules to resolve.cpModule - The module for resolved references.
NullPointerException - if cpModule is null.
private void resolveClasspath(Modules modules,
SpecificationReference ref,
Module cpModule)
private void resolveClasspath(Modules modules,
Specifications references,
Module cpModule)
private void resolveClasspath(Modules modules,
Implementations implementations,
Module cpModule)
private void resolveClasspath(Modules modules,
Dependencies dependencies,
Module cpModule)
private void resolveClasspath(String identifier,
Module cpModule)
private void resolveClasspath(Specification specification,
Module cpModule)
private boolean checkFactoryMethod(Class clazz,
Class type,
String methodName)
private Method getFactoryMethod(Class clazz,
String methodName)
private Set<URL> getSchemaResources()
throws IOException
META-INF/MANIFEST.MF resources and gets a set containing URLs of entries whose
name end with a known schema extension.
IOException - if reading or parsing fails.
private Implementation getImplementation(Modules modules,
Object object)
modules - The modules to search for the implementation of object.object - The object to get the implementation for.
object or null, if nothing is known about object.
private Implementation collectImplementation(Modules modules,
Class clazz)
private String getMessage(String key,
Object args)
private void assertMessagesUniqueness(Messages messages,
List<ModelException.Detail> details)
private void assertPropertiesUniqueness(Properties properties,
List<ModelException.Detail> details)
private ModelException.Detail newIncompatibleImplementationDetail(JAXBElement<? extends ModelObject> element,
String implementation,
String implementationModule,
String specification,
String specificationModule,
String implementedVersion,
String specifiedVersion)
private ModelException.Detail newIncompatibleDependencyDetail(JAXBElement<? extends ModelObject> element,
String implementation,
String implementationModule,
String specification,
String specificationModule,
String requiredVersion,
String availableVersion)
private ModelException.Detail newImplementationNameConstraintDetail(JAXBElement<? extends ModelObject> element,
String specification,
String implementations,
String nonUniqueName)
private ModelException.Detail newMandatoryDependencyConstraintDetail(JAXBElement<? extends ModelObject> element,
String implementation,
String dependencyName)
private ModelException.Detail newMultiplicityConstraintDetail(JAXBElement<? extends ModelObject> element,
Number implementations,
String specification,
Number expected,
Multiplicity multiplicity)
private ModelException.Detail newInheritanceConstraintDetail(JAXBElement<? extends ModelObject> element,
Implementation child,
Implementation parent)
private ModelException.Detail newDependencyPropertyReferenceConstraintDetail(JAXBElement<? extends ModelObject> element,
Implementation implementation,
Dependency dependency)
private ModelException.Detail newPropertyOverwriteConstraintDetail(JAXBElement<? extends ModelObject> element,
Implementation implementation,
Dependency dependency,
Specification specification,
String scope)
private ModelException.Detail newImplementationSpecificationDeclarationConstraintDetail(JAXBElement<? extends ModelObject> element,
Implementation implementation,
Specification specification)
private ModelException.Detail newModuleSpecificationReferenceConstraintDetail(JAXBElement<? extends ModelObject> element,
Module module,
SpecificationReference reference)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||