IBM Support

How to connect to a specific Rhapsody instance using Java API

Question & Answer


Question

How do you use Java API to connect to a specific Rhapsody instance when there are multiple IBM Rational Rhapsody instances with different version are running at the same time from the clients?

Cause

Java API RhapsodyAppServer.getActiveRhapsodyApplication() with Rhapsody v 8.0.1 or earlier would always connect to the first launched Rhapsody instance when multiple Rhapsody instances are running simultaneously. On the other hand, using COM API GetObject(,"Rhapsody.Application") would then always return the Rhapsody instance which is the last one being launched.

Therefore it is impossible to connect to a desired Rhapsody instance by using above mentioned APIs when multiple instances are active.

Background:

Rhapsody is a COM Server so when an instance is created, a new entry would be registered in system Running Object Table(ROT).

Rhapsody ver 8.0.1 or earlier, the entry representing one Rhapsody instance which registered in ROT has the same information. Although it is possible, it is not easy to connect to a specific instance by accessing ROT directly.

Answer

From Rhapsody 8.0.2, a new instance has been introduced and its version info along with the corresponding Process ID (PID) info will now be registered in ROT as a separated entry.
In addition, the following Java APIs are newly introduced into Rhapsody version 8.0.2 and above to be used to attach to a specific instance.

  • RhapsodyAppServer.getActiveRhapsodyApplicationIDList()
  • RhapsodyAppServer.getActiveRhapsodyApplicationByID(String arg0)
Using COM API GetObject(,"Rhapsody.Application") will then always return the Rhapsody instance which is the last one being launched.

Disclaimer

All source code and/or binaries attached to this document are referred to here as "the Program". IBM is not providing program services of any kind for the Program. IBM is providing the Program on an "AS IS" basis without warranty of any kind. IBM WILL NOT BE LIABLE FOR ANY ACTUAL, DIRECT, SPECIAL, INCIDENTAL, OR INDIRECT DAMAGES OR FOR ANY ECONOMIC CONSEQUENTIAL DAMAGES (INCLUDING LOST PROFITS OR SAVINGS), EVEN IF IBM, OR ITS RESELLER, HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

---------------------start---------------------

//retrieve all the entry info representing Rhapsody 8.0.2 or above instances from ROT

List<String> rhpInstanceList = RhapsodyAppServer.getActiveRhapsodyApplicationIDList();

//for each active instance ID, connect to the corresponding instance and output some info on GUI

for (String instanceID : rhpInstanceList) {


       IRPApplication app = RhapsodyAppServer.getActionRhapsodyApplicationByID(instanceID);

       app.writeToOutputWindows("", instance ID);


}

---------------------end---------------------

Additional Information:

  1. Since Rhapsody 8.0.2, using API IRPApplication.getApplicationConnectionString() could retrieve the connection string of a specific Rhapsody instance from ROT to further pass the info to an external program if required (e.g. plugin that invokes external Java process).

  2. Except Java API, you can also implement the same function in VB.Net, C# and etc. to directly read and analyse the contents from ROT. Even for Rhapsody instances previous to 8.0.2, you can also use other existed APIs to allocate the specific one by checking the opened model or version info.

[{"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.3;8.0.2","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21644501