Sun Adapter for Batch User's Guide

Dynamic Configuration Sample

The following sample code demonstrates how to dynamically configure the adapter and perform a simple file transfer.

  1. From BatchLocalFile:

    Set the TargetDirectoryName


    //@map:Copy "InDir" to TargetDirectoryName
    
    BatchLocalFile_1.getConfiguration().setTargetDirectoryName( "InDir" );
  2. From BatchFTP:

    Disconnect the adapter


    //@map:Client.disconnect
    
    BatchFTP_1.getClient().disconnect();
  3. Set the TargetDirectoryName


    //@map:Copy "OutDir" to TargetDirectoryName
    
    BatchFTP_1.getConfiguration().setTargetDirectoryName( "OutDir" );
  4. Set the HostName


    //@map:Copy "myftphostname" to HostName
    
    BatchFTP_1.getConfiguration().setHostName( "myftphostname" );
  5. Connect the adapter


    //@map:Client.connect
    
    BatchFTP_1.getClient().connect();
  6. Perform a simple file transfer:

    Get a local file


    //@map:
    
    BatchLocalFile_1.getClient().get();
  7. Assign the Payload


    //@map:Copy Payload to Payload
    
    BatchFTP_1.getClient().setPayload(BatchLocalFile_1.getClient().getPay
    load() );
  8. Put a file on the FTP server


    //@map:Client.put
    
    BatchFTP_1.getClient().put();

To view the Collaboration Editor’s Java Source Editor, click the Advance mode or Source Code mode icon, available on the Collaboration Editor toolbar.