Is this patch going to be integrated into sevak CVS in the near future? This is just what I need. Ofcourse I can always patch it in my workspace .

- Janne


Johan Sj�berg wrote:
Let's try again... If the patches get stripped again I'll send directly to interested ones.

//
J


------------------------------------------------------------------------


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 @@
<?xml version="1.0"?>
-<project default="main" basedir=".">
+<project default="sar" basedir=".">
<!-- set up properties -->
<property file="${user.home}/build.properties"/>



------------------------------------------------------------------------


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 @@
<include name="sevak-demo.war"/>
</zipfileset>
+ <zipfileset dir="jetty-download/Jetty-${jetty.rel}/Jetty-${jetty.rel}/etc" prefix="etc">
+ <include name="jetty.xml"/>
+ </zipfileset >
+
+ <zipfileset dir="jetty-download/Jetty-${jetty.rel}/Jetty-${jetty.rel}/webapps" prefix="webapps">
+ <include name="**/*"/>
+ </zipfileset >
+
</sar>
<!-- Copy build/lib contents to dist/ folder -->



------------------------------------------------------------------------


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 @@
<?xml version="1.0"?>
-
<config>
+ <sevak>
+ <!-- Sevak host -->
+ <!--
+ Sevak managed web applications will be deployed to this virtual
+ host. If it doesn't exist or is left empty the applications will
+ be deployed to all existing hosts. The default is null (all hosts).
+ -->
+ <hostname>localhost</hostname>
+
+ <!--
+ Define if Sevak managed Web Application Archives should be extracted.
+ The default is true.
+ -->
+ <extract-war>true</extract-war>
+
+ <!--
+ Define if Jetty's request log should be redirected to this
+ components log. Note that this will override any request log
+ defined later in Jetty's own configuration. The default is true.
+ -->
+ <redirect-request-log>false</redirect-request-log>
+
+ <!-- Jetty system parameters -->
+ <!--
+ If a parameter begins with "${app-home}", it will be prefixed
+ with the application's home directory.
+ -->
+ <system-parameters>
+ <parameter name="jetty.home">${app-home}</parameter>
+ </system-parameters>
+
+ <!-- Jetty's configuration file -->
+ <!--
+ If a the config file begins with "${app-home}", it will be
+ prefixed with the application's home directory. Note that
+ applications defined in Jetty's own configuration will not be
+ handeled by Sevak.
+ -->
+ <jetty-config-file>${app-home}/etc/jetty.xml</jetty-config-file>
- <sevak>
- <hostname>localhost</hostname>
- </sevak>
- <sevakTest>
- <Context docBase="/" path="sevak-demo.war"/>
- </sevakTest>
+ <!-- Jetty's configuration -->
+ <!--
+ If no jetty-config-file element exists Jetty will be configured
+ with the data inside the following element. Note that the
+ configuration always begins with a <Configure> element. In case
+ your Jetty configuration includes nested XML data you will have
+ to wrap the configuration within a <![CDATA[ ..... ]]> element.
+ Note that applications defined in Jetty's own configuration will
+ not be handeled by Sevak.
+ -->
+ <jetty-config>
+ </jetty-config>
+ </sevak>
+ <sevakTest>
+ <Context docBase="/sevak" path="sevak-demo.war"/>
+ </sevakTest>
</config>



------------------------------------------------------------------------


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 ) );
+ }
}
/**



------------------------------------------------------------------------


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 @@
<element name="hostname"><text/></element>
</optional>
<optional>
- <element name="port"><data type="integer"/></element>
+ <element name="extract-war"><data type="boolean"/></element>
</optional>
<optional>
- <element name="minthreads"><data type="integer"/></element>
+ <element name="redirect-request-log"><data type="boolean"/></element>
</optional>
<optional>
- <element name="maxthreads"><data type="integer"/></element>
+ <element name="system-parameters">
+ <oneOrMore>
+ <element name="parameter"><attribute name="name"/><text/></element>
+ </oneOrMore>
+ </element>
</optional>
<optional>
- <element name="extract-war"><data type="boolean"/></element>
+ <element name="jetty-config-file"><text/></element>
</optional>
+ <optional>
+ <element name="jetty-config"></element>
+ </optional> </interleave>
</element>



------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--
- Janne
k a r i o at m e r m i t dot f i


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to