Author: trustin
Date: Sun Oct 10 18:32:37 2004
New Revision: 54505

Added:
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EventFilter.java
      - copied, changed from rev 54504, 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Filter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Session.java
   (contents, props changed)
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SessionEvent.java
   (contents, props changed)
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SubscriberContext.java
   (contents, props changed)
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/ByteBufferEvent.java
   (contents, props changed)
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/filter/
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/filter/EventTypeFilter.java
   (contents, props changed)
   
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/session/ByteIoSession.java
   (contents, props changed)
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/StatefulSession.java
   (contents, props changed)
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/StatelessSession.java
   (contents, props changed)
Removed:
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Enum.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EnumUtils.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Filter.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/ValuedEnum.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/stage/
Modified:
   incubator/directory/seda/branches/trustin_api_redesign/   (props changed)
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SubscriberMonitor.java
   
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultEventRouter.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
Log:
* Moved top-level interfaces to top level package (org.apache.seda)

* Merged ClientKey and ClientSession to Session
  * Connect/DisconnectEvent are merged to SessionConstruction/DesctuctionEvent.

* Replacing ClientEvent to SessionEvent

* Redesigned EventRouter and Subscriber introducing SubscriberContext
- This enables 'event source'-based routing
- Replaced java.lang.Class parameter EventTypeFilter.

* Merged InputEvent and OutputEvent to ByteBufferEvent removing its semantics
- This works because 'event source'-based routing is ready.

* Moving implementation classes to org.apache.seda.impl package

* Moved adaptors to org.apache.seda.adaptor package

* Added Eclipse project files to ignore list



Copied: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EventFilter.java
 (from rev 54504, 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Filter.java)
==============================================================================
--- 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Filter.java
 (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/EventFilter.java
    Sun Oct 10 18:32:37 2004
@@ -24,8 +24,8 @@
  *         Project </a>
  * @version $Rev$
  */
-public interface Filter {
-       static Filter ALL = new Filter() {
+public interface EventFilter {
+       static EventFilter ALL = new EventFilter() {
                public boolean accept(SessionEvent event) {
                        return true;
                }

Added: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Session.java
==============================================================================
--- (empty file)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/Session.java
        Sun Oct 10 18:32:37 2004
@@ -0,0 +1,20 @@
+/*
+ * @(#) $Id$
+ */
+package org.apache.seda;
+
+import java.util.Set;
+
+/**
+ * TODO Insert type comment.
+ * 
+ * @author Trustin Lee ([EMAIL PROTECTED])
+ * @version $Rev$, $Date$
+ */
+public interface Session {
+       Set getAttributeNames();
+
+       Object getAttribute(String key);
+
+       Object setAttribute(String key, Object value);
+}
\ No newline at end of file

Added: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SessionEvent.java
==============================================================================
--- (empty file)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SessionEvent.java
   Sun Oct 10 18:32:37 2004
@@ -0,0 +1,50 @@
+/*
+ *   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;
+
+import java.util.EventObject;
+
+/**
+ * TODO Insert type comment.
+ * 
+ * @author Trustin Lee ([EMAIL PROTECTED])
+ * @version $Rev$, $Date$
+ */
+public class SessionEvent extends EventObject {
+
+       private final Session session;
+
+       /**
+        * Creates a new instance.
+        * 
+        * @param source
+        */
+       public SessionEvent(Subscriber source, Session session) {
+               super(source);
+               if (session == null)
+                       throw new NullPointerException();
+               this.session = session;
+       }
+
+       public Subscriber getSourceSubscriber() {
+               return (Subscriber) getSource();
+       }
+
+       public Session getSession() {
+               return session;
+       }
+}
\ No newline at end of file

Added: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SubscriberContext.java
==============================================================================
--- (empty file)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SubscriberContext.java
      Sun Oct 10 18:32:37 2004
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2002-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;
+
+import java.util.Collection;
+
+/**
+ * TODO Insert type comment.
+ * 
+ * @author Trustin Lee ([EMAIL PROTECTED])
+ * @version $Rev$, $Date$
+ */
+public interface SubscriberContext {
+       String getName();
+
+       void subscribe(String eventSourceName, EventFilter eventFilter);
+
+       void unsubscribe(String eventSourceName, EventFilter eventFilter);
+
+       void publish(SessionEvent event);
+
+       void publish(Collection eventCollection);
+       
+       SubscriberMonitor getMonitor();
+       
+       void setMonitor(SubscriberMonitor monitor);
+}
\ No newline at end of file

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SubscriberMonitor.java
==============================================================================
--- 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SubscriberMonitor.java
      (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/SubscriberMonitor.java
      Sun Oct 10 18:32:37 2004
@@ -38,7 +38,7 @@
     void failedOnInform( Subscriber subscriber, EventObject eventObject,
                          Throwable throwable );
     
-    void addedSubscription(String eventSourceName, Filter eventFilter);
+    void addedSubscription(String eventSourceName, EventFilter eventFilter);
     
-    void removedSubscription(String eventSourceName, Filter eventFilter);
+    void removedSubscription(String eventSourceName, EventFilter eventFilter);
 }

Added: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/ByteBufferEvent.java
==============================================================================
--- (empty file)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/ByteBufferEvent.java
  Sun Oct 10 18:32:37 2004
@@ -0,0 +1,56 @@
+/*
+ *   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.event;
+
+import java.nio.ByteBuffer;
+
+import org.apache.seda.Session;
+import org.apache.seda.SessionEvent;
+import org.apache.seda.Subscriber;
+
+/**
+ * TODO Insert type comment.
+ * 
+ * @author Trustin Lee ([EMAIL PROTECTED])
+ * @version $Rev$, $Date$
+ */
+public abstract class ByteBufferEvent extends SessionEvent {
+       private final ByteBuffer buffer;
+
+       /**
+        * Creates a new instance.
+        * 
+        * @param source
+        * @param session
+        */
+       public ByteBufferEvent(Subscriber source, Session session,
+                                                       ByteBuffer buffer) {
+               super(source, session);
+               if (buffer == null)
+                       throw new NullPointerException();
+               this.buffer = buffer;
+       }
+
+       public ByteBuffer getBuffer() {
+               return buffer;
+       }
+
+       public abstract void claimInterests(Object party);
+
+       public abstract void releaseInterests(Object party);
+
+}
\ No newline at end of file

Added: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/filter/EventTypeFilter.java
==============================================================================
--- (empty file)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/event/filter/EventTypeFilter.java
   Sun Oct 10 18:32:37 2004
@@ -0,0 +1,45 @@
+/*
+ *   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.event.filter;
+
+import org.apache.seda.EventFilter;
+import org.apache.seda.SessionEvent;
+
+/**
+ * TODO Insert type comment.
+ * 
+ * @author Trustin Lee ([EMAIL PROTECTED])
+ * @version $Rev$, $Date$
+ */
+public class EventTypeFilter implements EventFilter {
+       private final Class type;
+
+       /**
+        * Creates a new instance.
+        */
+       public EventTypeFilter(Class type) {
+               if (type == null)
+                       throw new NullPointerException();
+               if (!SessionEvent.class.isAssignableFrom(type))
+                       throw new IllegalArgumentException("not a 
SessionEvent");
+               this.type = type;
+       }
+
+       public boolean accept(SessionEvent event) {
+               return (type.isAssignableFrom(event.getClass()));
+       }
+}
\ No newline at end of file

Modified: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultEventRouter.java
==============================================================================
--- 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultEventRouter.java
        (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/impl/DefaultEventRouter.java
        Sun Oct 10 18:32:37 2004
@@ -22,13 +22,11 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.seda.EventFilter;
 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;
 
 
@@ -62,7 +60,7 @@
      * @see org.apache.seda.event.EventRouter#subscribe(java.lang.Class, 
      * org.apache.seda.event.Filter, org.apache.eve.event.Subscriber)
      */
-    public void subscribe( Class type, Filter filter, Subscriber subscriber )
+    public void subscribe( Class type, EventFilter filter, Subscriber 
subscriber )
     {
         if ( ! EventObject.class.isAssignableFrom( type ) ) 
         {
@@ -135,7 +133,7 @@
      * (non-Javadoc)
      * @see EventRouter#unsubscribe(java.lang.Class,Subscriber)
      */
-    public void unsubscribe( Class type, Filter filter, 
+    public void unsubscribe( Class type, EventFilter filter, 
                              Subscriber subscriber )
     {
         if ( ! EventObject.class.isAssignableFrom( type ) ) 

Modified: 
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/input/TCPInputManager.java
  (original)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/input/TCPInputManager.java
  Sun Oct 10 18:32:37 2004
@@ -17,25 +17,19 @@
 package org.apache.seda.input;
 
 
-import java.util.Iterator;
-import java.util.ArrayList;
-
+import java.awt.event.InputEvent;
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.nio.channels.Selector;
 import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
 import java.nio.channels.SocketChannel;
+import java.util.ArrayList;
+import java.util.Iterator;
 
-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.listener.ClientKey;
-import org.apache.seda.event.ConnectEvent;
-import org.apache.seda.event.DisconnectEvent;
-import org.apache.seda.event.ConnectSubscriber;
-import org.apache.seda.event.AbstractSubscriber;
-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/listener/TCPListenerManager.java
==============================================================================
--- 
incubator/directory/seda/branches/trustin_api_redesign/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 18:32:37 2004
@@ -17,9 +17,6 @@
 package org.apache.seda.listener;
 
 
-import org.apache.seda.EventRouter;
-import org.apache.seda.event.*;
-
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.Socket;
@@ -27,7 +24,14 @@
 import java.nio.channels.Selector;
 import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SocketChannel;
-import java.util.*;
+import java.util.EventObject;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.seda.EventRouter;
 
 
 /**

Added: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/ByteIoSession.java
==============================================================================
--- (empty file)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/ByteIoSession.java
  Sun Oct 10 18:32:37 2004
@@ -0,0 +1,29 @@
+/*
+ *   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.session;
+
+import org.apache.seda.Session;
+
+/**
+ * TODO Insert type comment.
+ * 
+ * @author Trustin Lee ([EMAIL PROTECTED])
+ * @version $Rev$, $Date$
+ */
+public interface ByteIoSession extends Session {
+
+}

Added: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/StatefulSession.java
==============================================================================
--- (empty file)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/StatefulSession.java
        Sun Oct 10 18:32:37 2004
@@ -0,0 +1,29 @@
+/*
+ *   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.session;
+
+import org.apache.seda.Session;
+
+/**
+ * TODO Insert type comment.
+ * 
+ * @author Trustin Lee ([EMAIL PROTECTED])
+ * @version $Rev$, $Date$
+ */
+public interface StatefulSession extends Session {
+       boolean isConnected();
+}

Added: 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/StatelessSession.java
==============================================================================
--- (empty file)
+++ 
incubator/directory/seda/branches/trustin_api_redesign/src/java/org/apache/seda/session/StatelessSession.java
       Sun Oct 10 18:32:37 2004
@@ -0,0 +1,29 @@
+/*
+ *   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.session;
+
+import org.apache.seda.Session;
+
+/**
+ * TODO Insert type comment.
+ * 
+ * @author Trustin Lee ([EMAIL PROTECTED])
+ * @version $Rev$, $Date$
+ */
+public interface StatelessSession extends Session {
+
+}

Reply via email to