uCosminexus Service Platform, Reception and Adapter Definition Guide
This subsection describes how to define custom adapters. You can define custom adapters in the Service Adapter Settings window.
One custom adapter can have multiple operations. For each operation, you need to design the operation name, communication model, request message, and response message.
The operation name is an identifier used for distinguishing operations when a service requester calls a service component, or when the invoke service activity of a business process calls a service component.
Specify a name (255 bytes or less) that is unique within the custom adapter. Do not specify the same name as another operation in the same custom adapter.
You can specify the following characters and symbols:
The protocol converter in a custom adapter uses the operation name to identify which operation was called when the custom adapter was called.
For a custom adapter, you can select the communication model for each operation. Select Sync or Async, depending on the service component to be called.
Design the message forms and message formats for the request message received by the protocol converter and for the response message used by the response protocol converter. However, if the communication model is Async, no response message is returned, so you do not have to define the response message.
For the message format, you can select XML or binary format.
The message format depends on whether the XML-format data or binary-format data (other than XML-format data) is used for the message used for executing the service component. Select either XML or binary format depending on the service component to be called, and create a message format depending on the service component to be called.
For details about the difference between XML and binary format, see 4.2 Message Format Types in the manual Service Platform Basic Development Guide.
For details about how to create a message format when XML-format data is used, see 4.3 Creating Message Formats (XML Format Definition File) in the manual Service Platform Basic Development Guide. For details about how to create a message format when binary-format data (other than XML-format data) is used, see 4.4 Creating Message Formats (Binary Format Definition File) in the manual Service Platform Basic Development Guide.
Data transformation is required if the message format received by the protocol converter designed in 3.3.14(1) Designing operations is different from the message format of a request from the service requester or business process. You can set the message format in the Service Adapter Settings window.
To perform data transformation of a message, set the transformation-source message format definition file and transformation-destination message format definition file, and then define data transformation in the Data-conversion definition screen.
For details about data transformation, see Chapter 6. Defining Data Transformation in the manual Service Platform Basic Development Guide.
Create definition files that are used by the protocol converter and custom adapter development framework.
Set the created definition files in the Service Adapter Settings window in the development environment.
The following describes the contents of the files to be created.
The protocol converter can read the contents of the resources set for a general custom adapter, via the adapter context.
Create this file if a file is necessary for operation of the protocol converter.
Specify the class name (including the package name) of the protocol converter used by the custom adapter development framework. Specify framework_properties.xml for the file name.
For details about the settings in the custom adapter development framework action definition file, see B.2(1) Custom adapter development framework action definition file.
Create this file as necessary (for example, when you want to have the protocol converter settings in an external file). This is a kind of self-defined file, and is used when a custom adapter is defined. Specify customadapter_properties.xml for the file name.
For details about the settings in the custom adapter property file, see B.2(2) Custom adapter property file.
You can use the HITACHI Application Integrated Property File for the custom adapter to set the parameters of the custom adapter according to your environment. Specify cscadapter_property.xml for the name of the HITACHI Application Integrated Property File for a custom adapter.
For details about the settings in the HITACHI Application Integrated Property File, see B.2(3) HITACHI Application Integrated Property File for custom adapter.
If you specify a HITACHI Application Integrated Property File, the value of <pooled-instance> of the Session Bean attribute will be the value specified in the HITACHI Application Integrated Property File.
You can use the custom adapter definition file to use the function for skipping message structure transformation (structure transformation skip function) during data transformation. Specify csccustomadapter.properties for the name of the custom adapter definition file.
For details about the settings in the custom adapter definition file, see B.2(4) Custom adapter definition file.
The following describes how to set the structure transformation skip function:
In data transformation for a request message, you might want to create a request message in binary format directly from the DOM tree received from a business process, and then pass the request message to a custom adapter. If so, you can enable the structure transformation skip function.
In data transformation for a response message, you might want to pass a DOM tree generated from the response message (in binary format, returned from a custom adapter) to the business process as is. If so, you can enable the structure transformation skip function.
To set the structure transformation skip function, in the Service Adapter Settings (details) window in the development environment, set the custom adapter definition file for Self-defined file.
For details about the Service Adapter Settings window, see 1.2.2 Service Adapter Definition Window in the manual Service Platform, Reference Guide.
The following are notes on using the structure transformation skip function:
Create a class file that implements the protocol converter (protocol conversion processing). The class file to be created implements the CSCMsgCustomProtocolConverter interface provided by the custom adapter development framework.
The protocol converter operates as part of the Stateless Session Bean running on the service platform. Therefore, when you create a class file, see the descriptions regarding EJB and Stateless Session Bean in the Application Server EJB Container Functionality Guide.
For details about the CSCMsgCustomProtocolConverter interface, see B.1(1)(a) CSCMsgCustomProtocolConverter interface. For details about example implementations, see B.3 Sample program of the custom adapter development framework.
The following describes what should be considered when you implement the protocol converter.
One custom adapter can have multiple instances. However, the protocol converter always has one instance. Therefore, when you implement the protocol converter, note that the protocol converter will be accessed by multiple threads.
Figure 3-30 Relationship between custom adapter instances and the protocol converter instance
The custom adapter development framework recommends the following methods to allocate resources for the protocol converter:
The protocol converter can access the resource files in the archive file by using the adapter context. When accessing a resource file in the archive file, note the following:
If an error occurs while the invoke method of CSCMsgCustomProtocolConverter is being executed, the protocol converter generates and issues an exception, or stores fault information in the response message.
Fault information is used to report a fault in a business operation that occurs while service component call processing (invoke method of CSCMsgCustomProtocolConverter) is being executed, to the custom adapter development framework.
An exception is used to report a system error (such as a communication error that occurs during the service component call processing) to the custom adapter development framework.
In the service adapter and business process that receive error information, there are the following differences between when a fault is used and when an exception is used:
You must specify, for the class path, the following JAR file that is used for the custom adapter development framework, and then compile the file:
installation-directory-of-the-service-platform\CSC\lib\csc_adapter.jar.
If you use a service platform API, separately add and compile the necessary JAR files.
The general names of the JAR files created during custom adapter development are classified as follows:
The following describes how to create individual JAR files.
Use the jar command to archive (to a JAR file) the protocol converter class file, the class file used by the protocol converter class file, and the custom adapter development framework action definition file.
The following shows the directory structure when necessary files are archived to a JAR file, and gives an example of specifying the jar command.
Table 3-82 Directory structure of JAR file when files are archived by the jar command
| Directory name or file name |
Description | Specification |
|---|---|---|
/ |
Root directory in the archive | R |
*.class |
Stores the protocol converters and the class files (*.class) of classes (interfaces) that the protocol converters depend on, into the directory hierarchy that conforms to the package name. | R |
framework_properties.xml |
Specifies the class name (including the package name) of the protocol converter used by the custom adapter development framework. | R# |
* |
Any resource files used by the protocol converter. You can create a directory, in which to store files. |
-- |
/META-INF/ |
Directory that stores management information. This directory is automatically created by the jar command. |
-- |
MANIFEST.MF |
The manifest file. This file is automatically created in the archive if the jar command is executed with the m option specified. |
-- |
framework_properties.xml protocolconverter/CustomProtocolConverter.class lib/MyLib.class data/table.dat |
jar cf ..\MyProtocolConverter.jar .\ |
Create library JAR files in the same way as general JAR files.
The following are notes on creating library JAR files.
Table 3-83 Example for when directory and file structures in the archive are the same
| Structure of A.jar | Structure of B.jar | Description |
|---|---|---|
myfile.txt |
-- | The file myfile.txt in A.jar is used. |
samedata.dat |
samedata.dat |
It cannot be determined whether the used file samedata.dat is the file in A.jar or B.jar. Do not use the same file name. |
dir/ |
dir/ |
You can use the same directory name. |
| -- | dir/b.class |
The file dir/b.class in B.jar is used. |
dir/same.class |
dir/same.class |
Whether the used file def/same.class is the file in A.jar or B.jar cannot be determined. Do not use the same file name. |
Create an EAR file (necessary for registering a new custom adapter).
To create an EAR file, use the jar command to archive JAR files provided by the service platform to an EAR file.
The following shows the directory structure when JAR files are archived to an EAR file, and gives an example of specifying the jar command.
Table 3-84 Directory structure of the EAR file to which JAR files are archived by the jar command
| Directory name or file name |
Description | Specification |
|---|---|---|
/ |
Root directory in the archive | R |
cscmsg_adpejb.jar |
Store the copy of the following file:installation-directory-of-the-service-platform\CSC\lib\cscmsg_adpejb.jar |
R |
/META-INF/ |
Directory that stores management information. This directory is automatically created by the jar command. |
-- |
MANIFEST.MF |
The manifest file. This file is automatically created in the archive if the jar command is executed with the m option specified. |
-- |
jar cf ..\CustomAdapter.ear .\ |
Set the EAR file when adding a custom adapter. If you need to modify the EAR file after adding a custom adapter, replace the EAR file in the Service Adapter Settings window of the custom adapter.
The EJB-JAR file names contained in the replacement EAR file must be the same as those (set when adding the custom adapter) in the EAR file. If the EJB-JAR file names are different, an error occurs when the EAR file is specified, and the EAR file cannot be set.
To replace the EAR file in the Service Adapter Settings window of the custom adapter:
To define a custom adapter:
All Rights Reserved. Copyright (C) 2015, Hitachi, Ltd.