directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 9646 - in incubator/directory/eve/trunk/eve/frontend/processor: merlin-impl merlin-impl/src/java/org/apache/eve/processor/impl merlin-impl/src/test/org/apache/eve/processor/impl pojo-impl pojo-impl/src/java/org/apache/eve/processor/impl spi/src/java/org/apache/eve/processor
Date Sat, 20 Mar 2004 03:55:13 GMT
Author: akarasulu
Date: Fri Mar 19 19:55:12 2004
New Revision: 9646

Modified:
   incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/project.properties
   incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/project.xml
   incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/src/java/org/apache/eve/processor/impl/MerlinRequestProcessor.java
   incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/src/test/org/apache/eve/processor/impl/MerlinRequestProcessorTest.java
   incubator/directory/eve/trunk/eve/frontend/processor/pojo-impl/project.xml
   incubator/directory/eve/trunk/eve/frontend/processor/pojo-impl/src/java/org/apache/eve/processor/impl/DefaultRequestProcessor.java
   incubator/directory/eve/trunk/eve/frontend/processor/spi/src/java/org/apache/eve/processor/RequestProcessorMonitorAdapter.java
Log:
Cleaned up the processor code.  I think we're golden here.  I really want
the logging stuff to work but I'll retrofit that.  For now we just need a 
few more test cases for the other message types just to confirm then we
move on to the encoder and the output module.


Modified: incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/project.properties
==============================================================================
--- incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/project.properties	(original)
+++ incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/project.properties	Fri
Mar 19 19:55:12 2004
@@ -3,3 +3,5 @@
 merlin.debug=true
 merlin.info=true
 merlin.override=conf/config.xml
+
+log4j.configuration=log4j.properties

Modified: incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/project.xml
==============================================================================
--- incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/project.xml	(original)
+++ incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/project.xml	Fri Mar 19
19:55:12 2004
@@ -36,6 +36,20 @@
       </dependency>
 
       <dependency>
+        <groupId>commons-logging</groupId>
+        <artifactId>commons-logging</artifactId>
+        <version>1.0.3</version>
+        <url>http://jakarta.apache.org/commons/logging</url>
+      </dependency>
+
+      <dependency>
+        <groupId>log4j</groupId>
+        <artifactId>log4j</artifactId>
+        <version>1.2.7</version>
+        <url>http://logging.apache.org/log4j/docs</url>
+      </dependency>
+
+      <dependency>
         <groupId>commons-lang</groupId>
         <artifactId>commons-lang</artifactId>
         <version>2.0</version>

Modified: incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/src/java/org/apache/eve/processor/impl/MerlinRequestProcessor.java
==============================================================================
--- incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/src/java/org/apache/eve/processor/impl/MerlinRequestProcessor.java
(original)
+++ incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/src/java/org/apache/eve/processor/impl/MerlinRequestProcessor.java
Fri Mar 19 19:55:12 2004
@@ -20,6 +20,7 @@
 import org.apache.eve.thread.ThreadPool ;
 import org.apache.eve.event.EventRouter ;
 import org.apache.eve.seda.DefaultStageConfig ;
+import org.apache.eve.seda.StageMonitorAdapter;
 
 import org.apache.eve.processor.RequestProcessor ;
 
@@ -74,12 +75,7 @@
     // ------------------------------------------------------------------------
 
 
-    /* (non-Javadoc)
-     * @see org.apache.eve.processor.RequestProcessor#dummy()
-     */
-    public void dummy()
-    {
-    }
+    // nothing here yet
     
     
     // ------------------------------------------------------------------------
@@ -142,7 +138,10 @@
      */
     public void initialize() throws Exception
     {
-        //throw new NotImplementedException( "STUB" ) ;
+        DefaultHandlerRegistry hooks = new DefaultHandlerRegistry() ;
+        requestProcessor = 
+            new DefaultRequestProcessor( router, stageConfig, hooks ) ;
+        requestProcessor.setMonitor( new StageMonitorAdapter() ) ;
     }
     
     
@@ -151,7 +150,7 @@
      */
     public void start() throws Exception
     {
-        //throw new NotImplementedException( "STUB" ) ;
+        requestProcessor.start() ;
     }
     
     
@@ -160,6 +159,7 @@
      */
     public void stop() throws Exception
     {
-        //throw new NotImplementedException( "STUB" ) ;
+        System.out.println( "stopping ... ") ;
+        requestProcessor.stop() ;
     }
 }

