com.sodius.mdw.core.model.emf
Class EMFModelReader

java.lang.Object
  extended by com.sodius.mdw.core.model.emf.EMFModelReader
All Implemented Interfaces:
ModelReader
Direct Known Subclasses:
EMFXMIModelReader, EMFXMLModelReader

public abstract class EMFModelReader
extends Object
implements ModelReader

Provides a skeletal implementation for EMF based model readers.

This class acts as a bridge between EMF Resource and MDWorkbench ModelReader. Subclasses are required to implement the createResource method. This class will delegate the loading to the created resource. Then it will attach to the model every created EMF model element.

A default implementation is available to handle XMI uris.

Clients may subclass this class.


Field Summary
static String MDW_CONNECTOR_CONTEXT
          Option that gives access to the connector context.
static String OPTION_DISABLE_AUTO_RESOLVE_PROXIES
           
 
Constructor Summary
EMFModelReader()
           
 
Method Summary
protected  Map<String,Object> createOptions(ConnectorContext context)
          Create options to pass to the created resource.
protected abstract  Resource createResource(URI uri, ConnectorContext context)
          Creates a resource that is able to handle the specified uri.
protected  ResourceSet createResourceSet(Model model, ConnectorContext context)
          Creates a resource set based on this connector context
protected  void logError(ConnectorContext context, Resource.Diagnostic error)
          Logs the specified diagnostic to the registered logger.
 void read(String filepath, Model model, ConnectorContext context)
          Reads the specified uri.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MDW_CONNECTOR_CONTEXT

public static final String MDW_CONNECTOR_CONTEXT
Option that gives access to the connector context. A resource load method can retrieve the connector context this way :
ConnectorContext context = (ConnectorContext) options.get(EMFModelReader.MDW_CONNECTOR_CONTEXT);

See Also:
Constant Field Values

OPTION_DISABLE_AUTO_RESOLVE_PROXIES

public static final String OPTION_DISABLE_AUTO_RESOLVE_PROXIES
See Also:
Constant Field Values
Constructor Detail

EMFModelReader

public EMFModelReader()
Method Detail

read

public void read(String filepath,
                 Model model,
                 ConnectorContext context)
          throws CoreException
Reads the specified uri. This implementation reads a model in four steps :

The context can be used to access a variery of properties and is to be used to check for cancellation.

Specified by:
read in interface ModelReader
Parameters:
filepath - the location of a resource to read.
model - the model in which model elements must be created.
context - the context in which this reader runs.
Throws:
CoreException - if anything prevents the connector to read the model.
See Also:
ConnectorDescriptor.getKind()

createResourceSet

protected ResourceSet createResourceSet(Model model,
                                        ConnectorContext context)
Creates a resource set based on this connector context

Parameters:
model - the model in which model elements must be created.
context - the connector context to use.
Returns:
a resource set used to create a resource.

createResource

protected abstract Resource createResource(URI uri,
                                           ConnectorContext context)
Creates a resource that is able to handle the specified uri.

Parameters:
uri - the URI to load.
context - the context in which the connector runs
Returns:
the created resource.

createOptions

protected Map<String,Object> createOptions(ConnectorContext context)
Create options to pass to the created resource. The default implementation set as option every property defined on the connector context, and add MDW_CONNECTOR_CONTEXT to give access to the context.

Parameters:
context - the context in which the connector runs
Returns:
the options to pass to the resource.

logError

protected void logError(ConnectorContext context,
                        Resource.Diagnostic error)
Logs the specified diagnostic to the registered logger.