7 Building Oracle Service Bus Projects with Maven
For more information about using the Oracle Service Bus development plug-in with Maven, see "Using the Oracle Service Bus Development Maven Plug-In" in Developing Services with Oracle Service Bus.
- Introduction to Building Oracle Service Bus Projects with Maven
Oracle Service Bus provides a Maven plug-in and three archetypes. - Creating an Oracle Service Bus Application from a Maven Archetype
You can create a new Oracle Service Bus application (containing an OSB Project and an OSB System Resources project) using the OSB Application Maven archetype. - Editing Your OSB Application in Oracle JDeveloper
You can edit your application in Oracle JDeveloper to define OSB resources. - Creating an Oracle Service Bus Project from a Maven Archetype
You can create a new Oracle Service Bus Project inside an existing OSB application using the OSB Project Maven archetype. - Building Your OSB Project with Maven
After you have written your project code, you can use Maven to build the your OSB project. - Deploying Your Project to the Oracle Service Bus Server with Maven
You can deploy your OSB project to the Oracle Service Bus server with Maven. - What You May Need to Know About the Oracle Service Bus Parent POM
The OSB Parent POM is provided as a point of customization. For example, you can use it to set some environment-wide defaults, such as the URL, user name, and password for your test server, then you may want to put these in the OSB Parent POM.
Introduction to Building Oracle Service Bus Projects with Maven
Oracle Service Bus provides a Maven plug-in and three archetypes.
The Maven coordinates are described in Table 7-1.
Table 7-1 Maven Coordinates with Oracle Service Bus
Name | GroupId | ArtifactId | Version |
---|---|---|---|
OSB plug-in |
|
|
|
OSB Application archetype |
|
|
|
OSB Project archetype |
|
|
|
OSB System Resources archetype |
|
|
|
Table 7-2 describes the goals supported by the Oracle Service Bus plug-in supports the following goals:
Table 7-2 Oracle Service Bus Plug-In Goals
Goal | Purpose |
---|---|
package |
Creates a service bus archive (SBAR) file from the project. |
deploy |
Deploys the SBAR file to a runtime environment. Note that this goal is mapped to the pre-integration-test phase in the default life cycle, not the deploy phase, as deployment to a runtime environment is usually done in the pre-integration-test phase in Maven. |
The custom packaging type sbar
is defined, representing an Oracle Service Bus archive.
Parent topic: Building Oracle Service Bus Projects with Maven
Creating an Oracle Service Bus Application from a Maven Archetype
You can create a new Oracle Service Bus application (containing an OSB Project and an OSB System Resources project) using the OSB Application Maven archetype.
To do so, run a command similar to the following:
mvn archetype:generate -DarchetypeGroupId=com.oracle.servicebus.archetype -DarchetypeArtifactId=oracle-servicebus-application -DarchetypeVersion=14.1.2-0-0 -DgroupId=org.mycompany -DartifactId=my-servicebus-application -Dversion=1.0-SNAPSHOT -DprojectName=my-project -DconfigJar=myjar.jar
This command runs Maven's archetype plug-in's generate goal which allows you to create a new project from an archetype. Table 7-5 describes the parameters.
Table 7-3 Parameters for the Oracle Service Bus Project
Parameter | Purpose |
---|---|
|
The group ID of the archetype that you want to use to create the new project. This
must be |
|
The artifact ID of the archetype that you want to use to create the new project.
This must be |
|
The version of the archetype that you want to use to create the new project. This
must be |
|
The group ID for your new project. This usually starts with your organization's domain name in reverse format. |
|
The artifact ID for your new project. This is usually an identifier for this project. |
|
The version for your new project. This is usually |
|
The name for the OSB project to create inside the application. This should be different from the name of the application (that is, |
|
Used to specify a precompiled This setting requires |
You can also run the command without any arguments, as shown in the following example. In this case, Maven displays a list of available archetypes and prompts you to enter the required information.
mvn archetype:generate
After creating your application, it contains the following files:
Table 7-4 describes the files included in the project.
Table 7-4 Files Created for the Oracle Service Bus Project
File | Purpose |
---|---|
|
The Maven Project Object Model (POM) file that describes your new application. It includes the Maven coordinates that you specified for your application. This POM is used to group all of the OSB projects that form part of this application. |
|
The Maven POM file that describes your new project. It includes the Maven coordinates that you specified for your project, and the appropriate plug-in definitions to use the Oracle Service Bus Maven plug-in to build your project into an SBAR file. |
|
A Maven Project Object Model (POM) file for building OSB system resources into a SBAR file. |
Parent topic: Building Oracle Service Bus Projects with Maven
Editing Your OSB Application in Oracle JDeveloper
You can edit your application in Oracle JDeveloper to define OSB resources.
To edit your application, first open the application in JDeveloper:
Your applications are opened in JDeveloper.
When you import an Oracle Service Bus application (or project)
into JDeveloper, you have the choice of creating a new application (or project)
directory, or simply creating the JDeveloper project files (jws
and
jpr
files) in the existing location:
-
To create a new copy of the application (or project) in a new directory, select the Also import source files into application option and provide a new directory in the import dialog box.
-
To create the JDeveloper files in the existing directory, do not select the Also import source files into application option, and select the existing directory when prompted for the project location.
Parent topic: Building Oracle Service Bus Projects with Maven
Creating an Oracle Service Bus Project from a Maven Archetype
You can create a new Oracle Service Bus Project inside an existing OSB application using the OSB Project Maven archetype.
To do so, run a command similar to the following, from your OSB Application root directory:
mvn archetype:generate -DarchetypeGroupId=com.oracle.servicebus.archetype -DarchetypeArtifactId=oracle-servicebus-project -DarchetypeVersion=14.1.2-0-0 -DgroupId=org.mycompany -DartifactId=my-second-project -Dversion=1.0-SNAPSHOT
This command runs Maven's archetype plug-in's generate goal, which allows you to create a new project from an archetype. Table 7-5 describes the parameters.
Table 7-5 Parameters for the Oracle Service Bus Project from a Maven Archetype
Parameter | Purpose |
---|---|
|
The group ID of the archetype that you want to use to create the new project. This
must be |
|
The artifact ID of the archetype that you want to use to create the new project.
This must be |
|
The version of the archetype that you want to use to create the new project. This
must be |
|
The group ID for your new project. This usually starts with your organization's domain name in reverse format. |
|
The artifact ID for your new project. This is usually an identifier for this project. It cannot be System, which is reserved for system resources. |
|
The version for your new project. This usually is |
You can also run the command without any arguments, as shown in the following example. In this case, Maven displays a list of available archetypes and prompts you to enter the required information.
mvn archetype:generate
Note that OSB Projects must be located inside an OSB Application.
After creating your project, it contains the following files:
Table 7-6 describes the files included in the project.
Table 7-6 Files Created for the Oracle Service Bus Project
File | Purpose |
---|---|
|
The Maven Project Object Model (POM) file that describes your new project, it includes the Maven coordinates that you specified for your project, and it also includes the appropriate plug-in definitions to use the OSB Maven plug-in to build your project into a SBAR file. |
Maven also updates the OSB Application POM file to include this new project. If you ran the preceding command in the application you created in Creating an Oracle Service Bus Application from a Maven Archetype, you would see the following in your OSB Application POM:
<modules> <module>my-project</module> <module>my-servicebus-project</module> <module>my-second-project</module> </modules>
Parent topic: Building Oracle Service Bus Projects with Maven
Building Your OSB Project with Maven
After you have written your project code, you can use Maven to build the your OSB project.
To build the SBAR file, run the following command:
mvn package -DoracleHome=/path/to/osbhome
The preceding command creates a SBAR file from your project and places it in:
project/.data/maven/sbconfig.sbar
The parameter in Table 7-7 may be specified for the packaging. You can specify it either in the POM file for the project or on the command line, as shown in the preceding example.
Table 7-7 Parameters for the Oracle Service Bus Plug-In package Goal
Parameter | Purpose |
---|---|
|
The location of the Oracle Home for Oracle Fusion Middleware. |
Parent topic: Building Oracle Service Bus Projects with Maven
Deploying Your Project to the Oracle Service Bus Server with Maven
You can deploy your OSB project to the Oracle Service Bus server with Maven.
To deploy the SBAR file, run the following command:
mvn pre-integration-test
You can specify the parameters in Table 7-8 for the deployment. You can specify them either in the POM file for the project or on the command line.
Table 7-8 Parameters for the Oracle Service Bus Plug-In deploy Goal
Parameter | Purpose |
---|---|
|
The location of the Oracle Fusion Middleware Oracle Home where OSB is installed. |
|
The URL of the server in the OSB domain. |
|
(optional) The name of the OSB customization file to use, if any. |
|
User name to be used for deployment. |
|
Password to be used for deployment. |
|
The name of the |
|
The name of the project. Use this parameter to specify the project for which the
|
To specify the parameters:
-
On the command line: Use the format
-Dparameter=value
, as shown in this example (note that you enter the whole command on one line):mvn pre-integration-test -DoracleServerUrl=http://test.server:7001 -DoracleUsername=weblogic -DoraclePassword=<password> -DconfigJar=D:\ServicebusApp\SBProject\.data\maven\sbconfig.sbar -DprojectName=SBProject
-
In your project POM file: Add a
plugin
section, as shown in the following example:<plugins> <plugin> <groupId>com.oracle.servicebus</groupId> <artifactId>oracle-servicebus-plugin</artifactId> <version>14.1.2-0-0</version> <extensions>true</extensions> <configuration> <oracleHome>/u01/osbhome</oracleHome> <oracleServerUrl>http://test.server:7001</oracleServerUrl> <oracleUsername>weblogic</oracleUsername> <oraclePassword><password></oraclePassword> </configuration> </plugin> </plugins>
Parent topic: Building Oracle Service Bus Projects with Maven
What You May Need to Know About the Oracle Service Bus Parent POM
The OSB Parent POM is provided as a point of customization. For example, you can use it to set some environment-wide defaults, such as the URL, user name, and password for your test server, then you may want to put these in the OSB Parent POM.
You can set these properties or define any other properties that you want to have available to OSB Projects. To refer to a property in your OSB Project POM, use the syntax $propertyName
. For example, $oracleServerName
would be replaced with osb_server1
in the following example.
Projects that are created from the OSB archetypes automatically use values from the OSB Parent POM if you do not override them.
The following is an example of an OSB Parent POM which defines some properties:
<properties> <!-- These two properties are defined in com.oracle.maven:oracle-common, you can overwrite them here. Users who do not want to add plain text password in their properties or pom file, should use the userConfigFile and userKeyFile options for deployment. --> <!-- <oracleUsername>USERNAME</oracleUsername> --> <!-- <oraclePassword>PASSWORD</oraclePassword> --> <!-- Change the default values according to your environment --> <oracleServerUrl>t3://localhost:7001</oracleServerUrl> <oracleServerName>osb_server1</oracleServerName> <oracleHome>/u01/osbhome</oracleHome> </properties>
Parent topic: Building Oracle Service Bus Projects with Maven