org.eclipse.xtext.mwe
Class Reader

java.lang.Object
  extended by org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent
      extended by org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2
          extended by org.eclipse.xtext.mwe.AbstractReader
              extended by org.eclipse.xtext.mwe.Reader
All Implemented Interfaces:
org.eclipse.emf.mwe.core.WorkflowComponent, org.eclipse.emf.mwe.core.WorkflowComponentWithID, org.eclipse.emf.mwe2.runtime.workflow.IWorkflowComponent

public class Reader
extends AbstractReader

A Reader used to read EMF resources from a set of pathes. A path can point to a folder or an archive (zips and jars are supported). Those pathes are recursively scanned and all resources for which an IResourceServiceProvider is registered in the IResourceServiceProvider.Registry will be available.

The ISetup of an Xtext language registers such an IResourceServiceProvider automatically. If you want to integrate with non Xtext-based models, make sure to add IResourceServiceProvider manually. The easiest way might be to implement an ISetup.

A SlotEntry is responsible for selecting certain EObjects from the loaded resources. It supports selecting EObjects by their name (see IEObjectDescription) or by an EClass. In many cases such selction returns multiple EObjects, if you're only interested in one element set the firstOnly flag to true.

You might want to populate multiple workflow slots with model elements.

Below an example of a usage in the MWE XML syntax:

 <component class="org.eclipse.xtext.mwe.Reader" useJavaClassPath="true">
   <register class="foo.bar.MyLanguageSetandaloneSetup"/>
   <load slot="types" type="Type"/>
   <validate/> 
 </component>
 
It supports fetching elements by type IResourceServiceProvider#getResourceDescriptionManager() is used to identify model elements within these resources.

Author:
Sven Efftinge - Initial contribution and API

Field Summary
protected static org.apache.log4j.Logger log
           
protected  java.util.List<java.lang.String> pathes
           
 
Constructor Summary
Reader()
           
 
Method Summary
 void addPath(java.lang.String path)
           A path pointing to a folder, jar or zip which contains EMF resources.
protected  void checkConfigurationInternal(org.eclipse.emf.mwe.core.issues.Issues issues)
           
 ContainersStateFactory getContainersStateFactory()
           
 java.util.List<java.lang.String> getPathes()
           
protected  PathTraverser getPathTraverser()
           
 UriFilter getUriFilter()
           
protected  void installAsAdapter(org.eclipse.emf.ecore.resource.ResourceSet set, IAllContainersState containersState)
           
protected  void invokeInternal(org.eclipse.emf.mwe.core.WorkflowContext ctx, org.eclipse.emf.mwe.core.monitor.ProgressMonitor monitor, org.eclipse.emf.mwe.core.issues.Issues issues)
           
protected  void populateResourceSet(org.eclipse.emf.ecore.resource.ResourceSet set, com.google.common.collect.Multimap<java.lang.String,org.eclipse.emf.common.util.URI> uris)
           
 void setContainersStateFactory(ContainersStateFactory containersStateFactory)
           
 void setUriFilter(UriFilter filter)
          Optionally set a filter that specifies which URIs are valid to be read.
 void setUseJavaClassPath(boolean isUse)
           Automatically adds all class path entries of the current process (more specifically uses 'java.class.path' system property).
 
Methods inherited from class org.eclipse.xtext.mwe.AbstractReader
addLoad, addLoadFromResourceSet, addLoadResource, addModelElementsToContext, addRegister, getInjectors, getRegistry, getResourceDescriptionsProvider, getResourceSet, getResourceSetProvider, getSlotEntries, getValidator, setResourceDescriptionsProvider, setResourceSetProvider, setValidate
 
Methods inherited from class org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent2
checkConfiguration
 
Methods inherited from class org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent
checkRequiredConfigProperty, getBridge, getComponentName, getContainer, getId, getLocation, getLogMessage, invoke, invoke, postInvoke, preInvoke, setContainer, setId, setLocation, setSkipOnErrors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final org.apache.log4j.Logger log

pathes

protected java.util.List<java.lang.String> pathes
Constructor Detail

Reader

public Reader()
Method Detail

addPath

public void addPath(java.lang.String path)

A path pointing to a folder, jar or zip which contains EMF resources.

Example use:

<path value="./foo/bar.jar"/>


getPathes

public java.util.List<java.lang.String> getPathes()

setUseJavaClassPath

public void setUseJavaClassPath(boolean isUse)

Automatically adds all class path entries of the current process (more specifically uses 'java.class.path' system property).

Example use:

<useJavaClassPath value="true"/>


setUriFilter

public void setUriFilter(UriFilter filter)
Optionally set a filter that specifies which URIs are valid to be read. A common use-case for filters is a file-name based selection of valid URIs.


getUriFilter

public UriFilter getUriFilter()

setContainersStateFactory

public void setContainersStateFactory(ContainersStateFactory containersStateFactory)

getContainersStateFactory

public ContainersStateFactory getContainersStateFactory()

checkConfigurationInternal

protected void checkConfigurationInternal(org.eclipse.emf.mwe.core.issues.Issues issues)
Overrides:
checkConfigurationInternal in class AbstractReader

invokeInternal

protected void invokeInternal(org.eclipse.emf.mwe.core.WorkflowContext ctx,
                              org.eclipse.emf.mwe.core.monitor.ProgressMonitor monitor,
                              org.eclipse.emf.mwe.core.issues.Issues issues)
Specified by:
invokeInternal in class org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent

getPathTraverser

protected PathTraverser getPathTraverser()

populateResourceSet

protected void populateResourceSet(org.eclipse.emf.ecore.resource.ResourceSet set,
                                   com.google.common.collect.Multimap<java.lang.String,org.eclipse.emf.common.util.URI> uris)

installAsAdapter

protected void installAsAdapter(org.eclipse.emf.ecore.resource.ResourceSet set,
                                IAllContainersState containersState)
                         throws org.eclipse.emf.mwe.core.WorkflowInterruptedException
Throws:
org.eclipse.emf.mwe.core.WorkflowInterruptedException