Author: niclas
Date: Sun Jul 25 21:40:20 2004
New Revision: 30706
Added:
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/DumpHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ErrorPageHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ExpiryHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ForwardHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/HTAccessHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/IPAccessHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/MsieSslHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/NotFoundHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/NullHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ProxyHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ResourceHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/RootNotFoundHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/SecurityHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/SetResponseHeadersHandler.java (contents, props changed)
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/StringUtils.java (contents, props changed)
Modified:
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/HttpContextImpl.java
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ModelHandler.java
avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/NcsaRequestLog.java
avalon/trunk/planet/facilities/http/spi/src/main/org/apache/avalon/http/HttpContextService.java
Log:
Added the needed wrappers for the Jetty handlers.
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/DumpHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/DumpHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-dump-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class DumpHandler
+ extends org.mortbay.http.handler.DumpHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public DumpHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting DumpHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping DumpHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
+
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ErrorPageHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ErrorPageHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-errorpage-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class ErrorPageHandler
+ extends org.mortbay.http.handler.ErrorPageHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public ErrorPageHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting ErrorPageHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping ErrorPageHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
+
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ExpiryHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ExpiryHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-expiry-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class ExpiryHandler
+ extends org.mortbay.http.handler.ExpiryHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public ExpiryHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+
+ int ttl = params.getParameterAsInteger( "time-to-live", -1 );
+ if( ttl > 0 )
+ setTimeToLive( ttl );
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting ExpiryHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping ExpiryHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
+
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ForwardHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ForwardHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+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.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-forward-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class ForwardHandler
+ extends org.mortbay.http.handler.ForwardHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public ForwardHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+
+ String rootForward = params.getParameter( "root-forward", null );
+ if( rootForward != null )
+ setRootForward( rootForward );
+
+ boolean queries = params.getParameterAsBoolean( "handle-queries", false );
+ setHandleQueries( queries );
+ }
+
+ public void configure( Configuration conf )
+ throws ConfigurationException
+ {
+ Configuration child = conf.getChild( "forwards" );
+ configureForwards( child );
+ }
+
+ private void configureForwards( Configuration conf )
+ throws ConfigurationException
+ {
+ Configuration[] children = conf.getChildren( "forward" );
+ for( int i=0 ; i < children.length ; i++ )
+ configureForward( children[i] );
+ }
+
+ private void configureForward( Configuration conf )
+ throws ConfigurationException
+ {
+ Configuration oldPath = conf.getChild( "from" );
+ Configuration newPath = conf.getChild( "to" );
+ addForward( oldPath.getValue(), newPath.getValue() );
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting ForwardHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping ForwardHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
+
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/HTAccessHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/HTAccessHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-htaccess-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class HTAccessHandler
+ extends org.mortbay.http.handler.HTAccessHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public HTAccessHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+
+ String defaultAccess = params.getParameter( "default-access", null );
+ if( defaultAccess != null )
+ setDefault( defaultAccess );
+
+ String filename = params.getParameter( "access-file", null );
+ if( filename != null )
+ setAccessFile( filename );
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting HTAccessHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping HTAccessHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
+
Modified: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/HttpContextImpl.java
==============================================================================
--- avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/HttpContextImpl.java (original)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/HttpContextImpl.java Sun Jul 25 21:40:20 2004
@@ -233,6 +233,13 @@
m_HttpContext.addHandler( handler );
}
+ public void addHandler( int index, HttpHandler handler )
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Adding handler: " + handler );
+ m_HttpContext.addHandler( handler );
+ }
+
public void removeHandler( HttpHandler handler )
{
if( m_Logger.isDebugEnabled() )
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/IPAccessHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/IPAccessHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+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.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-ipaccess-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class IPAccessHandler
+ extends org.mortbay.http.handler.IPAccessHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public IPAccessHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+
+ String standard = params.getParameter( "standard-action", null );
+ if( standard != null )
+ setStandard( standard );
+ }
+
+ public void configure( Configuration conf )
+ throws ConfigurationException
+ {
+ Configuration child = conf.getChild( "access" );
+ configureAccess( child );
+ }
+
+ private void configureAccess( Configuration conf )
+ throws ConfigurationException
+ {
+ Configuration[] allows = conf.getChildren( "allow" );
+ for( int i=0 ; i < allows.length ; i++ )
+ setAllowIP( allows[i].getValue() );
+
+ Configuration[] deny = conf.getChildren( "deny" );
+ for( int i=0 ; i < deny.length ; i++ )
+ setDenyIP( deny[i].getValue() );
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting IPAccessHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping IPAccessHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
+
+
Modified: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ModelHandler.java
==============================================================================
--- avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ModelHandler.java (original)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ModelHandler.java Sun Jul 25 21:40:20 2004
@@ -25,10 +25,6 @@
import org.apache.avalon.framework.activity.Startable;
-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.context.Context;
import org.apache.avalon.framework.context.ContextException;
import org.apache.avalon.framework.context.Contextualizable;
@@ -36,6 +32,10 @@
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
@@ -54,7 +54,7 @@
* @avalon.service type="org.mortbay.http.HttpHandler"
*/
public class ModelHandler
- implements Serviceable, Configurable, Contextualizable, LogEnabled,
+ implements Serviceable, Parameterizable, Contextualizable, LogEnabled,
HttpHandler, CompositionListener, Startable
{
private Logger m_Logger;
@@ -62,7 +62,8 @@
private HttpContextService m_Context;
private String m_Name;
private boolean m_Started;
-
+ private int m_Index;
+
public ModelHandler()
{
m_Started = false;
@@ -115,11 +116,12 @@
m_Context = (HttpContextService) man.lookup( "httpcontext" );
}
- public void configure( Configuration conf )
- throws ConfigurationException
+ public void parameterize( Parameters params )
+ throws ParameterException
{
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
}
-
+
/* HttpHandler interface */
public HttpContext getHttpContext()
@@ -154,7 +156,10 @@
{
if( m_Logger.isDebugEnabled() )
m_Logger.debug( "Starting ModelHandler: " + this );
- m_Context.addHandler( this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
m_Started = true;
}
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/MsieSslHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/MsieSslHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-msiessl-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class MsieSslHandler
+ extends org.mortbay.http.handler.MsieSslHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public MsieSslHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+
+ String agent = params.getParameter( "user-agent-substring", null );
+ if( agent != null )
+ setUserAgentSubString( agent );
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting MsieSslHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping MsieSslHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
+
Modified: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/NcsaRequestLog.java
==============================================================================
--- avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/NcsaRequestLog.java (original)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/NcsaRequestLog.java Sun Jul 25 21:40:20 2004
@@ -17,9 +17,6 @@
package org.apache.avalon.http.impl;
-import java.util.ArrayList;
-import java.util.StringTokenizer;
-
import org.apache.avalon.framework.activity.Startable;
import org.apache.avalon.framework.logger.LogEnabled;
@@ -71,7 +68,7 @@
String ignorepaths = params.getParameter( "ignore-paths", null );
if( ignorepaths != null )
{
- String[] paths = tokenize( ignorepaths );
+ String[] paths = StringUtils.tokenize( ignorepaths );
setIgnorePaths( paths );
}
@@ -84,19 +81,6 @@
setRetainDays( retain );
}
- private String[] tokenize( String string )
- {
- ArrayList result = new ArrayList();
- StringTokenizer st = new StringTokenizer( string, " ,", false );
- while( st.hasMoreTokens() )
- {
- result.add( st.nextToken() );
- }
- String[] retVal = new String[ result.size() ];
- result.toArray( retVal );
- return retVal;
- }
-
public void start()
throws Exception
{
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/NotFoundHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/NotFoundHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-notfound-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class NotFoundHandler
+ extends org.mortbay.http.handler.NotFoundHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public NotFoundHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting NotFoundHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping NotFoundHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/NullHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/NullHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-null-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class NullHandler
+ extends org.mortbay.http.handler.NullHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public NullHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting NullHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping NullHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
+
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ProxyHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ProxyHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-proxy-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class ProxyHandler
+ extends org.mortbay.http.handler.ProxyHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public ProxyHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+
+ String whitelist = params.getParameter( "proxy-host-white-list", null );
+ if( whitelist != null )
+ {
+ String[] hosts = StringUtils.tokenize( whitelist );
+ setProxyHostsWhiteList( hosts );
+ }
+
+ String blacklist = params.getParameter( "proxy-host-black-list", null );
+ if( blacklist != null )
+ {
+ String[] hosts = StringUtils.tokenize( blacklist );
+ setProxyHostsBlackList( hosts );
+ }
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting ProxyHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping ProxyHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
+
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ResourceHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/ResourceHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-resource-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class ResourceHandler
+ extends org.mortbay.http.handler.ResourceHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public ResourceHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ boolean ranges = params.getParameterAsBoolean( "accept-ranges", false );
+ setAcceptRanges( ranges );
+
+ boolean dirAllowed = params.getParameterAsBoolean( "allow-directory", false );
+ setDirAllowed( dirAllowed );
+
+ boolean redirectWelcome = params.getParameterAsBoolean( "redirect-welcome", false );
+ setDirAllowed( redirectWelcome );
+
+ int minGzip = params.getParameterAsInteger( "min-gzip-length", -1 );
+ if( minGzip > 0 )
+ setMinGzipLength( minGzip );
+
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+
+ String allow = params.getParameter( "allow-methods", null );
+ if( allow != null )
+ {
+ String[] methods = StringUtils.tokenize( allow );
+ setAllowedMethods( methods );
+ }
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting ResourceHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping ResourceHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+
+
+}
\ No newline at end of file
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/RootNotFoundHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/RootNotFoundHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-rootnotfound-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class RootNotFoundHandler
+ extends org.mortbay.http.handler.RootNotFoundHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public RootNotFoundHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting RootNotFoundHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping RootNotFoundHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
+
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/SecurityHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/SecurityHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-security-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class SecurityHandler
+ extends org.mortbay.http.handler.SecurityHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public SecurityHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+
+ String authMethod = params.getParameter( "authentication-method", null );
+ if( authMethod != null )
+ setAuthMethod( authMethod );
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting SecurityHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping SecurityHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
+
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/SetResponseHeadersHandler.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/SetResponseHeadersHandler.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import org.apache.avalon.framework.activity.Startable;
+
+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.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+import org.apache.avalon.framework.parameters.ParameterException;
+import org.apache.avalon.framework.parameters.Parameterizable;
+import org.apache.avalon.framework.parameters.Parameters;
+
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
+import org.apache.avalon.http.HttpContextService;
+
+/**
+ * @avalon.component name="http-setresponseheaders-handler" lifestyle="singleton"
+ * @avalon.server type="org.mortbay.http.HttpHandler"
+ */
+public class SetResponseHeadersHandler
+ extends org.mortbay.http.handler.SetResponseHeadersHandler
+ implements Startable, Parameterizable, LogEnabled,
+ Serviceable, Contextualizable
+{
+ private Logger m_Logger;
+ private HttpContextService m_Context;
+ private int m_Index;
+
+ public SetResponseHeadersHandler()
+ {
+ }
+
+ /**
+ * Enable the logging system.
+ *
+ * @avalon.logger name="http"
+ */
+ public void enableLogging( Logger logger )
+ {
+ m_Logger = logger;
+ }
+
+ public Logger getLogger()
+ {
+ return m_Logger;
+ }
+
+ /**
+ * Contextulaization of the Handler.
+ *
+ * @param context the supplied listener context
+ *
+ * @exception ContextException if a contextualization error occurs
+ *
+ * @avalon.entry key="urn:avalon:name"
+ * type="java.lang.String"
+ */
+ public void contextualize( Context ctx )
+ throws ContextException
+ {
+ String name = (String) ctx.get( "urn:avalon:name" );
+ setName( name );
+ }
+
+ public void parameterize( Parameters params )
+ throws ParameterException
+ {
+ m_Index = params.getParameterAsInteger( "handler-index", -1 );
+
+ }
+
+ public void configure( Configuration conf )
+ throws ConfigurationException
+ {
+ Configuration child = conf.getChild( "headers" );
+ configureHeaders( child );
+ }
+
+ private void configureHeaders( Configuration conf )
+ throws ConfigurationException
+ {
+ Configuration[] headers = conf.getChildren( "header" );
+ for( int i=0 ; i < headers.length ; i++ )
+ configureHeader( headers[i] );
+ }
+
+ private void configureHeader( Configuration conf )
+ throws ConfigurationException
+ {
+ Configuration name = conf.getChild( "name" );
+ Configuration value = conf.getChild( "value" );
+ setHeaderValue( name.getValue(), value.getValue() );
+ }
+
+ /**
+ * @avalon.dependency type="org.apache.avalon.http.HttpContextService"
+ * key="http-context"
+ */
+ public void service( ServiceManager man )
+ throws ServiceException
+ {
+ m_Context = (HttpContextService) man.lookup( "http-context" );
+ }
+
+ public void start()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Starting SetResponseHeadersHandler: " + this );
+ if( m_Index >= 0 )
+ m_Context.addHandler( m_Index, this );
+ else
+ m_Context.addHandler( this );
+ }
+
+ public void stop()
+ {
+ if( m_Logger.isDebugEnabled() )
+ m_Logger.debug( "Stopping SetResponseHeadersHandler: " + this );
+ m_Context.removeHandler( this );
+ }
+}
+
+
+
Added: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/StringUtils.java
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/StringUtils.java Sun Jul 25 21:40:20 2004
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2004 Apache Software Foundation
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.http.impl;
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+
+public class StringUtils
+{
+ static public String[] tokenize( String string )
+ {
+ ArrayList result = new ArrayList();
+ StringTokenizer st = new StringTokenizer( string, " ,", false );
+ while( st.hasMoreTokens() )
+ {
+ result.add( st.nextToken() );
+ }
+ String[] retVal = new String[ result.size() ];
+ result.toArray( retVal );
+ return retVal;
+ }
+}
+
Modified: avalon/trunk/planet/facilities/http/spi/src/main/org/apache/avalon/http/HttpContextService.java
==============================================================================
--- avalon/trunk/planet/facilities/http/spi/src/main/org/apache/avalon/http/HttpContextService.java (original)
+++ avalon/trunk/planet/facilities/http/spi/src/main/org/apache/avalon/http/HttpContextService.java Sun Jul 25 21:40:20 2004
@@ -28,6 +28,8 @@
void addHandler( HttpHandler handler );
+ void addHandler( int index, HttpHandler handler );
+
void removeHandler( HttpHandler handler );
HttpContext getHttpContext();
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.