org.jomc.modlet
Class DefaultModelContext

Package class diagram package DefaultModelContext
java.lang.Object
  extended by org.jomc.modlet.ModelContext
      extended by org.jomc.modlet.DefaultModelContext

public class DefaultModelContext
extends ModelContext

Default ModelContext implementation.

Version:
$JOMC: DefaultModelContext.java 4469 2012-04-01 00:12:58Z schulte2005 $
Author:
Christian Schulte
See Also:
ModelContextFactory

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jomc.modlet.ModelContext
ModelContext.Listener
 
Field Summary
static String PLATFORM_PROVIDER_LOCATION_ATTRIBUTE_NAME
          Constant for the name of the model context attribute backing property platformProviderLocation.
static String PROVIDER_LOCATION_ATTRIBUTE_NAME
          Constant for the name of the model context attribute backing property providerLocation.
 
Constructor Summary
DefaultModelContext()
          Creates a new DefaultModelContext instance.
DefaultModelContext(ClassLoader classLoader)
          Creates a new DefaultModelContext instance taking a class loader.
 
Method Summary
 javax.xml.bind.JAXBContext createContext(String model)
          Creates a new JAXB context instance of a given model.
 javax.xml.bind.JAXBContext createContext(URI publicId)
          Creates a new JAXB context instance for a given public identifier URI.
 EntityResolver createEntityResolver(String model)
          Creates a new SAX entity resolver instance of a given model.
 EntityResolver createEntityResolver(URI publicId)
          Creates a new SAX entity resolver instance for a given public identifier URI.
 javax.xml.bind.Marshaller createMarshaller(String model)
          Creates a new JAXB marshaller instance of a given model.
 javax.xml.bind.Marshaller createMarshaller(URI publicId)
          Creates a new JAXB marshaller instance for a given public identifier URI.
 LSResourceResolver createResourceResolver(String model)
          Creates a new L/S resource resolver instance of a given model.
 LSResourceResolver createResourceResolver(URI publicId)
          Creates a new L/S resource resolver instance for a given public identifier URI.
 Schema createSchema(String model)
          Creates a new JAXP schema instance of a given model.
 Schema createSchema(URI publicId)
          Creates a new JAXP schema instance for a given public identifier URI.
<T> T
createServiceObject(Service service, Class<T> type)
          Creates a new service object.
 javax.xml.bind.Unmarshaller createUnmarshaller(String model)
          Creates a new JAXB unmarshaller instance of a given model.
 javax.xml.bind.Unmarshaller createUnmarshaller(URI publicId)
          Creates a new JAXB unmarshaller instance for a given given public identifier URI.
 Model findModel(Model model)
          Populates a given Model instance.
 Model findModel(String model)
          Creates a new Model instance.
 Modlets findModlets()
          Searches the context for Modlets.
static String getDefaultPlatformProviderLocation()
          Gets the default location searched for platform provider resources.
static String getDefaultProviderLocation()
          Gets the default location searched for provider resources.
 String getPlatformProviderLocation()
          Gets the location searched for platform provider resources.
 String getProviderLocation()
          Gets the location searched for provider resources.
 Model processModel(Model model)
          Processes a Model.
static void setDefaultPlatformProviderLocation(String value)
          Sets the default location searched for platform provider resources.
static void setDefaultProviderLocation(String value)
          Sets the default location searched for provider resources.
 void setPlatformProviderLocation(String value)
          Sets the location searched for platform provider resources.
 void setProviderLocation(String value)
          Sets the location searched for provider resources.
 ModelValidationReport validateModel(Model model)
          Validates a given Model.
 ModelValidationReport validateModel(String model, Source source)
          Validates a given model.
 
Methods inherited from class org.jomc.modlet.ModelContext
clearAttribute, createModelContext, findClass, findResource, findResources, getAttribute, getAttribute, getAttributeNames, getClassLoader, getDefaultLogLevel, getDefaultModletSchemaSystemId, getListeners, getLogLevel, getModelContextClassName, getModlets, getModletSchemaSystemId, isLoggable, log, setAttribute, setDefaultLogLevel, setDefaultModletSchemaSystemId, setLogLevel, setModelContextClassName, setModlets, setModletSchemaSystemId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROVIDER_LOCATION_ATTRIBUTE_NAME

public static final String PROVIDER_LOCATION_ATTRIBUTE_NAME
Constant for the name of the model context attribute backing property providerLocation.

