Author: trustin
Date: Sun Oct 10 17:46:28 2004
New Revision: 54503

Added:
   incubator/directory/seda/branches/trustin_api_redesign/
      - copied from rev 54255, incubator/directory/seda/trunk/
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EnqueuePredicate.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/EnqueuePredicate.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EventRouter.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EventRouterMonitor.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouterMonitor.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Filter.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Filter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Stage.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/Stage.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/StageConfig.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageConfig.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/StageHandler.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageHandler.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/StageMonitor.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitor.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Subscriber.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Subscriber.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SubscriberMonitor.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SubscriberMonitor.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/adaptor/
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/adaptor/EventRouterMonitorAdapter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/adaptor/StageMonitorAdapter.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitorAdapter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/
      - copied from rev 54256, 
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultEventRouter.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DefaultEventRouter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultFrontend.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultFrontendFactory.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultStage.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStage.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultStageConfig.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStageConfig.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/util/Enum.java
      - copied unchanged from rev 54257, 
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/Enum.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/util/EnumUtils.java
      - copied unchanged from rev 54257, 
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/EnumUtils.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/util/LoggingStageMonitor.java
      - copied, changed from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/LoggingStageMonitor.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/util/ValuedEnum.java
      - copied unchanged from rev 54257, 
