notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2881 - development/main/test/components/http/impl/src/main/net/dpml/http/impl
- From: mcconnell AT dpml.net
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2881 - development/main/test/components/http/impl/src/main/net/dpml/http/impl
- Date: Fri, 17 Jun 2005 16:59:20 -0400
Author: mcconnell AT dpml.net
Date: Fri Jun 17 16:59:20 2005
New Revision: 2881
Modified:
development/main/test/components/http/impl/src/main/net/dpml/http/impl/HttpContextImpl.java
development/main/test/components/http/impl/src/main/net/dpml/http/impl/HttpServerImpl.java
development/main/test/components/http/impl/src/main/net/dpml/http/impl/IPAccessHandler.java
Log:
updating to FT
Modified:
development/main/test/components/http/impl/src/main/net/dpml/http/impl/HttpContextImpl.java
==============================================================================
---
development/main/test/components/http/impl/src/main/net/dpml/http/impl/HttpContextImpl.java
(original)
+++
development/main/test/components/http/impl/src/main/net/dpml/http/impl/HttpContextImpl.java
Fri Jun 17 16:59:20 2005
@@ -21,25 +21,15 @@
import net.dpml.activity.Disposable;
import net.dpml.activity.Startable;
-import net.dpml.configuration.Configurable;
import net.dpml.configuration.Configuration;
import net.dpml.configuration.ConfigurationException;
-import net.dpml.context.Context;
-import net.dpml.context.ContextException;
-import net.dpml.context.Contextualizable;
-
-import net.dpml.logging.LogEnabled;
import net.dpml.logging.Logger;
import net.dpml.http.HttpContextService;
import net.dpml.http.HttpService;
import net.dpml.http.MimeTypes;
-import net.dpml.service.ServiceException;
-import net.dpml.service.ServiceManager;
-import net.dpml.service.Serviceable;
-
import org.mortbay.http.Authenticator;
import org.mortbay.http.HttpException;
import org.mortbay.http.HttpContext;
@@ -55,8 +45,18 @@
* @metro.service type="net.dpml.http.HttpContextService"
*/
public class HttpContextImpl extends HttpContext
- implements Startable, Serviceable, Disposable, Configurable,
HttpContextService
+ implements Startable, Disposable, HttpContextService
{
+ public interface Context
+ {
+ HttpService getServer();
+ File getTempDirectory();
+ Authenticator getAuthenticator( Authenticator value );
+ UserRealm getUserRealm( UserRealm value );
+ RequestLog getRequestLog();
+ String getName();
+ }
+
private HttpService m_HttpServer;
private boolean m_Graceful;
private Logger m_logger;
@@ -69,72 +69,36 @@
* @metro.entry key="urn:metro:classloader"
* type="java.lang.ClassLoader"
*/
- public HttpContextImpl( Logger logger, Context ctx )
- throws ContextException
+ public HttpContextImpl( Logger logger, Context context, Configuration
conf )
+ throws ConfigurationException
{
m_logger = logger;
- File tmpDir = (File) ctx.get( "urn:metro:temp" );
+ File tmpDir = context.getTempDirectory();
tmpDir.mkdirs();
setTempDirectory( tmpDir );
-
- ClassLoader cl = (ClassLoader) ctx.get( "urn:metro:classloader" );
+ ClassLoader cl = HttpContextImpl.class.getClassLoader();
setClassLoader( cl );
- }
-
- public HttpContext getHttpContext()
- {
- return this;
- }
-
- /**
- * @metro.dependency type="net.dpml.http.HttpService"
- * key="server"
- * @metro.dependency type="net.dpml.http.MimeTypes"
- * key="mimetypes" optional="true"
- * @metro.dependency type="org.mortbay.http.Authenticator"
- * key="authenticator" optional="true"
- * @metro.dependency type="org.mortbay.http.UserRealm"
- * key="realm" optional="true"
- * @metro.dependency type="org.mortbay.http.RequestLog"
- * key="request-log"
- */
- public void service( ServiceManager man )
- throws ServiceException
- {
- m_HttpServer = (HttpService) man.lookup( "server" );
-
- if( man.hasService( "authenticator" ) )
+ m_HttpServer = context.getServer();
+ Authenticator authenticator = context.getAuthenticator( null );
+ if( null != authenticator )
{
- Authenticator authenticator = (Authenticator) man.lookup(
"authenticator" );
- if( authenticator != null )
- setAuthenticator( authenticator );
+ setAuthenticator( authenticator );
}
-
- if( man.hasService( "realm" ) )
+ UserRealm userRealm = context.getUserRealm( null );
+ if( null != userRealm )
{
- UserRealm userRealm = (UserRealm) man.lookup( "realm" );
- if( userRealm != null )
- {
- setRealm( userRealm );
- setRealmName( userRealm.getName() ); // this IS necessary.
- }
-
+ setRealm( userRealm );
+ setRealmName( userRealm.getName() ); // this IS necessary.
}
-
- RequestLog requestLog = (RequestLog) man.lookup( "request-log" );
+ RequestLog requestLog = context.getRequestLog();
setRequestLog( requestLog );
- if( man.hasService( "mimetypes" ) )
+ MimeTypes mimeTypes = context.getMimeTypes( null );
+ if( null != mimeTypes )
{
- MimeTypes mimeTypes = (MimeTypes) man.lookup( "mimetypes" );
- if( mimeTypes != null )
- setMimeMap( mimeTypes.getExtensionMap() );
+ setMimeMap( mimeTypes.getExtensionMap() );
}
- }
- public void configure( Configuration conf )
- throws ConfigurationException
- {
Configuration virtualHostConf = conf.getChild( "virtual-hosts" );
configureVirtualHosts( virtualHostConf );
@@ -163,6 +127,12 @@
int maxCacheSize = conf.getChild( "max-cache-size"
).getValueAsInteger( -1 );
if( maxCacheSize > 0 )
setMaxCacheSize( maxCacheSize );
+
+ }
+
+ public HttpContext getHttpContext()
+ {
+ return this;
}
private void configureAttributes( Configuration conf )
Modified:
development/main/test/components/http/impl/src/main/net/dpml/http/impl/HttpServerImpl.java
==============================================================================
---
development/main/test/components/http/impl/src/main/net/dpml/http/impl/HttpServerImpl.java
(original)
+++
development/main/test/components/http/impl/src/main/net/dpml/http/impl/HttpServerImpl.java
Fri Jun 17 16:59:20 2005
@@ -17,12 +17,9 @@
import net.dpml.activity.Disposable;
import net.dpml.activity.Startable;
-import net.dpml.logging.LogEnabled;
import net.dpml.logging.Logger;
-import net.dpml.parameters.ParameterException;
-import net.dpml.parameters.Parameterizable;
-import net.dpml.parameters.Parameters;
import net.dpml.http.HttpService;
+
import org.mortbay.jetty.Server;
import org.mortbay.util.MultiException;
@@ -34,34 +31,45 @@
public class HttpServerImpl extends Server
implements Startable, Disposable, HttpService
{
+ public interface Context
+ {
+ boolean getTrace( boolean value );
+ boolean getAnonymous( boolean value );
+ boolean getGracefulStop( boolean value );
+ int getRequestsPerGC( int value );
+ }
+
private Logger m_logger;
private boolean m_Graceful;
-
/**
* @metro.logger name="http"
*/
- public HttpServerImpl(Logger logger, Parameters params)
+ public HttpServerImpl(Logger logger, Context context )
{
m_logger = logger;
- boolean trace = params.getParameterAsBoolean( "trace", false );
+ boolean trace = context.getTrace( false );
setTrace( trace );
- boolean anonymous = params.getParameterAsBoolean( "anonymous", false
);
+ boolean anonymous = context.getAnonymous( false );
setAnonymous( anonymous );
- m_Graceful = params.getParameterAsBoolean( "graceful-stop", false );
+ boolean m_Graceful = context.getGracefulStop( false );
- int reqs = params.getParameterAsInteger( "request-gc", -1 );
+ int reqs = context.getRequestsPerGC( -1 );
if( reqs > 0 )
+ {
setRequestsPerGC( reqs );
+ }
}
public void dispose()
{
if( m_logger.isDebugEnabled() )
+ {
m_logger.debug( "Disposing server: " + this );
+ }
super.destroy();
}
}
Modified:
development/main/test/components/http/impl/src/main/net/dpml/http/impl/IPAccessHandler.java
==============================================================================
---
development/main/test/components/http/impl/src/main/net/dpml/http/impl/IPAccessHandler.java
(original)
+++
development/main/test/components/http/impl/src/main/net/dpml/http/impl/IPAccessHandler.java
Fri Jun 17 16:59:20 2005
@@ -18,18 +18,8 @@
import net.dpml.activity.Startable;
import net.dpml.configuration.Configuration;
import net.dpml.configuration.ConfigurationException;
-import net.dpml.context.Context;
-import net.dpml.context.ContextException;
-import net.dpml.context.Contextualizable;
-import net.dpml.logging.LogEnabled;
import net.dpml.logging.Logger;
-import net.dpml.parameters.ParameterException;
-import net.dpml.parameters.Parameterizable;
-import net.dpml.parameters.Parameters;
import net.dpml.http.HttpContextService;
-import net.dpml.service.ServiceException;
-import net.dpml.service.ServiceManager;
-import net.dpml.service.Serviceable;
/**
* @metro.component name="http-ipaccess-handler" lifestyle="singleton"
@@ -39,35 +29,33 @@
extends org.mortbay.http.handler.IPAccessHandler
implements Startable
{
+ public interface Context
+ {
+ HttpContextService getHttpContext();
+ int getHandlerIndex( int value );
+ String getName();
+ String getStandardAction( String value );
+ }
+
private Logger m_logger;
private HttpContextService m_context;
private int m_index;
- /**
- * @metro.logger name="http"
- * @metro.entry key="urn:metro:name"
- * type="java.lang.String"
- * @metro.dependency type="net.dpml.http.HttpContextService"
- * key="http-context"
- */
- public IPAccessHandler(Logger logger, Context ctx, Parameters params,
ServiceManager man )
- throws ContextException, ServiceException
+ public IPAccessHandler(Logger logger, Context context, Configuration
conf )
+ throws ConfigurationException
{
m_logger = logger;
- m_context = (HttpContextService) man.lookup( "http-context" );
- String name = (String) ctx.get( "urn:metro:name" );
+ m_context = context.getHttpContext();
+ m_index = context.getHandlerIndex( -1 );
+ String name = context.getName();
setName( name );
-
- m_index = params.getParameterAsInteger( "handler-index", -1 );
- String standard = params.getParameter( "standard-action", null );
+ String standard = context.getStandardAction( null );
if( standard != null )
+ {
setStandard( standard );
- }
+ }
- public void configure( Configuration conf )
- throws ConfigurationException
- {
Configuration child = conf.getChild( "access" );
configureAccess( child );
}
@@ -88,22 +76,34 @@
throws Exception
{
if( m_index >= 0 )
+ {
m_context.addHandler( m_index, this );
+ }
else
+ {
m_context.addHandler( this );
+ }
if( m_logger.isDebugEnabled() )
+ {
m_logger.debug( "Starting IPAccessHandler: " + this );
+ }
if( ! isStarted() )
+ {
super.start();
+ }
}
public void stop()
throws InterruptedException
{
if( m_logger.isDebugEnabled() )
+ {
m_logger.debug( "Stopping IPAccessHandler: " + this );
+ }
if( isStarted() )
+ {
super.stop();
+ }
m_context.removeHandler( this );
}
}
- svn commit: r2881 - development/main/test/components/http/impl/src/main/net/dpml/http/impl, mcconnell, 06/17/2005
Archive powered by MHonArc 2.6.24.