notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
r1120 - in trunk/main: metro/model/src/main/net/dpml/metro/info metro/tools/src/main/net/dpml/metro/tools planet/http/impl/src/main/net/dpml/http planet/http/server
- From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
- To: notify-dpml AT lists.ibiblio.org
- Subject: r1120 - in trunk/main: metro/model/src/main/net/dpml/metro/info metro/tools/src/main/net/dpml/metro/tools planet/http/impl/src/main/net/dpml/http planet/http/server
- Date: Sat, 18 Feb 2006 18:26:57 +0100
Author: mcconnell
Date: 2006-02-18 18:26:54 +0100 (Sat, 18 Feb 2006)
New Revision: 1120
Modified:
trunk/main/metro/model/src/main/net/dpml/metro/info/EntryDescriptor.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
trunk/main/planet/http/impl/src/main/net/dpml/http/ServletContextHandler.java
trunk/main/planet/http/server/build.xml
Log:
1. update the entry descriptor to support comparative evaluation (used when
sorting entries in the catalog display)
2. update the servlet context to take servlet definitions as a context
argument
Modified:
trunk/main/metro/model/src/main/net/dpml/metro/info/EntryDescriptor.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/info/EntryDescriptor.java
2006-02-18 04:46:34 UTC (rev 1119)
+++ trunk/main/metro/model/src/main/net/dpml/metro/info/EntryDescriptor.java
2006-02-18 17:26:54 UTC (rev 1120)
@@ -35,7 +35,7 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public final class EntryDescriptor implements Serializable
+public final class EntryDescriptor implements Serializable, Comparable
{
/**
* Serial version identifier.
@@ -294,4 +294,30 @@
}
return hash;
}
+
+ /**
+ * Compare this entry with another entry.
+ * @param other the other object
+ * @return the comparative index
+ */
+ public int compareTo( Object other )
+ {
+ if( null == other )
+ {
+ throw new NullPointerException( "other" );
+ }
+ EntryDescriptor entry = (EntryDescriptor) other;
+ if( getOptional() == entry.getOptional() )
+ {
+ return m_key.compareTo( entry.getKey() );
+ }
+ else if( isRequired() )
+ {
+ return -1;
+ }
+ else
+ {
+ return 1;
+ }
+ }
}
Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
2006-02-18 04:46:34 UTC (rev 1119)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
2006-02-18 17:26:54 UTC (rev 1120)
@@ -28,6 +28,7 @@
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Hashtable;
+import java.util.Arrays;
import java.util.Map;
import net.dpml.metro.info.PartReference;
@@ -578,46 +579,48 @@
EntryDescriptor[] entries = context.getEntryDescriptors();
if( entries.length > 0 )
{
+ Arrays.sort( entries );
writer.write( "\n <p class=\"category\">Context</p>" );
writer.write( "\n <table width=\"100%\">" );
- for( int j=0; j < entries.length; j++ )
+ for( int j=0; j<entries.length; j++ )
{
- EntryDescriptor entry = entries[j];
- String key = entry.getKey();
- String entryClassname = entry.getClassname();
- boolean optional = entry.isOptional();
-
- if( flag )
- {
- writer.write( "<tr class=\"c-even\">" );
- }
- else
- {
- writer.write( "<tr class=\"c-odd\">" );
- }
- writer.write( "<td>" + key + "</td>" );
- if( optional )
- {
- writer.write( "<td>optional</td>" );
- }
- else
- {
- writer.write( "<td>required</td>" );
- }
- writer.write( "<td>" + entryClassname + "</td>" );
- writer.write( "</tr>" );
- flag = !flag;
+ EntryDescriptor entry = entries[j];
+ String key = entry.getKey();
+ String entryClassname = entry.getClassname();
+ String entryDisplayClassname = getDisplayClassname(
entryClassname );
+ boolean optional = entry.isOptional();
+
+ if( flag )
+ {
+ writer.write( "<tr class=\"c-even\">" );
+ }
+ else
+ {
+ writer.write( "<tr class=\"c-odd\">" );
+ }
+ writer.write( "<td>" + key + "</td>" );
+ if( optional )
+ {
+ writer.write( "<td>optional</td>" );
+ }
+ else
+ {
+ writer.write( "<td>required</td>" );
+ }
+ writer.write( "<td>" + entryDisplayClassname + "</td>" );
+ writer.write( "</tr>" );
+ flag = !flag;
}
writer.write( "\n </table>" );
}
-
+
//
// write out links to embedded types
//
-
+
PartReference[] parts = type.getPartReferences();
writePartReferences( writer, type, parts, offset );
-
+
writer.write( "\n </body>" );
writer.write( "\n</html>" );
writer.close();
@@ -630,6 +633,26 @@
}
}
+ private String getDisplayClassname( String classname )
+ {
+ if( classname.startsWith( "[L" ) )
+ {
+ if( classname.endsWith( ";" ) )
+ {
+ int n = classname.length();
+ return classname.substring( 2, n-1 ) + "[]";
+ }
+ else
+ {
+ return classname.substring( 2 ) + "[]";
+ }
+ }
+ else
+ {
+ return classname;
+ }
+ }
+
private void writeServiceDescriptors( FileWriter writer,
ServiceDescriptor[] services ) throws IOException
{
boolean flag = true;
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-18 04:46:34 UTC (rev 1119)
+++
trunk/main/planet/http/impl/src/main/net/dpml/http/ServletContextHandler.java
2006-02-18 17:26:54 UTC (rev 1120)
@@ -41,6 +41,13 @@
* @return the resource base
*/
String getResourceBase();
+
+ /**
+ * Get the array of servlet holders.
+ * @param holders the default value
+ * @return the resolved value
+ */
+ ServletHolder[] getServletHolders( ServletHolder[] holders );
}
private int m_priority = 0;
@@ -63,26 +70,27 @@
String base = context.getResourceBase();
super.setResourceBase( base );
- Handler handler = buildHandler( logger, config );
+ ServletHolder[] holders = context.getServletHolders( new
ServletHolder[0] );
+ Handler handler = buildHandler( logger, holders, config );
super.setHandler( handler );
}
private Handler buildHandler(
- Logger logger, Configuration config ) throws ConfigurationException
+ 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 );
- }
+ //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" );
@@ -95,8 +103,8 @@
ServletMapping mapping = new ServletMapping( name, path );
mappingList.add( mapping );
}
- ServletHolder[] servletArray =
- (ServletHolder[]) servletList.toArray( new ServletHolder[0] );
+ //ServletHolder[] servletArray =
+ // (ServletHolder[]) servletList.toArray( new ServletHolder[0] );
ServletMapping[] mappingArray =
(ServletMapping[]) mappingList.toArray( new ServletMapping[0] );
return new ServletHandler( servletArray, mappingArray );
Modified: trunk/main/planet/http/server/build.xml
===================================================================
--- trunk/main/planet/http/server/build.xml 2006-02-18 04:46:34 UTC (rev
1119)
+++ trunk/main/planet/http/server/build.xml 2006-02-18 17:26:54 UTC (rev
1120)
@@ -87,13 +87,16 @@
<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>
</context>
<configuration>
- <servlets>
- <servlet name="data"
class="org.mortbay.jetty.servlet.DefaultServlet"/>
- </servlets>
<mappings>
- <map servlet="data" path="/"/>
+ <map path="/" servlet="data"/>
</mappings>
</configuration>
</component>
- r1120 - in trunk/main: metro/model/src/main/net/dpml/metro/info metro/tools/src/main/net/dpml/metro/tools planet/http/impl/src/main/net/dpml/http planet/http/server, mcconnell at BerliOS, 02/18/2006
Archive powered by MHonArc 2.6.24.