notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r1036 - in trunk/main/planet/web/server: . src/main/net/dpml/web/server
- From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
- To: notify-dpml AT lists.ibiblio.org
- Subject: r1036 - in trunk/main/planet/web/server: . src/main/net/dpml/web/server
- Date: Sun, 5 Feb 2006 17:17:49 +0100
Author: mcconnell
Date: 2006-02-05 17:17:48 +0100 (Sun, 05 Feb 2006)
New Revision: 1036
Added:
trunk/main/planet/web/server/src/main/net/dpml/web/server/ResourceContextHandler.java
Modified:
trunk/main/planet/web/server/build.xml
trunk/main/planet/web/server/src/main/net/dpml/web/server/ResourceHandler.java
trunk/main/planet/web/server/src/main/net/dpml/web/server/Server.java
Log:
simplification of the context handlers (for static resources)
Modified: trunk/main/planet/web/server/build.xml
===================================================================
--- trunk/main/planet/web/server/build.xml 2006-02-05 10:00:36 UTC (rev
1035)
+++ trunk/main/planet/web/server/build.xml 2006-02-05 16:17:48 UTC (rev
1036)
@@ -36,6 +36,12 @@
</services>
</type>
+ <type xmlns="metro" name="context"
class="net.dpml.web.server.ResourceContextHandler" threadsafe="true" >
+ <services>
+ <service class="net.dpml.web.server.ResourceContextHandler"/>
+ </services>
+ </type>
+
<type xmlns="metro" name="server" class="net.dpml.web.server.Server"
threadsafe="true" collection="hard">
<services>
<service class="net.dpml.web.server.Server"/>
@@ -78,15 +84,11 @@
-->
<component xmlns="metro" type="net.dpml.web.server.Server"
lifestyle="singleton">
<parts>
- <component key="context" type="net.dpml.web.server.ContextHandler">
+ <component key="context"
type="net.dpml.web.server.ResourceContextHandler">
<context>
<entry key="server" validate="false"/>
<entry key="resourceBase" value="${dpml.share}/docs"/>
<entry key="contextPath" value="/docs"/>
- <entry key="handler" class="net.dpml.web.server.ResourceHandler">
- <value value="resources"/>
- <value value="/"/>
- </entry>
</context>
</component>
<component key="servlets" type="net.dpml.web.server.ContextHandler">
Added:
trunk/main/planet/web/server/src/main/net/dpml/web/server/ResourceContextHandler.java
===================================================================
---
trunk/main/planet/web/server/src/main/net/dpml/web/server/ResourceContextHandler.java
2006-02-05 10:00:36 UTC (rev 1035)
+++
trunk/main/planet/web/server/src/main/net/dpml/web/server/ResourceContextHandler.java
2006-02-05 16:17:48 UTC (rev 1036)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2006 Stephen McConnell.
+ *
+ * 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 net.dpml.web.server;
+
+import net.dpml.transit.util.PropertyResolver;
+
+import net.dpml.logging.Logger;
+
+import org.mortbay.jetty.Handler;
+
+/**
+ * Context handler with enhanced support for symbolic property
dereferencing.
+ */
+public class ResourceContextHandler extends ResolvingContextHandler
+{
+ /**
+ * HTTP static resource vontext handler parameters.
+ */
+ public interface Context
+ {
+ /**
+ * Get the required HTTP server.
+ * @return the assigned http server
+ */
+ Server getServer();
+
+ /**
+ * Get the http context resource base. The value may contain symbolic
+ * property references and should resolve to a local directory.
+ *
+ * @return the resource base
+ */
+ String getResourceBase();
+
+ /**
+ * Get the context path under which the http context instance will
+ * be associated.
+ *
+ * @return the assigned context path
+ */
+ String getContextPath();
+ }
+
+ private int m_priority = 0;
+
+ public ResourceContextHandler( Context context ) throws Exception
+ {
+ String base = context.getResourceBase();
+ super.setResourceBase( base );
+ String path = context.getContextPath();
+ super.setContextPath( path );
+ ResourceHandler handler = new ResourceHandler( "static", "/" );
+ super.setHandler( handler );
+ Server server = context.getServer();
+ server.addHandler( this );
+ }
+
+}
Modified:
trunk/main/planet/web/server/src/main/net/dpml/web/server/ResourceHandler.java
===================================================================
---
trunk/main/planet/web/server/src/main/net/dpml/web/server/ResourceHandler.java
2006-02-05 10:00:36 UTC (rev 1035)
+++
trunk/main/planet/web/server/src/main/net/dpml/web/server/ResourceHandler.java
2006-02-05 16:17:48 UTC (rev 1036)
@@ -27,12 +27,6 @@
*/
public class ResourceHandler extends org.mortbay.jetty.servlet.ServletHandler
{
- public interface Context
- {
- String getName();
- String getPath( String path );
- }
-
public ResourceHandler( String name, String path )
{
super();
Modified:
trunk/main/planet/web/server/src/main/net/dpml/web/server/Server.java
===================================================================
--- trunk/main/planet/web/server/src/main/net/dpml/web/server/Server.java
2006-02-05 10:00:36 UTC (rev 1035)
+++ trunk/main/planet/web/server/src/main/net/dpml/web/server/Server.java
2006-02-05 16:17:48 UTC (rev 1036)
@@ -122,7 +122,8 @@
{
handler.getContextMap().put( "server", this );
Provider provider = handler.getProvider();
- ContextHandler ch = (ContextHandler) provider.getValue(
false );
+ org.mortbay.jetty.handler.ContextHandler ch =
+ (org.mortbay.jetty.handler.ContextHandler)
provider.getValue( false );
super.addHandler( ch );
}
catch( Throwable e )
- r1036 - in trunk/main/planet/web/server: . src/main/net/dpml/web/server, mcconnell at BerliOS, 02/05/2006
Archive powered by MHonArc 2.6.24.