1 17 18 package org.apache.james.imapserver; 19 20 import org.apache.avalon.cornerstone.services.connection.AbstractService; 21 import org.apache.avalon.cornerstone.services.connection.ConnectionHandlerFactory; 22 import org.apache.avalon.cornerstone.services.connection.DefaultHandlerFactory; 23 import org.apache.avalon.framework.configuration.Configuration; 24 import org.apache.avalon.framework.configuration.ConfigurationException; 25 import org.apache.avalon.framework.context.Context; 26 import org.apache.avalon.framework.component.Component; 27 28 import java.net.InetAddress ; 29 import java.net.UnknownHostException ; 30 31 38 public class IMAPServer 39 extends AbstractService implements Component { 40 41 private Context _context; 42 43 protected ConnectionHandlerFactory createFactory() 44 { 45 return new DefaultHandlerFactory( SingleThreadedConnectionHandler.class ); 46 } 47 48 public void configure( final Configuration configuration ) 49 throws ConfigurationException { 50 51 m_port = configuration.getChild( "port" ).getValueAsInteger( 143 ); 52 53 try 54 { 55 final String bindAddress = configuration.getChild( "bind" ).getValue( null ); 56 if( null != bindAddress ) 57 { 58 m_bindTo = InetAddress.getByName( bindAddress ); 59 } 60 } 61 catch( final UnknownHostException unhe ) 62 { 63 throw new ConfigurationException( "Malformed bind parameter", unhe ); 64 } 65 66 final String useTLS = configuration.getChild("useTLS").getValue( "" ); 67 if( useTLS.equals( "TRUE" ) ) m_serverSocketType = "ssl"; 68 69 super.configure( configuration.getChild( "handler" ) ); 70 } 71 72 public void initialize() throws Exception { 73 74 getLogger().info( "IMAPServer init..." ); 75 getLogger().info( "IMAPListener using " + m_serverSocketType + " on port " + m_port ); 76 super.initialize(); 77 getLogger().info("IMAPServer ...init end"); 78 System.out.println("Started IMAP Server "+m_connectionName); 79 } 80 } 81 82 | Popular Tags |