IBM Support

Testing API plugin execution with the RhapsodyCL command line application

Question & Answer


Question

Will the RhapsodyCL application allow plugins to complete before exiting?

Cause

You want to use the silent mode of the RhapsodyCL application whilst making use of your existing API scripts.

Answer

The answer is yes, RhapsodyCL will not exit before executing the following scenarios:

    a) executing a task implicitly on Rhapsody startup using the RhpPluginInit method or
    b) using the RhapsodyCL call command to execute a plugin directly.

Below we outline a procedure for testing the former (scenario a) by modifying and using one of the sample plugins provided with Rhapsody. This will call the API method generateEntireProject() from the plugin’s RhpPluginInit() method. This means that the code generation will run as soon as the project is opened (whether opened via Rhapsody or RhapsodyCL)

For more information on the latter (scenario b) please see the documentation on the RhapsodyCL call command.

A) Update the Simple Plugin example

  1. Open Eclipse, select a new workspace as “<RhapsodyInstallDir>\Samples\ExtensibilitySample\
  2. File > Import > Existing Projects into Workspace. Press the Select root Directory > Browse button and OK for the default selected directory.
  3. Several projects should be listed in the window. Deselect all except the Simple Plug-in:


  4. Press finish to import the project.
  5. Note that there are compile errors in the project. To resolve these right click the project and select properties. Modify the Java Build Path Library settings for the rhapsody.jar so that it matches your installation. Be sure to also modify the Native Library Location property also!
    For example:




  6. once completed successfully all compile errors should be resolved
  7. Open the SimplePlugin.java file in the editor.


    






  8. Modify the RhpPluginInit method by appending the following lines:



    m_rhpApplication.generateEntireProject();
    
m_rhpApplication.writeToOutputWindow(“Simple Plugin”, “Code Gen Completed”);

  9. Save the eclipse project

B) Add the Simple Plugin to a test project

  1. Open Rhapsody and create a new project in the “<RhapsodyInstallDir>\Samples\ExtensibilitySample\Simple Plug-in\TestProject directory
  2. File > Add profile. Select the profile “SimplePluginProfile.sbs” from the parent profile


  3. Save the project. You should see messages in the output window from the plugin:


    




  4. Close Rhapsody completely and reopen the same project. You should now see Code Generation message in the output window. Multiple instances of RhapsodyCL will launch. This may take some minutes to complete.
































C) Calling the project (and the Plugin) from the command line

  1. Open a command line prompt and change directory to “<RhapsodyInstallDir>\Samples\ExtensibilitySample\Simple Plug-in\TestProject
  2. Run RhapsodyCL loading your test project. This will automatically run code generation via the modified SimplePugin:

..\..\..\..\RhapsodyCL.exe -cmd=open .\Project.rpy

Note that, as before, the initial messages will be displayed but this time in the command prompt. The RhapsodyCL process will remain open while the plugin executes the code generation operation. Multiple RhapsodyCL processes are opened to spread the load of the code generation operation.




  3. Once it is complete Rhapsody will output a status message at the command prompt and the process will close

.


This concludes that the execution of a plugin is allowed to complete before the RhapsodyCL process exits.

[{"Product":{"code":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"General Information","Platform":[{"code":"PF033","label":"Windows"}],"Version":"8.0;8.0.1;8.0.2;8.0.3;8.0.4;8.0.5;8.0.6;8.1;8.1.1;8.1.2;8.1.2.1;8.1.3;8.1.4;8.1.5;8.2;8.2.1;8.3","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg22011390