JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle Java CAPS Adapter for Batch Tutorial     Java CAPS Documentation
search filter icon
search icon

Document Information

Oracle Java CAPS Adapter for Batch Tutorial

Importing Non-JBI Based Sample Projects

To Import a Non-JBI Based Sample Project

About the Oracle Java CAPS Business Process Manager Sample Project

Associating BPM Operators

Considerations for BPM Projects

Creating the bpBatch_Inbound_LocalFileIn_FTPOut Project

To Create a Project

Creating the bpBatch_Inbound_LocalFileIn_FTPOut Business Process

To Create the Business Process

Adding Business Rules to the Design Elements

To Create a Connectivity Map

To Generate the Connectivity Map

Creating an Environment

To Create an Environment

Configuring the Adapters' Properties

To Configure the BatchInbound Adapter Properties

To Configure the BatchLocalFile Adapter Properties

Configuring the BatchFTP Adapter Properties

Creating the Deployment Profile

To Create the Deployment Profile

Building and Deploying the Project

To Build the Project

To Deploy the Project

To Run the Sample

About the JCD Sample Projects

prjBatch_Inbound_FTPIn_LocalFileOut

prjBatch_Streaming

prjBatch_Record

prjBatch_Secure

JCD Components

Considerations for JCD Projects

The Adapter for Batch JCD Sample Projects

The prjBatch_Inbound_FTPIn_LocalFileOut Sample Project

To Create a Project

Creating the Java Collaboration Definitions

Creating the jcdBatch_Inbound_FTPIn_LocalFileOut Collaboration

To Create the jcdBatch_Inbound_FTPIn_LocalFileOut Collaboration

Using the Java Collaboration Editor

To Create the jcdBatch_Inbound_FTPIn_LocalFileOut Collaboration Business Rules

Creating a Connectivity Map

To Create a Connectivity Map

To Generate the Connectivity Map

Creating an Environment

To Create an Environment

Configuring the Adapters Properties

To Configure the BatchInbound Adapter Properties

Configuring the BatchFTP Adapter Properties

Building and Deploying the Project

To Build the Project

To Deploy the Project

To Run the Sample

The prjBatch_Streaming Sample Project

To Create a Project

Creating a Java Collaboration Definition

To Create the jcdBatch_Streaming Collaboration

Using the Java Collaboration Editor

To Create the jcdBatch_Streaming Collaboration Business Rules

To Create a Connectivity Map

To Generate the Connectivity Map

To Create an Environment

Configuring the Adapter Properties

To Configure the BatchInbound Adapter Properties

Configuring the BatchFTP Adapter Properties

Configuring the File Adapter Properties

Building and Deploying the Project

To Build the Project

To Deploy the Project

To Run the Sample

The prjBatch_Record Sample Project

To Create a Project

Creating a Java Collaboration Definition

To Create the jcdBatch_Record Collaboration

Using the Java Collaboration Editor

To Create the jcdBatch_Record Collaboration Business Rules

To Create a Connectivity Map

To Generate the Connectivity Map

To Create an Environment

Configuring the Adapter Properties

To Configure File Adapter Connectivity Map Properties

To Modify the File Adapter Environment properties

To Configure the BatchRecord Adapter Properties

To Modify the BatchRecordParse Adapter Connectivity Map properties

To Modify the BatchRecord Adapter Environment properties

To Create the Deployment Profile

Building and Deploying the Project

To Build the Project

To Deploy the Project

To Run the Sample

The prjBatch_Secure Project

The prjBatch_Secure Project Components

The prjBatch_Secure Project Collaboration Definitions

To Create the jcdBatchFTPOverSSL Java Collaboration

To Create the jcdBatchSCP Java Collaboration

To Create the jcdBatchSFTP Java Collaboration

Collaboration Business Rules

jcdBatchFTPOverSSL Business Rules

jcdBatchFTPOverSSL Java Source File

jcdBatchSCP Business Rules

jcdBatchSCP Java Source File

jcdBatchSFTP Business Rules

jcdBatchSFTP Java Source File

Completing the prjBatch_Secure Project

To Create an Environment

Configuring the Adapter Properties

To Configure the File Adapter Connectivity Map properties

To Modify the File Adapter Environment properties

To Modify the Batch/FTP Adapter Connectivity Map Properties

To Modify the BatchFTPoverSSL Adapter Environment Properties

To Create the Sample Directories

To Create the Deployment Profile

Building and Deploying the Project

To Build the Project

To Deploy the Project

To Run the Sample

The prjBatch_Record Sample Project

