Skip to Content.
Sympa Menu

notify-dpml - r1138 - in trunk/main: metro/builder/src/main/net/dpml/metro/builder planet/http/impl/src/main/net/dpml/http planet/http/server planet/http/server/etc

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1138 - in trunk/main: metro/builder/src/main/net/dpml/metro/builder planet/http/impl/src/main/net/dpml/http planet/http/server planet/http/server/etc
  • Date: Fri, 24 Feb 2006 20:14:29 +0100

Author: mcconnell
Date: 2006-02-24 20:14:26 +0100 (Fri, 24 Feb 2006)
New Revision: 1138

Added:
trunk/main/planet/http/impl/src/main/net/dpml/http/ServletEntry.java
trunk/main/planet/http/server/etc/plugin.xml
Removed:
trunk/main/planet/http/impl/src/main/net/dpml/http/ServletMapping.java
trunk/main/planet/http/server/etc/plugin/
Modified:

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPlugin.java

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginFactory.java

trunk/main/planet/http/impl/src/main/net/dpml/http/ServletContextHandler.java
trunk/main/planet/http/impl/src/main/net/dpml/http/ServletHandler.java
trunk/main/planet/http/server/build.xml
Log:
remove dependency on configurations from the http server (i.e. it's all
context now)

Modified:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPlugin.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPlugin.java
2006-02-24 19:02:09 UTC (rev 1137)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPlugin.java
2006-02-24 19:14:26 UTC (rev 1138)
@@ -65,7 +65,7 @@
private static final String NAME = "plugin";

private static final String PUBLIC_ID =
- "-//DPML//DTD Component Plugin Version 1.0//EN";
+ "-//DPML//DTD Component 1.0//EN";

private static final String SYSTEM_ID =
"http://download.dpml.net/dtds/component_1_0.dtd";;

