JBI Component development (Part 5)

Mapper component - LibMapper 

1. The Mapper component (LibMapper)

Components of the Mapper: LibMapper:

- WSDLParser using JAXB APIs to parse any WSDL as MyLib.wsdl (WSDLParser.jar).
WSDLParser parses the MyLib.wsdl to find the operation name from the NMR message input.

- Mapper component glues the Generic Service Engine with any Java Lib. (LibMapper.jar).
Mapper implements IMapper interface for dynamic loading from the SE. (JNIMapper.jar).
IMapper defines two methods:

- init(params): provides the wsdl name to the mapper.

- callLib(params): provides the:
DOM Node that content datas extracted from the NMR message.
messageInput name from the NMR message.


- JNIMapper: to glue the Generic Service Engine with the specific Java JNIWrapper (JNIMapper.jar).
JNIMapper extends Mapper for the specific JNIWrapper library.

To create the LibMappeur, use NetBeans and create a new Java project:LibMapper.
At the end of this topic the project will produce a LibMapper.jar file.


1.1. The WSDL parser

The WSDLParser will use the JAXB APIs to parse the any WSDL file.
To generate the JAXB classes we need to use the WSDL schema available at:
http://schemas.xmlsoap.org/wsdl/

To create the WSDLParser, use NetBeans and create a new Java project: WSDLParser.
At the end of this topic the project will produce a WSDLParser.jar file.

We need to use NetBeans to launch the JAXB wizard to generate the JAXB binding classes.


The illustration below shows the JAXB wizard.




The NetBeans wizard allows you to generate JAXB binding class from the wsdl schema:




Now we need to create a Java code to use the JAXB generated code.
We create a new Java class WSDLParser.class that will help us to manipulate the any WSDL data.


Three methods to manipulate the WSDL informations:

- unmarshall(String file);
- String finfOperationNameFromInput(String msgInput);
- String findMessageOutputNameFromOperation(String op);


For example unmarshall() method to parse the WSDL document:



We have created also a findOperationNameFromInput() method in the WSDLParser class.
This method allows us to find the operation name in the MyLib.wsdl from the input message provided by the NMR message. The operation name is the name of the method in the JNIWrapper library.




This WSDLParser + the generated JAXB binding code could be tested as a stand alone Java application:





For more details on JAXB see the JAXB jaxb.dev.java.net pages: https://jaxb.dev.java.net/


1.2. The Mapper

The Mapper component glues the Generic Service Engine with any Java Lib. (LibMapper.jar).
Mapper implements IMapper interface for dynamic loading from the SE. (JNIMapper.jar).

The IMapper interface is a common interface between the LibMapper and the LibWrapper Service Engine.
IMapper defines two methods:

- init(params): provides the wsdl name to the mapper.

- callLib(params): provides the:
DOM Node that content datas extracted from the NMR message.
messageInput name from the NMR message.


Any class that implement IMapper can be dynamically loaded by the Service Engine.

\* callLib(Params param) is the entrance point of the mapper from the Library Wrapper Service Engine.
The callLib method will be call at each NMR message dedicated to the Library Wrapper Service Engine.
The parameters of callLib provides the:

- method's name to call in the library.
- DOM that containt the parameters needed for the library method call.


\* Init(Params param); to perform initializations and called by the Service Engine when the Service Unit is deployed.


The Mapper class implements the IMapper interface and provides a:

- WSDL parsing by using the WSDLParser.


- libHandler(Params param) is an abstract method dedicated to any specific mapper that extends the Mapper class.
The libHandler method will be call at each NMR message dedicated to the Library Wrapper Service Engine. The parameter of the libHandler provide the:

- method's name to call in the library.
- DOM that contains the parameters needed for the library method call.


The illustration below shows the Mapper class that implements IMapper:




1.3. Build JNIMapper

The JNIMapper is specific for this use case, it implements the Mapper class to map the JNIWrapper library.

The abstract method libHandler must be implemented in the JNIMapper.
libHandler(String methodName, Node params) is an abstract method dedicated to any specific mapper that extend the Mapper class.
The libHandler method will be call at each NMR message dedicated to the Library Wrapper Service Engine. The parameter of the libHandler provide the:
- method's name to call in the library.
- DOM that containt the parameters needed for the library method call.

Inside the libHandler(Params param) we provide the code to call our specific JNIWrapper library methods.

The illustration below shows the implementation of the libHandler method:


See Part 6 ...

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Christophe Vaille

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today