The prjBatch_Record Project demonstrates the following:

  1. The inbound FileIn Adapter polls the input directory periodically. When it sees the specified file, it renames the file by adding .~in to the end, and triggers the Java Collaboration.

  2. The Collaboration generates a string. This string is converted into a record using BatchRecordCreate. The record is appended to the payload of BatchRecordCreate.

  3. The operation in Step 2 is repeated 10 times, resulting in 10 records in the BatchRecordCreate payload.

  4. The BatchRecordCreatepayload is copied to the FileOut payload.

  5. The outbound FileOut Adapter writes the payload to an output file.

  6. The Collaboration takes the BatchRecordCreate payload, and uses BatchRecordParse to parse the records.

  7. Each parsed record is copied to the FileOut payload, and the FileOut Adapter writes the payload to the output file.

  8. The operation in Step 7 is repeated until all 10 records are retrieved.

To Create a Project

The first step is to create a new Project in the NetBeans IDE.

  1. Start the NetBeans IDE.
  2. Click the New Project icon, or select File ⇒ New Project to initiate the New Project wizard.
  3. In Step 1 of the Wizard, select CAPS ⇒ ESB from the Categories column and CAPS Repository-Based Project from the Projects column, and click Next.
  4. In Step 2 of the Wizard, specify your Project Name (for this Project, use prjBatch_Record), and click Finish.

Creating a Java Collaboration Definition

The next step in the sample is to create a Java Collaboration using the Java Collaboration Definition Wizard. Once a Collaboration Definition has been created, the Business Rules of the Collaboration are written using the Collaboration Editor.

To Create the jcdBatch_Record Collaboration

  1. From the Projects window, right-click the prjBatch_Record Project and select New ⇒ Collaboration Definition (Java) from the context menu.

    The Collaboration Definition Wizard (Java) appears.

  2. Enter a Collaboration Definition name (for this Project, use jcdBatch_Record) and click Next.
  3. For Step 2 of the Wizard, from the Web Services Interfaces selection window, double-click CAPS Components Library⇒Adapters⇒File⇒FileClient⇒receive.

    The Name field now displays receive.

  4. Click Next.
  5. For Step 3 of the Wizard, from the Select OTDs selection window, double-click CAPS Components Library⇒Adapters⇒BatchAdapter⇒BatchRecord.

    The BatchAdapter.BatchRecord OTD is added to the Selected OTDs field.

  6. Double-click the BatchRecord_1 Instance Name and rename the instance to BatchRecord_Create.
  7. From the Select OTDs selection window, double-click CAPS Components Library⇒Adapters⇒BatchAdapter⇒BatchRecord again.

    Another BatchAdapter.BatchRecord OTD is added to the Selected OTDs field.

  8. Double-click the BatchRecord_2 Instance Name and rename the instance to BatchRecord_Parse.
  9. Click the Up One Level button.
  10. Double-click CAPS Components Library⇒Adapters⇒File⇒FileClient.

    The FileClient OTD is added to the Selected OTDs field.

  11. Click Finish.

    The Java Collaboration Editor opens to the new Collaboration in the right pane of the NetBeans IDE.

Using the Java Collaboration Editor

The prjBatch_Record Project uses the jcdBatch_Record Collaboration created in To Create the jcdBatch_Record Collaboration. To complete the Collaboration, use the Collaboration Editor to create the Business Rules.

To Create the jcdBatch_Record Collaboration Business Rules

Be careful to open all nodes specified in the directions to connect the correct items. The completed business appears as follows in the Java Collaboration Definition Editor's Business Rules Designer.

