directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject svn commit: r111879 - in incubator/directory/network/trunk/sedang: . src/java/org/apache/directory/seda src/java/org/apache/directory/seda/protocol src/test/org/apache/directory/seda/mocks src/test/org/apache/directory/seda/test
Date Tue, 14 Dec 2004 21:29:12 GMT
Author: bloritsch
Date: Tue Dec 14 13:29:11 2004
New Revision: 111879

URL: http://svn.apache.org/viewcvs?view=rev&rev=111879
Log:
Convert sedang to use the new protocolprovider
Added:
   incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestEvent.java
Removed:
   incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/ProtocolProvider.java
   incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestHandler.java
   incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockDecoderFactory.java
   incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockEncoderFactory.java
Modified:
   incubator/directory/network/trunk/sedang/SedaRedesign.iml
   incubator/directory/network/trunk/sedang/project.xml
   incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/SEDAServer.java
   incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/DecoderStage.java
   incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/EncoderStage.java
   incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestStage.java
   incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockDecoder.java
   incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockEncoder.java
   incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockProtocolProvider.java
   incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockRequestHandler.java
   incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/test/TestSEDAServer.java

Modified: incubator/directory/network/trunk/sedang/SedaRedesign.iml
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/SedaRedesign.iml?view=diff&rev=111879&p1=incubator/directory/network/trunk/sedang/SedaRedesign.iml&r1=111878&p2=incubator/directory/network/trunk/sedang/SedaRedesign.iml&r2=111879
==============================================================================
--- incubator/directory/network/trunk/sedang/SedaRedesign.iml	(original)
+++ incubator/directory/network/trunk/sedang/SedaRedesign.iml	Tue Dec 14 13:29:11 2004
@@ -17,7 +17,7 @@
     <orderEntry type="library" name="Doug Lea's Concurrent" level="application" />
     <orderEntry type="library" name="JUnit" level="application" />
     <orderEntry type="library" name="Event" level="application" />
-    <orderEntry type="library" name="Codec Stateful" level="application" />
+    <orderEntry type="library" name="ProtocolAPI" level="application" />
     <orderEntryProperties />
   </component>
 </module>

Modified: incubator/directory/network/trunk/sedang/project.xml
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/project.xml?view=diff&rev=111879&p1=incubator/directory/network/trunk/sedang/project.xml&r1=111878&p2=incubator/directory/network/trunk/sedang/project.xml&r2=111879
==============================================================================
--- incubator/directory/network/trunk/sedang/project.xml	(original)
+++ incubator/directory/network/trunk/sedang/project.xml	Tue Dec 14 13:29:11 2004
@@ -88,9 +88,9 @@
         </dependency>
         <dependency>
             <groupId>incubator-directory</groupId>
-            <artifactId>snickers-codec</artifactId>
-            <version>0.2.0-SNAPSHOT</version>
-            <url>http://incubator.apache.org/directory/subprojects/ldap/common</url>
+            <artifactId>protocol-api</artifactId>
+            <version>SNAPSHOT</version>
+            <url>http://incubator.apache.org/directory/subprojects/protocol-api/</url>
         </dependency>
     </dependencies>
 

Modified: incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/SEDAServer.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/SEDAServer.java?view=diff&rev=111879&p1=incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/SEDAServer.java&r1=111878&p2=incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/SEDAServer.java&r2=111879
==============================================================================
--- incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/SEDAServer.java
(original)
+++ incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/SEDAServer.java
Tue Dec 14 13:29:11 2004
@@ -20,10 +20,10 @@
 import org.apache.directory.seda.input.ReaderSource;
 import org.apache.directory.seda.input.ConnectSource;
 import org.apache.directory.seda.output.Writer;
-import org.apache.directory.seda.protocol.ProtocolProvider;
 import org.apache.directory.seda.protocol.EncoderStage;
 import org.apache.directory.seda.protocol.RequestStage;
 import org.apache.directory.seda.protocol.DecoderStage;
