This chapter provides details on how to use the Oracle Service Bus Maven archetypes to create, build, and deploy Oracle Service Bus applications.
This chapter contains the following topics:
Introduction to Building Oracle Service Bus Projects with Maven
Creating an Oracle Service Bus Application from a Maven Archetype
Creating an Oracle Service Bus Project from a Maven Archetype
Deploying Your Project to the Oracle Service Bus Server with Maven
What You May Need to Know About the Oracle Service Bus Parent POM
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.
A Maven plug-in and three archetypes are provided for Oracle Service Bus. The Maven coordinates are described in Table 14-1.
Table 14-1 Maven Coordinates with Oracle Service Bus
Artifact | groupId | artifactId | version |
---|---|---|---|
OSB plug-in |
com.oracle.servicebus |
oracle-servicebus-plugin |
12.2.1-0-0 |
OSB Application archetype |
com.oracle.servicebus |
oracle-servicebus-application |
12.2.1-0-0 |
OSB Project archetype |
com.oracle.servicebus |
oracle-servicebus-project |
12.2.1-0-0 |
OSB System Resources archetype |
com.oracle.servicebus |
oracle-servicebus-system |
12.2.1-0-0 |
The Oracle Service Bus plug-in supports the following 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 lifecycle, 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.
To create a new Oracle Service Bus application (containing an OSB Project and an OSB System Resources project) using the OSB Application Maven archetype, execute a command similar to the following:
mvn archetype:generate -DarchetypeGroupId=com.oracle.servicebus.archetype -DarchetypeArtifactId=oracle-servicebus-application -DarchetypeVersion=12.2.1-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:generate
goal which allows you to create a new project from an archetype. Table 14-4 describes the parameters.
Table 14-2 Parameters for the Oracle Service Bus Project
Parameter | Purpose |
---|---|
archetypeGroupId |
The groupId of the archetype that you want to use to create the new project. This must be |
archetypeArtifactId |
The artifactId of the archetype that you want to use to create the new project. This must be |
archetypeVersion |
The version of the archetype that you want to use to create the new project. This must be |
groupId |
The groupId for your new project. This usually starts with your organization's domain name in reverse format. |
artifactId |
The artifactId for your new project. This is usually an identifier for this project. |
version |
The version for your new project. This is usually |
projectName |
The name for the OSB project to create inside the application. This should be different from the name of the application (that is, |
-DconfigJar |
Used to specify a precompiled sbconfig.jar or .sbar file. This setting allows deployment of individual jar iles without previous fresh build. It can be an absolute path. This setting requires -DprojectName to be set as well. |
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 14-3 describes the files included in the project.
Table 14-3 Files Created for the Oracle Service Bus Project
File | Purpose |
---|---|
pom.xml |
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. |
my-project/pom.xml |
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. |
System/pom.xml |
A Maven Project Object Model (POM) file for building OSB system resources into a sbar file. |
You can edit your application in Oracle JDeveloper to define OSB resources. To open the application:
Open the File menu, then select Import….
In the Import dialog box, select the Maven Project option and click OK.
The Import Maven Projects dialog appears, as shown in the following figure:
In the Root Directory field, enter the path to the application you want to import into JDeveloper.
In the Settings File field, enter the path to your Maven settings.xml file. The default value is most likely correct unless you are using a non-standard location for your Maven settings file.
Click Refresh to load a list of projects available at that location.
Select the projects that you want to import. Also select Update existing JDeveloper Projects to synch with imported POM files.
Click OK to complete the import.
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.
To create a new Oracle Service Bus Project inside an existing OSB application using the OSB Project Maven archetype, execute 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=12.2.1-0-0 -DgroupId=org.mycompany -DartifactId=my-second-project -Dversion=1.0-SNAPSHOT
This command runs Maven's archetype:generate goal, which allows you to create a new project from an archetype. Table 14-4 describes the parameters.
Table 14-4 Parameters for the Oracle Service Bus Project from a Maven Archetype
Parameter | Purpose |
---|---|
archetypeGroupId |
The groupId of the archetype that you want to use to create the new project. This must be |
archetypeArtifactId |
The artifactId of the archetype that you want to use to create the new project. This must be |
archetypeVersion |
The version of the archetype that you want to use to create the new project. This must be |
groupId |
The groupId for your new project. This usually starts with your organization's domain name in reverse format. |
artifactId |
The artifactId for your new project. This is usually an identifier for this project. It cannot be System, which is reserved for system resources. |
version |
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:
my-second-project/ |-- pom.xml
The following table describes the file included in the project,:
File | Purpose |
---|---|
pom.xml | 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 Section 14.2, 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>
After you have written your project code, you can use Maven to build the project.
To build the SBAR file, execute 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 following parameter 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.
Parameter | Purpose |
---|---|
oracleHome | The location of the Oracle Home for Oracle Fusion Middleware. |
To deploy the SBAR file, execute the following command:
mvn pre-integration-test
You can specify the following parameters for the deployment. You can specify them either in the POM file for the project or on the command line.
Parameter | Purpose |
---|---|
oracleHome | The location of the Oracle Fusion Middleware Oracle Home where OSB is installed. |
oracleServerUrl | The URL of the server in the OSB domain. |
customization | (optional) The name of the OSB customization file to use, if any. |
oracleUsername | User name to be used for deployment. |
oraclePassword | Password to be used for deployment. |
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=welcome1
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>12.2.1-0-0</version> <extensions>true</extensions> <configuration> <oracleHome>/u01/osbhome</oracleHome> <oracleServerUrl>http://test.server:7001</oracleServerUrl> <oracleUsername>weblogic</oracleUsername> <oraclePassword>welcome1</oraclePassword> </configuration> </plugin> </plugins>
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>