image:Image shows the JCD Editor view of the jcdBatch_Record collaboration business rules
  1. From the Projects window, double-click jcdBatch_Record.

    The Java Collaboration Editor opens to the jcdBatch_Record Collaboration.

  2. To create commentsfor the Business Rules, from the Business Rules toolbar, click the comment icon.

    The Enter a Comment dialog box appears. The comment is placed on the Business Rules tree under the last selected item.

  3. Enter the comment and click OK.

    Once the Comment is created, it can be moved by clicking the comment and dragging it up or down the Business Rules tree to a new location.

  4. Create the Create uninitialized variable loopCount (of type int) variable:

    The Create uninitialized variable loopCount (of type int) rule defines a loop count integer variable

    1. From the Business Rules toolbar, click the Local Variable icon.

      The Create Variable dialog box appears.

    2. Enter loopCount as the name of the variable.

      The new variable is added to the Business Rules tree.

    3. For Type, select Primitive of type int, and click OK.
  5. Create the Create uninitialized variable recordStr (of type String) variable:

    The Create uninitialized variable recordStr (of type String) rule defines String called recordStr .

    1. From the Business Rules toolbar, click the Local Variable icon.

      The Create Variable dialog box appears.

    2. Enter recordStr as the name of the variable.
    3. From the Create Variable dialog box Type field, select Class and click the ellipsis button.

      The Class Browser dialog box appears.

    4. From the Class Browser dialog box, select String in the All Classes field, and select String in the String field.
    5. Click Select to close the Class Browser dialog box and click OK to close the Create Variable dialog box.

      The new variable is added to the Business Rules tree.

  6. Create the For Loop:

    The For Loop and its Business Rules create ten records, each incremented by 1 (as a String). It does a put for each incremented record until the payload contains ten records.

    1. From the Business Rules toolbar, click the For Loop icon.

      A For Loop is added to the Business Rules tree.

    2. From the Business Rules tree, select counter initialization under the For Loop.
    3. From the Business Rules Designer’s Math menu, select Literal Number.

      The Number literal box appears.

    4. Double-click the value field of the Number literal box and enter 1 as the Literal Number value.
    5. Map the 1 output node of the Number literal box to the loopCount variable in the right pane of the Business Rules Designer.
  7. Under the For Loop, create the condition, loopCount is less than 11:
    1. From the Business Rules tree, select the condition under the For Loop.
    2. From the Business Rules Designer’s Comparison menu, select Less Than.

      The Less Than method box appears.

    3. Double-click the number2 value field of the Less Than method box and enter 11 as the value.
    4. Map the loopCount variable in the left pane of the Business Rules Designer, to the number1 input node of the Less Than method box.
    5. Map the result(boolean) output node of the Less Than method box, to condition variable in the right pane of the Business Rules Designer.
  8. Under For Loop steps, create the increment loopCount rule:
    1. From the Business Rules tree, select steps under the For Loop.
    2. From the Business Rules Designer’s Math menu, select Increment.

      The Increment method box appears.

    3. Map the loopCount variable in the left pane of the Business Rules Designer, to the number input node of the Increment method box.
  9. Under For Loop rules, create the Copy "Record" + intToString(loopCount) to recordStr rule:
    1. From the Business Rules tree, select rules under the For Loop.
    2. Map the loopCount variable in the left pane of the Business Rules Designer, to the recordStr variable in the right pane of the Business Rules Designer.

      The Number to String Conversion dialog box appears.

    3. Click OK to accept the default values.

      The intToString method box appears.

    4. From the Business Rules Designer canvas, click the link between the result(String) output node of the intToString method box and the recordStr variable in the right pane of the Business Rules Designer.
    5. With the link selected, press the Delete key to break the link.
    6. From the Business Rules Designer’s String menu, select Add.

      The Add method box appears.

    7. Double-click the value1 value field of the Add method box and enter Record as the value.
    8. Map the result(String) output node of the intToString method box, to the value2 input node of the Add method box.
    9. Map the result output node of the Add method box, to the recordStr variable in the right pane of the Business Rules Designer.
  10. Create the Copy recordStr.Bytes to BatchRecord_Create.Record rule under For loop rules:
    1. Right-click the recordStr variable in the left pane of the Business Rules Designer and select Browse this type from the context menu.

      The Class Browser dialog box appears.

    2. From the Class Browser dialog box, select String in the All Classes field and getBytes() in the String field.
    3. Click Select.

      The getBytes method box appears.

    4. Map the result(byte[]) output node of the getBytes method box, to Record under BatchRecord_Create in the right pane of the Business Rules Designer.
  11. Create the BatchRecord_Create.put rule under FOR Loop rules:
    1. Right-click BatchRecord_Create in the left pane of the Business Rules Designer and select Select method to call from the context menu.

      The method selection window appears.

    2. Select put() from the method selection window.

      The put method box appears.

  12. Create the BatchRecord_Create.finish rule:
    1. From the Business Rules tree, select the For Loop, and from the Business Rules toolbar click the rule icon to create a new rule.
    2. Right-click BatchRecord_Create in the left pane of the Business Rules Designer, and choose Select method to call from the context menu.

      The method selection window appears.

    3. Select finish() from the method selection window.

      The finish method box appears in the Business Rules Designer canvas.

  13. Create the Copy BatchRecord_Create.Payload to FileClient_1.ByteArray rule:

    The Copy BatchRecord_Create.Payload to FileClient_1.ByteArray sets the ByteArray of the File Adapter to the payload.

    1. Click rule on the Business Rules toolbar to add a new rule in the Business Rules pane.
    2. Map Payload under BatchRecord_Create in the left pane of the Business Rules Designer, to ByteArray under FileClient_1 in the right pane of the Business Rules Designer.
  14. Create the FileClient_1.writeBytes rule:
    1. Click rule on the Business Rules toolbar to add a new rule in the Business Rules pane.
    2. Right-click FileClient_1 in the left pane of the Business Rules Designer, and click Select method to call from the context menu.

      The method selection window appears.

    3. Select writeBytes() from the method selection window.

      The writeBytes method box appears.

  15. Create the Copy BatchRecord_Create.Payload to BatchRecord_Parse.Payload rule:

    The Copy BatchRecord_Create.Payload to BatchRecord_Parse.Payload rule copies the payload to the BatchRecord_Parse Adapter.

    1. Click rule on the Business Rules toolbar to add a new rule in the Business Rules pane.
    2. Under BatchRecord_Create in the left pane of the Business Rules Designer, map Payload to Payload under BatchRecord_Parse in the right pane of the Business Rules Designer.
  16. Create the While statement:

    The While statement and its Business Rules parse the ten records and publishes each record to the File Adapter.

    1. From the Business Rules toolbar, click the While icon.

      A While statement is added to the Business Rules tree.

    2. From the Business Rules tree, select condition under the While statement.
    3. Right-click BatchRecord_Parse in the left pane of the Business Rules Designer, and click Select method to call from the context menu.

      The method selection window appears.

    4. Select get() from the method selection window.

      The get method box appears.

    5. Map the result(boolean) output node of the get method box to condition in the right pane of the Business Rules Designer.
  17. Create the Copy BatchRecord_Parse.Record to FileClient_1.ByteArray rule under the While statement rules:
    1. From the Business Rules tree, select rules under the While statement.
    2. Under BatchRecord_Parse in the left pane of the Business Rules Designer, map Record to ByteArray under FileClient_1 in the right pane of the Business Rules Designer.
  18. Create the FileClient_1.writeBytes rule under the While statement rules:
    1. Click rule on the Business Rules toolbar to add a new rule in the Business Rules pane.
    2. Right-click FileClient_1 in the left pane of the Business Rules Designer, and click Select method to call from the context menu.

      The method selection window appears.

    3. Select writeBytes() from the method selection window.

      The writeBytes method box appears.

  19. Create the BatchRecord_Parse.finish rule
    1. From the Business Rules tree, select the While statement, and from the Business Rules toolbar click the rule icon to create a new rule.
    2. Right-click BatchRecord_Parse in the left pane of the Business Rules Designer, and choose Select method to call from the context menu.

      The method selection window appears.

    3. Select finish() from the method selection window.

      The finish method box appears.

  20. From the editor’s toolbar, click Validate to check the Collaboration for errors.
  21. Save the Project.

To Create a Connectivity Map

The Connectivity Map provides a canvas for configuring a Project’s components.

  1. In Projects window, right-click the new Project (prjBatch_Record) and select New⇒Connectivity Map from the context menu.

    The New Connectivity Map appears and a node for the Connectivity Map is added under the Project, on the Project tree, labeled CMap1.

  2. Rename the Connectivity Map to cmBatch_Record.

To Generate the Connectivity Map

Once your Java Collaboration Definition is completed you can use it to generate your Connectivity Map. Generating the Connectivity Map will automatically populate the canvas with the correct components and bind the components according to the information provided by the Java Collaboration Definition.

  1. Drag and drop the jcdBatch_Record Java Collaboration Definition from the Project window to the Connectivity Map canvas.

    The cmBatch_Record_jcdBatch_Record service is added to the canvas.

  2. Click the Connectivity Map Generator icon. The Connectivity Map Generator dialog box appears listing the necessary components and bindings to generate the Connectivity Map. Click OK.

    The External applications are added to the Connectivity Map and the Bindings are created. The red squares in the bindings represent the Batch Adapters. The red color indicates that the adapter properties have not been configured.

  3. Save your current work.

To Create an Environment

Environments include the External Systems, Logical Hosts, Application Servers and Message Servers used by a Project and contain the configuration information for these components.

  1. From the NetBeans IDE, click the Services tab.
  2. Right-click CAPS Environment and select New Environment.
  3. Rename the new Environment envBatch_Record.
  4. Right-click the envBatch_Record Environment and select New ⇒File External System.
  5. Name this External System esFile.

    The esFile window is added to the Environment Editor.

  6. Right-click envBatch_Record and select New⇒BatchRecord External System.
  7. Name this External System esBatchRecord.
  8. Right-click envBatch_Record and select New Logical Host.

    The LogicalHost1 box is added to the Environment and LogicalHost1 is added to the Environment Editor tree.

  9. From the Services tree, right-click LogicalHost1 and select New⇒Sun Java System Application Server.

    A new Application Server is added to the Services tree under LogicalHost1.

  10. Save the Project.

