directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r151711 - in incubator/directory/network/mina/trunk: src/examples/org/apache/mina/examples/registry/ src/java/org/apache/mina/common/ src/java/org/apache/mina/io/datagram/ src/java/org/apache/mina/io/socket/ src/java/org/apache/mina/registry/ xdocs/
Date Mon, 07 Feb 2005 08:19:33 GMT
Author: trustin
Date: Mon Feb  7 00:19:28 2005
New Revision: 151711

URL: http://svn.apache.org/viewcvs?view=rev&rev=151711
Log:
Implemented registry package.

Added:
    incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/
    incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/Main.java
  (with props)
    incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/package.html
  (with props)
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
  (with props)
Removed:
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/SimpleService.java
Modified:
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/common/TransportType.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/Service.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
    incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/package.html
    incubator/directory/network/mina/trunk/xdocs/index.xml

Added: incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/Main.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/Main.java?view=auto&rev=151711
==============================================================================
--- incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/Main.java
(added)
+++ incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/Main.java
Mon Feb  7 00:19:28 2005
@@ -0,0 +1,45 @@
+/*
+ * @(#) $Id$
+ */
+package org.apache.mina.examples.registry;
+
+import org.apache.mina.common.TransportType;
+import org.apache.mina.examples.echoserver.EchoProtocolHandler;
+import org.apache.mina.examples.reverser.ReverseProtocolProvider;
+import org.apache.mina.registry.Service;
+import org.apache.mina.registry.ServiceRegistry;
+import org.apache.mina.registry.SimpleServiceRegistry;
+
+/**
+ * This example demonstrates the usage of {@link ServiceRegistry} in 
+ * <code>org.apache.mina.registry</code> package.
+ * 
+ * This application starts up echo and reverse protocol server. 
+ * 
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$, 
+ */
+public class Main
+{
+    public static void main( String[] args ) throws Exception
+    {
+        ServiceRegistry registry = new SimpleServiceRegistry();
+
+        // Register echo service
+        registry.bind( new Service( "echo", TransportType.SOCKET, 8080 ),
+                new EchoProtocolHandler() );
+        registry.bind( new Service( "echo", TransportType.DATAGRAM, 8080 ),
+                new EchoProtocolHandler() );
+
+        // Register reverse service
+        registry.bind( new Service( "reverse", TransportType.SOCKET, 8081 ),
+                new ReverseProtocolProvider() );
+        registry.bind(
+                new Service( "reverse", TransportType.DATAGRAM, 8081 ),
+                new ReverseProtocolProvider() );
+        registry.bind( new Service( "reverse", TransportType.VM_PIPE, 8081 ),
+                new ReverseProtocolProvider() );
+        
+        System.out.println(registry.getAllServices());
+    }
+}

Propchange: incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/Main.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Added: incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/package.html
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/package.html?view=auto&rev=151711
==============================================================================
--- incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/package.html
(added)
+++ incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/package.html
Mon Feb  7 00:19:28 2005
@@ -0,0 +1,8 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+</head>
+<body>
+Demonstrates the usage of <code>org.apache.mina.registry</code> package.
+</body>
+</html>

Propchange: incubator/directory/network/mina/trunk/src/examples/org/apache/mina/examples/registry/package.html
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/common/TransportType.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/common/TransportType.java?view=diff&r1=151710&r2=151711
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/common/TransportType.java
(original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/common/TransportType.java
Mon Feb  7 00:19:28 2005
@@ -18,32 +18,37 @@
  */
 package org.apache.mina.common;
 
+import java.io.InvalidObjectException;
+import java.io.ObjectStreamException;
+import java.io.Serializable;
+
 /**
  * Represents network transport types.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
-public class TransportType
+public class TransportType implements Serializable
 {
+    private static final long serialVersionUID = 3258132470497883447L;
+
     /**
      * Transport type: TCP/IP (<code>SocketChannel</code>)
      */
     public static final TransportType SOCKET = new TransportType( "SOCKET",
-                                                                  false );
+            false );
 
     /**
      * Transport type: UDP/IP (<code>DatagramChannel</code>)
      */
     public static final TransportType DATAGRAM = new TransportType(
-                                                                    "DATAGRAM",
-                                                                    true );
+            "DATAGRAM", true );
 
     /**
      * Transport type: VM pipe (direct message exchange)
      */
     public static final TransportType VM_PIPE = new TransportType( "VM_PIPE",
-                                                                   false );
+            false );
 
     private final String strVal;
 