Modified: incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/src/test/org/apache/eve/processor/impl/MerlinRequestProcessorTest.java
==============================================================================
--- incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/src/test/org/apache/eve/processor/impl/MerlinRequestProcessorTest.java
(original)
+++ incubator/directory/eve/trunk/eve/frontend/processor/merlin-impl/src/test/org/apache/eve/processor/impl/MerlinRequestProcessorTest.java
Fri Mar 19 19:55:12 2004
@@ -17,9 +17,22 @@
 package org.apache.eve.processor.impl ;
 
 
+import java.util.EventObject;
+
 import org.apache.avalon.merlin.unit.AbstractMerlinTestCase ;
 
-import org.apache.eve.processor.RequestProcessor ;
+import org.apache.eve.event.EventRouter ;
+import org.apache.eve.event.RequestEvent ;
+import org.apache.eve.event.ResponseEvent ;
+import org.apache.eve.event.ResponseSubscriber ;
+import org.apache.eve.event.AbstractSubscriber ;
+import org.apache.eve.processor.RequestProcessor;
+import org.apache.ldap.common.message.AbandonRequest ;
+import org.apache.ldap.common.message.AbandonRequestImpl ;
+import org.apache.ldap.common.message.AddRequest;
+import org.apache.ldap.common.message.AddRequestImpl;
+import org.apache.ldap.common.message.LockableAttributesImpl;
+import org.apache.ldap.common.message.MessageTypeEnum;
 
 
 /**
@@ -30,7 +43,10 @@
  * @version $Rev$
  */
 public class MerlinRequestProcessorTest extends AbstractMerlinTestCase
