1 17 18 19 package org.apache.james.imapserver; 20 21 import org.apache.avalon.cornerstone.services.connection.ConnectionHandler; 22 import org.apache.avalon.framework.configuration.Configurable; 23 import org.apache.avalon.framework.configuration.Configuration; 24 import org.apache.avalon.framework.configuration.ConfigurationException; 25 import org.apache.avalon.framework.logger.AbstractLogEnabled; 26 27 import java.net.InetAddress ; 28 import java.net.UnknownHostException ; 29 30 40 public class BaseConnectionHandler extends AbstractLogEnabled implements Configurable { 41 42 45 private static int DEFAULT_TIMEOUT = 1800000; 46 47 50 protected int timeout = DEFAULT_TIMEOUT; 51 52 55 protected String helloName; 56 57 63 public static String configHelloName(final Configuration configuration) 64 throws ConfigurationException { 65 String hostName = null; 66 67 try { 68 hostName = InetAddress.getLocalHost().getHostName(); 69 } catch (UnknownHostException ue) { 70 hostName = "localhost"; 72 } 73 74 Configuration helloConf = configuration.getChild("helloName"); 75 boolean autodetect = helloConf.getAttributeAsBoolean("autodetect", true); 76 77 return autodetect ? hostName : helloConf.getValue("localhost"); 78 } 79 80 81 84 public void configure( final Configuration configuration ) 85 throws ConfigurationException { 86 87 timeout = configuration.getChild( "connectiontimeout" ).getValueAsInteger( DEFAULT_TIMEOUT ); 88 helloName = configHelloName(configuration); 89 if (getLogger().isDebugEnabled()) { 90 getLogger().debug("Hello Name is: " + helloName); 91 } 92 } 93 94 99 public void releaseConnectionHandler(ConnectionHandler connectionHandler) { 100 } 101 } 102 | Popular Tags |