+import org.apache.protocol.ProtocolProvider;
 import org.d_haven.event.command.ThreadManager;
 import org.d_haven.event.command.DefaultThreadManager;
 import org.d_haven.event.impl.DefaultPipe;
@@ -135,7 +135,7 @@
         m_connect.listen( channel );
 
         m_router.addPipe( String.valueOf(port), new DefaultPipe() );
-        final DecoderStage decoder = new DecoderStage(handler.getDecoderFactory());
+        final DecoderStage decoder = new DecoderStage(handler);
         PipelineUtil.connectStage( m_router, String.valueOf(port), decoder );
 
         m_manager.register( decoder );
@@ -145,7 +145,7 @@
 
         m_manager.register( request );
 
-        final EncoderStage encoder = new EncoderStage(handler.getEncoderFactory());
+        final EncoderStage encoder = new EncoderStage(handler);
         PipelineUtil.connectStage( request, encoder );
 
         m_manager.register( encoder );

Modified: incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/DecoderStage.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/DecoderStage.java?view=diff&rev=111879&p1=incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/DecoderStage.java&r1=111878&p2=incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/DecoderStage.java&r2=111879
==============================================================================
--- incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/DecoderStage.java
(original)
+++ incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/DecoderStage.java
Tue Dec 14 13:29:11 2004
@@ -19,59 +19,50 @@
 import org.apache.directory.seda.Stage;
 import org.apache.directory.seda.NetworkEvent;
 import org.apache.directory.seda.bufferpool.BufferPool;
-import org.apache.snickers.codec.stateful.StatefulDecoder;
-import org.apache.snickers.codec.stateful.DecoderFactory;
-import org.apache.snickers.codec.DecoderException;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-import java.nio.channels.SocketChannel;
+import org.apache.protocol.Decoder;
+import org.apache.protocol.ProtocolProvider;
+import org.apache.protocol.DecoderCallback;
+
+import java.net.Socket;
 
 /**
  * Created by IntelliJ IDEA. User: berin Date: Dec 9, 2004 Time: 4:51:52
  * PM To change this template use File | Settings | File Templates.
  */
-public class DecoderStage extends Stage
+public class DecoderStage extends Stage implements DecoderCallback
 {
-    private final DecoderFactory m_factory;
-    private Map m_encoders;
+    private final ProtocolProvider m_provider;
 
-    public DecoderStage(final DecoderFactory factory)
+    public DecoderStage(final ProtocolProvider provider)
     {
-        m_factory = factory;
-        m_encoders = new WeakHashMap();
+        m_provider = provider;
     }
+
     public void handleEvent(final Object obj)
     {
         if (obj instanceof NetworkEvent)
         {
             final NetworkEvent event = (NetworkEvent)obj;
-            final StatefulDecoder encoder = getDecoder(event.channel());
-            try
-            {
-                encoder.decode( event.getBuffer() );
-                BufferPool.putBuffer( event.getBuffer() );
-                event.setBuffer( null );
-            }
-            catch ( DecoderException e )
-            {
-                e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-            }
-        }
+            final Decoder decoder = m_provider.getDecoder(event.socket(), this);
 
-        super.handleEvent( obj );
+            decoder.decode( event.getBuffer() );
+            BufferPool.putBuffer( event.getBuffer() );
+            event.setBuffer( null );
+        }
+        else
+        {
+            super.handleEvent( obj );
+        }
     }
 
-    private StatefulDecoder getDecoder( final SocketChannel socketChannel )
+    public void decoded( final Socket client, final Object response )
     {
-        StatefulDecoder encoder = (StatefulDecoder)m_encoders.get(socketChannel);
+        final RequestEvent event = new RequestEvent(client, response);
+        boolean enqueued = false;
 
-        if(encoder == null)
+        while ( ! enqueued )
         {
-            encoder = m_factory.createDecoder();
-            m_encoders.put(socketChannel, encoder);
+            enqueued = getDefaultPipe().tryEnqueue( event );
         }
-
-        return encoder;
     }
 }

