Skip to Content.
Sympa Menu

notify-dpml - svn commit: r1405 - in development/main: magic/core/src/main/net/dpml/magic/model planet/facilities planet/facilities/http planet/facilities/http/api/src/main/net/dpml/http planet/facilities/http/examples/hello/src/main/net/dpml/playground

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT netcompartner.com
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r1405 - in development/main: magic/core/src/main/net/dpml/magic/model planet/facilities planet/facilities/http planet/facilities/http/api/src/main/net/dpml/http planet/facilities/http/examples/hello/src/main/net/dpml/playground
  • Date: Sat, 08 Jan 2005 03:05:48 +0100

Author: mcconnell
Date: Sat Jan 8 03:05:48 2005
New Revision: 1405

Added:
development/main/planet/facilities/http/module.xml (contents, props
changed)
Removed:
development/main/planet/facilities/module.xml
Modified:
development/main/magic/core/src/main/net/dpml/magic/model/Resource.java

development/main/planet/facilities/http/api/src/main/net/dpml/http/ServletHandler.java

development/main/planet/facilities/http/examples/hello/src/main/net/dpml/playground/HelloComponent.java
development/main/planet/facilities/http/index.xml
development/main/planet/facilities/index.xml
Log:
Update the Resource equality test in Magic. Remove the module handling in
facilities. Add a http module as an example of how it should be done. Do some
cleaning up of the HelloComponent in the http examples package.

Modified:
development/main/magic/core/src/main/net/dpml/magic/model/Resource.java
==============================================================================
--- development/main/magic/core/src/main/net/dpml/magic/model/Resource.java
(original)
+++ development/main/magic/core/src/main/net/dpml/magic/model/Resource.java
Sat Jan 8 03:05:48 2005
@@ -297,8 +297,26 @@
return false;

final Resource def = (Resource) other;
- if( ! getInfo().equals( def.getInfo() ) )
+
+ if( null == getKey() )
+ {
+ if( def.getKey() != null )
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if( !getKey().equals( def.getKey() ) )
+ {
+ return false;
+ }
+ }
+
+ if( !getInfo().equals( def.getInfo() ) )
+ {
return false;
+ }

final ResourceRef[] refs = getResourceRefs();
final ResourceRef[] references = def.getResourceRefs();

Modified:
development/main/planet/facilities/http/api/src/main/net/dpml/http/ServletHandler.java
==============================================================================
---
development/main/planet/facilities/http/api/src/main/net/dpml/http/ServletHandler.java
(original)
+++
development/main/planet/facilities/http/api/src/main/net/dpml/http/ServletHandler.java
Sat Jan 8 03:05:48 2005
@@ -18,12 +18,16 @@
import org.mortbay.http.HttpHandler;

/**
- * @metro.service type="net.dpml.http.Servlethandler" version="1.0"
+ * Interface implemented by servlet handlers.
+ * @metro.service type="net.dpml.http.ServletHandler" version="1.0"
*/
public interface ServletHandler extends HttpHandler
{
- /** Adds the contextObject into the ServletContext object.
- *
+ /**
+ * Adds the contextObject into the ServletContext object.
+ * @param entryName the name of the entry
+ * @param contextObject the object to add to the servlet context under
+ * the entry name
*/
void addServletContextEntry( String entryName, Object contextObject );
}

Modified:
development/main/planet/facilities/http/examples/hello/src/main/net/dpml/playground/HelloComponent.java
==============================================================================
---
development/main/planet/facilities/http/examples/hello/src/main/net/dpml/playground/HelloComponent.java
(original)
+++
development/main/planet/facilities/http/examples/hello/src/main/net/dpml/playground/HelloComponent.java
Sat Jan 8 03:05:48 2005
@@ -21,7 +21,6 @@
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
-import java.util.Date;

import net.dpml.activity.Startable;

