Fusion Middleware Documentation
Advanced Search


Developing Applications Using Continuous Integration
Close Window

Table of Contents

Show All | Collapse

13 Building Oracle Service Bus Projects with Maven

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 sections:

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.

13.1 Introduction to Building Oracle Service Bus Projects with Maven

A Maven plug-in and three archetypes are provided for Oracle Service Bus. The Maven coordinates are described in Table 13-1.

Table 13-1 Maven Coordinates with Oracle Service Bus

Artifact groupId artifactId version

OSB plug-in

com.oracle.servicebus

oracle-servicebus-plugin

12.1.3-0-0

OSB Application archetype

com.oracle.servicebus

oracle-servicebus-application

12.1.3-0-0

OSB Project archetype

com.oracle.servicebus

oracle-servicebus-project

12.1.3-0-0

OSB System Resources archetype

com.oracle.servicebus

oracle-servicebus-system

12.1.3-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.

13.2 Creating an Oracle Service Bus Application from a Maven Archetype

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
    -DarchetypeArtifactId=oracle-servicebus-application
    -DarchetypeVersion=12.1.3-0-0
    -DgroupId=org.mycompany
    -DartifactId=my-servicebus-application
    -Dversion=1.0-SNAPSHOT
    -DprojectName=my-project

This command runs Maven's archetype:generate goal which allows you to create a new project from an archetype. Table 13-4 describes the parameters.

Table 13-2 Parameters for the Oracle Service Bus Project

Parameter Purpose

archetypeGroupId

Identifies the groupId of the archetype that you want to use to create the new project. This must be com.oracle.servicebus as shown in the preceding example.

archetypeArtifactId

Identifies the artifactId of the archetype that you want to use to create the new project. This must be oracle-servicebus-application as shown in the preceding example.

archetypeVersion

Identifies the version of the archetype that you want to use to create the new project. This must be 12.1.3-0-0, as shown in the preceding example.

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 1.0-SNAPSHOT for a new project.

projectName

The name for the OSB project to create inside the application. This should be different from the name of the application (that is, artifactId), and it cannot be System, which is reserved for system resources.


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:

Description of maven_dt_012.png follows
Description of the illustration maven_dt_012.png

Table 13-3 describes the files included in the project.

Table 13-3 Files Created for the Oracle Service Bus Project

File Purpose

pom.xml

This is 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

This is a Maven Project Object Model (POM) file for building OSB system resources into a sbar file.


13.3 Editing Your Application in Oracle JDeveloper

You can edit your application in Oracle JDeveloper to define OSB resources. To open the application:

  1. Open the File menu, then select Import….

  2. 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:

    Description of osb-image-1.png follows
    Description of the illustration osb-image-1.png

  3. In the Root Directory field, enter the path to the application you want to import into JDeveloper.

  4. 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.

  5. Click Refresh to load a list of projects available at that location.

  6. Select the projects that you want to import. Also select Update existing JDeveloper Projects to synch with imported POM files.

  7. 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. If you select the Also import source files into application option and provide a new directory in the import dialog box, JDeveloper creates a new copy of the application (or project) in a new directory. 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.

13.4 Creating an Oracle Service Bus Project from a Maven Archetype

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
 -DarchetypeArtifactId=oracle-servicebus-project
 -DarchetypeVersion=12.1.3-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. The following table describes the parameters:

Table 13-4 Parameters for the Oracle Service Bus Project from a Maven Archetype

Parameter Purpose

archetypeGroupId

Identifies the groupId of the archetype that you want to use to create the new project. This must be com.oracle.servicebus as shown in the preceding example.

archetypeArtifactId

Identifies the artifactId of the archetype that you want to use to create the new project. This must be oracle-servicebus-project as shown in the preceding example.

archetypeVersion

Identifies the version of the archetype that you want to use to create the new project. This must be 12.1.3-0-0 as shown in the preceding example.

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 1.0-SNAPSHOT for a new project.


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

This is 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 13.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>

13.5 Building Your Project with Maven

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.


13.6 Deploying Your Project to the Oracle Service Bus Server with Maven

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 the whole command would be entered on one line):

mvn pre-integration-test
     -DoracleServerUrl=http://test.server:7001
     -DoracleUsername=weblogic
     -DoraclePassword=welcome1

To specify the parameters 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.1.3-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>

13.7 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, 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>