Skip to main content
Kinetic Community

Sample Java Hello World

Calls into a simple Java "application" via an exposed Class and class method. The application returns a 'Message' result that represents a simple greeting.

Downloads

By downloading this file, you acknowledge that you agree to our Terms of Service

sample_java_hello_world_v1.zip

Detailed Description

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
Target An optional name to greet.  If this value is blank, the world will be greeted.

Sample Configuration

Parameter Example Configuration
Greeting Aloha
Target Luke Skywalker

Results

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

Change Log

Version Date Description
V1 2011-07-01 Initial Version