You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ni...@apache.org on 2004/07/25 19:00:07 UTC

svn commit: rev 23235 - in avalon/trunk/planet/facilities/http: impl impl/src/etc impl/src/main/org/apache/avalon/http/impl spi/src/main/org/apache/avalon/http

Author: niclas
Date: Sun Jul 25 10:00:06 2004
New Revision: 23235

Added:
   avalon/trunk/planet/facilities/http/impl/src/etc/
   avalon/trunk/planet/facilities/http/impl/src/etc/default-server.xml   (contents, props changed)
Modified:
   avalon/trunk/planet/facilities/http/impl/build.xml
   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/HttpServerImpl.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/HttpService.java
Log:
Further work on getting this facility into a working condition.

Modified: avalon/trunk/planet/facilities/http/impl/build.xml
==============================================================================
--- avalon/trunk/planet/facilities/http/impl/build.xml	(original)
+++ avalon/trunk/planet/facilities/http/impl/build.xml	Sun Jul 25 10:00:06 2004
@@ -8,8 +8,14 @@
 
   <target name="build" depends="standard.build">
     <x:block name="http" embed="MAIN">
-      <x:component name="model-listener" 
-         class="org.apache.avalon.http.impl.DefaultModelListener"/>
+      <x:component name="server" 
+         class="org.apache.avalon.http.impl.HttpServerImpl"/>
+      <x:component name="socket8088" 
+         class="org.apache.avalon.http.impl.SocketListenerComponent">
+         <x:parameters>
+           <x:parameter name="port" value="8088" />
+         </x:parameters>
+      </x:component>
     </x:block>
   </target>
 

Added: avalon/trunk/planet/facilities/http/impl/src/etc/default-server.xml
==============================================================================
--- (empty file)
+++ avalon/trunk/planet/facilities/http/impl/src/etc/default-server.xml	Sun Jul 25 10:00:06 2004
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<container name="http">
+
+  <classloader>
+    <classpath>
+      <artifact>jar:avalon/http/avalon-http-spi#SNAPSHOT</artifact>
+      <artifact>jar:avalon/http/avalon-http-api#SNAPSHOT</artifact>
+      <artifact>jar:servletapi/servletapi#2.3</artifact>
+      <artifact>jar:jetty/org.mortbay.jetty#SNAPSHOT</artifact>
+      <artifact>jar:avalon/http/avalon-http-util#SNAPSHOT</artifact>
+      <artifact>jar:avalon/util/avalon-util-configuration#1.0.0</artifact>
+      <artifact>jar:avalon/framework/avalon-framework-api#SNAPSHOT</artifact>
+      <artifact>jar:avalon/framework/avalon-framework-impl#SNAPSHOT</artifact>
+      <artifact>jar:avalon/framework/avalon-framework-legacy#SNAPSHOT</artifact>
+      <artifact>jar:avalon/logkit/avalon-logkit#2.0.0</artifact>
+      <artifact>jar:avalon/http/avalon-http-impl#SNAPSHOT</artifact>
+    </classpath>
+  </classloader>
+
+  <component name="socketlistener" class="org.apache.avalon.http.impl.SocketListenerComponent">
+    <parameters>
+      <parameter name="port" value="8088"/>
+    </parameters>
+  </component>
+    
+  <component name="server" class="org.apache.avalon.http.impl.HttpServerImpl" />
+  
+  <component name="context" class="org.apache.avalon.http.impl.HttpContextImpl" />
+  <component name="model-handler" class="org.apache.avalon.http.impl.ModelHandler" >
+    <configuration>
+      <url-path>/test</url-path>
+      <component>test</component>
+    </configuration>
+  </component>
+  <component name="request-log" class="org.apache.avalon.http.impl.NcsaRequestLog" />
+  
+<!--    
+  <container name="model-context" >
+    <component name="realm" class="org.apache.avalon.http.impl.DefaultUserRealm" />
+    <component name="authenticator" class="org.apache.avalon.http.impl.DefaultAuthenticator" />
+  </container>
+-->    
+  
+</container>
+ 

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 10:00:06 2004
@@ -97,23 +97,31 @@
      * @avalon.dependency type="org.apache.avalon.http.HttpService"
      *                    key="server"
      * @avalon.dependency type="org.mortbay.http.Authenticator"
