Hi,

The attached ZIP file contains a new poolable ftp-client component to fit
into the Cocoon2 / Avalon framework.

This component is registered in the cocoon.xconf using the following syntax
(and located after the <datasources/> section):

<ftp-connections>
    <connection pool-max="32" pool-min="0" pool-grow="2"
name="##pool-name##">
        <parameter name="server" value="##host##"/>
        <parameter name="port" value="##port##"/>
        <parameter name="user" value="##user##"/>
        <parameter name="password" value="##password##"/>
    </connection>
</ftp-connections>

Multiple ftp-connection pools are supported (it uses the standard
ExcaliburComponentSelector). The actual ftp connection is linked to the IBM
alphaWorks FTP Bean Suite project, available under IBM Public Licence.

The ftp connection is accessed using the
org.apache.cocoon.components.ftp.FtpClient interface, which provides access
to file upload / download, etc. Connections are managed through the
FtpConnect interface.

The included implementation satisfies these two interfaces, as well as
Component, Loggable, Parameterizable, Poolable and Startable. Therefore, to
access a connection, just include the following java code in your calling
component:

    import org.apache.cocoon.components.ftp.FtpClient;

    ComponentSelector selector = (ComponentSelector)
componentManager.lookup(FtpClient.ROLE);
    FtpClient ftpClient = (FtpClient) selector.select("##pool-name##");

    ftpClient.put(ftpFilename, inputStream); // or whatever

    selector.release((Component)ftpClient);
    componentManager.release((Component)selector);

For those who prefer XSP, there is a basic logisheet also included. Just add
the following namespace declaration to <xsp:page/>:
  xmlns:ftp-client="http://apache.org/xsp/ftp-client/2.0";

and then the following XSP:

    <ftp-client:connection pool="##pool-name##">
        <ftp-client:put src-file="winnt.bmp" dest-file="winnt.bin"
mode="binary"/>
        <ftp-client:get src-file="winnt.bin" dest-file="new-winnt.bmp"
mode="binary"/>
    </ftp-client:connection>


To update the Cocoon2.rc2 build, extract the attached ZIP file into the
appropriate folders, apply the diffs and download the IBM ftp Bean jar
(FTPProtocol.jar - available from
http://www-124.ibm.com/developerworks/oss/ftp/index.html) into the
cocoon/lib folder, and rebuild.


In the spirit of all things open, I would honour its inclusion in the
regular Cocoon distribution.
Many thanks,
Adrian Geissel

Attachment: cocoon ftp-client component.zip
Description: Zip compressed data

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to