This handler package includes a lib/helloworld.jar package. This package includes a single Java class (for sample.helloworld.Greeter) that defines the static method "greet". This method takes two java.util.LinkedHashMap parameters (one for the task handler info values and one for the passed parameters) and returns another java.util.LinkedHashMap.
The handler init.rb file defines the typical handler class (in this case SampleJavaHelloWorldV1) with an #initialize and #execute method. The #initialize method builds up a java.util.LinkedHashMap for for the info values and parameters rather than a Ruby Hash so that they are easier to pass into the Java application. The #execute method calls the desired Java class method, passing in the two java.util.LinkedHashMap objects, and then iterates over the returned java.util.LinkedHashMap object (representing a map of result names to values) to build up the typical XML result.
To modify this handler, the process/info.xml and process/node.xml files will need to be adjusted as normal (in order to define the handler node info configuration values, input parameters, and output results. The only changes necessary to the handler/init.rb file are to change the class name and the Java code that is called (see below for the current Java code call). Java::sample.helloworld.Greeter.greet(@info_values, @parameters)
This particular handler includes the helloworld application as a .jar file included in the handler/lib directory. Java applications that are compiled as jar files and included in the handler/lib directory need to be manually included in the handler/init.rb file (as helloworld.jar is for this sample package). This is only required for java libraries that have not already been loaded in the JVM classloader (usually by being placed somewhere on the classpath). Any Java libraries or classes that were loaded by the JVM can be referenced without additional Ruby require statements.
If there are multiple handlers that are using the same library jar files, it is typically preferred to put those jar files somewhere on the JVM classpath (in the case of Tomcat, %WEBAPP_HOME%/WEB-INF/lib and omitting the manual include call in the handler/init.rb file. Please remember that any changes to the jar file will require a restart of the JVM (or web application server) to be picked up.
Name | Description |
---|---|
Greeting | The expression to use for a greeting. |
Name | An optional name to greet. If this value is blank, the task info default target will be greeted. |
Name | Description |
---|---|
Greeting | Hola |
Name |
Name | Description |
---|---|
Message | The complete greeting returned by the SOAP service. This will be in a format similar to: {Greeting} {Target}! |
SampleJavaHelloWorld (2011-07-01)
Learn more about the Kinetic Data Enterprise Workflow Platform Check it out