Class 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 are examples of a usage in the MWE2 DSL and MWE XML syntax:

     component = org.eclipse.xtext.mwe.Reader {
       useJavaClassPath = true
       register = foo.bar.MyLanguageStandaloneSetup {}
       load = {
         slot = "types"
         type = "Type"
       }
       validate = org.eclipse.xtext.mwe.Validator { stopOnError = false }
     }
     
     <component class="org.eclipse.xtext.mwe.Reader" useJavaClassPath="true">
       <register class="foo.bar.MyLanguageStandaloneSetup"/>
       <load slot="types" type="Type"/>
       <validate/> 
     </component>
     
    It supports fetching elements by type IResourceServiceProvider.getResourceDescriptionManager() is used to identify model elements within these resources.
    • 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 comma-separated list of paths pointing to a folder, jar or zip which contains EMF resources.

        Example use (MWE2):

        path = "./foo/bar.jar,./src/main/model"

        Example use (MWE1):

        <path value="./foo/bar.jar,./src/main/model"/>
      • 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 (MWE2):

        useJavaClassPath = true

        Example use (MWE1):

        <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)
      • 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
      • 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