Packaging a Java user-defined node

Before you start

You must have a user-defined node written in Java. This can be one of the provided sample nodes described in Sample node files, or a node you have created yourself using the instructions in either Creating a message processing or output node in Java or Creating an input node in Java.

There are two ways to package a user-defined node:
  • PAR
    A Plug-in Archive (PAR) is the deployment unit for Java user-defined nodes. The PAR contains the user-defined node classes and, if required as dependencies, can contain JAR files. A PAR file is a zip file with a .par file extension. The directory structure in the .par file has the following format:
    • /classes

      The user-defined node classes are stored in this location.

    • /lib

      JAR files that are required by the user-defined node are stored in this location. This directory is optional because it will not always be necessary to include JAR files.

    The following procedure describes how to package an example user-defined node, parexamplenode. In this example, the PAR is to be contained in par.example.parexamplenode.class with a JAR file dependency dependency.jar.
    1. Create the directory structure; for example,
      • /classes/par/example/parexamplenode.class
      • /lib/dep.jar
    2. Issue a zip utility command to create the PAR; for example,

      jar cvf parexample.par classes lib

    The PAR should be placed in the LIL path that is specified in Installing a user-defined extension on a broker domain.

  • JAR

    User-defined nodes can be packaged using a simple JAR. For example, if your node is defined in example/jarexamplenode.class, create the JAR by using the jar cvf jarexample.jar example command.

    The preferred way to package a Java user-defined node is to use a PAR file. This is because all dependencies can be packaged with the node, and each node is loaded in a separate classloader. Refer to User-defined node classloading for information on classloading.

Deployment dependencies

If a user-defined node requires an external package, this can be deployed in one of following ways:
  • The external packages can be added to the /lib directory in the deployed PAR.
  • For external packages that are shared between several node types, the packages can be added to one of the following locations:
    • The<workpath>/shared-classes/ directory.
    • The CLASSPATH environment variable, where all user-defined nodes that are in the broker installation can access the packages.