You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ra...@apache.org on 2002/03/08 07:33:54 UTC
cvs commit: jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver FtpServerImpl.java
rana_b 02/03/07 22:33:54
Modified: ftpserver/src/java/org/apache/avalon/ftpserver
FtpServerImpl.java
Log:
disposable method added
Revision Changes Path
1.11 +28 -14 jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/FtpServerImpl.java
Index: FtpServerImpl.java
===================================================================
RCS file: /home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/FtpServerImpl.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- FtpServerImpl.java 6 Mar 2002 13:55:17 -0000 1.10
+++ FtpServerImpl.java 8 Mar 2002 06:33:54 -0000 1.11
@@ -21,6 +21,7 @@
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.component.ComponentException;
@@ -49,6 +50,7 @@
Contextualizable,
Composable,
Configurable,
+ Disposable,
ConnectionHandlerFactory {
private ServerSocket mServerSocket = null;
@@ -75,12 +77,12 @@
mConfig.setContext(mContext);
}
catch(Exception ex) {
- getLogger().error("FtpServerImpl:contextualize()", ex);
+ getLogger().error("FtpServerImpl.contextualize()", ex);
ex.printStackTrace();
if (mConfig != null) {
mConfig.close();
}
- throw new ContextException("FtpServerImpl:contextualize()", ex);
+ throw new ContextException("FtpServerImpl.contextualize()", ex);
}
}
@@ -97,12 +99,12 @@
mConManager = (ConnectionManager)compManager.lookup(ConnectionManager.ROLE);
}
catch(Exception ex) {
- getLogger().error("FtpServerImpl:compose()", ex);
+ getLogger().error("FtpServerImpl.compose()", ex);
ex.printStackTrace();
if (mConfig != null) {
mConfig.close();
}
- throw new ComponentException("FtpServerImpl:compose()", ex);
+ throw new ComponentException("FtpServerImpl.compose()", ex);
}
}
@@ -114,18 +116,17 @@
*/
public void configure(Configuration conf) throws ConfigurationException {
try {
- mConfig.setConfiguration(conf);
-
- // get server address
- InetAddress selfAddress = mConfig.getServerAddress();
- InetAddress localhost = InetAddress.getLocalHost();
- if (localhost.equals(selfAddress)) {
- selfAddress = null;
- }
+ mConfig.setConfiguration(conf);
// open server socket
ServerSocketFactory factory = mSocManager.getServerSocketFactory("plain");
- mServerSocket = factory.createServerSocket(mConfig.getServerPort(), 5, selfAddress);
+ InetAddress serverAddress = mConfig.getServerAddress();
+ if(serverAddress == null) {
+ mServerSocket = factory.createServerSocket(mConfig.getServerPort(), 5);
+ }
+ else {
+ mServerSocket = factory.createServerSocket(mConfig.getServerPort(), 5, serverAddress);
+ }
mConManager.connect(DISPLAY_NAME, mServerSocket, this);
System.out.println("FTP server ready!");
@@ -134,7 +135,7 @@
}
}
catch(Exception ex) {
- getLogger().error("FtpServerImpl:configure(): Exception", ex);
+ getLogger().error("FtpServerImpl.configure()", ex);
ex.printStackTrace();
if (mConfig != null) {
mConfig.close();
@@ -143,6 +144,19 @@
}
}
+ /**
+ * Release all resources.
+ */
+ public void dispose() {
+ getLogger().info("Closing Ftp server...");
+ try {
+ mServerSocket.close();
+ mConfig.close();
+ }
+ catch(Exception ex) {
+ getLogger().warn("FtpServerImpl.dispose()", ex);
+ }
+ }
/**
* Construct an appropriate <code>ConnectionHandler</code>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>