Since:
1.2
See Also:
getProviderLocation(), ModelContext.getAttribute(java.lang.String), Constant Field Values

PLATFORM_PROVIDER_LOCATION_ATTRIBUTE_NAME

public static final String PLATFORM_PROVIDER_LOCATION_ATTRIBUTE_NAME
Constant for the name of the model context attribute backing property platformProviderLocation.

Since:
1.2
See Also:
getPlatformProviderLocation(), ModelContext.getAttribute(java.lang.String), Constant Field Values
Constructor Detail

DefaultModelContext

public DefaultModelContext()
Creates a new DefaultModelContext instance.

Since:
1.2

DefaultModelContext

public DefaultModelContext(ClassLoader classLoader)
Creates a new DefaultModelContext instance taking a class loader.

Parameters:
classLoader - The class loader of the context.
Method Detail

getDefaultProviderLocation

public static String getDefaultProviderLocation()
Gets the default location searched for provider resources.

The default provider location is controlled by system property org.jomc.modlet.DefaultModelContext.defaultProviderLocation holding the location to search for provider resources by default. If that property is not set, the META-INF/services default is returned.

Returns:
The location searched for provider resources by default.
See Also:
setDefaultProviderLocation(java.lang.String)

setDefaultProviderLocation

public static void setDefaultProviderLocation(String value)
Sets the default location searched for provider resources.

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

getProviderLocation

public final String getProviderLocation()
Gets the location searched for provider resources.

Returns:
The location searched for provider resources.
See Also:
getDefaultProviderLocation(), setProviderLocation(java.lang.String), PROVIDER_LOCATION_ATTRIBUTE_NAME

setProviderLocation

public final void setProviderLocation(String value)
Sets the location searched for provider resources.

Parameters:
value - The new location to search for provider resources or null.
See Also:
getProviderLocation()

getDefaultPlatformProviderLocation

public static String getDefaultPlatformProviderLocation()
Gets the default location searched for platform provider resources.

The default platform provider location is controlled by system property org.jomc.modlet.DefaultModelContext.defaultPlatformProviderLocation holding the location to search for platform provider resources by default. If that property is not set, the <java-home>/lib/jomc.properties default is returned.

Returns:
The location searched for platform provider resources by default.
See Also:
setDefaultPlatformProviderLocation(java.lang.String)

setDefaultPlatformProviderLocation

public static void setDefaultPlatformProviderLocation(String value)
Sets the default location searched for platform provider resources.

Parameters:
value - The new default location to search for platform provider resources or null.
See Also:
getDefaultPlatformProviderLocation()

getPlatformProviderLocation

public final String getPlatformProviderLocation()
Gets the location searched for platform provider resources.

Returns:
The location searched for platform provider resources.
See Also:
getDefaultPlatformProviderLocation(), setPlatformProviderLocation(java.lang.String), PLATFORM_PROVIDER_LOCATION_ATTRIBUTE_NAME

setPlatformProviderLocation

public final void setPlatformProviderLocation(String value)
Sets the location searched for platform provider resources.

Parameters:
value - The new location to search for platform provider resources or null.
See Also:
getPlatformProviderLocation()

findModlets

public Modlets findModlets()
                    throws ModelException
Searches the context for Modlets.

This method loads ModletProvider classes setup via the platform provider configuration file and <provider-location>/org.jomc.modlet.ModletProvider resources to return a list of Modlets.

Specified by:
findModlets in class ModelContext
Returns:
The Modlets found in the context.
Throws:
ModelException - if searching Modlets fails.
See Also:
getProviderLocation(), getPlatformProviderLocation(), ModletProvider.findModlets(org.jomc.modlet.ModelContext)

findModel

public Model findModel(String model)
                throws ModelException
Creates a new Model instance.

This method loads all ModelProvider service classes of the model identified by model to create a new Model instance.

Specified by:
findModel in class ModelContext
Parameters:
model - The identifier of the Model to create.
Returns:
A new instance of the Model identified by model.
Throws:
ModelException - if creating a new Model instance fails.
See Also:
findModel(org.jomc.modlet.Model), ModelProvider.findModel(org.jomc.modlet.ModelContext, org.jomc.modlet.Model)

findModel

public Model findModel(Model model)
                throws ModelException
Populates a given Model instance.

This method loads all ModelProvider service classes of the given model to populate the given model instance.

