Return-Path: Delivered-To: apmail-avalon-dev-archive@avalon.apache.org Received: (qmail 74518 invoked by uid 500); 6 Jun 2003 15:55:14 -0000 Mailing-List: contact dev-help@avalon.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Avalon Developers List" Reply-To: "Avalon Developers List" Delivered-To: mailing list dev@avalon.apache.org Received: (qmail 74162 invoked from network); 6 Jun 2003 15:55:09 -0000 Received: from unknown (HELO amon.avain.intra) (195.197.158.226) by daedalus.apache.org with SMTP; 6 Jun 2003 15:55:09 -0000 Received: from avaintec.com ([192.168.0.102]) (authenticated bits=0) by amon.avain.intra (8.12.8/8.12.8) with ESMTP id h56FtXdM010260 for ; Fri, 6 Jun 2003 18:55:39 +0300 Message-ID: <3EE0B891.4050205@avaintec.com> Date: Fri, 06 Jun 2003 18:51:45 +0300 From: =?ISO-8859-1?Q?Johan_Sj=F6berg?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Avalon Developers List Subject: Re: [sevak-patch] Jetty configuration References: <3EE0AB21.9070908@avaintec.com> Content-Type: multipart/mixed; boundary="------------000009020609020208050501" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --------------000009020609020208050501 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Let's try again... If the patches get stripped again I'll send directly to interested ones. // J --------------000009020609020208050501 Content-Type: text/plain; name="catalina.xml.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="catalina.xml.patch" Index: sevak/catalina.xml =================================================================== RCS file: /home/cvspublic/avalon-sandbox/sevak/catalina.xml,v retrieving revision 1.14 diff -u -r1.14 catalina.xml --- sevak/catalina.xml 25 Apr 2003 06:04:05 -0000 1.14 +++ sevak/catalina.xml 6 Jun 2003 15:38:06 -0000 @@ -1,6 +1,6 @@ - + --------------000009020609020208050501 Content-Type: text/plain; name="jetty.xml.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="jetty.xml.patch" Index: sevak/jetty.xml =================================================================== RCS file: /home/cvspublic/avalon-sandbox/sevak/jetty.xml,v retrieving revision 1.16 diff -u -r1.16 jetty.xml --- sevak/jetty.xml 11 Apr 2003 00:52:19 -0000 1.16 +++ sevak/jetty.xml 6 Jun 2003 15:39:02 -0000 @@ -144,6 +144,14 @@ + + + + + + + + --------------000009020609020208050501 Content-Type: text/plain; name="jetty-config.xml.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="jetty-config.xml.patch" Index: sevak/src/demo/conf/jetty-config.xml =================================================================== RCS file: /home/cvspublic/avalon-sandbox/sevak/src/demo/conf/jetty-config.xml,v retrieving revision 1.5 diff -u -r1.5 jetty-config.xml --- sevak/src/demo/conf/jetty-config.xml 4 Apr 2003 22:04:07 -0000 1.5 +++ sevak/src/demo/conf/jetty-config.xml 6 Jun 2003 15:39:53 -0000 @@ -1,12 +1,60 @@ - + + + + localhost + + + true + + + false + + + + + ${app-home} + + + + + ${app-home}/etc/jetty.xml - - localhost - - - - + + + + + + + + --------------000009020609020208050501 Content-Type: text/plain; name="JettySevak.java.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="JettySevak.java.patch" Index: sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak.java =================================================================== RCS file: /home/cvspublic/avalon-sandbox/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak.java,v retrieving revision 1.21 diff -u -r1.21 JettySevak.java --- sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak.java 11 Apr 2003 00:29:11 -0000 1.21 +++ sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak.java 6 Jun 2003 15:41:16 -0000 @@ -60,6 +60,7 @@ import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; +import org.apache.avalon.framework.configuration.DefaultConfigurationSerializer; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.context.Contextualizable; @@ -72,6 +73,8 @@ import org.mortbay.jetty.servlet.WebApplicationContext; import org.mortbay.util.Log; import org.mortbay.util.MultiException; +import org.mortbay.xml.XmlConfiguration; + /** * @phoenix:block @@ -90,16 +93,23 @@ implements Sevak, Startable, Contextualizable, Configurable, Initializable, Serviceable { + private final static String c_appHome = "${app-home}"; + + /** The Jetty server */ private Server m_server; - /** Virtual host to bind the Jetty to. null implies all hosts are in context. */ + /** Jetty's configuration */ + private String m_jettyConfiguration; + + /** Jetty's configuration file */ + private String m_jettyConfFile; + + /** Virtual host to deploy web applications to, null for all hosts. */ private String m_hostName; private HashMap m_webapps = new HashMap(); - private int m_port; - private int m_minThreads; - private int m_maxThreads; private boolean m_extractWebArchive; + private boolean m_redirectRequestLog; private File m_sarRootDir; private SevakContext m_sevakContext; private Context m_context; @@ -128,49 +138,112 @@ /** * Configure * @param configuration the configuration - * @throws ConfigurationException if a problem + * @throws ConfigurationException if the component couldn't be configured * * @phoenix:configuration-schema type="http://relaxng.org/ns/structure/1.0" */ public void configure( final Configuration configuration ) throws ConfigurationException { - m_hostName = configuration.getChild( "hostname" ).getValue( null ); - m_port = configuration.getChild( "port" ).getValueAsInteger( 8080 ); - m_minThreads = configuration.getChild( "minthreads" ).getValueAsInteger( 5 ); - m_maxThreads = configuration.getChild( "maxthreads" ).getValueAsInteger( 250 ); - m_extractWebArchive = configuration.getChild( "extract-war" ).getValueAsBoolean( true ); + m_jettyConfFile = configuration.getChild( "jetty-config-file" ).getValue( null ); + if( null == m_jettyConfFile ) + { + m_jettyConfiguration = configuration.getChild( "jetty-config" ).getValue( null ); + if( null == m_jettyConfiguration ) + { + try + { + DefaultConfigurationSerializer serializer = + new DefaultConfigurationSerializer(); + m_jettyConfiguration = serializer.serialize( + configuration.getChild( "jetty-config" ).getChild( "Configure" ) ); + } + catch( Exception e ) + { + final String message = "Serialization of Jetty's configuration failed."; + getLogger().fatalError( message, e ); + throw new ConfigurationException( message, e ); + } + } + if( m_jettyConfiguration.indexOf ("?>") >= 0 ) + { + m_jettyConfiguration = m_jettyConfiguration.substring( + m_jettyConfiguration.indexOf ("?>") + 2 ); + } + getLogger().info( "Configurating Jetty from component configuration." ); + } + else + { + if( m_jettyConfFile.startsWith( c_appHome ) ) + { + m_jettyConfFile = m_sarRootDir.getAbsolutePath() + + m_jettyConfFile.substring( c_appHome.length() ); + } + if( m_jettyConfFile.startsWith( c_appHome ) ) + { + m_jettyConfFile = m_jettyConfFile.substring( c_appHome.length() ); + } + m_jettyConfFile = m_jettyConfFile.replace( '\\', File.separatorChar ); + m_jettyConfFile = m_jettyConfFile.replace( '/', File.separatorChar ); + getLogger().info( "Configurating Jetty from file [" + m_jettyConfFile + "]." ); + } - if( m_maxThreads < m_minThreads ) + Configuration systemParameters = configuration.getChild( "system-parameters", false ); + if( null != systemParameters ) { - throw new ConfigurationException( "maxthreads must be greater than minthreads" ); + Configuration parameters[] = systemParameters.getChildren( "parameter" ); + for( int i = 0; i < parameters.length; i ++ ) + { + String key = parameters[i].getAttribute( "name" ); + String value = parameters[i].getValue( "" ); + if( value.startsWith( c_appHome ) ) + { + value = m_sarRootDir.getAbsolutePath() + value.substring( c_appHome.length() ); + } + getLogger().debug( "Adding system property [" + key + "] = [" + value + "]" ); + System.setProperty( key, value ); + } } + + m_hostName = configuration.getChild( "hostname" ).getValue( null ); + m_extractWebArchive = configuration.getChild( "extract-war" ).getValueAsBoolean( true ); + m_redirectRequestLog = configuration.getChild( "redirect-request-log") + .getValueAsBoolean( true ); } /** * Initialize - * @throws Exception if a problem + * + * @throws Exception If Jetty couldn't be created */ public void initialize() throws Exception { - m_server = new Server(); - SocketListener listener = new SocketListener(); - - if( null != m_hostName ) + try + { + if( null == m_jettyConfFile ) + { + m_server = (Server) new XmlConfiguration( m_jettyConfiguration ).newInstance(); + } + else + { + m_server = new Server( m_jettyConfFile ); + } + } + catch( Exception e ) { - listener.setHost( m_hostName ); + getLogger().fatalError( "Couldn't configure and initialize Jetty. " + + "Check the configuration. Your service manager's log might also help." ); + throw e; } - - listener.setPort( m_port ); - listener.setMinThreads( m_minThreads ); - listener.setMaxThreads( m_maxThreads ); - m_server.addListener( listener ); - PhoenixLogSink phoenixLogSink = new PhoenixLogSink(); - phoenixLogSink.enableLogging( getLogger() ); - Log.instance().add( phoenixLogSink ); - - RequestLogger logger = (RequestLogger) - m_sevakContext.getServiceManager().lookup( RequestLogger.ROLE ); - m_server.setRequestLog( new JettyRequestLogAdapter( logger ) ); + + if( m_redirectRequestLog ) + { + PhoenixLogSink phoenixLogSink = new PhoenixLogSink(); + phoenixLogSink.enableLogging( getLogger() ); + Log.instance().add( phoenixLogSink ); + RequestLogger logger = (RequestLogger) + m_sevakContext.getServiceManager().lookup( RequestLogger.ROLE ); + m_server.setRequestLog( new JettyRequestLogAdapter( logger ) ); + } } /** --------------000009020609020208050501 Content-Type: text/plain; name="JettySevak-schema.xml.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="JettySevak-schema.xml.patch" Index: sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak-schema.xml =================================================================== RCS file: /home/cvspublic/avalon-sandbox/sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak-schema.xml,v retrieving revision 1.2 diff -u -r1.2 JettySevak-schema.xml --- sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak-schema.xml 10 Feb 2003 20:38:22 -0000 1.2 +++ sevak/src/java/org/apache/avalon/apps/sevak/blocks/jetty/JettySevak-schema.xml 6 Jun 2003 15:42:21 -0000 @@ -9,16 +9,23 @@ - + - + - + + + + + - + + + + --------------000009020609020208050501 Content-Type: application/x-java-applet;version=1.1.1; name=".cvsignore" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename=".cvsignore" YnVpbGQKZGlzdApqZXR0eS1kb3dubG9hZApqby1kb3dubG9hZApjYXRhbGluYS1kb3dubG9h ZA== --------------000009020609020208050501 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org For additional commands, e-mail: dev-help@avalon.apache.org --------------000009020609020208050501--