avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: avalon/merlin/facilities/http/test/src/java/test/http TestComponent.java
Date Fri, 06 Feb 2004 16:25:22 GMT
mcconnell    2004/02/06 08:25:22

  Modified:    merlin/facilities/http/test/conf test.block
               merlin/facilities/http/test/src/java/test/http
                        TestComponent.java
  Log:
  Minor enhancements demonstrating componwent to component links.
  
  Revision  Changes    Path
  1.4       +15 -1     avalon/merlin/facilities/http/test/conf/test.block
  
  Index: test.block
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/facilities/http/test/conf/test.block,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- test.block	6 Feb 2004 15:27:14 -0000	1.3
  +++ test.block	6 Feb 2004 16:25:21 -0000	1.4
  @@ -18,7 +18,21 @@
        </classpath>
      </classloader>
   
  -   <component name="hello" class="test.http.TestComponent"/>
  +   <component name="primary" class="test.http.TestComponent">
  +     <configuration>
  +       <name>Primary</name>
  +       <message>I'm an avalon component.</message>
  +       <link>/test/secondary</link>
  +     </configuration>
  +   </component>
  +
  +   <component name="secondary" class="test.http.TestComponent">
  +     <configuration>
  +       <name>Secondary</name>
  +       <message>I'm also an avalon component.</message>
  +       <link>/test/primary</link>
  +     </configuration>
  +   </component>
   
      <component name="http" 
            class="org.apache.avalon.http.impl.DefaultModelListener" 
  
  
  
  1.2       +28 -6     avalon/merlin/facilities/http/test/src/java/test/http/TestComponent.java
  
  Index: TestComponent.java
  ===================================================================
  RCS file: /home/cvs/avalon/merlin/facilities/http/test/src/java/test/http/TestComponent.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestComponent.java	6 Feb 2004 15:27:15 -0000	1.1
  +++ TestComponent.java	6 Feb 2004 16:25:21 -0000	1.2
  @@ -26,6 +26,9 @@
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.configuration.Configurable;
   
   import javax.servlet.ServletException;
   import javax.servlet.http.HttpServlet;
  @@ -44,7 +47,7 @@
    * @avalon.service type="org.apache.avalon.http.Handler"
    */
   public class TestComponent extends HttpHandler 
  -  implements LogEnabled, Serviceable
  +  implements LogEnabled, Serviceable, Configurable
   {
       //----------------------------------------------------------
       // state
  @@ -56,6 +59,12 @@
   
       private Counter m_counter;
   
  +    private String m_link;
  +
  +    private String m_message;
  +
  +    private String m_name;
  +
       //----------------------------------------------------------
       // lifecycle
       //----------------------------------------------------------
  @@ -81,6 +90,13 @@
           m_counter = (Counter) manager.lookup( "counter" );
       }
   
  +    public void configure( Configuration config ) throws ConfigurationException
  +    {
  +        m_link = config.getChild( "link" ).getValue();
  +        m_message = config.getChild( "message" ).getValue();
  +        m_name = config.getChild( "name" ).getValue();
  +    }
  +
       //----------------------------------------------------------
       // Handler
       //----------------------------------------------------------
  @@ -108,16 +124,22 @@
           String context = request.getContextPath();
           writer.println("<html>");
           writer.println("<head>");
  -        writer.println("<title>Test HTTP Handler</title>" );
  +        writer.println("<title>" + m_name + "</title>" );
           writer.println("</head>");
           writer.println("<body>" );
           writer.println("<hr/>");
  -        writer.println("<h3>Hello (" + m_count + "/" + count + ").</h3>");
  +        writer.println("<h3>" 
  +          + m_name 
  +          + "</h3>");
           writer.println("<hr/>");
  +        writer.println("<P>" 
  +          + "local hits: " + m_count + "</br>"
  +          + "total hits: " + count + "</p>" );
           writer.println("<p>I'm an Avalon component.<br/>");
  -        writer.println("I'm also an HTTP Handler.<br/>");
  -        writer.println("I exist!!<br/>");
  -        writer.println("Therefore I am.</p>");
  +        writer.println(
  +           "Here is <a href=\"" 
  +           + m_link 
  +           + "\">a link to my mate.</a></p>");
           writer.println("<hr/>");
           writer.println("</body>");
           writer.println("</html>");
  
  
  

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


Mime
View raw message