Modified:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginFactory.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginFactory.java
2006-02-24 19:02:09 UTC (rev 1137)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentPluginFactory.java
2006-02-24 19:14:26 UTC (rev 1138)
@@ -53,7 +53,7 @@
public class ComponentPluginFactory extends DefaultPluginFactory
{
/**
- * Build the plugin definition.
+ * Build the plugin definition for the supplied resource.
* @exception exception if a build related error occurs
*/
public Plugin build( File dir, Resource resource ) throws Exception
@@ -70,7 +70,7 @@
protected Strategy getStrategy( File dir, Resource resource )
{
Type type = resource.getType( "plugin" );
- String source = type.getProperty( "project.plugin.srcfile",
"plugin/definition.xml" );
+ String source = type.getProperty( "project.plugin.srcfile",
"plugin.xml" );
File src = new File( dir, source );
if( src.exists() )
{

Modified:
trunk/main/planet/http/impl/src/main/net/dpml/http/ServletContextHandler.java
===================================================================
---
trunk/main/planet/http/impl/src/main/net/dpml/http/ServletContextHandler.java
2006-02-24 19:02:09 UTC (rev 1137)
+++
trunk/main/planet/http/impl/src/main/net/dpml/http/ServletContextHandler.java
2006-02-24 19:14:26 UTC (rev 1138)
@@ -48,6 +48,13 @@
* @return the resolved value
*/
ServletHolder[] getServletHolders( ServletHolder[] holders );
+
+ /**
+ * Get the array of servlet name to path mappings.
+ * @param entries the default value
+ * @return the resolved array of name to path mappings
+ */
+ ServletEntry[] getServletEntries( ServletEntry[] entries );
}

private int m_priority = 0;
@@ -56,11 +63,9 @@
* Creation of a new servlet context handler.
* @param logger the assigned logging channel
* @param context the deployment context
- * @param config the deployment configuration
* @exception Exception if an instantiation error occurs
*/
- public ServletContextHandler(
- Logger logger, Context context, Configuration config ) throws Exception
+ public ServletContextHandler( Logger logger, Context context ) throws
Exception
{
super();

@@ -71,42 +76,8 @@
super.setResourceBase( base );

ServletHolder[] holders = context.getServletHolders( new
ServletHolder[0] );
- Handler handler = buildHandler( logger, holders, config );
+ ServletEntry[] entries = context.getServletEntries( new
ServletEntry[0] );
+ ServletHandler handler = new ServletHandler( holders, entries );
super.setHandler( handler );
}
-
- private Handler buildHandler(
- Logger logger, ServletHolder[] servletArray, Configuration config )
throws ConfigurationException
- {
- logger.debug( "configuration " + config );
- //Configuration servlets = config.getChild( "servlets" );
- //ArrayList servletList = new ArrayList();
- //Configuration[] servletConfigs = servlets.getChildren( "servlet" );
- //logger.debug( "servlet count: " + servletConfigs.length );
- //for( int i=0; i<servletConfigs.length; i++ )
- //{
- // Configuration servletConfig = servletConfigs[i];
- // String name = servletConfig.getAttribute( "name" );
- // String classname = servletConfig.getAttribute( "class" );
- // ServletHolder holder = new ServletHolder( name, classname );
- // servletList.add( holder );
- //}
- ArrayList mappingList = new ArrayList();
- Configuration mappings = config.getChild( "mappings" );
- Configuration[] servletMappings = mappings.getChildren( "map" );
- logger.debug( "mapping count: " + servletMappings.length );
- for( int i=0; i<servletMappings.length; i++ )
- {
- Configuration servletMap = servletMappings[i];
- String name = servletMap.getAttribute( "servlet" );
- String path = servletMap.getAttribute( "path" );
- ServletMapping mapping = new ServletMapping( name, path );
- mappingList.add( mapping );
- }
- //ServletHolder[] servletArray =
- // (ServletHolder[]) servletList.toArray( new ServletHolder[0] );
- ServletMapping[] mappingArray =
- (ServletMapping[]) mappingList.toArray( new ServletMapping[0] );
- return new ServletHandler( servletArray, mappingArray );
- }
}

Added: trunk/main/planet/http/impl/src/main/net/dpml/http/ServletEntry.java
===================================================================
--- trunk/main/planet/http/impl/src/main/net/dpml/http/ServletEntry.java
2006-02-24 19:02:09 UTC (rev 1137)
+++ trunk/main/planet/http/impl/src/main/net/dpml/http/ServletEntry.java
2006-02-24 19:14:26 UTC (rev 1138)
@@ -0,0 +1,97 @@
+/*
+ * 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.http;
+
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.servlet.ServletMapping;
+
+/**
+ * A ServletEntry maintains a mapping between a servlet name and a relative
path.
+ */
+public class ServletEntry
+{
+ private final String m_name;
+ private final String m_path;
+
+ /**
+ * Creation of a new servlet name to path entry.
+ * @param name the servlet name
+ * @param path the context relative path
+ */
+ public ServletEntry( String name, String path )
+ {
+ m_name = name;
+ m_path = path;
+ }
+
+ /**
+ * Return the servlet name.
+ * @return the servlet name
+ */
+ public String getName()
+ {
+ return m_name;
+ }
+
+ /**
+ * Return the path.
+ * @return the servlet path
+ */
+ public String getPath()
+ {
+ return m_path;
+ }
+
+ /**
+ * Test is this object is equal to the supplied object.
+ * @param other the object to evaluate this object against
+ * @return tryue if the objects are equal else false
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof ServletEntry )
+ {
+ ServletEntry entry = (ServletEntry) other;
+ if( !m_name.equals( entry.m_name ) )
+ {
+ return false;
+ }
+ else
+ {
+ return m_path.equals( entry.m_path );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Return the instance hashcode.
+ * @return the hash value
+ */
+ public int hashCode()
+ {
+ int hash = m_name.hashCode();
+ hash ^= m_path.hashCode();
+ return hash;
+ }
+}

Modified:
trunk/main/planet/http/impl/src/main/net/dpml/http/ServletHandler.java
===================================================================
--- trunk/main/planet/http/impl/src/main/net/dpml/http/ServletHandler.java
2006-02-24 19:02:09 UTC (rev 1137)
+++ trunk/main/planet/http/impl/src/main/net/dpml/http/ServletHandler.java
2006-02-24 19:14:26 UTC (rev 1138)
@@ -27,13 +27,30 @@
/**
* Creation of a new servlet handler.
* @param servlets the servlet holder array
- * @param maps the servlet mappings
+ * @param entries the servlet name to path mappings
*/
- public ServletHandler( ServletHolder[] servlets, ServletMapping[] maps )
+ public ServletHandler( ServletHolder[] servlets, ServletEntry[] entries )
{
super();

setServlets( servlets );
- setServletMappings( maps );
+ ServletMapping[] mapping = getServletMappings( entries );
+ setServletMappings( mapping );
}
+
+ private ServletMapping[] getServletMappings( ServletEntry[] entries )
+ {
+ ServletMapping[] maps = new ServletMapping[ entries.length ];
+ for( int i=0; i<entries.length; i++ )
+ {
+ ServletEntry entry = entries[i];
+ String name = entry.getName();
+ String path = entry.getPath();
+ ServletMapping map = new ServletMapping();
+ map.setServletName( name );
+ map.setPathSpec( path );
+ maps[i] = map;
+ }
+ return maps;
+ }
}

