简体   繁体   中英

Rhapsody plugin Java API, extremely slow execution

I have used Rhapsody Java API, to create a plugin for my rhapsody project. My problem is that it is extremely slow. I have the following function:

    private static void collectElements(final IRPModelElement curEl,
        final IRPCollection elCol) {
    // collect contained elements
    for (Object it : curEl.getNestedElements().toList()) {
        IRPModelElement element = (IRPModelElement) it;
        if (!skipElement(element)) {
            // add element itself
            elCol.addItem(element);

            // descend
            collectElements(element, elCol);
        }
    }
}

that collects all the nested elements of the selected element. My project has about 7500 elements and it takes 22 seconds to do the above function. I tried to get all the elements with selectedElement.getNestedElementsRecursive() and to work with List or HashSet, but the .toList() function is also extremely slow. Any suggestion?

For some reason, Rhapsody add-ins run much (much) faster when run within the internal Rhapsody virtual machine.

To do this, compile your java into a .jar and configure your model with a helper file to link a Rhapsody trigger (generally a tools menu or context menu option) to the jar.

Running add-ins this way uses the common Rhapsody virtual machine and is faster, but beware! The java version depends on what the Rhapsody version you're using is set up for and name clashes can be a problem (if you have multiple add-ins with 2 classes of the same name, Rhapsody will load in only one).

More information on setting up helper files can be found on Andy Lapping (an IBM employee)'s website here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM