directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 9596 - incubator/directory/eve/trunk/eve/frontend/processor/pojo-impl/src/java/org/apache/eve/processor/impl
Date Fri, 19 Mar 2004 01:11:03 GMT
Author: akarasulu
Date: Thu Mar 18 17:11:02 2004
New Revision: 9596

Removed:
   incubator/directory/eve/trunk/eve/frontend/processor/pojo-impl/src/java/org/apache/eve/processor/impl/HandlerTypeEnum.java
   incubator/directory/eve/trunk/eve/frontend/processor/pojo-impl/src/java/org/apache/eve/processor/impl/RequestHandler.java
Modified:
   incubator/directory/eve/trunk/eve/frontend/processor/pojo-impl/src/java/org/apache/eve/processor/impl/DefaultRequestProcessor.java
Log:
playing around with old interfaces and ideas

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
Thu Mar 18 17:11:02 2004
@@ -23,12 +23,20 @@
 import org.apache.eve.event.EventRouter ;
 import org.apache.eve.event.RequestEvent ;
 import org.apache.eve.event.RequestSubscriber ;
+import org.apache.eve.listener.ClientKey;
+import org.apache.eve.processor.HandlerRegistry;
+import org.apache.eve.processor.HandlerTypeEnum;
+import org.apache.eve.processor.NoReplyHandler;
+import org.apache.eve.processor.RequestHandler;
 import org.apache.eve.processor.RequestProcessor ;
 import org.apache.eve.processor.RequestProcessorMonitor;
 import org.apache.eve.processor.RequestProcessorMonitorAdapter;
+import org.apache.eve.processor.SingleReplyHandler;
 import org.apache.eve.seda.DefaultStage ;
 import org.apache.eve.seda.StageConfig ;
+import org.apache.eve.seda.StageHandler;
 import org.apache.ldap.common.message.Request;
+import org.apache.ldap.common.message.SingleReplyRequest;
 
 
 /**
@@ -41,14 +49,24 @@
 public class DefaultRequestProcessor extends DefaultStage
     implements RequestProcessor, RequestSubscriber
 {
+    private final HandlerRegistry hooks ;
     private final EventRouter router ;
     private RequestProcessorMonitor monitor = null ;
     
     
-    public DefaultRequestProcessor( EventRouter router, StageConfig config )
+    /**
+     * Creates a default RequestProcessor.
+     * 
+     * @param router the event router we subscribe and publish to
+     * @param config the configuration for this stage 
+     * @param hooks the handler registry to use for setting the request hooks
+     */
+    public DefaultRequestProcessor( EventRouter router, StageConfig config, 
+                                    HandlerRegistry hooks )
     {
         super( config ) ;
         
+        this.hooks = hooks ;
         this.router = router ;
         this.router.subscribe( RequestEvent.class, this ) ;
         this.monitor = new RequestProcessorMonitorAdapter() ;
@@ -61,9 +79,8 @@
      */
     public void inform( RequestEvent event )
     {
-        Request request = event.getRequest() ;
-        
-        
+        // @todo do something with the monitor here
+        enqueue( event ) ;
     }
     
     
@@ -88,5 +105,61 @@
      */
     public void dummy()
     {
+    }
+    
+    
+    class ProcessorStageHandler implements StageHandler
+    {
+        /**
+         * Event handler method for processing RequestEvents.
+         *
+         * @param event the RequestEvent to process.
+         */
+        public void handleEvent( EventObject event )
+        {
+            Request l_request = null ;
+            ClientKey l_clientKey = null ;
+
+            // Throw protocol exception if the event is not a request event.
+            if( ! ( event instanceof RequestEvent ) )
+            {
+                throw new ProtocolException( "Unrecognized event: " + event ) ;
+            }
+
+            // Extract the ClientKey and Request parameters from the event
+            l_request = ( ( RequestEvent ) event ).getRequest() ;
+            l_clientKey = ( ClientKey )
+                ( ( RequestEvent ) event ).getSource() ;
+
+            // Get the handler if we have one defined.
+            RequestHandler l_handler = ( RequestHandler )
+                m_handlers.get( l_request.getType() ) ;
+            if( l_handler == null )
+            {
+                throw new ProtocolException( "Unknown request message type: "
+                    + l_request.getType().getName() ) ;
+            }
+
+            // Based on the handler type start request handling.
+            switch( l_handler.getHandlerType().getValue() )
+            {
+            case( HandlerTypeEnum.NOREPLY_VAL ):
+                NoReplyHandler l_noreply = ( NoReplyHandler ) l_handler ;
+                l_noreply.handle( l_request ) ;
+                break ;
+            case( HandlerTypeEnum.SINGLEREPLY_VAL ):
+                SingleReplyHandler l_single = ( SingleReplyHandler ) l_handler ;
+                doSingleReply( l_single, ( SingleReplyRequest ) l_request ) ;
+                break ;
+            case( HandlerTypeEnum.SEARCH_VAL ):
+                SearchHandler l_search = ( SearchHandler ) l_handler ;
+                l_search.handle( ( SearchRequest ) l_request ) ;
+                break ;
+            default:
+                throw new ProtocolException( "Unrecognized handler type: "
+                    + l_handler.getRequestType().getName() ) ;
+            }
+
+        }
     }
 }

Mime
View raw message