Deleted:
trunk/main/planet/http/impl/src/main/net/dpml/http/ServletMapping.java
===================================================================
--- trunk/main/planet/http/impl/src/main/net/dpml/http/ServletMapping.java
2006-02-24 19:02:09 UTC (rev 1137)
+++ trunk/main/planet/http/impl/src/main/net/dpml/http/ServletMapping.java
2006-02-24 19:14:26 UTC (rev 1138)
@@ -1,35 +0,0 @@
-/*
- * 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.http;
-
-/**
- * Servlet path to name mapping.
- */
-public class ServletMapping extends org.mortbay.jetty.servlet.ServletMapping
-{
- /**
- * Creation of a new servlet mapping.
- * @param name the servlet name
- * @param path the path
- */
- public ServletMapping( String name, String path )
- {
- super();
-
- setServletName( name );
- setPathSpec( path );
- }
-}

Modified: trunk/main/planet/http/server/build.xml
===================================================================
--- trunk/main/planet/http/server/build.xml 2006-02-24 19:02:09 UTC (rev
1137)
+++ trunk/main/planet/http/server/build.xml 2006-02-24 19:14:26 UTC (rev
1138)
@@ -93,12 +93,13 @@
<value value="org.mortbay.jetty.servlet.DefaultServlet"/>
</value>
</entry>
+ <entry key="servletEntries">
+ <value class="net.dpml.http.ServletEntry">
+ <value value="data"/>
+ <value value="/"/>
+ </value>
+ </entry>
</context>
- <configuration>
- <mappings>
- <map path="/" servlet="data"/>
- </mappings>
- </configuration>
</component>
</parts>
</component>

Added: trunk/main/planet/http/server/etc/plugin.xml
===================================================================
--- trunk/main/planet/http/server/etc/plugin.xml 2006-02-24 19:02:09
UTC (rev 1137)
+++ trunk/main/planet/http/server/etc/plugin.xml 2006-02-24 19:14:26
UTC (rev 1138)
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE component PUBLIC "-//DPML//DTD Component 1.0//EN"
"http://download.dpml.net/dtds/component_1_0.dtd"; >
+
+<component xmlns="metro" type="net.dpml.http.Server" lifestyle="singleton">
+ <parts>
+ <!--
+ Add a select channel connector to 8080.
+ -->
+ <component key="plain" type="net.dpml.http.SelectChannelConnector">
+ <context>
+ <entry key="port" value="8080"/>
+ <entry key="maxIdleTime" value="50000"/>
+ <entry key="acceptors" value="10"/>
+ </context>
+ </component>
+ <!--
+ Add a SSL connector to 8443.
+ -->
+ <component key="ssl" type="net.dpml.http.SslSocketConnector">
+ <context>
+ <entry key="port" value="8443"/>
+ <entry key="maxIdleTime" value="30000"/>
+ <entry key="keystore"
value="local:keystore:dpml/planet/http/jetty"/>
+ <entry key="password"
value="OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"/>
+ <entry key="keyPassword"
value="OBF:1u2u1wml1z7s1z7a1wnl1u2g"/>
+ </context>
+ </component>
+ <!--
+ Add a user realm.
+ -->
+ <component key="realm" type="net.dpml.http.HashUserRealm">
+ <context>
+ <entry key="name" value="Test Realm"/>
+ <entry key="URI"
value="local:properties:dpml/planet/http/realm"/>
+ </context>
+ </component>
+ <!--
+ Add a web application.
+ -->
+ <component key="webapp" type="net.dpml.http.WebAppContextHandler">
+ <context>
+ <entry key="contextPath" value="/"/>
+ <entry key="war"
value="link:war:dpml/planet/http/dpml-http-app"/>
+ </context>
+ </component>
+ <!--
+ Creation of a HTTP server configured to present static content in
+ the ${dpml.share}/docs directory.
+ -->
+ <component key="context" type="net.dpml.http.ResourceContextHandler">
+ <context>
+ <entry key="resourceBase" value="$${dpml.share}/docs"/>
+ <entry key="contextPath" value="/docs"/>
+ </context>
+ </component>
+ <!--
+ Add an experimental servlet context.
+ (Need to add context cloassloader configuration but this requires
+ per-component threads - currently limited to classes declared within
+ the part classloader).
+ -->
+ <component key="servlets" type="net.dpml.http.ServletContextHandler">
+ <context>
+ <entry key="resourceBase" value="$${dpml.data}"/>
+ <entry key="contextPath" value="/data"/>
+ <entry key="servletHolders">
+ <value class="net.dpml.http.ServletHolder">
+ <value value="data"/>
+ <value
value="org.mortbay.jetty.servlet.DefaultServlet"/>
+ </value>
+ </entry>
+ <entry key="servletEntries">
+ <value class="net.dpml.http.ServletEntry">
+ <value value="data"/>
+ <value value="/"/>
+ </value>
+ </entry>
+ </context>
+ </component>
+ </parts>
+</component>




  • r1138 - in trunk/main: metro/builder/src/main/net/dpml/metro/builder planet/http/impl/src/main/net/dpml/http planet/http/server planet/http/server/etc, mcconnell at BerliOS, 02/24/2006

Archive powered by MHonArc 2.6.24.

Top of Page