Eclipse EMFT
Bernd Kolb
http://www.kolbware.de
Peter Friese
http://www.gentleware.com
� A language for describing sequential workflows
� Designed to bind together various model-processing tools (initially in the context of oAW)
� Orchestrate the model processing chain
� Read a model
� Check the model
� Modify the model
� Store the model
� Generate code from that model
� The workflow engine itself� Several basic components for reading and writing Ecore-
based models� API lets you integrate your project with MWE
� Tool support
� Editor with code completion (using reflection) and outline
� Run as…
� Ant task
� Debug support
� Debug as…
� Simple API to add a debugger for your project
� 3 steps
public interface WorkflowComponent {
public void checkConfiguration(Issues issues);
public void invoke(WorkflowContext ctx, ProgressMonitor m, Issues i);
}
Parse
Check
Execute
�<?xml version="1.0"?><workflow>
<component class="org.eclipse.emf.mwe.utils.Reader">
<uri value=“platform:/resource/project-name/pathToFile.xmi”/>
<modelSlot value=“mySlot”/>
</component>
<component class=" org.eclipse.emf.mwe.utils.Writer“
uri=“platform:/resource/project-name/pathToOutputFile.xmi”
modelSlot=“mySlot” />
</workflow>
public class Reader {
//…
public void setUri(String uri) {
//…
}
}
� Supported Method prefixes
� Set, add, put, get
� Supported types
� String, boolean, int, String[]
� Components can communicate among each other
� Workflow slots – designed to pass models
� Report problems (Diagnostic)
▪ Errors
▪ Warnings
▪ Infos
public interface WorkflowContext {
public Object get(String slotName);
public void set(String slotName, Object value);
public String[] getSlotNames();
}
� Sample: OCL Engine integrationpublic void invoke(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) {
Object object = ctx.get(getModelSlot());
EObject context;
if (object instanceof EList) {
EList l = (EList) object;
context = (EObject) l.get(0);
} else {
context = (EObject) object;
}
if (isEMF) {
oclFactory = new EcoreOCLFactory(context);
} else {
oclFactory = new UMLOCLFactory(context);
}
OCL<?, Object, ?, ?, ?, ?, ?, ?, ?, Constraint, ?, ?> ocl =
oclFactory.createOCL();
OCLHelper<Object, ?, ?, Constraint> helper =
ocl.createOCLHelper();
boolean result = eval(issues, context, ocl, helper, exp);
if (!result) {
issues.addError(exp + " evaluated to false");
}
}
� Sample: OCL Engine integrationprivate boolean eval(Issues issues,
EObject context, OCL ocl, OCLHelper helper, String exp) {
// set our helper's context classifier to parse against it
helper.setContext(oclFactory.getContextClassifier(context));
try {
Constraint parsed = (Constraint) helper.createInvariant(exp);
return ocl.check(context, parsed);
} catch (Exception e) {
issues.addError("Exception while evaluating " + exp + ": " + e.getMessage(), e);
}
return false;
}
public void setOCLExpression(String exp) {
this.exp = exp;
}
� Sample: OCL Engine integration<workflow>
<component file='org/example/dsl/parser/Parser.oaw'>
<modelFile value='model/mymodel.dsl' />
<outputSlot value='test' />
</component>
<component
class="org.openarchitectureware.adapter.ocl.OCLWorkflowComponent">
<OCLExpression value="contents -> size() = 1" />
<modelSlot value="test" />
<isEMF value="true" />
</component>
<!-- will fail -->
<component
class="org.openarchitectureware.adapter.ocl.OCLWorkflowComponent">
<OCLExpression value="name = 'lalalala'" />
<modelSlot value="test" />
<isEMF value="true" />
</component>
</workflow>
� TCP-based; communication is handled by MWE� 2 extension points
� org.eclipse.emf.mwe.ui.debugAdapters
▪ Used for exchanging information between runtime and Eclipse
(breakpoints, suspend resume, variables, ...)
▪ Provide a class for the runtime-side
▪ Provide a class for the Eclipse-side
� org.eclipse.emf.mwe.ui.debugHandlers
▪ Typically you do not have to use it
▪ Used to specify the packages transported between the runtime-
side and Eclipse
▪ Implementations available for Breakpoints, Variables, etc.
� Get the build running
� Fix some minor problems (introduced during the refactoring)
� Provide support for execution in an OSGi environment
� Improve editor (Remove WTP dependency)
� Replace handwritten AST with an EMF-Model
� …
� www.openarchitectureware.org
� www.eclipse.org/gmt/oaw
� www.eclipse.org/emft
Top Related