SummaryThis tutorial explains how you can make expose a EJB (2.x or 3.x) as a service in Petals ESB.
|
Creating the Service-Unit project
Getting started
Start Petals Studio.
In the menu, select File > New > Service-Unit Project.
If you do not see it, go into File > New > Other... Then, select Service-Unit Project under the Petals category.
A wizard opens up, showing three drop-down lists.
In the Use Case list, select Communication.
In the Petals Component list, select EJB // petals-bc-EJB.
In the Component Usage list, select Provide or Import a Service in Petals ESB.
In the Component Version list, select the version of the Petals-BC-EJB that you are using in Petals.
In the scope of this tutorial, we are going to work with the version 3.1 of the EJB component.
Which gives us:
Click Next.
Preparing the WSDL generation
To expose an EJB as a service in Petals, a WSDL has to be generated from the EJB's remote interface.
This way, the Petals SQL component is able to convert XML messages into Java objects that can be passed to the EJB as arguments.
The WSDL generation is prepared by the first page in the wizard.
The EJB libraries contain the EJB specific classes. They will be copied in the created project.
The Server libraires contain the required classes to compile the EJB classes. They will be used in the WSDL generation but will not be imported in the created project.
Once the libraries have been selected, the EJB's remote interface must be set. This can be done by selecting Browse.... A list of the classes located inside the EJB libraries will be displayed. The selection of the remote interface also completes the WSDL file name. Obviously, this name can be changed.
Note that there is no page to define the JBI fields (interface, service and end-point names). These values will be deduced from the generated WSDL definition. |
Defining the project name
This page defines the name and the location of the project that will be created.
Indeed, this wizard will result in the creation of a project containing all the required elements for a EJB service-unit.
Enter a project name for your project.
If you do not want your project to be created in the default workspace, uncheck Use default location.
Then click Browse... and select the location where the project will be created.
Petals service-units have a naming convention. For a service-unit which provides a service, the convention is su-<Protocol or Technology>-<Service name>-provide |
Then, click Next.
Specifying the EJB parameters
This page defines information which are specific to the Petals EJB component.
The required parameters are mostly about the JNDI properties of the EJB.
The meaning of all the parameters can be read in the documentation of the Petals-BC-EJB component.
Click Next.
Specifying the CDK parameters
The CDK is the Petals framework to develop JBI components.
The Petals-BC-EJB component was developed with this framework.
This page requires information related to the CDK.
By default, you have nothing to do here.
The meaning of all the CDK parameters for EJB can be found in the documentation of the Petals-BC-EJB component.
Click Finish to complete the wizard.
Checking the result
When the wizard has completed, a new project has been created and is visible in your workspace.
It contains a jbi.xml file, located under src/main/jbi.
This hierarchy allows you to work with Apache Maven then (a pom.xml was also created at the root of the project).
In the same directory, and if you provided a WSDL in the wizard, you can see your WSDL interface, which was imported with all its dependencies (e.g. referenced XML schemas or other WSDL interfaces).
Updating, packaging and deploying
Further edition and packaging
After completion, the newly created jbi.xml file has been open in the Service-Unit editor.
Regarding EJB configurations, the wizards are complete and provide all the options.
Thus, you do not need to edit the jbi.xml.
The project contains everything the EJB component needs.
You can now package it before deploying it.
The created project being a Service-Unit project, you can package it as any Service-Unit project.
It results in the creation of a Service Assembly for the Petals-BC-EJB component. Its location depends on your export choices.
Deployment
The deployment of the created service assembly can be achieved with the Petals web console.
Or you can do it by dropping the service assembly in the install directory of your Petals installation.
This second option should only be used in development steps.
First, make sure the Petals-BC-EJB is installed in your Petals environment.
Then, install the service assembly in your Petals, using one of the two ways indicated above.
Be careful, the Petals EJB component cannot be used as it.
It needs to be configured to use the shared-library associated with your EJB server.
You may also have to create this shared-library, in case where your EJB server is not supported by the Petals team.
Do not worry, creating a shared-library is very easy with the Petals Maven plug-in (provided you are familiar with Maven).
And configuring the EJB (or any other Petals) component to use a shared-library can be achieved with the Petals Maven plug-in.