1 17 18 package org.apache.avalon.cornerstone.blocks.sockets; 19 20 import org.apache.avalon.framework.activity.Initializable; 21 import org.apache.avalon.framework.configuration.Configurable; 22 import org.apache.avalon.framework.configuration.Configuration; 23 import org.apache.avalon.framework.configuration.ConfigurationException; 24 import org.apache.avalon.framework.container.ContainerUtil; 25 import org.apache.avalon.framework.context.Context; 26 import org.apache.avalon.framework.context.Contextualizable; 27 import org.apache.avalon.framework.logger.AbstractLogEnabled; 28 29 37 public abstract class AbstractTLSSocketFactory 38 extends AbstractLogEnabled 39 implements Contextualizable, Configurable, Initializable 40 { 41 private final static int WAIT_FOREVER = 0; 42 protected int m_socketTimeOut; 43 44 private Context m_context; 45 private Configuration m_childConfig; 46 47 public void contextualize( final Context context ) 48 { 49 m_context = context; 50 } 51 52 58 public void configure( final Configuration configuration ) 59 throws ConfigurationException 60 { 61 m_socketTimeOut = configuration.getChild( "timeout" ).getValueAsInteger( WAIT_FOREVER ); 62 m_childConfig = configuration.getChild( "ssl-factory", false ); 63 if( m_childConfig == null ) 64 { 65 final String message = "ssl-factory child not found, please" + 66 " update your configuration according to" + 67 " the documentation. Reverting to the" + 68 " old configuration format."; 69 getLogger().warn( message ); 70 m_childConfig = configuration; 72 } 73 } 74 75 78 public void initialize() throws Exception 79 { 80 final SSLFactoryBuilder builder = new SSLFactoryBuilder(); 81 setupLogger( builder ); 82 ContainerUtil.contextualize( builder, m_context ); 83 ContainerUtil.configure( builder, m_childConfig ); 84 ContainerUtil.initialize( builder ); 85 86 visitBuilder( builder ); 87 88 ContainerUtil.shutdown( builder ); 89 m_context = null; 90 m_childConfig = null; 91 } 92 93 101 protected abstract void visitBuilder( SSLFactoryBuilder builder ); 102 } 103 | Popular Tags |