@@ -48,23 +47,46 @@
public class HelloComponent
implements HttpHandler, Startable
{
+ /**
+ * Logging channel assigned by the container.
+ */
private Logger m_logger;
- private boolean m_Started;
- private HttpContext m_Context;
- private String m_Name;
+
+ /**
+ * State of the server.
+ */
+ private boolean m_started;
+
+ /**
+ * The HTTP context.
+ */
+ private HttpContext m_context;
+
+ /**
+ * the component name.
+ */
+ private String m_name;


/**
+ * Create of a new hello component.
+ *
+ * @param logger the container supplied logging channel
+ * @param manager the supplied service manager
+ * @param context the supplied context object
+ * @exception ContextException if a context related error occurs
+ * @exception ServiceException if a service lookup related error occurs
+ *
* @metro.dependency type="net.dpml.http.HttpContextService"
key="context"
* @metro.entry key="urn:metro:name"
* type="java.lang.String"
*/
- public HelloComponent( Logger logger, ServiceManager man, Context ctx )
+ public HelloComponent( Logger logger, ServiceManager manager, Context
context )
throws ContextException, ServiceException
{
m_logger = logger;
- m_Name = (String) ctx.get( "urn:metro:name" );
- HttpContextService httpCtx = (HttpContextService) man.lookup(
"context" );
+ m_name = (String) context.get( "urn:metro:name" );
+ HttpContextService httpCtx = (HttpContextService) manager.lookup(
"context" );
httpCtx.addHandler( 2, this );
}

@@ -72,79 +94,125 @@
// implemetation
//----------------------------------------------------------

- protected Logger getLogger()
- {
- return m_logger;
- }
-
-
+ /**
+ * Handle an HTTP request.
+ * @param path the request path
+ * @param params the params string
+ * @param request the request instance
+ * @param response the response instance
+ * @exception IOException if an IO error occurs
+ */
public void handle( String path, String params,
HttpRequest request, HttpResponse response )
throws IOException
{
- if( ! path.startsWith( "/hello" ) )
+ if( !path.startsWith( "/hello" ) )
+ {
return;
-
+ }
+
if( m_logger.isDebugEnabled() )
+ {
m_logger.debug( "Hello - Handling HTTP: " + path );
-
- response.setContentType("text/html");
+ }
+
+ response.setContentType( "text/html" );
OutputStream out = response.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter( out, "ISO8859-1" );
PrintWriter writer = new PrintWriter( osw );

- writer.println("<html>");
- writer.println("<head>");
- writer.print("<title>" );
+ writer.println( "<html>" );
+ writer.println( "<head>" );
+ writer.print( "<title>" );
writer.print( "Hello " );
if( request.hasUserPrincipal() )
+ {
writer.print( request.getUserPrincipal() );
+ }
else
+ {
writer.print( "stranger" );
+ }
writer.println( " !!</title>" );
- writer.println("</head>");
- writer.println("<body>" );
- writer.println("<hr/>");
- writer.print("<h3>Hello " );
+ writer.println( "</head>" );
+ writer.println( "<body>" );
+ writer.println( "<hr/>" );
+ writer.print( "<h3>Hello " );
if( request.hasUserPrincipal() )
+ {
writer.print( request.getUserPrincipal() );
+ }
else
+ {
writer.print( "stranger" );
- writer.println( " !!</h3>");
- writer.println("<hr/>");
- writer.println("</body>");
- writer.println("</html>");
+ }
+ writer.println( " !!</h3>" );
+ writer.println( "<hr/>" );
+ writer.println( "</body>" );
+ writer.println( "</html>" );
writer.flush();
request.setHandled( true );
}

+ /**
+ * Return the name of this component.
+ * @return the component name
+ */
public String getName()
{
- return m_Name;
+ return m_name;
}

+ /**
+ * Initialization of the request handler with the supplied http context.
+ * @param context the http context
+ */
public void initialize( HttpContext context )
{
- m_Context = context;
+ m_context = context;
}

+ /**
+ * Return the assigned http context object.
+ * @return the http context object
+ */
public HttpContext getHttpContext()
{
- return m_Context;
+ return m_context;
}

+ /**
+ * Start the server.
+ */
public void start()
{
- m_Started = true;
+ m_started = true;
}

+ /**
+ * Stop the server.
+ */
public void stop()
{
- m_Started = false;
+ m_started = false;
}

+ /**
+ * Return the current state of the server. Returns TRUE if
+ * the servicer is running else FALSE.
+ * @return the started state
+ */
public boolean isStarted()
{
- return m_Started;
+ return m_started;
+ }
+
+ /**
+ * Return the logging channel.
+ * @return the logging channel
+ */
+ private Logger getLogger()
+ {
+ return m_logger;
}
}