Modified: incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/EncoderStage.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/EncoderStage.java?view=diff&rev=111879&p1=incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/EncoderStage.java&r1=111878&p2=incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/EncoderStage.java&r2=111879
==============================================================================
--- incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/EncoderStage.java
(original)
+++ incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/EncoderStage.java
Tue Dec 14 13:29:11 2004
@@ -18,42 +18,32 @@
 
 import org.apache.directory.seda.Stage;
 import org.apache.directory.seda.NetworkEvent;
-import org.apache.snickers.codec.stateful.EncoderFactory;
-import org.apache.snickers.codec.stateful.StatefulEncoder;
-import org.apache.snickers.codec.EncoderException;
+import org.apache.protocol.Encoder;
+import org.apache.protocol.ProtocolProvider;
+import org.apache.protocol.EncoderCallback;
 
-import java.nio.channels.SocketChannel;
-import java.util.Map;
-import java.util.WeakHashMap;
+import java.nio.ByteBuffer;
+import java.net.Socket;
 
 /**
  * Created by IntelliJ IDEA. User: berin Date: Dec 9, 2004 Time: 3:32:12
  * PM To change this template use File | Settings | File Templates.
  */
-public class EncoderStage extends Stage
+public class EncoderStage extends Stage implements EncoderCallback
 {
-    private final EncoderFactory m_factory;
-    private Map m_encoders;
+    private final ProtocolProvider m_provider;
 
-    public EncoderStage(final EncoderFactory factory)
+    public EncoderStage(final ProtocolProvider provider)
     {
-        m_factory = factory;
-        m_encoders = new WeakHashMap();
+        m_provider = provider;
     }
     public void handleEvent(final Object obj)
     {
-        if (obj instanceof NetworkEvent)
+        if (obj instanceof RequestEvent)
         {
-            final NetworkEvent event = (NetworkEvent)obj;
-            final StatefulEncoder encoder = getEncoder(event.channel());
-            try
-            {
-                encoder.encode( event );
-            }
-            catch ( EncoderException e )
-            {
-                e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-            }
+            final RequestEvent event = (RequestEvent)obj;
+            final Encoder encoder = m_provider.getEncoder(event.m_client, this);
+            encoder.encode( event.m_request );
         }
         else
         {
@@ -61,16 +51,15 @@
         }
     }
 
-    private StatefulEncoder getEncoder( final SocketChannel socketChannel )
+    public void encoded( final Socket client, final ByteBuffer message )
     {
-        StatefulEncoder encoder = (StatefulEncoder)m_encoders.get(socketChannel);
+        final NetworkEvent event = new NetworkEvent(client.getChannel());
+        event.setBuffer( message );
+        boolean enqueued = false;
 
-        if(encoder == null)
+        while ( ! enqueued )
         {
-            encoder = m_factory.createEncoder();
-            m_encoders.put(socketChannel, encoder);
+            enqueued = getDefaultPipe().tryEnqueue(event);
         }
-
-        return encoder;
     }
 }

Deleted: /incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/ProtocolProvider.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/ProtocolProvider.java?view=auto&rev=111878
==============================================================================

Added: incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestEvent.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestEvent.java?view=auto&rev=111879
==============================================================================
--- (empty file)
+++ incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestEvent.java
Tue Dec 14 13:29:11 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.directory.seda.protocol;
+
+import java.net.Socket;
+
+/**
+ * Created by IntelliJ IDEA. User: berin Date: Dec 14, 2004 Time:
+ * 3:50:00 PM To change this template use File | Settings | File
+ * Templates.
+ */
+public class RequestEvent extends Object
+{
+    public final Socket m_client;
+    public final Object m_request;
+
+    public RequestEvent( final Socket client, final Object request )
+    {
+        m_client = client;
+        m_request = request;
+    }
+}

