Java Methods

Building blocks can contain operations. Their content is described by Java methods. The behavior of the building block determines when and in which sequence Java methods are called, and passes parameters to them. Java methods are edited in the usual context of JDT within Eclipse, which means that everything you know about Java programming in Eclipse applies also for Java operations of building blocks.

  • Java methods are never allowed to block or wait. This rule ensures that applications can be executed efficiently and stay responsive. If some code has to wait for an external response (for instance an HTTP request) there exist notification patterns to decouple the behavior.
  • Exceptions must be caught within the methods. Java methods that represent operations must not throw any exceptions. This means you have to think of all exceptions that may happen and handle them appropriately.
  • Since the operations in the graphical model refer to the Java methods by name, only one Java method with a certain name may exist, although Java allows several methods with the same name as long as they have a different signature.

Editing Java Methods

  • Select the operation from the context menu.

  • Click on a partition to create a new operation in that partition.
  • In the editor, create a new one by assigning a new name.

  • Double-click on the operation, and the corresponding Java method is revealed.

  • Now add any parameters by editing the signature of the method, and add a return type, if needed.

  • Once you save your java class and switch back to the behavior page of your block, the operation will updated with input and output pins.

Java methods referred to by the building block need to be public. You may also include private methods in the class for the building block, but these are invisible for the behavior of the block.

Note that an operation to be added to a block can also be selected from the context menu, if it is already available in the *.java page.

Renaming Java Methods

Currently, there is no automated refactoring support available to rename a Java methods, but you can do the following:

  • Rename the Java method in the Java source code.
  • Switch to the behavior view of the building block.
  • Open the context menu on the operation pointing to the Java method.
  • Select “Operation Code”, and point to the new name of the Java method.