-     *                    key="authenticator"
+     *                    key="authenticator" optional="true"
      * @avalon.dependency type="org.mortbay.http.UserRealm"
-     *                    key="realm"
+     *                    key="realm" optional="true"
      * @avalon.dependency type="org.mortbay.http.RequestLog"
-     *                    key="request-log"
+     *                    key="request-log" 
      */
     public void service( ServiceManager man )
         throws ServiceException
     {
         m_HttpServer = (HttpService) man.lookup( "server" );
         
-        Authenticator auth = (Authenticator) man.lookup( "authenticator" );
-        m_HttpContext.setAuthenticator( auth );
+        try
+        {
+            Authenticator auth = (Authenticator) man.lookup( "authenticator" );
+            m_HttpContext.setAuthenticator( auth );
+        } catch( ServiceException e )
+        {} // ignore, quite ok.
         
-        UserRealm realm = (UserRealm) man.lookup( "realm" );
-        m_HttpContext.setRealm( realm );
-        m_HttpContext.setRealmName( realm.getName() ); // Is this necessary?
+        try
+        {
+            UserRealm realm = (UserRealm) man.lookup( "realm" );
+            m_HttpContext.setRealm( realm );
+            m_HttpContext.setRealmName( realm.getName() ); // Is this necessary?
+        } catch( ServiceException e )
+        {} // ignore, quite ok.
         
         RequestLog log = (RequestLog) man.lookup( "request-log" );
         m_HttpContext.setRequestLog( log );

Modified: avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/HttpServerImpl.java
==============================================================================
--- avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/HttpServerImpl.java	(original)
+++ avalon/trunk/planet/facilities/http/impl/src/main/org/apache/avalon/http/impl/HttpServerImpl.java	Sun Jul 25 10:00:06 2004
@@ -35,6 +35,7 @@
 /** Wrapper for the Jetty HttpServer
  *
  * @avalon.component name="http-server" lifestyle="singleton"
+ * @avalon.service type="org.apache.avalon.http.HttpService"
  */
 public class HttpServerImpl extends HttpServer
     implements LogEnabled, Parameterizable, Startable, Disposable, HttpService

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 10:00:06 2004
@@ -51,9 +51,10 @@
  * @avalon.service type="org.mortbay.http.HttpHandler"
  */
 public class ModelHandler
-    implements Serviceable, Configurable, Contextualizable,
+    implements Serviceable, Configurable, Contextualizable, LogEnabled,
                HttpHandler, CompositionListener
 {
+    private Logger           m_Logger;
     private ContainmentModel m_Model;
     private HttpContext      m_Context;
     private String           m_Name;
@@ -65,6 +66,21 @@
     }
     
     /**
+     * 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 listener by the container during 
      * which we are supplied with the root composition model for 
      * the application.
@@ -111,7 +127,7 @@
     public void handle( String pathInContext, String pathParams, 
                         HttpRequest request, HttpResponse response ) 
     {
-        
+        getLogger().info( "Request: " + pathInContext + ", " + pathParams );
     }
 
     public void initialize( HttpContext context )

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 10:00:06 2004
@@ -36,6 +36,7 @@
 /** Wrapper for the Jetty NCSA request logger.
  *
  * @avalon.component name="http-ncsa-log" lifestyle="singleton"
+ * @avalon.service type="org.mortbay.http.RequestLog" lifestyle="singleton"
  */
 public class NcsaRequestLog extends NCSARequestLog
     implements RequestLog, Parameterizable, Startable

Modified: avalon/trunk/planet/facilities/http/spi/src/main/org/apache/avalon/http/HttpService.java
==============================================================================
--- avalon/trunk/planet/facilities/http/spi/src/main/org/apache/avalon/http/HttpService.java	(original)
+++ avalon/trunk/planet/facilities/http/spi/src/main/org/apache/avalon/http/HttpService.java	Sun Jul 25 10:00:06 2004
@@ -27,7 +27,7 @@
 /**
  * Defintion of the HttpService service contract.
  *
- * @avalon.service version="1.0"
+ * @avalon.service type="org.apache.avalon.http.HttpService" version="1.0"
  */
 public interface HttpService
 {

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org