Here is that I am implementing

               server = serverFactory.createServer(); 
                        
               server.start();
               
               while(!server.isStopped()) {
                   Thread.sleep(1000);
               }

In the FTPlet I do this. Notice the server.stop.

    public FtpletResult onUploadStart(FtpSession session, FtpRequest request) 
throws FtpException, IOException {
        ByteArrayOutputStream bos = null;

        try {
            bos = new ByteArrayOutputStream();
            DataConnectionFactory dcf = session.getDataConnection(); 
            DataConnection dc = dcf.openConnection();
            session.write(new DefaultFtpReply(150, "Data transfer starting."));
            dc.transferFromClient(session, bos);
            session.write(new DefaultFtpReply(226, "Data transfer complete."));
            
            if ("Receive".equals("Receive") == true) {
                result.setProperty("Payload", bos.toString());
            }
            
               lastError = "000000";
            lastErrorMessage = "SUCCESS";
        } catch (Exception ex) {
            ex.printStackTrace();
            CFMEnterpriseServiceLogMessage m = new 
CFMEnterpriseServiceLogMessage();
            m.errorID = "07_01_1001";
            m.shortDescription = CFMError.E07_01_1001;
            m.resolution = CFMError.R07_01_1001;
            m.longDescription = ex.getLocalizedMessage();
            m.offendingObject = "Repository : " + getProperty("Repository") + " 
| Enterprise Service : " + getProperty("Name");
            m.es = this;
            m.parameters = in;
            String log = logger.log(CFMLogger.ERROR,m,ex);                    
            
            setLastError("07_01_1001");
            setLastErrorMessage(CFMError.E07_01_1001);
            setLastErrorLog(log);
            setLastErrorResolution(CFMError.R07_01_1001);
            setLastErrorLocation("Repository : " + getProperty("Repository") + 
" | Enterprise Service : " + getProperty("Name") + " : receive");
        } finally {
            session.getDataConnection().closeDataConnection();
            if ("Receive".equals("Receive") == true) server.stop();
            if (bos != null) bos.close();

            result.setProperty("Last Error", lastError);
            result.setProperty("Last Error Message", lastErrorMessage);
            result.setProperty("Last Error Log", lastErrorLog);
            result.setProperty("Last Error Resolution", lastErrorResolution);
            result.setProperty("Last Error Location", lastErrorLocation);
        }
        
        return FtpletResult.SKIP;        
    }






----- Original Message ----
From: Niklas Gustavsson <[email protected]>
To: [email protected]
Sent: Wednesday, March 11, 2009 8:24:28 AM
Subject: Re: Server execution

On Wed, Mar 11, 2009 at 4:19 PM, Edward Scanzano <[email protected]> wrote:
>
> I have a situation where I bring up an FTP server to accept a one time put 
> and mput. After complete the FTP server will stop and the overall application 
> will continue forward.

That's an interesting use of FtpServer. Are you planning on
intercepting the puts by an Ftplet? If so, you can start FtpServer,
then wait on some object (mutex.wait()) and then have the Ftplet call
notify() on the mutex object when it is done.

/niklas

Reply via email to