Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

Java Component Reference

Java

Java Component Reference

Overview

The Java component enables the developer to package custom Java code that executes when the component receives a message. The Java component can be used to enhance the functionality and capability of your web-based applications written in Java.

To configure the Java component, selecting a class is the only required entry. The class is simply a collection of properties, attributes and methods the component applies to all messages. In addition, this component allows you to optionally configure Singleton (object factory that creates an object instance) and Spring (object factory used to obtain Spring bean instances) object factories, which are invoked when a message is received. Singleton is simply the mode used to deploy the bean. The singleton object factory does not create a new instance for each request; instead, the instance is shared. On the other hand, the Spring object factory does not create any instances; it simply looks them up from Spring.

Lastly, the Java component allows you to configure interceptors. An interceptor enables the developer to provide additional synchronous that are executed on messages received by the Java component. Use interceptors to act on received messages, to log errors or exceptions, apply some business logic, or invoke additional Java services.

Configuration

If the application referencing Java expects a response, use a request-response endpoint to enable the Java component to communicate in a two-way fashion (See: below).

JavaRequestresponse

If Java is used to simply pass data to the next building block in the flow, the transaction is referred to as one-way. No response is required from the client (See: below).

JavaOneway

General Tab

The General tab lets you change the display name, select a class and enter the spring bean information this component will reference. To configure the Java component, from the Message Flow canvas double-click the component to open the Pattern Properties pane. Use the browse button to select a class for the component. Selecting a class is a required setting.

JavaGeneralClass

Field Description

Display Name

Defaults to the generic component name. Change the Display Name, which must be alpha-numeric, to reflect the transformer’s specific role, i.e. Custom Java Component.

Class Name

A class is a collection of properties, attributes and methods referenced by the component. Use the ellipse button to select a class. Type the first few characters of the class name to narrow the list of choices.

Object

This parameter allows the developer to define singleton and spring bean objects. When using a singleton bean, only one shared instance of the bean will be managed and all requests for beans with an id or ids matching this bean definition will result in this specific bean instance being returned. To configure a singleton bean, select an appropriate class that contains the required properties, attributes and methods. Configure the spring bean object to define the class that will be used to obtain the spring bean instances. The class attribute tells Spring which class to instantiate.

JavaGeneralObject

Advanced Tab

The Advanced tab lets you manage interceptors and select the object factory to be used by the component. An interceptor contains the business logic that is applied to the message payload before being sent to the next building block. You can add the following types of interceptors to the Java component:

  • Custom interceptor

  • Logging interceptor

  • Timer interceptor

If necessary, you can add an Abstract Lifecycle Adapter Factory, which enables the object to reference an alternative class when required. When configuring this factory it is required to select a class. In addition, you can use this panel to define the Spring bean property elements.

JavaAdvInterceptor

Panel Description

Interceptors Management

Interceptors enable the developer to provide additional services to the component such as the ability to log transactions and the ability to log the time for each transaction. Use the Add Custom Interceptor to create a custom interceptor that can be referenced by Spring bean objects. The Interceptor Stack enables you to bundle multiple interceptors. Use the Interceptor Stack to apply multiple interceptors on this Java component. The interceptors will be applied in the order defined in the stack.

Object Factory

A collection of properties, attributes and classes referenced by the component. The object factory must contain a class. To configure the object factory, select the plus add button then use the browse button to select a class. Configure the generic panel to enter spring bean element information.

JavaAdvObjectFactory

Field Description

Name

Enter the property name of the spring bean instance.

Value

Enter the value of the spring bean instance. e.g., it could be a string or Boolean. This spring instance can have a value or the spring instance can reference another spring bean.

Reference

Enter the name of the spring bean you want to reference. The value field is not used if you are referencing another spring bean.

Documentation Tab

The Documentation tab lets you add optional descriptive documentation for the Java component. Each component has a Documentation tab and optional Description field.

JavaDoc

Field Description

Documentation

Enter all relevant information regarding this Java component. This information is displayed in Studio when you hover over the transformer icon on the Message Flow canvas.

In this topic: