Sun Adapter for Batch Tutorial

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.

ProcedureTo 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 shows the JCD Editor view of the jcdBatch_Record
collaboration business rules
  1. From the Project Explorer tree, 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.

ProcedureTo Create a Connectivity Map

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

  1. In Enterprise Explorer’s Project Explorer, 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 Explorer tree, labeled CMap1.

  2. Rename the Connectivity Map to cmBatch_Record.

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

ProcedureTo Create an Environment

Environments include the External Systems, Logical Hosts, Sun Java System 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 the Repository 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 Sun Java System Application Server is added to the Services tree under LogicalHost1.

  10. Save the Project.