+    implements ResponseSubscriber
 {
+    ResponseEvent event = null ;
+    EventRouter router = null ;
     RequestProcessor processor = null ;
 
     
@@ -52,8 +68,9 @@
     public void setUp() throws Exception
     {
         super.setUp() ;
-        processor = ( RequestProcessor ) 
-            resolve( "/server/request-processor" ) ; 
+        router = ( EventRouter ) resolve( "/server/event-router" ) ; 
+        router.subscribe( ResponseEvent.class, this ) ;
+        processor = ( RequestProcessor ) resolve( "/server/request-processor" ); 
     }
 
     
@@ -63,6 +80,82 @@
     public void tearDown()
     {
         super.tearDown() ;
+        event = null ;
+        router = null ;
         processor = null ;
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.event.Subscriber#inform(java.util.EventObject)
+     */
+    public void inform( EventObject event )
+    {
+        try
+        {
+            AbstractSubscriber.inform( this, event ) ;
+        }
+        catch( Throwable t )
+        {
+            t.printStackTrace() ;
+            fail( "failed to deliver event " + event ) ;
+        }
+    }
+    
+    
+    /* (non-Javadoc)
+     * @see org.apache.eve.event.ResponseSubscriber#
+     * inform(org.apache.eve.event.ResponseEvent)
+     */
+    public void inform( ResponseEvent event )
+    {
+        assertNotNull( event ) ;
+        this.event = event ;
+    }
+
+
+    /**
+     * Tests the handling of an Abandon request.
+     * 
+     * @throws Exception on failures
+     */
+    public void testAbandon() throws Exception
+    {
+        AbandonRequest req = new AbandonRequestImpl( 5 ) ;
+        req.setAbandoned( 3 ) ;
+        RequestEvent e = new RequestEvent( this, null, req ) ;
+        router.publish( e ) ;
+
+        // must wait for delivery - there has to be a better way
+        Thread.sleep( 100 ) ;
+        
+        // this message does not produce a response
+        assertNull( this.event ) ;
+    }
+
+
+    /**
+     * Tests the handling of an Add request.
+     * 
+     * @throws Exception on failures
+     */
+    public void testAdd() throws Exception
+    {
+        AddRequest req = new AddRequestImpl( 5 ) ;
+        LockableAttributesImpl attrs = new LockableAttributesImpl( req ) ;
+        attrs.put( "testAttrId", "testAttrValue" ) ;
+        req.setEntry( attrs ) ;
+        req.setName( "uid=akarasulu,dc=example,dc=com" ) ;
+        RequestEvent e = new RequestEvent( this, null, req ) ;
+        router.publish( e ) ;
+        
+        // prematurely stop processor to for event delivery
+        Thread.sleep( 100 ) ;
+        
+        // this message does not produce a response
+        assertNotNull( this.event ) ;
+        assertEquals( 5, this.event.getResponse().getMessageId() ) ;
+        assertEquals( MessageTypeEnum.ADDRESPONSE, 
+                this.event.getResponse().getType() ) ;
     }
 }

Modified: incubator/directory/eve/trunk/eve/frontend/processor/pojo-impl/project.xml
==============================================================================
--- incubator/directory/eve/trunk/eve/frontend/processor/pojo-impl/project.xml	(original)
+++ incubator/directory/eve/trunk/eve/frontend/processor/pojo-impl/project.xml	Fri Mar 19
19:55:12 2004
@@ -1,86 +1,92 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <project>
-    <extend>${basedir}/../../../project.xml</extend>
-    <groupId>incubator-directory</groupId>
-    <id>eve-frontend-processor-pojo-impl</id>
+  <extend>${basedir}/../../../project.xml</extend>
+  <groupId>incubator-directory</groupId>
+  <id>eve-frontend-processor-pojo-impl</id>
   
-    <name>Eve Frontend Request Processor Implementation</name>
-    <package>org.apache.eve.processor.impl</package>
-    <currentVersion>SNAPSHOT</currentVersion>
-    <inceptionYear>2003</inceptionYear>
+  <name>Eve Frontend Request Processor Implementation</name>
+  <package>org.apache.eve.processor.impl</package>
+  <currentVersion>SNAPSHOT</currentVersion>
+  <inceptionYear>2003</inceptionYear>
       
-    <shortDescription>
-      Eve's Frontend Request Processor Implementation
-    </shortDescription>
+  <shortDescription>
+    Eve's Frontend Request Processor Implementation
+  </shortDescription>
 
-    <description>
-    </description>
+  <description>
+  </description>
       
-    <dependencies>
+  <dependencies>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+      <version>1.0.3</version>
+      <url>http://jakarta.apache.org/commons/logging</url>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <url>http://junit.org</url>
+    </dependency>
+
+    <dependency>
+      <groupId>regexp</groupId>
+      <artifactId>regexp</artifactId>
+      <version>1.2</version>
+      <url>http://jakarta.apache.org/regexp</url>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>SNAPSHOT</version>
+      <url>http://jakarta.apache.org/commons/lang</url>
+    </dependency>
         
-      <dependency>
-        <groupId>junit</groupId>
-        <artifactId>junit</artifactId>
-        <version>3.8.1</version>
-        <url>http://junit.org</url>
-      </dependency>
-
-      <dependency>
-        <groupId>regexp</groupId>
-        <artifactId>regexp</artifactId>
-        <version>1.2</version>
-        <url>http://jakarta.apache.org/regexp</url>
-      </dependency>
-
-      <dependency>
-        <groupId>commons-lang</groupId>
-        <artifactId>commons-lang</artifactId>
-        <version>SNAPSHOT</version>
-        <url>http://jakarta.apache.org/commons/lang</url>
-      </dependency>
+    <dependency>
+      <groupId>commons-primitives</groupId>
+      <artifactId>commons-primitives</artifactId>
+      <version>1.1-dev</version>
+      <url>http://jakarta.apache.org/commons/primitives</url>
+    </dependency>
         
-      <dependency>
-        <groupId>commons-primitives</groupId>
-        <artifactId>commons-primitives</artifactId>
-        <version>1.1-dev</version>
-        <url>http://jakarta.apache.org/commons/primitives</url>
-      </dependency>
-        
-      <dependency>
-        <groupId>incubator-directory</groupId>
-        <artifactId>ldap-common</artifactId>
-        <version>SNAPSHOT</version>
-        <url>http://directory.apache.org</url>
-      </dependency>
-
-      <dependency>
-        <groupId>incubator-directory</groupId>
-        <artifactId>eve-frontend-common-api</artifactId>
-        <version>SNAPSHOT</version>
-        <url>http://directory.apache.org</url>
-      </dependency>
-
-      <dependency>
-        <groupId>incubator-directory</groupId>
-        <artifactId>eve-frontend-event-spi</artifactId>
-        <version>SNAPSHOT</version>
-        <url>http://directory.apache.org</url>
-      </dependency>
-
-      <dependency>
-        <groupId>incubator-directory</groupId>
-        <artifactId>eve-frontend-processor-spi</artifactId>
-        <version>SNAPSHOT</version>
-        <url>http://directory.apache.org</url>
-      </dependency>
-
-      <dependency>
-        <groupId>incubator-directory</groupId>
-        <artifactId>eve-frontend-event-pojo-impl</artifactId>
-        <version>SNAPSHOT</version>
-        <url>http://directory.apache.org</url>
-      </dependency>
+    <dependency>
+      <groupId>incubator-directory</groupId>
+      <artifactId>ldap-common</artifactId>
+      <version>SNAPSHOT</version>
+      <url>http://directory.apache.org</url>
+    </dependency>
+
+    <dependency>
+      <groupId>incubator-directory</groupId>
+      <artifactId>eve-frontend-common-api</artifactId>
+      <version>SNAPSHOT</version>
+      <url>http://directory.apache.org</url>
+    </dependency>
+
+    <dependency>
+      <groupId>incubator-directory</groupId>
+      <artifactId>eve-frontend-event-spi</artifactId>
+      <version>SNAPSHOT</version>
+      <url>http://directory.apache.org</url>
+    </dependency>
+
+    <dependency>
+      <groupId>incubator-directory</groupId>
+      <artifactId>eve-frontend-processor-spi</artifactId>
+      <version>SNAPSHOT</version>
+      <url>http://directory.apache.org</url>
+    </dependency>
+
+    <dependency>
+      <groupId>incubator-directory</groupId>
+      <artifactId>eve-frontend-event-pojo-impl</artifactId>
+      <version>SNAPSHOT</version>
+      <url>http://directory.apache.org</url>
+    </dependency>
 
-    </dependencies>
+  </dependencies>
 </project>
 

Modified: incubator/directory/eve/trunk/eve/frontend/processor/pojo-impl/src/java/org/apache/eve/processor/impl/DefaultRequestProcessor.java
==============================================================================
--- incubator/directory/eve/trunk/eve/frontend/processor/pojo-impl/src/java/org/apache/eve/processor/impl/DefaultRequestProcessor.java
(original)
+++ incubator/directory/eve/trunk/eve/frontend/processor/pojo-impl/src/java/org/apache/eve/processor/impl/DefaultRequestProcessor.java
Fri Mar 19 19:55:12 2004
@@ -17,8 +17,8 @@
 package org.apache.eve.processor.impl ;
 
 
+import java.util.Iterator ;
 import java.util.EventObject ;
-import java.util.Iterator;
 
 import org.apache.commons.lang.exception.ExceptionUtils ;
 
@@ -30,10 +30,11 @@
 
 import org.apache.eve.listener.ClientKey ;
 
-import org.apache.eve.seda.DefaultStageConfig;
 import org.apache.eve.seda.StageConfig ;
 import org.apache.eve.seda.DefaultStage ;
 import org.apache.eve.seda.StageHandler ;
+import org.apache.eve.seda.DefaultStageConfig ;
+import org.apache.eve.seda.StderrLoggingStageMonitor;
 
 import org.apache.eve.processor.NoReplyHandler ;
 import org.apache.eve.processor.RequestHandler ;
@@ -92,6 +93,7 @@
         
         DefaultStageConfig defaultConfig = ( DefaultStageConfig ) config ;
         defaultConfig.setHandler( new ProcessorStageHandler() ) ;
+        super.setMonitor( new StderrLoggingStageMonitor( getClass() ) ) ;
         
         this.hooks = hooks ;
         this.router = router ;

Modified: incubator/directory/eve/trunk/eve/frontend/processor/spi/src/java/org/apache/eve/processor/RequestProcessorMonitorAdapter.java
==============================================================================
--- incubator/directory/eve/trunk/eve/frontend/processor/spi/src/java/org/apache/eve/processor/RequestProcessorMonitorAdapter.java
(original)
+++ incubator/directory/eve/trunk/eve/frontend/processor/spi/src/java/org/apache/eve/processor/RequestProcessorMonitorAdapter.java
Fri Mar 19 19:55:12 2004
@@ -19,7 +19,8 @@
 
 import java.util.EventObject ;
 
-import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.commons.lang.exception.ExceptionUtils ;
+
 import org.apache.eve.event.Subscriber ;
 import org.apache.eve.listener.ClientKey ;
 import org.apache.ldap.common.message.Request ;
@@ -43,7 +44,7 @@
     public void failedOnInform( Subscriber subscriber, EventObject event,
 								Throwable t )
     {
-        throw new RuntimeException( t ) ;
+        System.err.println( ExceptionUtils.getFullStackTrace( t ) ) ;
     }
     
     
@@ -65,7 +66,6 @@
         buf.append( " request. Please report the the following server stack" );
         buf.append( " trace to the Apache Directory Project:\n" ) ;
         buf.append( ExceptionUtils.getFullStackTrace( t ) ) ;
-        
-        throw new RuntimeException( buf.toString(), t ) ;
+        System.err.println( buf.toString() ) ;
     }
 }

Mime
View raw message