incubator/directory/seda/trunk/src/java/org/apache/seda/impl/util/ValuedEnum.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/protocol/HandlerTypeEnum.java
      - copied unchanged from rev 54257, 
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/HandlerTypeEnum.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/protocol/TransportTypeEnum.java
      - copied unchanged from rev 54257, 
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/TransportTypeEnum.java
Removed:
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/DefaultFrontend.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/DefaultFrontendFactory.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/AddProtocolEvent.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/ClientEvent.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/ConnectEvent.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/ConnectSubscriber.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/DefaultEventRouter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/DisconnectEvent.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/DisconnectSubscriber.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/EventRouter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/EventRouterMonitor.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/EventRouterMonitorAdapter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/Filter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/InputEvent.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/InputSubscriber.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/OutputEvent.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/OutputSubscriber.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/ProtocolEvent.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/ProtocolSubscriber.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/RequestEvent.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/RequestSubscriber.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/ResponseEvent.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/ResponseSubscriber.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/RoutingAdvice.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/Subscriber.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/SubscriberMonitor.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/Subscription.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/protocol/DefaultRequestProcessor.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/stage/DefaultStage.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/stage/DefaultStageConfig.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/stage/EnqueuePredicate.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/stage/LoggingStageMonitor.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/stage/Stage.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/stage/StageConfig.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/stage/StageHandler.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/stage/StageMonitor.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/stage/StageMonitorAdapter.java
Modified:
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/decoder/DecodeStageHandler.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/decoder/DecoderManagerMonitor.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/decoder/DecoderManagerMonitorAdapter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/encoder/EncodeStageHandler.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/AbstractSubscriber.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/SessionCreationEvent.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/SessionCreationSubscriber.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/SessionDestructionEvent.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/input/TCPInputManager.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/listener/TCPListenerManager.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/output/DefaultOutputManager.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/protocol/RequestProcessorMonitor.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/protocol/RequestProcessorMonitorAdapter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/DefaultFrontendFactoryTest.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/ProtocolTestCase.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/decoder/DefaultDecoderManagerTest.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/event/DefaultStageTest.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/listener/TCPListenerManagerTest.java
Log:
Branched for more user-friendly API



Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EnqueuePredicate.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/EnqueuePredicate.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/EnqueuePredicate.java
 (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EnqueuePredicate.java
       Sun Oct 10 17:46:28 2004
@@ -14,7 +14,7 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.stage;
+package org.apache.seda;
 
 
 import java.util.EventObject;

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EventRouter.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouter.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouter.java  
    (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EventRouter.java
    Sun Oct 10 17:46:28 2004
@@ -14,65 +14,31 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.event;
-
-
-import java.util.EventObject;
-
+package org.apache.seda;
 
 /**
  * Event service based on an exact version of the event notifier pattern found
- * <a 
href="http://www.dralasoft.com/products/eventbroker/whitepaper/";>here</a>.
+ * <a href="http://www.dralasoft.com/products/eventbroker/whitepaper/";>here
+ * </a>.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory
+ *         Project </a>
  * @version $Rev$
  */
-public interface EventRouter
-{
-    /**
-     * Subscribes an event subscriber.
-     * 
-     * @param type an event type enumeration value
-     * @param filter an event filter if any to apply
-     * @param subscriber the Subscriber to subscribe
-     */
-    void subscribe( Class type, Filter filter, Subscriber subscriber );
-    
-    /**
-     * Subscribes an event subscriber.
-     * 
-     * @param type an event type
-     * @param subscriber the Subscriber to subscribe
-     */
-    void subscribe( Class type, Subscriber subscriber );
-    
-    /**
-     * Unsubscribes an event subscriber.
-     * 
-     * @param subscriber the Subscriber to unsubscribe
-     */
-    void unsubscribe( Subscriber subscriber );
-    
-    /**
-     * Unsubscribes an event subscriber.
-     * 
-     * @param type an event type
-     * @param subscriber the Subscriber to unsubscribe
-     */
-    void unsubscribe( Class type, Subscriber subscriber );
-    
-    /**
-     * Fires an event synchronously in the thread of the caller to all 
-     * subscribers registered for a specific event type.
-     * 
-     * @param event the event to publish
-     */
-    void publish( EventObject event );
+public interface EventRouter {
+       /**
+        * Subscribes an event subscriber.
+        * 
+        * @param subscriber
+        *            the Subscriber to subscribe
+        */
+       SubscriberContext add(String name, Subscriber subscriber);
 
-    /**
-     * Applies some routing advice to applicable events.
-     *
-     * @param advice the advice to apply
-     */
-    void apply( RoutingAdvice advice );
-}
+       /**
+        * Unsubscribes an event subscriber.
+        * 
+        * @param name
+        *            the name of the [EMAIL PROTECTED] Subscriber}.
+        */
+       void remove(String name);
+}
\ No newline at end of file

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EventRouterMonitor.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouterMonitor.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/EventRouterMonitor.java
       (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EventRouterMonitor.java
     Sun Oct 10 17:46:28 2004
@@ -14,39 +14,24 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.event;
-
-
-import java.util.EventObject;
-
+package org.apache.seda;
 
 /**
  * Monitors the activities of the event router.
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">
- * Apache Directory Project</a>
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]"> Apache Directory
+ *         Project </a>
  * @version $Rev$
  */
-public interface EventRouterMonitor
-{
-    /**
-     * Monitors events that are published.
-     * 
-     * @param event the published event object 
-     */
-    void eventPublished( EventObject event );
-    
-    /**
-     * Monitores the addition of new subscriptions.
-     * 
-     * @param subscription
-     */
-    void addedSubscription( Subscription subscription );
-    
-    /**
-     * Monitors the removal of new subscriptions
-     * 
-     * @param subscription
-     */
-    void removedSubscription( Subscription subscription );
-}
+public interface EventRouterMonitor {
+       /**
+        * Monitores the addition of new subscriptions.
+        */
+       void addedSubscriber(String name, Subscriber subscriber,
+                                                       SubscriberContext ctx);
+
+       /**
+        * Monitors the removal of new subscriptions
+        */
+       void removedSubscriber(String name);
+}
\ No newline at end of file

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Filter.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Filter.java)
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/event/Filter.java   
(original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Filter.java
 Sun Oct 10 17:46:28 2004
@@ -14,26 +14,29 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.event;
-
-
-import java.util.EventObject;
-
+package org.apache.seda;
 
 /**
- * A filter in the event router is used to further prune the subscriber's 
+ * A filter in the event router is used to further prune the subscriber's
  * interest list.
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory
+ *         Project </a>
  * @version $Rev$
  */
-public interface Filter
-{
-    /**
-     * Determines whether or not to inform a subscriber of an event.
-     * 
-     * @param event the event to test
-     * @return true if the event can be sent, false if it cannot
-     */
-    boolean accept( EventObject event );
-}
+public interface Filter {
+       static Filter ALL = new Filter() {
+               public boolean accept(SessionEvent event) {
+                       return true;
+               }
+       };
+
+       /**
+        * Determines whether or not to inform a subscriber of an event.
+        * 
+        * @param event
+        *            the event to test
+        * @return true if the event can be sent, false if it cannot
+        */
+       boolean accept(SessionEvent event);
+}
\ No newline at end of file

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Stage.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/Stage.java)
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/stage/Stage.java    
(original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Stage.java
  Sun Oct 10 17:46:28 2004
@@ -14,13 +14,7 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.stage;
-
-
-import org.apache.seda.stage.EnqueuePredicate;
-
-import java.util.EventObject;
-
+package org.apache.seda;
 
 /**
  * Simple SEDA Stage interface.
@@ -42,7 +36,7 @@
      * 
      * @param event the event to enqueue
      */
-    void enqueue( EventObject event );
+    void enqueue( SessionEvent event );
     
     /**
      * Adds an EnqueuePredicate to control what events can and cannot be 

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/StageConfig.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageConfig.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageConfig.java  
    (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/StageConfig.java
    Sun Oct 10 17:46:28 2004
@@ -14,13 +14,11 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.stage;
-
+package org.apache.seda;
 
 import java.util.List;
 
 import org.apache.seda.thread.ThreadPool;
-
 
 /**
  * The configuration required for a stage.

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/StageHandler.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageHandler.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageHandler.java 
    (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/StageHandler.java
   Sun Oct 10 17:46:28 2004
@@ -14,25 +14,23 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.stage ;
-
-
-import java.util.EventObject ;
-import java.util.EventListener ;
+package org.apache.seda;
 
+import java.util.EventListener;
 
 /**
  * Thread safe Event handler used by Stages.
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory
+ *         Project </a>
  * @version $Rev$
  */
-public interface StageHandler extends EventListener
-{
-    /**
-     * Handles an event for the Stage.
-     *
-     * @param event the event to process or handle.
-     */
-    void handleEvent( EventObject event ) ;
-}
+public interface StageHandler extends EventListener {
+       /**
+        * Handles an event for the Stage.
+        * 
+        * @param event
+        *            the event to process or handle.
+        */
+       void handleEvent(SessionEvent event);
+}
\ No newline at end of file

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/StageMonitor.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitor.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitor.java 
    (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/StageMonitor.java
   Sun Oct 10 17:46:28 2004
@@ -14,155 +14,178 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.stage;
-
+package org.apache.seda;
 
 import java.util.EventObject;
 
-
 /**
  * Interface used to monitor Stage protocol.
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">
- * Apache Directory Project</a>
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]"> Apache Directory
+ *         Project </a>
  * @version $Rev$
  */
-public interface StageMonitor
-{
-    /**
-     * Reports when the Stage is missing its handler.
-     * 
-     * @param stage the stage reporting a missing handler
-     */
-    void handlerMissing( Stage stage );
-    
-    /**
-     * A has been made to gracefully stop the Stage.
-     * 
-     * @param stage the Stage being stopped
-     */
-    void stopping( Stage stage );
-    
-    /**
-     * A has been made to gracefully stop the Stage but we're waiting for some 
-     * active workers to complete.
-     * 
-     * @param stage the Stage being stopped
-     * @param millis the time in milliseconds waiting for workers to complete
-     */
-    void stopping( Stage stage, long millis );
-    
-    /**
-     * The stage driver thread was notified out of the wait state due to an 
-     * enqueue operation or to the driver being requested to stop.
-     * 
-     * @param stage the notified Stage 
-     */
-    void notified( Stage stage );
-    
-    /**
-     * Notification of stage driver thread going into wait state due to an 
-     * empty queue.
-     * 
-     * @param stage the waiting Stage 
-     */
-    void waiting( Stage stage );
-    
-    /**
-     * Monitors Stage has starts.
-     * 
-     * @param stage the started Stage 
-     */
-    void started( Stage stage );
-
-    /**
-     * Monitors Stage has stops.
-     * 
-     * @param stage the stopped Stage 
-     */
-    void stopped( Stage stage );
-    
-    /**
-     * Monitors StageDriver starts.
-     * 
-     * @param stage the Stage whose driver started
-     */
-    void startedDriver( Stage stage );
-    
-    /**
-     * Monitor for successful enqueue operations on the stage.
-     * 
-     * @param stage the stage enqueued on
-     * @param event the event enqueued
-     */
-    void enqueueOccurred( Stage stage, EventObject event );
-    
-    /**
-     * Monitor for failed enqueue operations on the stage.
-     * 
-     * @param stage the stage where enqueue failed
-     * @param event the event enqueue failed on
-     */
-    void enqueueRejected( Stage stage, EventObject event );
-    
-    /**
-     * Queue lock acquired to enqueue an event.
-     * 
-     * @param stage the Stage whose queue lock was acquired
-     * @param event the event to be enqueued
-     */
-    void lockedQueue( Stage stage, EventObject event );
-    
-    /**
-     * Queue lock acquired by awoken Stage driver thread.
-     * 
-     * @param stage the Stage whose queue lock was acquired
-     */
-    void lockedQueue( Stage stage );
-    
-    /**
-     * Monitor for dequeue operations.
-     * 
-     * @param stage the Stage dequeued
-     * @param event the event that was dequeued
-     */
-    void eventDequeued( Stage stage, EventObject event );
-    
-    /**
-     * Monitor for successfully completing the handling of an event.
-     * 
-     * @param stage the Stage processing the event 
-     * @param event the event that was handled
-     */
-    void eventHandled( Stage stage, EventObject event );
-    
-    // ------------------------------------------------------------------------
-    // failure monitors
-    // ------------------------------------------------------------------------
-
-    /**
-     * Monitors driver thread interruption failures.
-     * 
-     * @param stage the stage that caused the failure
-     * @param fault the faulting exception
-     */
-    void driverFailed( Stage stage, InterruptedException fault );
-    
-    /**
-     * Monitors handler failures.
-     * 
-     * @param stage the stage that caused the failure
-     * @param event the event the handler failed on
-     * @param fault the faulting exception
-     */
-    void handlerFailed( Stage stage, EventObject event, Throwable fault );
-
-    /**
-     * Monitors enqueue predicate additions.
-     *
-     * @param stage the default stage the predicate is added to
-     * @param predicate the enqueue predicate added to the stage
-     */
-    void predicateAdded( Stage stage,
-                         EnqueuePredicate predicate );
-}
+public interface StageMonitor {
+       /**
+        * Reports when the Stage is missing its handler.
+        * 
+        * @param stage
+        *            the stage reporting a missing handler
+        */
+       void handlerMissing(Stage stage);
+
+       /**
+        * A has been made to gracefully stop the Stage.
+        * 
+        * @param stage
+        *            the Stage being stopped
+        */
+       void stopping(Stage stage);
+
+       /**
+        * A has been made to gracefully stop the Stage but we're waiting for 
some
+        * active workers to complete.
+        * 
+        * @param stage
+        *            the Stage being stopped
+        * @param millis
+        *            the time in milliseconds waiting for workers to complete
+        */
+       void stopping(Stage stage, long millis);
+
+       /**
+        * The stage driver thread was notified out of the wait state due to an
+        * enqueue operation or to the driver being requested to stop.
+        * 
+        * @param stage
+        *            the notified Stage
+        */
+       void notified(Stage stage);
+
+       /**
+        * Notification of stage driver thread going into wait state due to an 
empty
+        * queue.
+        * 
+        * @param stage
+        *            the waiting Stage
+        */
+       void waiting(Stage stage);
+
+       /**
+        * Monitors Stage has starts.
+        * 
+        * @param stage
+        *            the started Stage
+        */
+       void started(Stage stage);
+
+       /**
+        * Monitors Stage has stops.
+        * 
+        * @param stage
+        *            the stopped Stage
+        */
+       void stopped(Stage stage);
+
+       /**
+        * Monitors StageDriver starts.
+        * 
+        * @param stage
+        *            the Stage whose driver started
+        */
+       void startedDriver(Stage stage);
+
+       /**
+        * Monitor for successful enqueue operations on the stage.
+        * 
+        * @param stage
+        *            the stage enqueued on
+        * @param event
+        *            the event enqueued
+        */
+       void enqueueOccurred(Stage stage, SessionEvent event);
+
+       /**
+        * Monitor for failed enqueue operations on the stage.
+        * 
+        * @param stage
+        *            the stage where enqueue failed
+        * @param event
+        *            the event enqueue failed on
+        */
+       void enqueueRejected(Stage stage, SessionEvent event);
+
+       /**
+        * Queue lock acquired to enqueue an event.
+        * 
+        * @param stage
+        *            the Stage whose queue lock was acquired
+        * @param event
+        *            the event to be enqueued
+        */
+       void lockedQueue(Stage stage, EventObject event);
+
+       /**
+        * Queue lock acquired by awoken Stage driver thread.
+        * 
+        * @param stage
+        *            the Stage whose queue lock was acquired
+        */
+       void lockedQueue(Stage stage);
+
+       /**
+        * Monitor for dequeue operations.
+        * 
+        * @param stage
+        *            the Stage dequeued
+        * @param event
+        *            the event that was dequeued
+        */
+       void eventDequeued(Stage stage, EventObject event);
+
+       /**
+        * Monitor for successfully completing the handling of an event.
+        * 
+        * @param stage
+        *            the Stage processing the event
+        * @param event
+        *            the event that was handled
+        */
+       void eventHandled(Stage stage, EventObject event);
+
+       // 
------------------------------------------------------------------------
+       // failure monitors
+       // 
------------------------------------------------------------------------
+
+       /**
+        * Monitors driver thread interruption failures.
+        * 
+        * @param stage
+        *            the stage that caused the failure
+        * @param fault
+        *            the faulting exception
+        */
+       void driverFailed(Stage stage, InterruptedException fault);
+
+       /**
+        * Monitors handler failures.
+        * 
+        * @param stage
+        *            the stage that caused the failure
+        * @param event
+        *            the event the handler failed on
+        * @param fault
+        *            the faulting exception
+        */
+       void handlerFailed(Stage stage, EventObject event, Throwable fault);
+
+       /**
+        * Monitors enqueue predicate additions.
+        * 
+        * @param stage
+        *            the default stage the predicate is added to
+        * @param predicate
+        *            the enqueue predicate added to the stage
+        */
+       void predicateAdded(Stage stage, EnqueuePredicate predicate);
+}
\ No newline at end of file

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Subscriber.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Subscriber.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/Subscriber.java   
    (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Subscriber.java
     Sun Oct 10 17:46:28 2004
@@ -14,26 +14,26 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.event;
-
-
-import java.util.EventObject ;
-import java.util.EventListener ;
+package org.apache.seda;
 
+import java.util.EventListener;
 
 /**
- * A Subscriber from the Event Notifier pattern. 
+ * A Subscriber from the Event Notifier pattern.
  * 
- * @see <a 
href="http://www.dralasoft.com/products/eventbroker/whitepaper/";>Event Notifier 
Pattern</a>
- * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
+ * @see <a
+ *      href="http://www.dralasoft.com/products/eventbroker/whitepaper/";>Event
+ *      Notifier Pattern </a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory
+ *         Project </a>
  * @version $Rev$
  */
-public interface Subscriber extends EventListener
-{
-    /**
-     * Informs this Subscriber of an event.
-     * 
-     * @param event the event notified of 
-     */
-    void inform( EventObject event );
-}
+public interface Subscriber extends EventListener {
+       /**
+        * Informs this Subscriber of an event.
+        * 
+        * @param event
+        *            the event notified of
+        */
+       void inform(SubscriberContext ctx, SessionEvent event);
+}
\ No newline at end of file

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SubscriberMonitor.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SubscriberMonitor.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SubscriberMonitor.java
        (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SubscriberMonitor.java
      Sun Oct 10 17:46:28 2004
@@ -14,7 +14,7 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.event;
+package org.apache.seda;
 
 
 import java.util.EventObject;
@@ -37,4 +37,8 @@
      */
     void failedOnInform( Subscriber subscriber, EventObject eventObject,
                          Throwable throwable );
+    
+    void addedSubscription(String eventSourceName, Filter eventFilter);
+    
+    void removedSubscription(String eventSourceName, Filter eventFilter);
 }

Added: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/adaptor/EventRouterMonitorAdapter.java
==============================================================================
--- (empty file)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/adaptor/EventRouterMonitorAdapter.java
      Sun Oct 10 17:46:28 2004
@@ -0,0 +1,36 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   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.
+ *
+ */
+package org.apache.seda.adaptor;
+
+import org.apache.seda.EventRouterMonitor;
+import org.apache.seda.Subscriber;
+import org.apache.seda.SubscriberContext;
+
+/**
+ * Does nothing and created by the default constructor.
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]"> Apache Directory
+ *         Project </a>
+ * @version $Rev: 45930 $
+ */
+public class EventRouterMonitorAdapter implements EventRouterMonitor {
+       public void addedSubscriber(String name, Subscriber subscriber, 
SubscriberContext ctx) {
+       }
+
+       public void removedSubscriber(String name) {
+       }
+}
\ No newline at end of file

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/adaptor/StageMonitorAdapter.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitorAdapter.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/StageMonitorAdapter.java
      (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/adaptor/StageMonitorAdapter.java
    Sun Oct 10 17:46:28 2004
@@ -14,11 +14,16 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.stage;
+package org.apache.seda.adaptor;
 
 
 import java.util.EventObject;
 
+import org.apache.seda.EnqueuePredicate;
+import org.apache.seda.SessionEvent;
+import org.apache.seda.Stage;
+import org.apache.seda.StageMonitor;
+
 
 /**
  * A do nothing adapter for a stage.  For safty's sake this adapter reports 
@@ -102,7 +107,7 @@
      * @see org.apache.seda.seda.StageMonitor#enqueueOccurred(
      * org.apache.seda.seda.Stage, java.util.EventObject)
      */
-    public void enqueueOccurred( Stage stage, EventObject event )
+    public void enqueueOccurred( Stage stage, SessionEvent event )
     {
     }
 
@@ -111,7 +116,7 @@
      * @see org.apache.seda.seda.StageMonitor#enqueueRejected(
      * org.apache.seda.seda.Stage, java.util.EventObject)
      */
-    public void enqueueRejected( Stage stage, EventObject event )
+    public void enqueueRejected( Stage stage, SessionEvent event )
     {
     }
 

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/decoder/DecodeStageHandler.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecodeStageHandler.java
     (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/decoder/DecodeStageHandler.java
     Sun Oct 10 17:46:28 2004
@@ -18,14 +18,13 @@
 
 
 import java.nio.ByteBuffer;
-import java.util.EventObject;
 
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.stateful.StatefulDecoder;
-
-import org.apache.seda.event.InputEvent;
-import org.apache.seda.stage.StageHandler;
-import org.apache.seda.listener.ClientKey;
+import org.apache.seda.Session;
+import org.apache.seda.SessionEvent;
+import org.apache.seda.StageHandler;
+import org.apache.seda.event.ByteBufferEvent;
 
 
 /**
@@ -57,14 +56,14 @@
      * stateful decoder.  The decoder's decodeNonBlocking method is called and
      * control is returned.  Error handling is left upto the decoder's monitor.
      * 
-     * @see 
org.apache.seda.stage.StageHandler#handleEvent(java.util.EventObject)
+     * @see org.apache.seda.StageHandler#handleEvent(java.util.EventObject)
      */
-    public void handleEvent( EventObject event )
+    public void handleEvent( SessionEvent event )
     {
-        InputEvent e = ( InputEvent ) event;
-        ClientKey key = e.getClientKey();
+        ByteBufferEvent e = ( ByteBufferEvent ) event;
+        Session session = e.getSession();
         ByteBuffer buf = e.claimInterest( this );
-        StatefulDecoder decoder = manager.getDecoder( key );
+        StatefulDecoder decoder = manager.getDecoder( session );
         
         try
         {

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/decoder/DecoderManagerMonitor.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManagerMonitor.java
  (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/decoder/DecoderManagerMonitor.java
  Sun Oct 10 17:46:28 2004
@@ -19,7 +19,7 @@
 
 import java.util.EventObject;
 
-import org.apache.seda.event.Subscriber;
+import org.apache.seda.Subscriber;
 
 /**
  * Monitors DecoderManagers.

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/decoder/DecoderManagerMonitorAdapter.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DecoderManagerMonitorAdapter.java
   (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/decoder/DecoderManagerMonitorAdapter.java
   Sun Oct 10 17:46:28 2004
@@ -19,7 +19,7 @@
 
 import java.util.EventObject;
 
-import org.apache.seda.event.Subscriber;
+import org.apache.seda.Subscriber;
 
 
 /**

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
  (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
  Sun Oct 10 17:46:28 2004
@@ -17,25 +17,26 @@
 package org.apache.seda.decoder;
 
 
-import java.util.Map;
-import java.util.HashMap;
-import java.util.EventObject;
-
+import java.awt.event.InputEvent;
 import java.nio.ByteBuffer;
-
-import org.apache.seda.stage.StageConfig;
-import org.apache.seda.stage.DefaultStage;
-import org.apache.seda.stage.LoggingStageMonitor;
-
-import org.apache.seda.listener.ClientKey;
-import org.apache.seda.listener.KeyExpiryException;
-import org.apache.seda.event.*;
-import org.apache.seda.protocol.InetServicesDatabase;
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.apache.commons.codec.DecoderException;
 import org.apache.commons.codec.stateful.DecoderCallback;
-import org.apache.commons.codec.stateful.StatefulDecoder;
 import org.apache.commons.codec.stateful.DecoderFactory;
+import org.apache.commons.codec.stateful.StatefulDecoder;
+import org.apache.seda.EventRouter;
+import org.apache.seda.StageConfig;
+import org.apache.seda.event.AbstractSubscriber;
+import org.apache.seda.event.SessionCreationSubscriber;
+import org.apache.seda.event.SessionDestructionListener;
+import org.apache.seda.impl.DefaultStage;
+import org.apache.seda.impl.util.LoggingStageMonitor;
+import org.apache.seda.listener.ClientKey;
+import org.apache.seda.listener.KeyExpiryException;
+import org.apache.seda.protocol.InetServicesDatabase;
 
 
 /**
@@ -47,10 +48,8 @@
 public class DefaultDecoderManager extends DefaultStage
     implements
     DecoderManager,
-    InputSubscriber,
-    ConnectSubscriber,
-    ProtocolSubscriber,
-    DisconnectSubscriber
+       SessionCreationSubscriber,
+       SessionDestructionListener,
 {
     /** event router or bus this component subscribes and publishes events on 
*/
     private final EventRouter router;
@@ -95,7 +94,7 @@
     /**
      * Routes the event to the appropriate typed <code>inform()</code> method.
      * 
-     * @see org.apache.seda.event.Subscriber#inform(java.util.EventObject)
+     * @see org.apache.seda.Subscriber#inform(java.util.EventObject)
      * @see org.apache.seda.event.AbstractSubscriber#inform(
      *      org.apache.seda.event.Subscriber, java.util.EventObject)
      */

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
  (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
  Sun Oct 10 17:46:28 2004
@@ -26,9 +26,13 @@
 import org.apache.commons.codec.stateful.StatefulEncoder;
 import org.apache.commons.codec.stateful.EncoderCallback;
 
+import org.apache.seda.EventRouter;
+import org.apache.seda.StageConfig;
 import org.apache.seda.stage.*;
 
 import org.apache.seda.event.*;
+import org.apache.seda.impl.DefaultStage;
+import org.apache.seda.impl.util.LoggingStageMonitor;
 import org.apache.seda.listener.ClientKey;
 import org.apache.seda.listener.KeyExpiryException;
 import org.apache.seda.protocol.InetServicesDatabase;

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/encoder/EncodeStageHandler.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/EncodeStageHandler.java
     (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/encoder/EncodeStageHandler.java
     Sun Oct 10 17:46:28 2004
@@ -17,7 +17,7 @@
 package org.apache.seda.encoder;
 
 
-import org.apache.seda.stage.StageHandler;
+import org.apache.seda.StageHandler;
 import org.apache.seda.event.ResponseEvent;
 import org.apache.seda.listener.ClientKey;
 import org.apache.commons.codec.stateful.StatefulEncoder;

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/AbstractSubscriber.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/AbstractSubscriber.java
       (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/AbstractSubscriber.java
       Sun Oct 10 17:46:28 2004
@@ -17,13 +17,16 @@
 package org.apache.seda.event;
 
 
-import java.util.List;
-import java.util.HashMap;
-import java.util.EventObject;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.List;
 
-import java.lang.reflect.Method;
-import java.lang.reflect.InvocationTargetException;
+import org.apache.seda.SessionEvent;
+import org.apache.seda.Subscriber;
+import org.apache.seda.SubscriberMonitor;
 
 
 /**
@@ -67,7 +70,7 @@
     /* (non-Javadoc)
      * @see org.apache.seda.event.Subscriber#inform(java.util.EventObject)
      */
-    public void inform( EventObject event )
+    public void inform( SessionEvent event )
     {
         try
         {

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/SessionCreationEvent.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionCreationEvent.java
     (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/SessionCreationEvent.java
     Sun Oct 10 17:46:28 2004
@@ -16,47 +16,32 @@
  */
 package org.apache.seda.event;
 
-
-import org.apache.seda.session.ClientSession;
-
+import org.apache.seda.SessionEvent;
+import org.apache.seda.Subscriber;
+import org.apache.seda.session.StatefulSession;
 
 /**
  * Denotes the creation of a client session which does not necessarily coincide
- * with the establishment of a new client connection.  Attempts to rebind to
- * the directory may destroy an existing session and create another one without
+ * with the establishment of a new client connection. Attempts to rebind to the
+ * directory may destroy an existing session and create another one without
  * droping the socket connection.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory
+ *         Project </a>
  * @version $Rev$
  */
-public class SessionCreationEvent extends ClientEvent
-{
-    /** the newly created client session */
-    private final ClientSession session;
-    
-    
-    /**
-     * Creates a new event using a source, a client and the newly created 
-     * session object.
-     * 
-     * @param source the source that created this event
-     * @param session the newly created client session
-     */
-    public SessionCreationEvent( Object source, ClientSession session )
-    {
-        super( source, session.getClientKey() );
-        this.session = session;
-    }
-
-
-    /**
-     * Gets the newly created session object.
-     * 
-     * @return the newly created session object
-     */
-    public ClientSession getClientSession()
-    {
-        return this.session;
-    }
+public class SessionCreationEvent extends SessionEvent {
+       /**
+        * Creates a new event using a source, a client and the newly created
+        * session object.
+        * 
+        * @param source
+        *            the source that created this event
+        * @param session
+        *            the newly created client session
+        */
+       public SessionCreationEvent(Subscriber source, StatefulSession session) 
{
+               super(source, session);
+       }
 }
 

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/SessionCreationSubscriber.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionCreationSubscriber.java
        (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/SessionCreationSubscriber.java
        Sun Oct 10 17:46:28 2004
@@ -16,6 +16,8 @@
  */
 package org.apache.seda.event ;
 
+import org.apache.seda.Subscriber;
+
 
 /**
  * Type safe Subscriber for session creation events for clients.

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/SessionDestructionEvent.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/SessionDestructionEvent.java
  (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/SessionDestructionEvent.java
  Sun Oct 10 17:46:28 2004
@@ -16,47 +16,31 @@
  */
 package org.apache.seda.event;
 
-
-import org.apache.seda.session.ClientSession;
-
+import org.apache.seda.SessionEvent;
+import org.apache.seda.Subscriber;
+import org.apache.seda.session.StatefulSession;
 
 /**
- * Denotes the destruction of a client session which does not necessarily 
- * coincide with the loss of a socket connection.  Attempts to rebind to
- * the directory may destroy an existing session and create another one without
+ * Denotes the destruction of a client session which does not necessarily
+ * coincide with the loss of a socket connection. Attempts to rebind to the
+ * directory may destroy an existing session and create another one without
  * droping the socket connection.
  * 
- * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
+ * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory
+ *         Project </a>
  * @version $Rev$
  */
-public class SessionDestructionEvent extends ClientEvent
-{
-    /** the newly created client session */
-    private final ClientSession session;
-    
-    
-    /**
-     * Creates a new event using a source, a client and the destroyed client
-     * session object.
-     * 
-     * @param source the source that created this event
-     * @param session the newly created client session
-     */
-    public SessionDestructionEvent( Object source, ClientSession session )
-    {
-        super( source, session.getClientKey() );
-        this.session = session;
-    }
-
-
-    /**
-     * Gets the destroyed client session object.
-     * 
-     * @return the destroyed session object
-     */
-    public ClientSession getClientSession()
-    {
-        return this.session;
-    }
-}
-
+public class SessionDestructionEvent extends SessionEvent {
+       /**
+        * Creates a new event using a source, a client and the destroyed client
+        * session object.
+        * 
+        * @param source
+        *            the source that created this event
+        * @param session
+        *            the newly created client session
+        */
+       public SessionDestructionEvent(Subscriber source, StatefulSession 
session) {
+               super(source, session);
+       }
+}
\ No newline at end of file

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultEventRouter.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DefaultEventRouter.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/event/DefaultEventRouter.java
       (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultEventRouter.java
        Sun Oct 10 17:46:28 2004
@@ -14,13 +14,22 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.event;
+package org.apache.seda.impl;
 
 
-import java.util.List;
-import java.util.Iterator;
 import java.util.ArrayList;
 import java.util.EventObject;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.seda.EventRouter;
+import org.apache.seda.EventRouterMonitor;
+import org.apache.seda.Filter;
+import org.apache.seda.RoutingAdvice;
+import org.apache.seda.SessionEvent;
+import org.apache.seda.Subscriber;
+import org.apache.seda.Subscription;
+import org.apache.seda.adaptor.EventRouterMonitorAdapter;
 
 
 /**
@@ -77,8 +86,7 @@
 
     
     /**
-     * @see org.apache.seda.event.EventRouter#unsubscribe(
-     * org.apache.seda.event.Subscriber)
+     * @see EventRouter#unsubscribe(Subscriber)
      */
     public void unsubscribe( Subscriber subscriber )
     {
@@ -101,8 +109,7 @@
 
     /**
      * (non-Javadoc)
-     * @see org.apache.seda.event.EventRouter#unsubscribe(java.lang.Class,
-     * org.apache.seda.event.Subscriber)
+     * @see EventRouter#unsubscribe(java.lang.Class,Subscriber)
      */
     public void unsubscribe( Class type, Subscriber subscriber )
     {
@@ -126,8 +133,7 @@
 
     /**
      * (non-Javadoc)
-     * @see org.apache.seda.event.EventRouter#unsubscribe(java.lang.Class,
-     * org.apache.seda.event.Subscriber)
+     * @see EventRouter#unsubscribe(java.lang.Class,Subscriber)
      */
     public void unsubscribe( Class type, Filter filter, 
                              Subscriber subscriber )
@@ -150,9 +156,9 @@
 
     /**
      * (non-Javadoc)
-     * @see org.apache.seda.event.EventRouter#publish(java.util.EventObject)
+     * @see EventRouter#publish(SessionEvent)
      */
-    public void publish( EventObject event ) 
+    public void publish( SessionEvent event ) 
     {
         final ArrayList applicableAdvice = new ArrayList();
 
@@ -177,7 +183,7 @@
         Subscription[] subscrArray;
         synchronized ( subscriptions )
         {
-            subscrArray = ( Subscription [] ) subscriptions
+            subscrArray = (org.apache.seda.Subscription [] ) subscriptions
                 .toArray( new Subscription [ subscriptions.size() ] );
         }
 
@@ -221,7 +227,7 @@
 
 
 
-    private void publish( EventObject ev, Subscription[] subscriptions )
+    private void publish( SessionEvent ev, Subscription[] subscriptions )
     {
         for ( int ii = 0; ii < subscriptions.length; ii++ )
         {

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultFrontend.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java    
    (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultFrontend.java
   Sun Oct 10 17:46:28 2004
@@ -14,26 +14,25 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda;
+package org.apache.seda.impl;
 
 
+import org.apache.seda.EventRouter;
+import org.apache.seda.Frontend;
 import org.apache.seda.buffer.BufferPool;
-import org.apache.seda.event.EventRouter;
-import org.apache.seda.event.AddProtocolEvent;
 import org.apache.seda.decoder.DecoderManager;
 import org.apache.seda.decoder.DefaultDecoderManager;
-import org.apache.seda.encoder.EncoderManager;
 import org.apache.seda.encoder.DefaultEncoderManager;
+import org.apache.seda.encoder.EncoderManager;
 import org.apache.seda.input.InputManager;
 import org.apache.seda.input.TCPInputManager;
 import org.apache.seda.listener.ListenerManager;
 import org.apache.seda.listener.TCPListenerManager;
-import org.apache.seda.output.OutputManager;
 import org.apache.seda.output.DefaultOutputManager;
-import org.apache.seda.protocol.RequestProcessor;
+import org.apache.seda.output.OutputManager;
 import org.apache.seda.protocol.InetServicesDatabase;
-import org.apache.seda.protocol.DefaultRequestProcessor;
 import org.apache.seda.protocol.ProtocolProvider;
+import org.apache.seda.protocol.RequestProcessor;
 
 
 /**
@@ -77,8 +76,13 @@
 
     public void register( ProtocolProvider provider )
     {
-        AddProtocolEvent event = new AddProtocolEvent( provider );
-        router.publish( event );
+       // FIXME Have to find the better way to manage protocols.
+       // Managing protocols with event-driven way looks fancy, but 
+       // it looks like over-engineered.  I'll provide a dedicated
+       // protocol manager later.
+       
+        // AddProtocolEvent event = new AddProtocolEvent( provider );
+        // router.publish( event );
     }
 
 
@@ -87,7 +91,7 @@
         ( ( TCPListenerManager ) srvMan ).stop();
         ( ( TCPInputManager ) inMan ).stop();
         ( ( DefaultOutputManager ) outMan ).stop();
-        ( ( DefaultRequestProcessor ) reqProc ).stop();
+        //( ( DefaultRequestProcessor ) reqProc ).stop();
         ( ( DefaultDecoderManager ) decMan ).stop();
         ( ( DefaultEncoderManager ) encMan ).stop();
     }

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultFrontendFactory.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java
 (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultFrontendFactory.java
    Sun Oct 10 17:46:28 2004
@@ -14,35 +14,38 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda;
+package org.apache.seda.impl;
 
 
+import java.io.IOException;
+
+import org.apache.commons.threadpool.CommonsLoggingThreadPoolMonitor;
+import org.apache.commons.threadpool.DefaultThreadPool;
+import org.apache.seda.EventRouter;
+import org.apache.seda.Frontend;
+import org.apache.seda.FrontendFactory;
+import org.apache.seda.adaptor.EventRouterMonitorAdapter;
 import org.apache.seda.buffer.BufferPool;
 import org.apache.seda.buffer.DefaultBufferPool;
 import org.apache.seda.buffer.DefaultBufferPoolConfig;
 import org.apache.seda.buffer.LoggingBufferMonitor;
-import org.apache.seda.event.EventRouter;
-import org.apache.seda.event.DefaultEventRouter;
-import org.apache.seda.event.EventRouterMonitorAdapter;
-import org.apache.seda.protocol.*;
+import org.apache.seda.decoder.DecodeStageHandler;
 import org.apache.seda.decoder.DecoderManager;
 import org.apache.seda.decoder.DefaultDecoderManager;
-import org.apache.seda.decoder.DecodeStageHandler;
-import org.apache.seda.stage.DefaultStageConfig;
-import org.apache.seda.thread.ThreadPool;
-import org.apache.seda.encoder.EncoderManager;
 import org.apache.seda.encoder.DefaultEncoderManager;
 import org.apache.seda.encoder.EncodeStageHandler;
-import org.apache.seda.listener.ListenerManager;
-import org.apache.seda.listener.TCPListenerManager;
+import org.apache.seda.encoder.EncoderManager;
 import org.apache.seda.input.InputManager;
 import org.apache.seda.input.TCPInputManager;
-import org.apache.seda.output.OutputManager;
+import org.apache.seda.listener.ListenerManager;
+import org.apache.seda.listener.TCPListenerManager;
 import org.apache.seda.output.DefaultOutputManager;
-import org.apache.commons.threadpool.DefaultThreadPool;
-import org.apache.commons.threadpool.CommonsLoggingThreadPoolMonitor;
-
-import java.io.IOException;
+import org.apache.seda.output.OutputManager;
+import org.apache.seda.protocol.DefaultInetServicesDatabase;
+import org.apache.seda.protocol.InetServiceEntry;
+import org.apache.seda.protocol.InetServicesDatabase;
+import org.apache.seda.protocol.RequestProcessor;
+import org.apache.seda.thread.ThreadPool;
 
 
 /**

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultStage.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStage.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStage.java 
    (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultStage.java
      Sun Oct 10 17:46:28 2004
@@ -14,307 +14,260 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.stage;
+package org.apache.seda.impl;
 
-
-import java.util.Set;
 import java.util.HashSet;
 import java.util.LinkedList;
-import java.util.EventObject;
+import java.util.Set;
 
+import org.apache.seda.EnqueuePredicate;
+import org.apache.seda.SessionEvent;
+import org.apache.seda.Stage;
+import org.apache.seda.StageConfig;
+import org.apache.seda.StageMonitor;
+import org.apache.seda.adaptor.StageMonitorAdapter;
 
 /**
  * The default Stage implementation.
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory Project</a>
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Apache Directory
+ *         Project </a>
  * @version $Rev$
  */
-public class DefaultStage implements Stage
-{
-    /** 
-     * time to sleep in milliseconds waiting for this stage to stop
-     * @todo migth want add this to config and use this as the default value
-     */
-    private static final long STOP_WAIT = 100;
-    
-    /** the configuration bean */
-    protected final StageConfig config;
-    /** this Stage's event queue */
-    private final LinkedList queue = new LinkedList();
-    /** this Stage's active handler threads */
-    private final Set activeWorkers = new HashSet();
-
-    /** this Stage's StageDriver's driving thread */
-    private Thread thread = null;
-    /** the start stop control variable */
-    private Boolean hasStarted = new Boolean( false );
-    /** this Stage's monitor */
-    private StageMonitor monitor = new StageMonitorAdapter();
-
-    
-    // ------------------------------------------------------------------------
-    // C O N S T R U C T O R S
-    // ------------------------------------------------------------------------
-
-
-    /**
-     * Creates a DefaultStage using a configuration bean.
-     * 
-     * @param config the configuration bean
-     */
-    public DefaultStage( StageConfig config )
-    {
-        this.config = config;
-        hasStarted = new Boolean( false );
-    }
-    
-    
-    // ------------------------------------------------------------------------
-    // Stage Methods
-    // ------------------------------------------------------------------------
-
-
-    /**
-     * @see org.apache.seda.stage.Stage#addPredicate(
-     *          org.apache.seda.stage.EnqueuePredicate)
-     * addPredicate(org.apache.seda.seda.EnqueuePredicate)
-     */
-    public void addPredicate( EnqueuePredicate predicate )
-    {
-        config.getPredicates().add( predicate );
-        monitor.predicateAdded( this, predicate );
-    }
-    
-    
-    /**
-     * @see org.apache.seda.stage.Stage#getConfig()
-     */
-    public StageConfig getConfig()
-    {
-        return config;
-    }
-
-
-    /**
-     * Enqueue's an event onto the event queue of this stage if the stage
-     * predicates permit the operation and the stage has started.  The event
-     * enqueue is rejected if the stage has not started.
-     *
-     * @see org.apache.seda.stage.Stage#enqueue(java.util.EventObject)
-     */
-    public void enqueue( final EventObject event )
-    {
-        boolean isAccepted = true;
-
-        if ( ! hasStarted.booleanValue() )
-        {
-            monitor.enqueueRejected( this, event );
-            return;
-        }
-
-        for ( int ii = 0; ii < config.getPredicates().size() && isAccepted;
-            ii++ ) 
-        {
-            EnqueuePredicate test = 
-                ( EnqueuePredicate ) config.getPredicates().get( ii );
-            isAccepted &= test.accept( event );
-        }
-
-        if( isAccepted ) 
-        {
-            synchronized ( queue ) 
-            {
-                monitor.lockedQueue( this, event );
-                queue.addFirst( event );
-                queue.notifyAll();
-            }
-
-            monitor.enqueueOccurred( this, event );
-        } 
-        else 
-        {
-            monitor.enqueueRejected( this, event );
-        }
-    }
-    
-
-    // ------------------------------------------------------------------------
-    // Runnable Implementations 
-    // ------------------------------------------------------------------------
-
-
-    /**
-     * The runnable driving the main thread of this Stage.
-     *
-     * @author <a href="mailto:[EMAIL PROTECTED]">Alex Karasulu</a>
-     * @author $Author: akarasulu $
-     * @version $Revision$
-     */
-    class StageDriver implements Runnable
-    {
-        public final void run()
-        {
-            monitor.startedDriver( DefaultStage.this );
-
-            /*
-             * keep processing until the hasStarted variable is toggled off
-             * and there are no queue events left.  Before without the queue
-             * term events would be left unprocessed on the queue on stop calls
-             */
-            while( hasStarted.booleanValue() || !queue.isEmpty() )
-            {
-                synchronized ( queue )
-                {
-                    monitor.lockedQueue( DefaultStage.this );
-
-                    if( queue.isEmpty() )
-                    {
-                        try
-                        {
-                            monitor.waiting( DefaultStage.this );
-                            queue.wait();
-                            monitor.notified( DefaultStage.this );
-                        }
-                        catch( InterruptedException e )
-                        {
-                            try { stop(); } catch ( Exception e2 )
-                            {/*NOT THROWN*/}
-                            monitor.driverFailed( DefaultStage.this, e );
-                        }
-                    } 
-                    else 
-                    {
-                        EventObject event = ( EventObject ) queue.removeLast();
-                        monitor.eventDequeued( DefaultStage.this, event );
-                        Runnable l_runnable = new ExecutableHandler( event );
-                        config.getThreadPool().execute( l_runnable );
-                        monitor.eventHandled( DefaultStage.this, event );
-                    }
-                }
-            }
-        }
-    }
-    
-    
-    /**
-     * The runnable driving the work of this Stage's handler.
-     *
-     * @author <a href="mailto:[EMAIL PROTECTED]">Alex Karasulu</a>
-     * @author $Author: akarasulu $
-     * @version $Revision$
-     */
-    class ExecutableHandler implements Runnable
-    {
-        final EventObject m_event;
-        
-        public ExecutableHandler( EventObject event )
-        {
-            m_event = event;
-        }
-        
-        public void run()
-        {
-            activeWorkers.add( Thread.currentThread() );
-            
-            try 
-            {
-                if ( config.getHandler() == null )
-                {
-                    monitor.handlerMissing( DefaultStage.this );
-                }
-                else
-                {
-                    config.getHandler().handleEvent( m_event );
-                }
-            } 
-            catch( Throwable t ) 
-            {
-                monitor.handlerFailed( DefaultStage.this, m_event, t );
-            }
-            finally
-            {
-                activeWorkers.remove( Thread.currentThread() );
-            }
-        }
-    }
-
-
-    // ------------------------------------------------------------------------
-    // start stop controls
-    // ------------------------------------------------------------------------
-    
-    
-    /**
-     * Starts up this Stage's driver.
-     */
-    public void start()
-    {
-        if ( hasStarted.booleanValue() )
-        {
-            throw new IllegalStateException( "Already started!" );
-        }
-        
-        hasStarted = new Boolean( true );
-        thread = new Thread( new StageDriver() );
-        thread.start();
-        
-        monitor.started( this );
-    }
-    
-    
-    /**
-     * Blocks calling thread until this Stage gracefully stops its driver and
-     * all its worker threads.
-     */
-    public void stop() throws InterruptedException
-    {
-        hasStarted = new Boolean( false );
-        monitor.stopping( this );
-
-        while ( thread.isAlive() || ! activeWorkers.isEmpty() )
-        {
-            monitor.stopping( this, STOP_WAIT );
-            Thread.sleep( STOP_WAIT );
-            
-            synchronized( queue )
-            {
-                queue.notifyAll();
-            }
-        }
-        
-        monitor.stopped( this );
-    }
-
-
-    /**
-     * Tests to see if this stage has started.
-     *
-     * @return true if this stage has started, false otherwise
-     */
-    public boolean hasStarted()
-    {
-        return hasStarted.booleanValue();
-    }
-
-
-    /**
-     * Gets this Stage's monitor.
-     * 
-     * @return the monitor for this Stage
-     */
-    public StageMonitor getStageMonitor()
-    {
-        return monitor;
-    }
-
-    
-    /**
-     * Sets this Stage's monitor.
-     * 
-     * @param monitor the monitor to set for this Stage
-     */
-    public void setMonitor( StageMonitor monitor )
-    {
-        this.monitor = monitor;
-    }
-}
+public class DefaultStage implements Stage {
+       /**
+        * time to sleep in milliseconds waiting for this stage to stop
+        * 
+        * @todo migth want add this to config and use this as the default value
+        */
+       private static final long STOP_WAIT = 100;
+
+       /** the configuration bean */
+       protected final StageConfig config;
+       /** this Stage's event queue */
+       private final LinkedList queue = new LinkedList();
+       /** this Stage's active handler threads */
+       private final Set activeWorkers = new HashSet();
+
+       /** this Stage's StageDriver's driving thread */
+       private Thread thread = null;
+       /** the start stop control variable */
+       private Boolean hasStarted = new Boolean(false);
+       /** this Stage's monitor */
+       private StageMonitor monitor = new StageMonitorAdapter();
+
+       // 
------------------------------------------------------------------------
+       // C O N S T R U C T O R S
+       // 
------------------------------------------------------------------------
+
+       /**
+        * Creates a DefaultStage using a configuration bean.
+        * 
+        * @param config
+        *            the configuration bean
+        */
+       public DefaultStage(StageConfig config) {
+               this.config = config;
+               hasStarted = new Boolean(false);
+       }
+
+       // 
------------------------------------------------------------------------
+       // Stage Methods
+       // 
------------------------------------------------------------------------
+
+       /**
+        * @see Stage#addPredicate(EnqueuePredicate)
+        *      addPredicate(org.apache.seda.seda.EnqueuePredicate)
+        */
+       public void addPredicate(EnqueuePredicate predicate) {
+               config.getPredicates().add(predicate);
+               monitor.predicateAdded(this, predicate);
+       }
+
+       /**
+        * @see Stage#getConfig()
+        */
+       public StageConfig getConfig() {
+               return config;
+       }
+
+       /**
+        * Enqueue's an event onto the event queue of this stage if the stage
+        * predicates permit the operation and the stage has started. The event
+        * enqueue is rejected if the stage has not started.
+        * 
+        * @see Stage#enqueue(SessionEvent)
+        */
+       public void enqueue(final SessionEvent event) {
+               boolean isAccepted = true;
+
+               if (!hasStarted.booleanValue()) {
+                       monitor.enqueueRejected(this, event);
+                       return;
+               }
+
+               for (int ii = 0; ii < config.getPredicates().size() && 
isAccepted; ii++) {
+                       EnqueuePredicate test = (EnqueuePredicate) 
config.getPredicates()
+                                       .get(ii);
+                       isAccepted &= test.accept(event);
+               }
+
+               if (isAccepted) {
+                       synchronized (queue) {
+                               monitor.lockedQueue(this, event);
+                               queue.addFirst(event);
+                               queue.notifyAll();
+                       }
+
+                       monitor.enqueueOccurred(this, event);
+               } else {
+                       monitor.enqueueRejected(this, event);
+               }
+       }
+
+       // 
------------------------------------------------------------------------
+       // Runnable Implementations
+       // 
------------------------------------------------------------------------
+
+       /**
+        * The runnable driving the main thread of this Stage.
+        * 
+        * @author <a href="mailto:[EMAIL PROTECTED]">Alex Karasulu </a>
+        * @author $Author: akarasulu $
+        * @version $Revision$
+        */
+       class StageDriver implements Runnable {
+               public final void run() {
+                       monitor.startedDriver(DefaultStage.this);
+
+                       /*
+                        * keep processing until the hasStarted variable is 
toggled off and
+                        * there are no queue events left. Before without the 
queue term
+                        * events would be left unprocessed on the queue on 
stop calls
+                        */
+                       while (hasStarted.booleanValue() || !queue.isEmpty()) {
+                               synchronized (queue) {
+                                       monitor.lockedQueue(DefaultStage.this);
+
+                                       if (queue.isEmpty()) {
+                                               try {
+                                                       
monitor.waiting(DefaultStage.this);
+                                                       queue.wait();
+                                                       
monitor.notified(DefaultStage.this);
+                                               } catch (InterruptedException 
e) {
+                                                       try {
+                                                               stop();
+                                                       } catch (Exception e2) 
{/* NOT THROWN */
+                                                       }
+                                                       
monitor.driverFailed(DefaultStage.this, e);
+                                               }
+                                       } else {
+                                               SessionEvent event = 
(SessionEvent) queue.removeLast();
+                                               
monitor.eventDequeued(DefaultStage.this, event);
+                                               Runnable l_runnable = new 
ExecutableHandler(event);
+                                               
config.getThreadPool().execute(l_runnable);
+                                               
monitor.eventHandled(DefaultStage.this, event);
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /**
+        * The runnable driving the work of this Stage's handler.
+        * 
+        * @author <a href="mailto:[EMAIL PROTECTED]">Alex Karasulu </a>
+        * @author $Author: akarasulu $
+        * @version $Revision$
+        */
+       class ExecutableHandler implements Runnable {
+               final SessionEvent m_event;
+
+               public ExecutableHandler(SessionEvent event) {
+                       m_event = event;
+               }
+
+               public void run() {
+                       activeWorkers.add(Thread.currentThread());
+
+                       try {
+                               if (config.getHandler() == null) {
+                                       
monitor.handlerMissing(DefaultStage.this);
+                               } else {
+                                       
config.getHandler().handleEvent(m_event);
+                               }
+                       } catch (Throwable t) {
+                               monitor.handlerFailed(DefaultStage.this, 
m_event, t);
+                       } finally {
+                               activeWorkers.remove(Thread.currentThread());
+                       }
+               }
+       }
+
+       // 
------------------------------------------------------------------------
+       // start stop controls
+       // 
------------------------------------------------------------------------
+
+       /**
+        * Starts up this Stage's driver.
+        */
+       public void start() {
+               if (hasStarted.booleanValue()) {
+                       throw new IllegalStateException("Already started!");
+               }
+
+               hasStarted = new Boolean(true);
+               thread = new Thread(new StageDriver());
+               thread.start();
+
+               monitor.started(this);
+       }
+
+       /**
+        * Blocks calling thread until this Stage gracefully stops its driver 
and
+        * all its worker threads.
+        */
+       public void stop() throws InterruptedException {
+               hasStarted = new Boolean(false);
+               monitor.stopping(this);
+
+               while (thread.isAlive() || !activeWorkers.isEmpty()) {
+                       monitor.stopping(this, STOP_WAIT);
+                       Thread.sleep(STOP_WAIT);
+
+                       synchronized (queue) {
+                               queue.notifyAll();
+                       }
+               }
+
+               monitor.stopped(this);
+       }
+
+       /**
+        * Tests to see if this stage has started.
+        * 
+        * @return true if this stage has started, false otherwise
+        */
+       public boolean hasStarted() {
+               return hasStarted.booleanValue();
+       }
+
+       /**
+        * Gets this Stage's monitor.
+        * 
+        * @return the monitor for this Stage
+        */
+       public StageMonitor getStageMonitor() {
+               return monitor;
+       }
+
+       /**
+        * Sets this Stage's monitor.
+        * 
+        * @param monitor
+        *            the monitor to set for this Stage
+        */
+       public void setMonitor(StageMonitor monitor) {
+               this.monitor = monitor;
+       }
+}
\ No newline at end of file

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultStageConfig.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStageConfig.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/DefaultStageConfig.java
       (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultStageConfig.java
        Sun Oct 10 17:46:28 2004
@@ -14,12 +14,14 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.stage;
+package org.apache.seda.impl;
 
 
-import java.util.List;
 import java.util.ArrayList;
+import java.util.List;
 
+import org.apache.seda.StageConfig;
+import org.apache.seda.StageHandler;
 import org.apache.seda.thread.ThreadPool;
 
 

Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/util/LoggingStageMonitor.java
 (from rev 54255, 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/LoggingStageMonitor.java)
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/stage/LoggingStageMonitor.java
      (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/util/LoggingStageMonitor.java
  Sun Oct 10 17:46:28 2004
@@ -14,13 +14,18 @@
  *   limitations under the License.
  *
  */
-package org.apache.seda.stage;
+package org.apache.seda.impl.util;
 
 
 import java.util.EventObject;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.seda.EnqueuePredicate;
+import org.apache.seda.SessionEvent;
+import org.apache.seda.Stage;
+import org.apache.seda.StageMonitor;
+import org.apache.seda.impl.DefaultStage;
 
 
 /**
@@ -114,7 +119,7 @@
      * @see org.apache.seda.seda.StageMonitor#enqueueOccurred(
      * org.apache.seda.seda.Stage, java.util.EventObject)
      */
-    public void enqueueOccurred( Stage stage, EventObject event )
+    public void enqueueOccurred( Stage stage, SessionEvent event )
     {
         if ( log.isDebugEnabled() )
         {
@@ -128,7 +133,7 @@
      * @see org.apache.seda.seda.StageMonitor#enqueueRejected(
      * org.apache.seda.seda.Stage, java.util.EventObject)
      */
-    public void enqueueRejected( Stage stage, EventObject event )
+    public void enqueueRejected( Stage stage, SessionEvent event )
     {
         if ( log.isWarnEnabled() )
         {

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/input/TCPInputManager.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/input/TCPInputManager.java
  (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/input/TCPInputManager.java
  Sun Oct 10 17:46:28 2004
@@ -27,9 +27,9 @@
 import java.nio.channels.SocketChannel;
 
 import org.apache.seda.event.InputEvent;
+import org.apache.seda.EventRouter;
 import org.apache.seda.ResourceException;
 import org.apache.seda.buffer.BufferPool;
-import org.apache.seda.event.EventRouter;
 import org.apache.seda.listener.ClientKey;
 import org.apache.seda.event.ConnectEvent;
 import org.apache.seda.event.DisconnectEvent;

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/listener/TCPListenerManager.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPListenerManager.java
    (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/listener/TCPListenerManager.java
    Sun Oct 10 17:46:28 2004
@@ -17,6 +17,7 @@
 package org.apache.seda.listener;
 
 
+import org.apache.seda.EventRouter;
 import org.apache.seda.event.*;
 
 import java.io.IOException;

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/output/DefaultOutputManager.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/output/DefaultOutputManager.java
    (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/output/DefaultOutputManager.java
    Sun Oct 10 17:46:28 2004
@@ -26,18 +26,18 @@
 import java.util.HashMap;
 import java.util.EventObject;
 
-import org.apache.seda.event.EventRouter;
+import org.apache.seda.EventRouter;
+import org.apache.seda.StageHandler;
 import org.apache.seda.event.OutputEvent;
-import org.apache.seda.stage.DefaultStage;
-import org.apache.seda.stage.StageHandler;
+import org.apache.seda.impl.DefaultStage;
+import org.apache.seda.impl.DefaultStageConfig;
+import org.apache.seda.impl.util.LoggingStageMonitor;
 import org.apache.seda.listener.ClientKey;
 import org.apache.seda.event.ConnectEvent;
 import org.apache.seda.event.DisconnectEvent;
 import org.apache.seda.event.OutputSubscriber;
 import org.apache.seda.event.ConnectSubscriber;
-import org.apache.seda.stage.DefaultStageConfig;
 import org.apache.seda.event.AbstractSubscriber;
-import org.apache.seda.stage.LoggingStageMonitor;
 import org.apache.seda.event.DisconnectSubscriber;
 import org.apache.seda.listener.KeyExpiryException;
 

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/protocol/RequestProcessorMonitor.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessorMonitor.java
       (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/protocol/RequestProcessorMonitor.java
       Sun Oct 10 17:46:28 2004
@@ -19,7 +19,7 @@
 
 import java.util.EventObject;
 
-import org.apache.seda.event.Subscriber;
+import org.apache.seda.Subscriber;
 import org.apache.seda.listener.ClientKey;
 import org.apache.seda.listener.KeyExpiryException;
 

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/protocol/RequestProcessorMonitorAdapter.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/java/org/apache/seda/protocol/RequestProcessorMonitorAdapter.java
        (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/protocol/RequestProcessorMonitorAdapter.java
        Sun Oct 10 17:46:28 2004
@@ -19,7 +19,7 @@
 
 import java.util.EventObject;
 
-import org.apache.seda.event.Subscriber;
+import org.apache.seda.Subscriber;
 import org.apache.seda.listener.ClientKey;
 import org.apache.seda.listener.KeyExpiryException;
 

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/DefaultFrontendFactoryTest.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/test/org/apache/seda/DefaultFrontendFactoryTest.java
     (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/DefaultFrontendFactoryTest.java
     Sun Oct 10 17:46:28 2004
@@ -20,6 +20,8 @@
 import junit.framework.TestCase;
 import org.apache.commons.net.EchoTCPClient;
 import org.apache.seda.examples.EchoProtocolProvider;
+import org.apache.seda.impl.DefaultFrontend;
+import org.apache.seda.impl.DefaultFrontendFactory;
 import org.apache.seda.listener.AvailablePortFinder;
 import org.apache.seda.listener.ListenerConfig;
 import org.apache.seda.listener.TCPListenerConfig;

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/ProtocolTestCase.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java   
    (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/ProtocolTestCase.java
       Sun Oct 10 17:46:28 2004
@@ -20,6 +20,8 @@
 
 import junit.framework.TestCase;
 
+import org.apache.seda.impl.DefaultFrontend;
+import org.apache.seda.impl.DefaultFrontendFactory;
 import org.apache.seda.listener.AvailablePortFinder;
 import org.apache.seda.listener.ListenerConfig;
 import org.apache.seda.listener.TCPListenerConfig;

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/decoder/DefaultDecoderManagerTest.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/test/org/apache/seda/decoder/DefaultDecoderManagerTest.java
      (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/decoder/DefaultDecoderManagerTest.java
      Sun Oct 10 17:46:28 2004
@@ -20,18 +20,18 @@
 import java.util.EventObject;
 import java.util.Iterator;
 
+import org.apache.seda.EventRouter;
 import org.apache.seda.buffer.BufferPool;
 import org.apache.seda.buffer.BufferPoolConfig;
 import org.apache.seda.buffer.DefaultBufferPool;
 import org.apache.seda.buffer.DefaultBufferPoolConfig;
 import org.apache.seda.event.AbstractSubscriber;
-import org.apache.seda.event.EventRouter;
-import org.apache.seda.event.DefaultEventRouter;
 import org.apache.seda.event.RequestEvent;
 import org.apache.seda.event.RequestSubscriber;
+import org.apache.seda.impl.DefaultEventRouter;
+import org.apache.seda.impl.DefaultStageConfig;
 
 import org.apache.seda.thread.ThreadPool;
-import org.apache.seda.stage.DefaultStageConfig;
 import org.apache.seda.protocol.InetServicesDatabase;
 import org.apache.seda.protocol.InetServiceEntry;
 

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/event/DefaultStageTest.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/test/org/apache/seda/event/DefaultStageTest.java
 (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/event/DefaultStageTest.java
 Sun Oct 10 17:46:28 2004
@@ -20,7 +20,12 @@
 import java.util.ArrayList;
 import java.util.EventObject;
 
+import org.apache.seda.EnqueuePredicate;
+import org.apache.seda.StageHandler;
 import org.apache.seda.thread.ThreadPool;
+import org.apache.seda.impl.DefaultStage;
+import org.apache.seda.impl.DefaultStageConfig;
+import org.apache.seda.impl.util.LoggingStageMonitor;
 import org.apache.seda.stage.*;
 
 import junit.framework.TestCase;

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/listener/TCPListenerManagerTest.java
==============================================================================
--- 
incubator/directory/seda/trunk/src/test/org/apache/seda/listener/TCPListenerManagerTest.java
        (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/test/org/apache/seda/listener/TCPListenerManagerTest.java
        Sun Oct 10 17:46:28 2004
@@ -17,8 +17,8 @@
 package org.apache.seda.listener;
 
 
-import org.apache.seda.event.EventRouter;
-import org.apache.seda.event.DefaultEventRouter;
+import org.apache.seda.EventRouter;
+import org.apache.seda.impl.DefaultEventRouter;
 import org.apache.seda.protocol.InetServiceEntry;
 
 import junit.framework.TestCase;

Reply via email to