public class DXLEngine extends Object
Note that by default messages logged by the DXL scripts will be reported as errors by throwing an exception in the execute()
method.
Here is a snippet demonstrating how to use a DXLEngine:
DoorsApplication application = null; try { // Create a DOORS batch application PropertySet properties = new DefaultPropertySet(); properties.setProperty(Common.PREFERENCE_DOORS_IS_SILENT, true); properties.setProperty(Common.PREFERENCE_DOORS_PATH, "C:\\Program Files (x86)\\IBM\\Rational\\DOORS\\9.6\\bin\\doors.exe"); properties.setProperty(Common.PREFERENCE_DOORS_PORTSERVER, "36677@myServer"); properties.setProperty(Common.PREFERENCE_DOORS_USER, "myUser"); properties.setProperty(Common.PREFERENCE_DOORS_PASSWORD, "myPassword"); application = DoorsUtils.createApplication(properties); // Creates DXL code fragments // A fragment can be loaded from a URL (e.g. a file) DXLFragment fileFragment = DXLFileFragment.create(new File("c:\\dxl\\myScript.dxl").toURL()); // A fragment can be some DXL code dynamically inserted into a buffer DXLBufferFragment buffer = DXLBufferFragment.create(); buffer.append("// some DXL code to be executed"); DXLFragment[] fragments = new DXLFragment[] { fileFragment, buffer }; // Execute DXL script DXLEngine engine = new DXLEngine(application); engine.execute(fragments); } finally { if (application != null) { application.dispose(); } }
In case DXL execution does not perform as you would expect, you can turn debugging mode on.
Setting the Java System property -Ddoors.dxl.debug=true
makes the engine to trace the executions.
It reports the executed DXL files, the time it takes to execute and provides a hint on what the execution is for.
Moreover, DXL files generated by the engine are no longer deleted, so that you can review them, reproduce and fix the non expected behavior.
DXLBufferFragment
,
DXLFileFragment
Modifier and Type | Class and Description |
---|---|
static class |
DXLEngine.Context
The context under which a DXL execution is performed.
|
Constructor and Description |
---|
DXLEngine(DoorsApplication application)
Instantiates a engine that will use the specified DOORS client.
|
Modifier and Type | Method and Description |
---|---|
void |
addExecutionListeners(DXLExecutionListener listener)
Registers a listener that is notified when a DXL execution is about to start or is completed.
|
void |
execute(DXLFragment[] fragments)
Combines the specified DXL code fragments into a file and
requests the DOORS client to execute the resulting DXL script.
|
void |
execute(DXLFragment[] fragments,
DXLEngine.Context context)
Combines the specified DXL code fragments into a file and
requests the DOORS client to execute the resulting DXL script.
|
boolean |
isTrackingDXLErrors()
Determines whether messages logged during the DXL execution
must be reported as errors by throwing an exception in the
execute() method. |
void |
removeExecutionListeners(DXLExecutionListener listener)
Unregister a listener.
|
void |
setTrackingDXLErrors(boolean trackDXLErrors)
Sets whether messages logged during the DXL execution
must be reported as errors by throwing an exception in the
execute() method. |
public DXLEngine(DoorsApplication application)
application
- the DOORS client the engine must use to execute DXL scripts.public boolean isTrackingDXLErrors()
execute()
method.
Default value is true
.true
if messages logged during the DXL execution
must be reported as errorsexecute(DXLFragment[])
public void setTrackingDXLErrors(boolean trackDXLErrors)
execute()
method.trackDXLErrors
- the new value.public void addExecutionListeners(DXLExecutionListener listener)
listener
- a listener that is notified when a DXL execution is about to start or is completed.public void removeExecutionListeners(DXLExecutionListener listener)
listener
- the listener to remove.public void execute(DXLFragment[] fragments) throws org.eclipse.core.runtime.CoreException
fragments
- the fragments to combine into a DXL file.org.eclipse.core.runtime.CoreException
- if anything prevents the DXL script to execute properly.public void execute(DXLFragment[] fragments, DXLEngine.Context context) throws org.eclipse.core.runtime.CoreException
fragments
- the fragments to combine into a DXL file.context
- the context that provides information on the execution to perform, mostly for logging reason.org.eclipse.core.runtime.CoreException
- if anything prevents the DXL script to execute properly.