@@ -71,4 +76,17 @@
     {
         return strVal;
     }
-}
\ No newline at end of file
+    
+    private Object readResolve() throws ObjectStreamException
+    {
+        if( strVal.equals( SOCKET.toString() ) )
+            return SOCKET;
+        if( strVal.equals( DATAGRAM.toString() ) )
+            return DATAGRAM;
+        if( strVal.equals( VM_PIPE.toString() ) )
+            return VM_PIPE;
+        else
+            throw new InvalidObjectException( "Unknown transport type: "
+                    + this );
+    }
+}

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java?view=diff&r1=151710&r2=151711
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
(original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
Mon Feb  7 00:19:28 2005
@@ -136,8 +136,7 @@
             ch = ( DatagramChannel ) channels.get( address );
 
             if( ch == null )
-                throw new IllegalArgumentException( "Unknown address: "
-                                                    + address );
+                return;
 
             SelectionKey key = ch.keyFor( selector );
             channels.remove( address );

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java?view=diff&r1=151710&r2=151711
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
(original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
Mon Feb  7 00:19:28 2005
@@ -146,8 +146,7 @@
             ssc = ( ServerSocketChannel ) channels.get( address );
 
             if( ssc == null )
-                throw new IllegalArgumentException( "Unknown address: "
-                                                    + address );
+                return;
 
             SelectionKey key = ssc.keyFor( selector );
             channels.remove( address );

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/Service.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/Service.java?view=diff&r1=151710&r2=151711
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/Service.java
(original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/Service.java
Mon Feb  7 00:19:28 2005
@@ -18,6 +18,8 @@
  */
 package org.apache.mina.registry;
 
+import java.io.Serializable;
+
 import org.apache.mina.common.TransportType;
 
 /**
@@ -26,11 +28,92 @@
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
-public interface Service
+public class Service implements Serializable, Cloneable
 {
-    String getName();
+    private static final long serialVersionUID = 3258407344110383155L;
+
+    private final String name;
+
+    private final TransportType transportType;
+
+    private final int port;
+
+    /**
+     * Creates a new instance with the specified protocol name, transport type,
+     * and port number.
+     */
+    public Service( String name, TransportType transportType, int port )
+    {
+        if( name == null )
+            throw new NullPointerException( "name" );
+        if( transportType == null )
+            throw new NullPointerException( "transportType" );
+        if( port < 0 || port > 65535 )
+            throw new IllegalArgumentException( "port: " + port );
+
+        this.name = name;
+        this.transportType = transportType;
+        this.port = port;
+    }
+
+    /**
+     * Returns the name of this service (protocol).
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /**
+     * Returns the transport type this service uses.
+     */
+    public TransportType getTransportType()
+    {
+        return transportType;
+    }
+
+    /**
+     * Returns the port number this service is bound on.
+     */
+    public int getPort()
+    {
+        return port;
+    }
+
+    public int hashCode()
+    {
+        return ( ( name.hashCode() * 37 ) ^ transportType.hashCode() * 37 )
+                ^ port;
+    }
+
+    public boolean equals( Object o )
+    {
+        if( o == null )
+            return false;
+        if( this == o )
+            return true;
+        if( !( o instanceof Service ) )
+            return false;
 
-    TransportType getTransportType();
+        Service that = ( Service ) o;
+        return this.name.equals( that.name )
+                && this.transportType == that.transportType
+                && this.port == that.port;
+    }
 
-    int getPort();
-}
\ No newline at end of file
+    public Object clone()
+    {
+        try
+        {
+            return super.clone();
+        }
+        catch( CloneNotSupportedException e )
+        {
+            throw new InternalError();
+        }
+    }
+    
+    public String toString() {
+        return "(" + transportType + ", " + name + ", " + port + ')';
+    }
+}

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java?view=diff&r1=151710&r2=151711
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
(original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
Mon Feb  7 00:19:28 2005
@@ -19,13 +19,13 @@
 package org.apache.mina.registry;
 
 import java.io.IOException;
-import java.util.Iterator;
+import java.util.Set;
 
 import org.apache.mina.common.TransportType;
 import org.apache.mina.io.IoHandler;
 import org.apache.mina.io.IoHandlerFilter;
-import org.apache.mina.protocol.ProtocolHandler;
 import org.apache.mina.protocol.ProtocolHandlerFilter;
+import org.apache.mina.protocol.ProtocolProvider;
 
 /**
  * Interface for the internet service registry. The registry is used by MINA
@@ -37,51 +37,94 @@
  */
 public interface ServiceRegistry
 {
-    void bind( Service service, IoHandler sessionHandler ) throws IOException;
+    /**
+     * Binds the specified I/O handler to the specified service.
+     */
+    void bind( Service service, IoHandler ioHandler ) throws IOException;
 
-    void bind( Service service, ProtocolHandler sessionHandler )
+    /**
+     * Binds the specified protocol provider to the specified service.
+     */
+    void bind( Service service, ProtocolProvider protocolProvider )
             throws IOException;
 
+    /**
+     * Unbinds the specified service (and its aggregated I/O handler or
+     * protocol provider). 
+     */
     void unbind( Service service );
 
+    /**
+     * Adds the specified filter to the acceptors of all transport types
+     * in this registry.
+     */
     void addFilter( int priority, IoHandlerFilter filter );
-
+    
+    /**
+     * Adds the specified filter to the acceptors of all transport types
+     * in this registry.
+     */
     void addFilter( int priority, ProtocolHandlerFilter filter );
+    
+    /**
+     * Adds the specified filter to the acceptor of the specified transport
+     * type with the specified priority.
+     */
+    void addFilter( TransportType transportType, int priority,
+                   IoHandlerFilter filter );
 
-    void addFilter( Service service, int priority, IoHandlerFilter filter );
-
-    void addFilter( Service service, int priority, ProtocolHandlerFilter filter );
+    /**
+     * Adds the specified filter to the acceptor of the specified transport
+     * type with the specified priority.
+     */
+    void addFilter( TransportType transportType, int priority,
+                   ProtocolHandlerFilter filter );
 
+    /**
+     * Removes the specified filter from the acceptors of all transport types
+     * in this registry.
+     */
     void removeFilter( IoHandlerFilter filter );
 
+    /**
+     * Removes the specified filter from the acceptors of all transport types
+     * in this registry.
+     */
     void removeFilter( ProtocolHandlerFilter filter );
 
-    Service getByName( String name, TransportType transportType );
-
-    Service getByPort( int port, TransportType transportType );
-
-    Iterator getAll();
+    /**
+     * Removes the specified filter from the acceptor of the specified
+     * transport type.
+     */
+    void removeFilter( TransportType transportType, IoHandlerFilter filter );
 
-    Iterator getByTransportType( TransportType transportType );
+    /**
+     * Removes the specified filter from the acceptor of the specified
+     * transport type.
+     */
+    void removeFilter( TransportType transportType,
+                      ProtocolHandlerFilter filter );
 
     /**
-     * Gets an iteration over all the entries for a service by the name of the
-     * service.
-     * 
-     * @param name
-     *            the authoritative name of the service
-     * @return an Iterator over InetServiceEntry objects
+     * Returns {@link Set} of all services bound in this registry.
      */
-    Iterator getByName( String name );
+    Set getAllServices();
+    
+    /**
+     * Returns {@link Set} of services bound in this registry with the
+     * specified service(or protocol) name.
+     */
+    Set getServices(String name);
 
     /**
-     * Gets an iteration over all the entries for a service by port number.
-     * This method returns an Iterator over the set of InetServiceEntry objects
-     * since more than one transport protocol can be used on the same port.
-     * 
-     * @param port
-     *            the port one which the service resides
-     * @return an Iterator over InetServiceEntry objects
+     * Returns {@link Set} of services bound in this registry with the
+     * specified transport type.
+     */
+    Set getServices(TransportType transportType);
+    
+    /**
+     * Returns {@link Set} of services bound in this registry with the
+     * specified port number.
      */
-    Iterator getByPort( int port );
-}
\ No newline at end of file
+    Set getServices(int port);
+}

Added: incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java?view=auto&rev=151711
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
(added)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
Mon Feb  7 00:19:28 2005
@@ -0,0 +1,311 @@
+/*
+ * @(#) $Id$
+ */
+package org.apache.mina.registry;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.mina.common.TransportType;
+import org.apache.mina.io.IoAcceptor;
+import org.apache.mina.io.IoHandler;
+import org.apache.mina.io.IoHandlerFilter;
+import org.apache.mina.io.datagram.DatagramAcceptor;
+import org.apache.mina.io.filter.IoThreadPoolFilter;
+import org.apache.mina.io.socket.SocketAcceptor;
+import org.apache.mina.protocol.ProtocolAcceptor;
+import org.apache.mina.protocol.ProtocolHandlerFilter;
+import org.apache.mina.protocol.ProtocolProvider;
+import org.apache.mina.protocol.filter.ProtocolThreadPoolFilter;
+import org.apache.mina.protocol.io.IoProtocolAcceptor;
+import org.apache.mina.protocol.vmpipe.VmPipeAcceptor;
+import org.apache.mina.protocol.vmpipe.VmPipeAddress;
+
+/**
+ * A simple implementation of {@link ServiceRegistry}.
+ * 
+ * This service registry supports socket, datagram, VM-pipe transport types,
+ * and thread pools were added by default. 
+ * 
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$, 
+ */
+public class SimpleServiceRegistry implements ServiceRegistry
+{
+    protected final IoAcceptor socketIoAcceptor = new SocketAcceptor();
+
+    protected final IoAcceptor datagramIoAcceptor = new DatagramAcceptor();
+
+    protected final ProtocolAcceptor socketProtocolAcceptor = new IoProtocolAcceptor(
+            socketIoAcceptor );
+
+    protected final ProtocolAcceptor datagramProtocolAcceptor = new IoProtocolAcceptor(
+            datagramIoAcceptor );
+
+    protected final ProtocolAcceptor vmPipeAcceptor = new VmPipeAcceptor();
+
+    protected final IoThreadPoolFilter ioThreadPoolFilter = new IoThreadPoolFilter();
+
+    protected final ProtocolThreadPoolFilter protocolThreadPoolFilter = new ProtocolThreadPoolFilter();
+
+    private final Set services = new HashSet();
+
+    public SimpleServiceRegistry() throws IOException
+    {
+        socketIoAcceptor.addFilter( IoHandlerFilter.MAX_PRIORITY,
+                ioThreadPoolFilter );
+        datagramIoAcceptor.addFilter( IoHandlerFilter.MAX_PRIORITY,
+                ioThreadPoolFilter );
+        socketProtocolAcceptor.addFilter( ProtocolHandlerFilter.MAX_PRIORITY,
+                protocolThreadPoolFilter );
+        datagramProtocolAcceptor.addFilter(
+                ProtocolHandlerFilter.MAX_PRIORITY, protocolThreadPoolFilter );
+        vmPipeAcceptor.addFilter( ProtocolHandlerFilter.MAX_PRIORITY,
+                protocolThreadPoolFilter );
+    }
+
+    public synchronized void bind( Service service, IoHandler ioHandler )
+            throws IOException
+    {
+        IoAcceptor acceptor = findIoAcceptor( service.getTransportType() );
+        acceptor.bind( new InetSocketAddress( service.getPort() ), ioHandler );
+        startThreadPools();
+        services.add( service );
+    }
+
+    public synchronized void bind( Service service,
+                                  ProtocolProvider protocolProvider )
+            throws IOException
+    {
+        ProtocolAcceptor acceptor = findProtocolAcceptor( service
+                .getTransportType() );
+        if( acceptor instanceof VmPipeAcceptor )
+        {
+            acceptor.bind( new VmPipeAddress( service.getPort() ),
+                    protocolProvider );
+        }
+        else
+        {
+            acceptor.bind( new InetSocketAddress( service.getPort() ),
+                    protocolProvider );
+        }
+        startThreadPools();
+        services.add( service );
+    }
+
+    public synchronized void unbind( Service service )
+    {
+        ProtocolAcceptor acceptor = findProtocolAcceptor( service
+                .getTransportType() );
+        acceptor.unbind( new InetSocketAddress( service.getPort() ) );
+        acceptor.unbind( new VmPipeAddress( service.getPort() ) );
+        services.remove( service );
+        stopThreadPools();
+    }
+
+    public synchronized void addFilter( int priority, IoHandlerFilter filter )
+    {
+        boolean s = false;
+        boolean d = false;
+        try
+        {
+            socketIoAcceptor.addFilter( priority, filter );
+            s = true;
+            datagramIoAcceptor.addFilter( priority, filter );
+            d = true;
+        }
+        finally
+        {
+            if( !s || !d )
+            {
+                // rollback
+                if( s )
+                {
+                    socketIoAcceptor.removeFilter( filter );
+                }
+
+                if( d )
+                {
+                    datagramIoAcceptor.removeFilter( filter );
+                }
+            }
+        }
+    }
+
+    public synchronized void addFilter( int priority,
+                                       ProtocolHandlerFilter filter )
+    {
+        boolean s = false;
+        boolean d = false;
+        boolean v = false;
+        try
+        {
+            socketProtocolAcceptor.addFilter( priority, filter );
+            s = true;
+            datagramProtocolAcceptor.addFilter( priority, filter );
+            d = true;
+            vmPipeAcceptor.addFilter( priority, filter );
+            v = true;
+        }
+        finally
+        {
+            if( !s || !d || !v )
+            {
+                // rollback
+                if( s )
+                {
+                    socketProtocolAcceptor.removeFilter( filter );
+                }
+
+                if( d )
+                {
+                    datagramProtocolAcceptor.removeFilter( filter );
+                }
+
+                if( v )
+                {
+                    vmPipeAcceptor.removeFilter( filter );
+                }
+            }
+        }
+    }
+
+    public synchronized void addFilter( TransportType transportType,
+                                       int priority, IoHandlerFilter filter )
+    {
+        IoAcceptor acceptor = findIoAcceptor( transportType );
+        acceptor.addFilter( priority, filter );
+    }
+
+    public synchronized void addFilter( TransportType transportType,
+                                       int priority,
+                                       ProtocolHandlerFilter filter )
+    {
+        ProtocolAcceptor acceptor = findProtocolAcceptor( transportType );
+        acceptor.addFilter( priority, filter );
+    }
+
+    public synchronized void removeFilter( IoHandlerFilter filter )
+    {
+        socketIoAcceptor.removeFilter( filter );
+        datagramIoAcceptor.removeFilter( filter );
+    }
+
+    public synchronized void removeFilter( ProtocolHandlerFilter filter )
+    {
+        socketProtocolAcceptor.removeFilter( filter );
+        datagramProtocolAcceptor.removeFilter( filter );
+        vmPipeAcceptor.removeFilter( filter );
+    }
+
+    public synchronized void removeFilter( TransportType transportType,
+                                          IoHandlerFilter filter )
+    {
+        IoAcceptor acceptor = findIoAcceptor( transportType );
+        acceptor.removeFilter( filter );
+    }
+
+    public synchronized void removeFilter( TransportType transportType,
+                                          ProtocolHandlerFilter filter )
+    {
+        ProtocolAcceptor acceptor = findProtocolAcceptor( transportType );
+        acceptor.removeFilter( filter );
+    }
+
+    public synchronized Set getAllServices()
+    {
+        return new HashSet( services );
+    }
+
+    public synchronized Set getServices( String name )
+    {
+        Set result = new HashSet();
+        Iterator it = services.iterator();
+        while( it.hasNext() )
+        {
+            Service s = ( Service ) it.next();
+            if( name.equals( s.getName() ) )
+            {
+                result.add( s );
+            }
+        }
+        return result;
+    }
+
+    public Set getServices( TransportType transportType )
+    {
+        Set result = new HashSet();
+        Iterator it = services.iterator();
+        while( it.hasNext() )
+        {
+            Service s = ( Service ) it.next();
+            if( s.getTransportType() == transportType )
+            {
+                result.add( s );
+            }
+        }
+        return result;
+    }
+
+    public Set getServices( int port )
+    {
+        Set result = new HashSet();
+        Iterator it = services.iterator();
+        while( it.hasNext() )
+        {
+            Service s = ( Service ) it.next();
+            if( s.getPort() == port )
+            {
+                result.add( s );
+            }
+        }
+        return result;
+    }
+
+    protected IoAcceptor findIoAcceptor( TransportType transportType )
+    {
+        if( transportType == TransportType.SOCKET )
+            return socketIoAcceptor;
+        else if( transportType == TransportType.DATAGRAM )
+            return datagramIoAcceptor;
+        else
+            throw new IllegalArgumentException(
+                    "Unsupported transport type: " + transportType );
+
+    }
+
+    protected ProtocolAcceptor findProtocolAcceptor(
+                                                    TransportType transportType )
+    {
+        if( transportType == TransportType.SOCKET )
+            return socketProtocolAcceptor;
+        else if( transportType == TransportType.DATAGRAM )
+            return datagramProtocolAcceptor;
+        else if( transportType == TransportType.VM_PIPE )
+            return vmPipeAcceptor;
+        else
+            throw new IllegalArgumentException(
+                    "Unsupported transport type: " + transportType );
+    }
+
+    private void startThreadPools()
+    {
+        if( !services.isEmpty() )
+            return;
+
+        ioThreadPoolFilter.start();
+        protocolThreadPoolFilter.start();
+    }
+
+    private void stopThreadPools()
+    {
+        if( !services.isEmpty() )
+            return;
+
+        ioThreadPoolFilter.stop();
+        protocolThreadPoolFilter.stop();
+    }
+}

Propchange: incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/package.html
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/package.html?view=diff&r1=151710&r2=151711
==============================================================================
--- incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/package.html
(original)
+++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/registry/package.html
Mon Feb  7 00:19:28 2005
@@ -3,6 +3,6 @@
 <head>
 </head>
 <body>
-This package is not yet implemented.
+A frontend package that makes setting up MINA easier.
 </body>
 </html>

Modified: incubator/directory/network/mina/trunk/xdocs/index.xml
URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/xdocs/index.xml?view=diff&r1=151710&r2=151711
==============================================================================
--- incubator/directory/network/mina/trunk/xdocs/index.xml (original)
+++ incubator/directory/network/mina/trunk/xdocs/index.xml Mon Feb  7 00:19:28 2005
@@ -61,6 +61,11 @@
                         <td>Both</td>
                     </tr>
                     <tr>
+                        <td><a target="classFrame" href="xref-examples/org/apache/mina/examples/registry/package-summary.html">Registry</a></td>
+                        <td>A frontend package that makes setting up MINA easier.</td>
+                        <td>Server (registry)</td>
+                    </tr>
+                    <tr>
                         <td><a target="classFrame" href="xref-examples/org/apache/mina/examples/sumup/package-summary.html">SumUp</a></td>
                         <td>Migration from <a target="_blank" href="http://gleamynode.net/dev/projects/netty2-example-sumup/">Netty
SumUp example</a>.</td>
                         <td>Both</td>



Mime
View raw message