Specified by:
findModel in class ModelContext
Parameters:
model - The Model to populate.
Returns:
The populated model.
Throws:
ModelException - if populating model fails.
Since:
1.2
See Also:
createServiceObject(org.jomc.modlet.Service, java.lang.Class), ModelProvider.findModel(org.jomc.modlet.ModelContext, org.jomc.modlet.Model)

createServiceObject

public <T> T createServiceObject(Service service,
                                 Class<T> type)
                      throws ModelException
Creates a new service object.

Specified by:
createServiceObject in class ModelContext
Type Parameters:
T - The type of the service.
Parameters:
service - The service to create a new object of.
type - The class of the type of the service.
Returns:
An new service object for service.
Throws:
ModelException - if creating the service object fails.
Since:
1.2
See Also:
ModelProvider, ModelProcessor, ModelValidator

createEntityResolver

public EntityResolver createEntityResolver(String model)
                                    throws ModelException
Description copied from class: ModelContext
Creates a new SAX entity resolver instance of a given model.

Specified by:
createEntityResolver in class ModelContext
Parameters:
model - The identifier of the model to create a new SAX entity resolver of.
Returns:
A new SAX entity resolver instance of the model identified by model.
Throws:
ModelException - if creating a new SAX entity resolver instance fails.
See Also:
ModletObject.MODEL_PUBLIC_ID

createEntityResolver

public EntityResolver createEntityResolver(URI publicId)
                                    throws ModelException
Description copied from class: ModelContext
Creates a new SAX entity resolver instance for a given public identifier URI.

Specified by:
createEntityResolver in class ModelContext
Parameters:
publicId - The public identifier URI to create a new SAX entity resolver for.
Returns:
A new SAX entity resolver instance for the public identifier URI publicId.
Throws:
ModelException - if creating a new SAX entity resolver instance fails.
See Also:
ModletObject.PUBLIC_ID

createResourceResolver

public LSResourceResolver createResourceResolver(String model)
                                          throws ModelException
Description copied from class: ModelContext
Creates a new L/S resource resolver instance of a given model.

Specified by:
createResourceResolver in class ModelContext
Parameters:
model - The identifier of the model to create a new L/S resource resolver of.
Returns:
A new L/S resource resolver instance of the model identified by model.
Throws:
ModelException - if creating a new L/S resource resolver instance fails.
See Also:
ModletObject.MODEL_PUBLIC_ID

createResourceResolver

public LSResourceResolver createResourceResolver(URI publicId)
                                          throws ModelException
Description copied from class: ModelContext
Creates a new L/S resource resolver instance for a given public identifier URI.

Specified by:
createResourceResolver in class ModelContext
Parameters:
publicId - The public identifier URI to create a new L/S resource resolver for.
Returns:
A new L/S resource resolver instance for the public identifier URI publicId.
Throws:
ModelException - if creating a new L/S resource resolver instance fails.
See Also:
ModletObject.PUBLIC_ID

createSchema

public Schema createSchema(String model)
                    throws ModelException
Description copied from class: ModelContext
Creates a new JAXP schema instance of a given model.

Specified by:
createSchema in class ModelContext
Parameters:
model - The identifier of the model to create a new JAXP schema instance of.
Returns:
A new JAXP schema instance of the model identified by model.
Throws:
ModelException - if creating a new JAXP schema instance fails.
See Also:
ModletObject.MODEL_PUBLIC_ID

createSchema

public Schema createSchema(URI publicId)
                    throws ModelException
Description copied from class: ModelContext
Creates a new JAXP schema instance for a given public identifier URI.

Specified by:
createSchema in class ModelContext
Parameters:
publicId - The public identifier URI to create a new JAXP schema instance for.
Returns:
A new JAXP schema instance for the public identifier URI publicId.
Throws:
ModelException - if creating a new JAXP schema instance fails.
See Also:
ModletObject.PUBLIC_ID

createContext

public javax.xml.bind.JAXBContext createContext(String model)
                                         throws ModelException
Description copied from class: ModelContext
Creates a new JAXB context instance of a given model.

Specified by:
createContext in class ModelContext
Parameters:
model - The identifier of the model to create a new JAXB context instance of.
Returns:
A new JAXB context instance of the model identified by model.
Throws:
ModelException - if creating a new JAXB context instance fails.
See Also:
ModletObject.MODEL_PUBLIC_ID

createContext

public javax.xml.bind.JAXBContext createContext(URI publicId)
                                         throws ModelException
Description copied from class: ModelContext
Creates a new JAXB context instance for a given public identifier URI.

