Troubleshooting
Problem
Rational XDE 2003 introduces the RXE, which is the extensibility interface for XDE. It is possible to write pattern callouts that use this interface to get access to model information. These pattern callouts can be written using various programming languages, among which Java.
Resolving The Problem
PART 1: Creation of the pattern
-----------------------------------
Create a Simple Project called RXEPatternProject
Create one Blank Model called RXEPatternModel
Add a Pattern Asset called RASPackage with a pattern called RXEPattern
Add to the pattern some template parameters of various types
PART 2: Creation of the callout
-----------------------------------
Create one Java Project called RXEJavaPatternProject
Add references to the following two external .jar files:
C:\Program Files\Rational\XDE\xdepkg\rxe.jar
C:\Program Files\Rational\XDE \addins\codetemplates\codetemplates.jar
(assuming XDE was installed in the default location).
Add a Java package to the class, called "patterncallouts"
Add to this package a Java class called: PostApplyCalloutClass that implements:
com.rational.xde.pcc.rxe.interfaces.IRXEPatternsCallout
This interface contains only one method called Exec that is invoked by XDE when the specific callout event is fired.
When called, the Exec method passes to PostApplyCalloutClass a reference to an object that implements:
com.rational.xde.pcc.rxe.interfaces.IRXEPatternCalloutData
from which it's possible to get access to the running XDE application, the pattern templates parameters etc.
It is advisable to store this reference as a class data member as it's needed throughout the code:
</pre>
package patterncallouts;
import java.io.IOException;
import com.rational.xde.pcc.rxe.interfaces.IRXEPatCalloutData;
import com.rational.xde.pcc.rxe.interfaces.IRXEPatternsCallout;
public class PostApplyCalloutClass implements IRXEPatternsCallout {
private IRXEPatCalloutData theData;
public void Exec(IRXEPatCalloutData arg0) throws IOException {
theData = arg0;
}
}
The following example implements the class so that it loops over all template parameters, retrieves the associated elements and prints out their names and types:
package patterncallouts;
import java.io.IOException;
import com.rational.rxe.IRXEApplication;
import com.rational.rxe.IRXEElement;
import com.rational.rxe.IRXETemplateParameter;
import com.rational.rxe.IRXETemplateParameters;
import com.rational.rxe.IRXEUtil;
import com.rational.xde.pcc.rxe.interfaces.IRXEPatCTArgumentValue;
import com.rational.xde.pcc.rxe.interfaces.IRXEPatCalloutData;
import com.rational.xde.pcc.rxe.interfaces.IRXEPatternsCallout;
public class PostApplyCalloutClass
implements IRXEPatternsCallout {
private IRXEPatCalloutData theData;
private IRXEApplication theApplication;
private IRXEUtil theUtil;
public void Exec(IRXEPatCalloutData arg0)
throws IOException {
theData = arg0;
theApplication = theData.getRXE();
theUtil = theApplication.getUtil();
theUtil.writeToGuiOutputWindow(
"PostApply callout started\n", "");
LogParametersInfo();
theUtil.writeToGuiOutputWindow(
"PostApply callout ended\n", "");
}
private void LogParametersInfo() throws IOException {
IRXETemplateParameters theTemplateParameters;
theTemplateParameters =
theData.getPatternTemplate().getTemplateParameters();
for (short i = 1; i <= theTemplateParameters.getCount();
i++) {
IRXETemplateParameter theTemplateParameter;
theTemplateParameter =
theTemplateParameters.
getTemplateParameterByPosition(i);
theUtil.writeToGuiOutputWindow(
"Template Parameter Name: "
+ theTemplateParameter.getFullyQualifiedName()
+ "\n","");
Object[] theValues =
(Object[]) theData.lookupParameterValues(
theTemplateParameter.getName());
for (short j = 0 ; j
PART 3: Creation of the Jar file
-----------------------------------
To make the code available to the pattern, create a .jar file containing only this class with:
File -> Export: Jar file
Call the .jar file: RXEPattern.jar
PART 4: Adding the callout to the pattern
----------------------------------------------
Right click the pattern in the Model Explorer and choose Select in Pattern Explorer
Once in the Pattern Explorer, expand the Advanced Properties
Right click on Callout and choose Add Callout: PostApply
In the Pattern properties choose:
API Type: RXE
Enabled: checked
Callout Type: Java
Class Name: patterncallouts.PostApplyCalloutClass
Class Path: add the just created .jar file: RXEPattern.jar
PART 5: Applying the pattern
-----------------------------
Create a new Blank Model, in the simple project, called TargetModel
Add some model elements to give in input to the pattern.
Right click on the pattern and choose: Apply this pattern
Provide all the requested input values.
Inspect the Output window to see the results.
Note that a callout implemented with the Java language can be used in a pattern in any edition of XDE.
IBM
Historical Number
192284317
Was this topic helpful?
Document Information
Modified date:
29 September 2018
UID
swg21142861