Sample Java Hello World Version 1

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.

Modifying This Handler

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.

Parameters

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.

Sample Configuration

Name Description
Greeting Hola
Name

Results

Name Description
Message The complete greeting returned by the SOAP service. This will be in a format similar to: {Greeting} {Target}!

Changelog

SampleJavaHelloWorld (2011-07-01)

  • Initial version. See README for details.


Related Handlers

Sample Command Line Hello World
Executes 'echo' from a command line, passing a "hello" string argument, and returns the standard out and standard error results. If the 'name' parameter is present, that person will be greeted. Otherwise the world will be greeted.
Sample Database Count
This is a sample handler that shows you how to count the amount of records are returned in a query to your database using JDBC. The handler will return an xml string containing the amount of records that were counted.
Sample Database Delete
This is a sample handler that shows you how to delete a record from your database using JDBC.
Sample Database Insert
This is a sample handler that shows you how to insert a record into your database using JDBC.
Sample Database Retrieve Multiple Records
This is a sample handler that shows you how to retrieve records from a database using JDBC.
Sample Database Retrieve
This is a sample handler that shows you how to retrieve a record from your database using JDBC. The handler will return an xml string containing data from all of the columns that the record returned.
Sample HTML to PDF
Converts an HTML string to a PDF.
Sample REST Hello World
Calls the 'EchoService' RESTful web service using, passing a "hello" string argument, and returns the result of the call. If the 'name' parameter is present, that person will be greeted. Otherwise, the world will be greeted.
Sample SOAP Hello World
Calls the SOAP based 'EchoService' web service, passing the desired greeting and target and returns the resulting message. If the 'name' parameter is present, that person will be greeted. Otherwise, the world will be greeted.

Looking for a workflow engine?

Learn more about the Kinetic Data Enterprise Workflow Platform Check it out Caret right circle