Configuring the Adapter Properties

The prjBatch_Record Project uses four Adapters, each represented in the Connectivity Map as a node between an External Application and a Service.

To Configure File Adapter Connectivity Map Properties

The inbound File Adapter properties are set from the Connectivity Map.

  1. Double-click the inbound FileIn1 Adapter, located between the FileIn1 External Application and the jcdBatch_Record1 service.

    The Properties Editor opens to the inbound File Adapter properties.

  2. Modify the configuration for your system, including the settings in the following table.
    Inbound File Adapter Connectivity Map Properties
    Parameter Settings - Set as directed, otherwise use the default settings
    Input File Name
    FileInput.txt
  3. From the Connectivity Map, modify the outbound FileOut1 Adapter configuration for your system, including the settings in the following table.
    Outbound File Adapter Connectivity Map Properties
    Parameter Settings - Set as directed, otherwise use the default settings
    Output File Name
    FileOutput.txt

To Modify the File Adapter Environment properties

  1. From the Services tree, right-click the esFile External System, and select Properties.

    The Properties Editor opens to the File Adapter Environment properties.

  2. Modify the File Adapter Environment properties for your system, including the settings in the following table, and click OK.
    File Adapter Environment Properties
    Inbound File⇒Parameter Settings - Set as directed, otherwise use the default settings.
    Directory
    An input directory on your system that the inbound File Adapters poll and pick up any specified input files.
    Outbound File Adapter⇒Parameter Settings - Set as directed, otherwise use the default settings.
    Directory
    An output directory to which the outbound File Adapter publishes (writes) the output messages.

To Configure the BatchRecord Adapter Properties

The BatchRecord_Create Adapter’s specific properties are set from the Connectivity Map.

To Modify the BatchRecordParse Adapter Connectivity Map properties

  1. From the Connectivity Map, double-click the BatchRecordParse Adapter.

    The Properties Editor opens to the Adapter’s Connectivity Map properties.

  2. Modify the configuration for your system, including the settings in the following table.
    BatchRecordParse Connectivity Map Properties
    General Settings - Set as directed, otherwise use the default settings
    Parse or Create Mode
    Parse
    Record - Set as directed, otherwise use the default settings
    Delimiter on Last Record
    No
    Record Delimiter
    ~
    Record Type
    Delimited

To Modify the BatchRecord Adapter Environment properties

The BatchRecordCreate and BatchRecordParse Adapters share the same Environment Properties. The default BatchRecord Adapter Environment property settings can be used for this Project, but they must be accepted.

  1. From the Services tree, right-click the esBatchRecord External System, and select Properties.

    The Properties Editor opens to the BatchRecord Adapter Environment properties.

  2. Click OK to accept the default settings and close the Properties Editor.
  3. Save the current changes to your Repository.

To Create the Deployment Profile

A Deployment Profile is used to assign Collaborations and message destinations to the Application Server and message server. Deployment Profiles are created using the Deployment Editor.

  1. From the Projects window, right-click the Project (prjBatch_Record) and select New ⇒ Deployment Profile.
  2. Enter a name for the Deployment Profile (for this sample dpBatch_Record).

    Make sure that the selected Environment is envBatch_Record .

  3. Click OK.
  4. Click Automap.

    The Project’s components are automatically mapped to their respective system windows.


    Note - If any of your Project components did not successfully map to an external system, open each of your Adapter’s configuration properties (Connectivity Map and Environment) and click OK to close and save the current configuration, then click Automap again.


  5. Save the Project.

Building and Deploying the Project

The Build process compiles and validates the Project’s Java files and creates the Project EAR file.

To Build the Project

  1. From the Deployment Editor toolbar, click the Build icon.

    If there are any validation errors, a Validation Errors pane will appear at the bottom of the Deployment Editor and displays information regarding the errors.

  2. Make any necessary corrections and click Build again.

To Deploy the Project

Before You Begin

Make sure the GlassFish server is started.

  1. From the Deployment Editor toolbar, click the Deploy icon.

    The Deploy prompt appears.

  2. Click Yes.

    A message appears when the project is successfully deployed.

To Run the Sample

To run your deployed sample Project do the following

  1. From your configured input directory, paste (or rename) the sample input file to trigger the Adapter.
  2. From your output directory, verify the output data.

    Note - For UNIX, be sure to upload the appropriate LogicalHost.