001    package railo.commons.io.res.type.ftp;
002    
003    import java.io.IOException;
004    import java.io.OutputStream;
005    
006    import railo.commons.io.res.Resource;
007    import railo.commons.io.res.util.ResourceOutputStream;
008    
009    public final class FTPResourceOutputStream extends ResourceOutputStream {
010            
011    
012            private final FTPResourceClient client;
013    
014            /**
015             * Constructor of the class
016             * @param client
017             * @param res
018             * @param os
019             * @throws IOException 
020             */
021            public FTPResourceOutputStream(FTPResourceClient client,Resource res, OutputStream os) {
022                    super(res, os);
023                    this.client=client;
024            }
025            
026            @Override
027            public void close() throws IOException {
028                    try {
029                            super.close();
030                    }
031                    finally {
032                            client.completePendingCommand();
033                            ((FTPResourceProvider)getResource().getResourceProvider()).returnClient(client);
034                    }
035            }
036    }