Specified by:
createContext in class ModelContext
Parameters:
publicId - The public identifier URI to create a new JAXB context instance for.
Returns:
A new JAXB context instance for the public identifier URI publicId.
Throws:
ModelException - if creating a new JAXB context instance fails.
See Also:
ModletObject.PUBLIC_ID

createMarshaller

public javax.xml.bind.Marshaller createMarshaller(String model)
                                           throws ModelException
Description copied from class: ModelContext
Creates a new JAXB marshaller instance of a given model.

Specified by:
createMarshaller in class ModelContext
Parameters:
model - The identifier of the model to create a new JAXB marshaller instance of.
Returns:
A new JAXB marshaller instance of the model identified by model.
Throws:
ModelException - if creating a new JAXB marshaller instance fails.
See Also:
ModletObject.MODEL_PUBLIC_ID

createMarshaller

public javax.xml.bind.Marshaller createMarshaller(URI publicId)
                                           throws ModelException
Description copied from class: ModelContext
Creates a new JAXB marshaller instance for a given public identifier URI.

Specified by:
createMarshaller in class ModelContext
Parameters:
publicId - The public identifier URI to create a new JAXB marshaller instance for.
Returns:
A new JAXB marshaller instance for the public identifier URI publicId.
Throws:
ModelException - if creating a new JAXB marshaller instance fails.
See Also:
ModletObject.PUBLIC_ID

createUnmarshaller

public javax.xml.bind.Unmarshaller createUnmarshaller(String model)
                                               throws ModelException
Description copied from class: ModelContext
Creates a new JAXB unmarshaller instance of a given model.

Specified by:
createUnmarshaller in class ModelContext
Parameters:
model - The identifier of the model to create a new JAXB unmarshaller instance of.
Returns:
A new JAXB unmarshaller instance of the model identified by model.
Throws:
ModelException - if creating a new JAXB unmarshaller instance fails.
See Also:
ModletObject.MODEL_PUBLIC_ID

createUnmarshaller

public javax.xml.bind.Unmarshaller createUnmarshaller(URI publicId)
                                               throws ModelException
Description copied from class: ModelContext
Creates a new JAXB unmarshaller instance for a given given public identifier URI.

Specified by:
createUnmarshaller in class ModelContext
Parameters:
publicId - The public identifier URI to create a new JAXB unmarshaller instance for.
Returns:
A new JAXB unmarshaller instance for the public identifier URI publicId.
Throws:
ModelException - if creating a new JAXB unmarshaller instance fails.
See Also:
ModletObject.PUBLIC_ID

processModel

public Model processModel(Model model)
                   throws ModelException
Processes a Model.

This method loads all ModelProcessor service classes of model to process the given Model.

Specified by:
processModel in class ModelContext
Parameters:
model - The Model to process.
Returns:
The processed Model.
Throws:
ModelException - if processing model fails.
See Also:
createServiceObject(org.jomc.modlet.Service, java.lang.Class), ModelProcessor.processModel(org.jomc.modlet.ModelContext, org.jomc.modlet.Model)

validateModel

public ModelValidationReport validateModel(Model model)
                                    throws ModelException
Validates a given Model.

This method loads all ModelValidator service classes of model to validate the given Model.

Specified by:
validateModel in class ModelContext
Parameters:
model - The Model to validate.
Returns:
Validation report.
Throws:
ModelException - if validating the modules fails.
See Also:
createServiceObject(org.jomc.modlet.Service, java.lang.Class), ModelValidator.validateModel(org.jomc.modlet.ModelContext, org.jomc.modlet.Model)

validateModel

public ModelValidationReport validateModel(String model,
                                           Source source)
                                    throws ModelException
Validates a given model.

Specified by:
validateModel in class ModelContext
Parameters:
model - The identifier of the Model to use for validating source.
source - A source providing the model to validate.
Returns:
Validation report.
Throws:
ModelException - if validating the model fails.
See Also:
createSchema(java.lang.String)


Copyright © 2005-2012 The JOMC Project. All Rights Reserved.Get JOMC at SourceForge.net. Fast, secure and Free Open Source software downloads
Please note that this documentation is maintained by non-native english speaking authors. As such, you may encounter phrases or wordings which seem imprecise or may even have a totally different meaning to native english speaking readers than what the individual author was trying to express. If you are a native english speaking reader and find any such phrases or wordings we kindly ask you to send an email to the corresponding author and help us improve this documentation in order to avoid misunderstandings. You will find the authors' email addresses at the top of each class. Please accept our apologies for any inconvenience caused.