Deleted: /incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestHandler.java?view=auto&rev=111878
==============================================================================

Modified: incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestStage.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestStage.java?view=diff&rev=111879&p1=incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestStage.java&r1=111878&p2=incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestStage.java&r2=111879
==============================================================================
--- incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestStage.java
(original)
+++ incubator/directory/network/trunk/sedang/src/java/org/apache/directory/seda/protocol/RequestStage.java
Tue Dec 14 13:29:11 2004
@@ -17,28 +17,46 @@
 package org.apache.directory.seda.protocol;
 
 import org.apache.directory.seda.Stage;
+import org.apache.protocol.ProtocolProvider;
+import org.apache.protocol.RequestHandler;
+import org.apache.protocol.RequestHandlerCallback;
+
+import java.net.Socket;
 
 /**
  * Created by IntelliJ IDEA. User: berin Date: Dec 9, 2004 Time: 4:55:11
  * PM To change this template use File | Settings | File Templates.
  */
-public class RequestStage extends Stage
+public class RequestStage extends Stage implements RequestHandlerCallback
 {
-    private ProtocolProvider m_provider;
+    private RequestHandler m_handler;
 
     public RequestStage( final ProtocolProvider provider )
     {
-        m_provider = provider;
+        m_handler = provider.getRequestHandler( this );
     }
 
     public void handleEvent(final Object event)
     {
-        final RequestHandler handler = m_provider.getHandler( event );
-        final Object[] values = handler.handleRequest( event );
+        if ( event instanceof RequestEvent )
+        {
+            final RequestEvent request = (RequestEvent)event;
+            m_handler.handleRequest( request.m_client, request.m_request );
+        }
+        else
+        {
+            super.handleEvent( event );
+        }
+    }
+
+    public void requestHandled( final Socket client, final Object response )
+    {
+        final RequestEvent event = new RequestEvent(client, response);
+        boolean enqueued = false;
 
-        for (int i = 0; i < values.length; i++)
+        while ( ! enqueued )
         {
-            super.handleEvent( values[i] );
+            enqueued = getDefaultPipe().tryEnqueue( event );
         }
     }
 }

Modified: incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockDecoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockDecoder.java?view=diff&rev=111879&p1=incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockDecoder.java&r1=111878&p2=incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockDecoder.java&r2=111879
==============================================================================
--- incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockDecoder.java
(original)
+++ incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockDecoder.java
Tue Dec 14 13:29:11 2004
@@ -16,29 +16,28 @@
  */
 package org.apache.directory.seda.mocks;
 
-import org.apache.snickers.codec.stateful.StatefulDecoder;
-import org.apache.snickers.codec.stateful.DecoderCallback;
-import org.apache.snickers.codec.stateful.DecoderMonitor;
-import org.apache.snickers.codec.DecoderException;
+import org.apache.protocol.Decoder;
+import org.apache.protocol.DecoderCallback;
+
+import java.nio.ByteBuffer;
+import java.net.Socket;
 
 /**
  * Created by IntelliJ IDEA. User: berin Date: Dec 9, 2004 Time: 3:28:49
  * PM To change this template use File | Settings | File Templates.
  */
-public class MockDecoder implements StatefulDecoder
+public class MockDecoder implements Decoder
 {
-    public void decode( Object o ) throws DecoderException
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
+    private final Socket m_client;
+    private final DecoderCallback m_destination;
 
-    public void setCallback( final DecoderCallback decoderCallback )
+    public MockDecoder(final Socket client, final DecoderCallback destination )
     {
-        //To change body of implemented methods use File | Settings | File Templates.
+        m_client = client;
+        m_destination = destination;
     }
-
-    public void setDecoderMonitor( final DecoderMonitor decoderMonitor )
+    public void decode( final ByteBuffer buffer )
     {
-        //To change body of implemented methods use File | Settings | File Templates.
+        m_destination.decoded( m_client, buffer );
     }
 }

