Sun Adapter for Batch Tutorial

Using the Java Collaboration Editor

The prjBatch_Streaming Project uses the jcdBatch_Streaming Collaboration created in the Creating a Java Collaboration Definition. To complete the Collaboration, use the Collaboration Editor to create the Business Rules.

ProcedureTo Create the jcdBatch_Streaming Collaboration Business Rules

  1. From the Project Explorer tree, double-click jcdBatch_Streaming.

    The Java Collaboration Editor opens to the jcdBatch_Streaming Collaboration.

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

    The Enter a Comment dialog box appears.

  3. Enter the comment and click OK.

    The comment is placed on the Business Rules tree under the last selected item. Click the comment to drag it up or down the Business Rules tree to a new location.

  4. Create the CopyBatchLocalFile_1.Client.OutputStreamAdapter to BatchFTP_1.Client.OutputStreamAdapter rule:

    The CopyBatchLocalFile_1.Client.OutputStreamAdapter to BatchFTP_1.Client.OutputStreamAdapter rule configures the BatchFTP and BatchLocalFile stream adapters so that the BatchFTP Adapter does a stream get, and the BatchLocalFile Adapter receives the stream.

    1. Click rule on the Business Rules toolbar to add a new rule.

    2. Map OutputStreamAdapter under BatchLocalFile_1 ⇒ Client in the left pane of the Business Rules Designer, under to OutputStreamAdapter under BatchFTP_1 ⇒ Client in the right pane of the Business Rules Designer. To do this, Click on OutputStreamAdapter under BatchLocalFile_1 ⇒ Client in the left pane of the Business Rules Designer, and drag your cursor to OutputStreamAdapter under BatchFTP_1 ⇒ Client in the right pane of the Business Rules Designer. A link now connects the two nodes.

  5. Create the BatchFTP_1.Client.get rule:

    The BatchFTP_1.Client.get rule gets the file.

    1. Click rule on the Business Rules toolbar to add a new rule.

    2. Under BatchFTP_1 in the left pane of the Business Rules Designer, right-click Client, and click Select method to call from the context menu.

      The method selection window appears.

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

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

  6. Create the Copy BatchLocalFile_1.Configuration.PostDirectoryName to BatchLocalFile_1.Configuration.TargetDirectoryName rule:

    The Copy BatchLocalFile_1.Configuration.PostDirectoryName to BatchLocalFile_1.Configuration.TargetDirectoryName rule dynamically configures the name of the target directory to the post directory name.

    1. Click rule on the Business Rules toolbar to add a new rule.

    2. Map PostDirectoryName under BatchLocalFile_1 ⇒ Configuration in the left pane of the Business Rules Designer, to TargetDirectoryName under BatchLocalFile_1 ⇒ Configuration in the right pane.

  7. Create the Copy BatchLocalFile_1.Configuration.PostFileName to BatchLocalFile_1.Configuration.TargetFileName rule:

    The Copy BatchLocalFile_1.Configuration.PostFileName to BatchLocalFile_1.Configuration.TargetFileName rule dynamically configures the name of the target file to the post file name.

    1. Click rule on the Business Rules toolbar to add a new rule.

    2. Under BatchLocalFile_1⇒Configuration in the left pane of the Business Rules Designer, map PostFileName to TargetFileName under BatchLocalFile_1 ⇒ Configuration in the right pane of the Business Rules Designer.

  8. Create the Copy "None" to BatchLocalFile_1.Configuration.PostTransferCommand rule:

    The Copy "None" to BatchLocalFile_1.Configuration.PostTransferCommand rule dynamically configures the post transfer command to None so that no post transfer will take place.

    1. From the Business Rules Designer’s String menu, select Literal String.

      The String literal box appears.

    2. Double-click the value field of the String literal box and enter None as the value.

    3. Map the None output node of the String literal box to PostTransferCommand under BatchLocalFile_1⇒Configuration in the right pane of the Business Rules Designer

  9. Create the Copy BatchLocalFile_1.Client.InputStreamAdapter to BatchRecord_1.InputStreamAdapter rule:

    The Copy BatchLocalFile_1.Client.InputStreamAdapter to BatchRecord_1.InputStreamAdapter rule configures the BatchLocalFile and BatchRecord stream adapters so that the BatchLocalFile Adapter does a stream get, and the BatchRecord Adapter receives the stream.

    1. Click rule on the Business Rules toolbar to add a new rule.

    2. Under BatchLocalFile_1 > Client in the left pane of the Business Rules Designer, map InputStreamAdapter to InputStreamAdapter under BatchRecord_1 in the right pane of the Business Rules Designer.

  10. Create the While statement:

    The While statement’s rules get the record, publish it to the outbound File Adapter, and the File Adapter writes the file to a local directory.

    1. Click While on the Business Rules toolbar to add a new while statement in the Business Rules pane.

    2. From the Business Rules tree, expand the While statement and select the condition.

    3. From the Business Rules Designer, right-click BatchRecord_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.

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

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

    5. Map the output node of the get method box to result (boolean) condition in the right pane of the Business Rules Designer.

      Image shows the While statement in the Business Rules
Designer
  11. Create the Copy BatchRecord_1.Record to FileClient_1.ByteArray rule under the while statement:

    1. From the Business Rules tree, select rules under the While statement.

    2. Map Record, under BatchRecord_1 in the left pane of the Business Rules Designer, to ByteArray under FileClient_1 in the right pane of the Business Rules Designer.

  12. To create the FileClient_1.write rule under the while statement do the following:

    1. Click rule on the Business Rules toolbar to add a new rule under the While statement.

    2. Right-click FileClient_1 in the left pane of the Business Rules Designer, and click Select method to callfrom the context menu.

      The method selection window appears.

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

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

  13. Create the BatchRecord_1.finish rule:

    1. Select the while statement on the Business Rules tree and click rule on the Business Rules toolbar.

      A new rule is added to the Business Rules tree.

    2. Right-click BatchRecord_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 finish() from the method selection window.

      The finish method box appears.

  14. From the editor’s toolbar, click Validate to check the Collaboration for errors.

    Image shows the completed business rules for the prjBatch_Streaming
Collaboration Definition
  15. 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_Streaming) and select New ⇒ Connectivity Map from the context menu.

    The new Connectivity Map appears and a node for the new Connectivity Map is added under the Project on the Project Explorer tree labeled CMAP1.

  2. Rename the Connectivity Map to cmBatch_Streaming.

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_Streaming Java Collaboration Definition from the Project window to the Connectivity Map canvas.

    The cmBatch_Streaming_jcdBatch_Streaming1 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_Streaming.

  4. Right-click the envBatch_Streaming Environment and select New⇒BatchInbound External System.

  5. Name this External System esBatchInbound.

    The esBatchInbound window is added to the Environment Editor.

  6. Right-click envBatch_Streaming and select New⇒BatchFTP External System.

  7. Name this External System esBatchFTP.

  8. Right-click envBatch_Streaming and select New⇒BatchLocalFile External System.

  9. Name the External System esBatchLocalFile.

  10. Right-click envBatch_Streaming and select New⇒BatchRecord External System.

  11. Name the External System esBatchRecord.

  12. Right-click envBatch_Streaming and select New⇒File External System.

  13. Name this External System esFile.

  14. Right-click envBatch_Streaming and select New Logical Host.

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

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

  16. Save the Project.