directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r350180 - in /directory/network/trunk/src/java/org/apache/mina/registry: ServiceRegistry.java SimpleServiceRegistry.java
Date Thu, 01 Dec 2005 05:57:50 GMT
Author: trustin
Date: Wed Nov 30 21:57:46 2005
New Revision: 350180

URL: http://svn.apache.org/viewcvs?rev=350180&view=rev
Log:
Resolved issue: DIRMINA-116 Get the Service from which a connection is accepted
* Added a custom attribute ServiceRegistry.SERVICE
* Modified SimpleServiceRegister.IoFilterChainBuilderWrapper to add SERVICE attribute
** Is this a little bit abuse? :)

Modified:
    directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
    directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java

Modified: directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java?rev=350180&r1=350179&r2=350180&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java Wed Nov
30 21:57:46 2005
@@ -24,6 +24,7 @@
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
 import org.apache.mina.common.TransportType;
 
 /**
@@ -35,6 +36,18 @@
  */
 public interface ServiceRegistry
 {
+    /**
+     * An attribute key of the {@link IoSession} attribute which contains
+     * {@link Service} object if the {@ilnk IoSession} is created from
+     * {@link ServiceRegistry}.
+     * <pre>
+     * IoSession session = ...;
+     * Service service = ( Service ) session.getAttribute( ServiceRegistry.SERVICE );
+     * System.out.println( "Service name: " + service.getName() );
+     * </pre>
+     */
+    public static final String SERVICE = ServiceRegistry.class.getName() + ".service";
+    
     /**
      * Binds the specified I/O handler to the specified service.
      */

Modified: directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java?rev=350180&r1=350179&r2=350180&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java Wed
Nov 30 21:57:46 2005
@@ -33,13 +33,9 @@
 public class SimpleServiceRegistry implements ServiceRegistry
 {
     protected final IoAcceptor socketIoAcceptor = new SocketAcceptor();
-
     protected final IoAcceptor datagramIoAcceptor = new DatagramAcceptor();
-
     protected final IoAcceptor vmPipeAcceptor = new VmPipeAcceptor();
-
     protected final ThreadPoolFilter threadPoolFilter = new ThreadPoolFilter();
-
     private final Set services = new HashSet();
 
     public SimpleServiceRegistry()
@@ -60,7 +56,7 @@
         }
         acceptor.bind(
                 service.getAddress(), handler,
-                new IoFilterChainBuilderWrapper( filterChainBuilder ) );
+                new IoFilterChainBuilderWrapper( service, filterChainBuilder ) );
         services.add( service );
     }
 
@@ -174,15 +170,19 @@
     
     private class IoFilterChainBuilderWrapper implements IoFilterChainBuilder
     {
+        private final Service service;
         private final IoFilterChainBuilder originalBuilder;
         
-        private IoFilterChainBuilderWrapper( IoFilterChainBuilder originalBuilder )
+        private IoFilterChainBuilderWrapper( Service service, IoFilterChainBuilder originalBuilder
)
         {
+            this.service = service;
             this.originalBuilder = originalBuilder;
         }
         
         public void buildFilterChain( IoFilterChain chain ) throws Exception
         {
+            chain.getSession().setAttribute( SERVICE, service );
+
             try
             {
                 originalBuilder.buildFilterChain( chain );



Mime
View raw message