Modified: development/main/planet/facilities/http/index.xml
==============================================================================
--- development/main/planet/facilities/http/index.xml (original)
+++ development/main/planet/facilities/http/index.xml Sat Jan 8 03:05:48
2005
@@ -19,7 +19,25 @@
<index>
<import index="blocks/index.xml" />
<import index="examples/index.xml" />
-
+
+ <project file="module.xml">
+ <info>
+ <group>dpml/http</group>
+ <name>dpml-http</name>
+ <version>1.0.0</version>
+ <status>SNAPSHOT</status>
+ <type>module</type>
+ </info>
+ <plugins>
+ <include key="dpml-magic-checkstyle"/>
+ </plugins>
+ <dependencies>
+ <include key="dpml-util"/>
+ <include key="dpml-transit"/>
+ <include key="dpml-metro"/>
+ </dependencies>
+ </project>
+
<project basedir="api">
<info>
<group>dpml/http</group>

Added: development/main/planet/facilities/http/module.xml
==============================================================================
--- (empty file)
+++ development/main/planet/facilities/http/module.xml Sat Jan 8 03:05:48
2005
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Copyright 2004 Stephen J 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.
+-->
+
+<project name="dpml-http" default="docs" basedir="."
+ xmlns:magic="antlib:net.dpml.magic"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core">
+
+ <magic:import uri="artifact:template:dpml/magic/standard"/>
+ <magic:import uri="artifact:template:dpml/magic/checkstyle"/>
+
+ <target name="build" depends="standard.build">
+ <x:module index="index.xml">
+ <header>
+ <svn href="http://paris.dpml.net/svn/development/main/planet"/>
+ <home href="http://www.dpml.net/products/planet"/>
+ </header>
+ </x:module>
+ </target>
+
+ <target name="docs" depends="install,checkstyle">
+ <x:javadoc>
+ <link href="http://java.sun.com/j2se/1.4/docs/api"/>
+ <group title="HTTP Facility">
+ <package name="net.dpml.http"/>
+ <package name="net.dpml.http.impl"/>
+ </group>
+ <group title="HTTP Examples">
+ <package name="net.dpml.http.hangman"/>
+ <package name="net.dpml.http.hangman.*"/>
+ <package name="net.dpml.playground"/>
+ <package name="test.*"/>
+ </group>
+ </x:javadoc>
+ </target>
+
+ <target name="junit-report">
+ <mkdir dir="target/reports/junit"/>
+ <junitreport todir="target/reports/junit">
+ <fileset dir=".">
+ <include name="**/target/test-reports/TEST-*.xml"/>
+ </fileset>
+ <report format="frames" todir="target/reports/junit"/>
+ </junitreport>
+ </target>
+
+</project>

Modified: development/main/planet/facilities/index.xml
==============================================================================
--- development/main/planet/facilities/index.xml (original)
+++ development/main/planet/facilities/index.xml Sat Jan 8 03:05:48
2005
@@ -24,29 +24,6 @@
<import index="./http/index.xml"/>
<import index="./reflector/blocks/index.xml"/>

- <!-- Does not build ATM.
- Modules
-
- <project file="module.xml">
- <info>
- <group>dpml/facilities</group>
- <name>dpml-facilities</name>
- <version>1.0.0</version>
- <status>SNAPSHOT</status>
- <type>module</type>
- </info>
- <plugins>
- <include key="dpml-magic-checkstyle"/>
- </plugins>
- <dependencies>
- <include key="dpml-util"/>
- <include key="dpml-transit"/>
- <include key="dpml-magic"/>
- <include key="dpml-metro"/>
- </dependencies>
- </project>
- -->
-
<resource>
<info>
<group>servletapi</group>



  • svn commit: r1405 - in development/main: magic/core/src/main/net/dpml/magic/model planet/facilities planet/facilities/http planet/facilities/http/api/src/main/net/dpml/http planet/facilities/http/examples/hello/src/main/net/dpml/playground, mcconnell, 01/07/2005

Archive powered by MHonArc 2.6.24.

Top of Page