Eclipse EMFT · A language for describing sequential workflows Designed to bind together various...

12
Eclipse EMFT Bernd Kolb [email protected] http://www.kolbware.de Peter Friese [email protected] http://www.gentleware.com

Transcript of Eclipse EMFT · A language for describing sequential workflows Designed to bind together various...

Page 1: Eclipse EMFT · A language for describing sequential workflows Designed to bind together various model-processing tools (initially in the context of oAW) Orchestrate the model processing

Eclipse EMFT

Bernd Kolb

[email protected]

http://www.kolbware.de

Peter Friese

[email protected]

http://www.gentleware.com

Page 2: Eclipse EMFT · A language for describing sequential workflows Designed to bind together various model-processing tools (initially in the context of oAW) Orchestrate the model processing

� 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

Page 3: Eclipse EMFT · A language for describing sequential workflows Designed to bind together various model-processing tools (initially in the context of oAW) Orchestrate the model processing

� 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

Page 4: Eclipse EMFT · A language for describing sequential workflows Designed to bind together various model-processing tools (initially in the context of oAW) Orchestrate the model processing

� 3 steps

public interface WorkflowComponent {

public void checkConfiguration(Issues issues);

public void invoke(WorkflowContext ctx, ProgressMonitor m, Issues i);

}

Parse

Check

Execute

Page 5: Eclipse EMFT · A language for describing sequential workflows Designed to bind together various model-processing tools (initially in the context of oAW) Orchestrate the model processing

�<?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[]

Page 6: Eclipse EMFT · A language for describing sequential workflows Designed to bind together various model-processing tools (initially in the context of oAW) Orchestrate the model processing

� 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();

}

Page 7: Eclipse EMFT · A language for describing sequential workflows Designed to bind together various model-processing tools (initially in the context of oAW) Orchestrate the model processing

� 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");

}

}

Page 8: Eclipse EMFT · A language for describing sequential workflows Designed to bind together various model-processing tools (initially in the context of oAW) Orchestrate the model processing

� 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;

}

Page 9: Eclipse EMFT · A language for describing sequential workflows Designed to bind together various model-processing tools (initially in the context of oAW) Orchestrate the model processing

� 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>

Page 10: Eclipse EMFT · A language for describing sequential workflows Designed to bind together various model-processing tools (initially in the context of oAW) Orchestrate the model processing

� 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.

Page 11: Eclipse EMFT · A language for describing sequential workflows Designed to bind together various model-processing tools (initially in the context of oAW) Orchestrate the model processing

� 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

� …

Page 12: Eclipse EMFT · A language for describing sequential workflows Designed to bind together various model-processing tools (initially in the context of oAW) Orchestrate the model processing

� www.openarchitectureware.org

� www.eclipse.org/gmt/oaw

� www.eclipse.org/emft