Table of Contents

Using Connect Java rules versus function rules to call external Java methods

Summary

A developer asks: I have an existing Java class with fewer than a dozen methods that do computation and return a result (no I/O, no external data, no side effects).  I need to integrate these within a Process Commander application.  I have the Java source code for the class.

Design A:

Create a Rule-Utility-Library. Create a Rule-Utility-Function for each method.  Call the functions from an activity, expression, anywhere.

Design B:

Use a Rule-Connect-Java.  Create an activity that accepts a parameter to determine which original Java method to call.

When is Design B preferable?  Why?  Also, we do observe that for Design B, the app server needs to be stopped and restarted whenever the CLASS files change.



 

Suggested Approach

if it's a simple calculation you're trying to perform, where methods don't depend on each other, where you don't need to keep the code organized, where you don't need member variables – that is, it's less object-oriented and instead mere calculation - then the library and function rule approach is fine..

But if you're doing something that's more complex, requires saving state, and so on, it is better to code it in a Java class and then plug it in with a Connect Java rule.

The other benefits of Connect Java rules are:

  • You can use the Performance tool
  • You don't need the source code but can work with just the class files.
  • Tracer output is more complete. With Tracer you don't see the step where you're calling an external class if that's embedded within a function.

50% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.