Deleted: /incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockDecoderFactory.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockDecoderFactory.java?view=auto&rev=111878
==============================================================================

Modified: incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockEncoder.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockEncoder.java?view=diff&rev=111879&p1=incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockEncoder.java&r1=111878&p2=incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockEncoder.java&r2=111879
==============================================================================
--- incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockEncoder.java
(original)
+++ incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockEncoder.java
Tue Dec 14 13:29:11 2004
@@ -16,29 +16,28 @@
  */
 package org.apache.directory.seda.mocks;
 
-import org.apache.snickers.codec.stateful.StatefulEncoder;
-import org.apache.snickers.codec.stateful.EncoderCallback;
-import org.apache.snickers.codec.stateful.EncoderMonitor;
-import org.apache.snickers.codec.EncoderException;
+import org.apache.protocol.Encoder;
+import org.apache.protocol.EncoderCallback;
+
+import java.net.Socket;
+import java.nio.ByteBuffer;
 
 /**
  * Created by IntelliJ IDEA. User: berin Date: Dec 9, 2004 Time: 3:30:04
  * PM To change this template use File | Settings | File Templates.
  */
-public class MockEncoder implements StatefulEncoder
+public class MockEncoder implements Encoder
 {
-    public void encode( Object o ) throws EncoderException
-    {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
+    private EncoderCallback m_destination;
+    private Socket m_client;
 
-    public void setCallback( EncoderCallback encoderCallback )
+    public MockEncoder(final Socket client, final EncoderCallback destination )
     {
-        //To change body of implemented methods use File | Settings | File Templates.
+        m_client = client;
+        m_destination = destination;
     }
-
-    public void setEncoderMonitor( EncoderMonitor encoderMonitor )
+    public void encode( Object o )
     {
-        //To change body of implemented methods use File | Settings | File Templates.
+        m_destination.encoded( m_client, (ByteBuffer)o );
     }
 }

Deleted: /incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockEncoderFactory.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockEncoderFactory.java?view=auto&rev=111878
==============================================================================

Modified: incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockProtocolProvider.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockProtocolProvider.java?view=diff&rev=111879&p1=incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockProtocolProvider.java&r1=111878&p2=incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockProtocolProvider.java&r2=111879
==============================================================================
--- incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockProtocolProvider.java
(original)
+++ incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockProtocolProvider.java
Tue Dec 14 13:29:11 2004
@@ -16,10 +16,16 @@
  */
 package org.apache.directory.seda.mocks;
 
-import org.apache.directory.seda.protocol.ProtocolProvider;
-import org.apache.directory.seda.protocol.RequestHandler;
-import org.apache.snickers.codec.stateful.DecoderFactory;
-import org.apache.snickers.codec.stateful.EncoderFactory;
+import org.apache.protocol.ProtocolProvider;
+import org.apache.protocol.Decoder;
+import org.apache.protocol.DecoderCallback;
+import org.apache.protocol.RequestHandler;
+import org.apache.protocol.RequestHandlerCallback;
+import org.apache.protocol.Encoder;
+import org.apache.protocol.EncoderCallback;
+import org.apache.protocol.ClientManager;
+
+import java.net.Socket;
 
 /**
  * Created by IntelliJ IDEA. User: berin Date: Dec 9, 2004 Time: 3:27:08
@@ -27,47 +33,26 @@
  */
 public class MockProtocolProvider implements ProtocolProvider
 {
-    /**
-     * Gets the authoritative name for the service of this provider.
-     *
-     * @return the authoritative service name
-     */
-    public String getName()
+    public Decoder getDecoder( final Socket socket,
+                               final DecoderCallback decoderCallback )
     {
-        return "MockProtocolProvider";
+        return new MockDecoder(socket, decoderCallback);
     }
 
-    /**
-     * Gets a factory used to create a new StatefulDecoder for this
-     * service's protocol.
-     *
-     * @return a new StatefulDecoder for this service's protocol
-     */
-    public DecoderFactory getDecoderFactory()
+    public RequestHandler getRequestHandler(
+            final RequestHandlerCallback requestHandlerCallback )
     {
-        return new MockDecoderFactory();  //To change body of implemented methods use File
| Settings | File Templates.
+        return new MockRequestHandler(requestHandlerCallback);
     }
 
-    /**
-     * Gets a factory used to create a new StatefulEncoder for this
-     * service's protocol.
-     *
-     * @return a new StatefulEncoder for this service's protocol
-     */
-    public EncoderFactory getEncoderFactory()
+    public Encoder getEncoder( final Socket socket,
+                               final EncoderCallback encoderCallback )
     {
-        return new MockEncoderFactory();  //To change body of implemented methods use File
| Settings | File Templates.
+        return new MockEncoder(socket, encoderCallback);
     }
 
-    /**
-     * Gets a protocol specific handler for an request object.
-     *
-     * @param request the protocol request to handle
-     *
-     * @return the protocol request handler for the request object
-     */
-    public RequestHandler getHandler( final Object request )
+    public void setClientManager( final ClientManager clientManager )
     {
-        return new MockRequestHandler();  //To change body of implemented methods use File
| Settings | File Templates.
+        // do nothing for now.
     }
 }

Modified: incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockRequestHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockRequestHandler.java?view=diff&rev=111879&p1=incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockRequestHandler.java&r1=111878&p2=incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockRequestHandler.java&r2=111879
==============================================================================
--- incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockRequestHandler.java
(original)
+++ incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/mocks/MockRequestHandler.java
Tue Dec 14 13:29:11 2004
@@ -16,7 +16,11 @@
  */
 package org.apache.directory.seda.mocks;
 
-import org.apache.directory.seda.protocol.RequestHandler;
+
+import org.apache.protocol.RequestHandler;
+import org.apache.protocol.RequestHandlerCallback;
+
+import java.net.Socket;
 
 /**
  * Created by IntelliJ IDEA. User: berin Date: Dec 9, 2004 Time: 3:30:40
@@ -24,16 +28,15 @@
  */
 public class MockRequestHandler implements RequestHandler
 {
-    /**
-     * Handles a request that can return 0..n responses.  Those
-     * responses are then encoded and returned to the user.
-     *
-     * @param request the request object from the encoder
-     *
-     * @return an array of 0..n elements for the responses.
-     */
-    public Object[] handleRequest( final Object request )
+    private final RequestHandlerCallback m_destination;
+
+    public MockRequestHandler(final RequestHandlerCallback callback)
+    {
+        m_destination = callback;
+    }
+
+    public void handleRequest( Socket socket, Object o )
     {
-        return RequestHandler.NO_RESPONSE;
+        m_destination.requestHandled( socket, o );
     }
 }

Modified: incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/test/TestSEDAServer.java
Url: http://svn.apache.org/viewcvs/incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/test/TestSEDAServer.java?view=diff&rev=111879&p1=incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/test/TestSEDAServer.java&r1=111878&p2=incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/test/TestSEDAServer.java&r2=111879
==============================================================================
--- incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/test/TestSEDAServer.java
(original)
+++ incubator/directory/network/trunk/sedang/src/test/org/apache/directory/seda/test/TestSEDAServer.java
Tue Dec 14 13:29:11 2004
@@ -20,7 +20,6 @@
 import org.apache.directory.seda.SEDAServer;
 import org.apache.directory.seda.mocks.MockProtocolProvider;
 import org.apache.directory.seda.input.Firewall;
-import org.apache.directory.seda.input.ReaderSource;
 
 import java.nio.channels.SocketChannel;
 import java.io.IOException;

Mime
View raw message