Return-Path: Delivered-To: apmail-incubator-directory-cvs-archive@www.apache.org Received: (qmail 77165 invoked from network); 7 Feb 2005 08:19:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 7 Feb 2005 08:19:39 -0000 Received: (qmail 62462 invoked by uid 500); 7 Feb 2005 08:19:38 -0000 Delivered-To: apmail-incubator-directory-cvs-archive@incubator.apache.org Received: (qmail 62406 invoked by uid 500); 7 Feb 2005 08:19:38 -0000 Mailing-List: contact directory-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: directory-dev@incubator.apache.org Delivered-To: mailing list directory-cvs@incubator.apache.org Received: (qmail 62385 invoked by uid 99); 7 Feb 2005 08:19:37 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 07 Feb 2005 00:19:34 -0800 Received: (qmail 77098 invoked by uid 65534); 7 Feb 2005 08:19:33 -0000 Message-ID: <20050207081933.77093.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Mon, 07 Feb 2005 08:19:33 -0000 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/ To: directory-cvs@incubator.apache.org From: trustin@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: trustin Date: Mon Feb 7 00:19:28 2005 New Revision: 151711 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D151711 Log: Implemented registry package. Added: incubator/directory/network/mina/trunk/src/examples/org/apache/mina/exa= mples/registry/ incubator/directory/network/mina/trunk/src/examples/org/apache/mina/exa= mples/registry/Main.java (with props) incubator/directory/network/mina/trunk/src/examples/org/apache/mina/exa= mples/registry/package.html (with props) incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/SimpleServiceRegistry.java (with props) Removed: incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/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/data= gram/DatagramAcceptor.java incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/sock= et/SocketAcceptor.java incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/Service.java incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/ServiceRegistry.java incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/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/s= rc/examples/org/apache/mina/examples/registry/Main.java?view=3Dauto&rev=3D1= 51711 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/directory/network/mina/trunk/src/examples/org/apache/mina/exa= mples/registry/Main.java (added) +++ incubator/directory/network/mina/trunk/src/examples/org/apache/mina/exa= mples/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=20 + * org.apache.mina.registry package. + *=20 + * This application starts up echo and reverse protocol server.=20 + *=20 + * @author Trustin Lee (trustin@apache.org) + * @version $Rev$, $Date$,=20 + */ +public class Main +{ + public static void main( String[] args ) throws Exception + { + ServiceRegistry registry =3D 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() ); + =20 + System.out.println(registry.getAllServices()); + } +} Propchange: incubator/directory/network/mina/trunk/src/examples/org/apache/= mina/examples/registry/Main.java ---------------------------------------------------------------------------= --- svn:keywords =3D HeadURL Id LastChangedBy LastChangedDate LastChangedRe= vision 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/s= rc/examples/org/apache/mina/examples/registry/package.html?view=3Dauto&rev= =3D151711 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/directory/network/mina/trunk/src/examples/org/apache/mina/exa= mples/registry/package.html (added) +++ incubator/directory/network/mina/trunk/src/examples/org/apache/mina/exa= mples/registry/package.html Mon Feb 7 00:19:28 2005 @@ -0,0 +1,8 @@ + + + + + +Demonstrates the usage of org.apache.mina.registry package. + + Propchange: incubator/directory/network/mina/trunk/src/examples/org/apache/= mina/examples/registry/package.html ---------------------------------------------------------------------------= --- svn:keywords =3D HeadURL Id LastChangedBy LastChangedDate LastChangedRe= vision Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/c= ommon/TransportType.java URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/s= rc/java/org/apache/mina/common/TransportType.java?view=3Ddiff&r1=3D151710&r= 2=3D151711 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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; =20 +import java.io.InvalidObjectException; +import java.io.ObjectStreamException; +import java.io.Serializable; + /** * Represents network transport types. *=20 * @author Trustin Lee (trustin@apache.org) * @version $Rev$, $Date$ */ -public class TransportType +public class TransportType implements Serializable { + private static final long serialVersionUID =3D 3258132470497883447L; + /** * Transport type: TCP/IP (SocketChannel) */ public static final TransportType SOCKET =3D new TransportType( "SOCKE= T", - false ); + false ); =20 /** * Transport type: UDP/IP (DatagramChannel) */ public static final TransportType DATAGRAM =3D new TransportType( - "DATAG= RAM", - true )= ; + "DATAGRAM", true ); =20 /** * Transport type: VM pipe (direct message exchange) */ public static final TransportType VM_PIPE =3D new TransportType( "VM_P= IPE", - false )= ; + false ); =20 private final String strVal; =20 @@ -71,4 +76,17 @@ { return strVal; } -} \ No newline at end of file + =20 + 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/i= o/datagram/DatagramAcceptor.java URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/s= rc/java/org/apache/mina/io/datagram/DatagramAcceptor.java?view=3Ddiff&r1=3D= 151710&r2=3D151711 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/data= gram/DatagramAcceptor.java (original) +++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/data= gram/DatagramAcceptor.java Mon Feb 7 00:19:28 2005 @@ -136,8 +136,7 @@ ch =3D ( DatagramChannel ) channels.get( address ); =20 if( ch =3D=3D null ) - throw new IllegalArgumentException( "Unknown address: " - + address ); + return; =20 SelectionKey key =3D ch.keyFor( selector ); channels.remove( address ); Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/i= o/socket/SocketAcceptor.java URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/s= rc/java/org/apache/mina/io/socket/SocketAcceptor.java?view=3Ddiff&r1=3D1517= 10&r2=3D151711 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/sock= et/SocketAcceptor.java (original) +++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/io/sock= et/SocketAcceptor.java Mon Feb 7 00:19:28 2005 @@ -146,8 +146,7 @@ ssc =3D ( ServerSocketChannel ) channels.get( address ); =20 if( ssc =3D=3D null ) - throw new IllegalArgumentException( "Unknown address: " - + address ); + return; =20 SelectionKey key =3D ssc.keyFor( selector ); channels.remove( address ); Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/r= egistry/Service.java URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/s= rc/java/org/apache/mina/registry/Service.java?view=3Ddiff&r1=3D151710&r2=3D= 151711 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/Service.java (original) +++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/Service.java Mon Feb 7 00:19:28 2005 @@ -18,6 +18,8 @@ */ package org.apache.mina.registry; =20 +import java.io.Serializable; + import org.apache.mina.common.TransportType; =20 /** @@ -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 =3D 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 =3D=3D null ) + throw new NullPointerException( "name" ); + if( transportType =3D=3D null ) + throw new NullPointerException( "transportType" ); + if( port < 0 || port > 65535 ) + throw new IllegalArgumentException( "port: " + port ); + + this.name =3D name; + this.transportType =3D transportType; + this.port =3D 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 =3D=3D null ) + return false; + if( this =3D=3D o ) + return true; + if( !( o instanceof Service ) ) + return false; =20 - TransportType getTransportType(); + Service that =3D ( Service ) o; + return this.name.equals( that.name ) + && this.transportType =3D=3D that.transportType + && this.port =3D=3D that.port; + } =20 - int getPort(); -} \ No newline at end of file + public Object clone() + { + try + { + return super.clone(); + } + catch( CloneNotSupportedException e ) + { + throw new InternalError(); + } + } + =20 + public String toString() { + return "(" + transportType + ", " + name + ", " + port + ')'; + } +} Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/r= egistry/ServiceRegistry.java URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/s= rc/java/org/apache/mina/registry/ServiceRegistry.java?view=3Ddiff&r1=3D1517= 10&r2=3D151711 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/ServiceRegistry.java (original) +++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/ServiceRegistry.java Mon Feb 7 00:19:28 2005 @@ -19,13 +19,13 @@ package org.apache.mina.registry; =20 import java.io.IOException; -import java.util.Iterator; +import java.util.Set; =20 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; =20 /** * Interface for the internet service registry. The registry is used by MI= NA @@ -37,51 +37,94 @@ */ public interface ServiceRegistry { - void bind( Service service, IoHandler sessionHandler ) throws IOExcept= ion; + /** + * Binds the specified I/O handler to the specified service. + */ + void bind( Service service, IoHandler ioHandler ) throws IOException; =20 - void bind( Service service, ProtocolHandler sessionHandler ) + /** + * Binds the specified protocol provider to the specified service. + */ + void bind( Service service, ProtocolProvider protocolProvider ) throws IOException; =20 + /** + * Unbinds the specified service (and its aggregated I/O handler or + * protocol provider).=20 + */ void unbind( Service service ); =20 + /** + * Adds the specified filter to the acceptors of all transport types + * in this registry. + */ void addFilter( int priority, IoHandlerFilter filter ); - + =20 + /** + * Adds the specified filter to the acceptors of all transport types + * in this registry. + */ void addFilter( int priority, ProtocolHandlerFilter filter ); + =20 + /** + * Adds the specified filter to the acceptor of the specified transpor= t + * type with the specified priority. + */ + void addFilter( TransportType transportType, int priority, + IoHandlerFilter filter ); =20 - void addFilter( Service service, int priority, IoHandlerFilter filter = ); - - void addFilter( Service service, int priority, ProtocolHandlerFilter f= ilter ); + /** + * Adds the specified filter to the acceptor of the specified transpor= t + * type with the specified priority. + */ + void addFilter( TransportType transportType, int priority, + ProtocolHandlerFilter filter ); =20 + /** + * Removes the specified filter from the acceptors of all transport ty= pes + * in this registry. + */ void removeFilter( IoHandlerFilter filter ); =20 + /** + * Removes the specified filter from the acceptors of all transport ty= pes + * in this registry. + */ void removeFilter( ProtocolHandlerFilter filter ); =20 - 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= ); =20 - Iterator getByTransportType( TransportType transportType ); + /** + * Removes the specified filter from the acceptor of the specified + * transport type. + */ + void removeFilter( TransportType transportType, + ProtocolHandlerFilter filter ); =20 /** - * Gets an iteration over all the entries for a service by the name of= the - * service. - *=20 - * @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(); + =20 + /** + * Returns {@link Set} of services bound in this registry with the + * specified service(or protocol) name. + */ + Set getServices(String name); =20 /** - * Gets an iteration over all the entries for a service by port number= . - * This method returns an Iterator over the set of InetServiceEntry ob= jects - * since more than one transport protocol can be used on the same port= . - *=20 - * @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); + =20 + /** + * 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/regi= stry/SimpleServiceRegistry.java URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/s= rc/java/org/apache/mina/registry/SimpleServiceRegistry.java?view=3Dauto&rev= =3D151711 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/SimpleServiceRegistry.java (added) +++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/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}. + *=20 + * This service registry supports socket, datagram, VM-pipe transport type= s, + * and thread pools were added by default.=20 + *=20 + * @author Trustin Lee (trustin@apache.org) + * @version $Rev$, $Date$,=20 + */ +public class SimpleServiceRegistry implements ServiceRegistry +{ + protected final IoAcceptor socketIoAcceptor =3D new SocketAcceptor(); + + protected final IoAcceptor datagramIoAcceptor =3D new DatagramAcceptor= (); + + protected final ProtocolAcceptor socketProtocolAcceptor =3D new IoProt= ocolAcceptor( + socketIoAcceptor ); + + protected final ProtocolAcceptor datagramProtocolAcceptor =3D new IoPr= otocolAcceptor( + datagramIoAcceptor ); + + protected final ProtocolAcceptor vmPipeAcceptor =3D new VmPipeAcceptor= (); + + protected final IoThreadPoolFilter ioThreadPoolFilter =3D new IoThread= PoolFilter(); + + protected final ProtocolThreadPoolFilter protocolThreadPoolFilter =3D = new ProtocolThreadPoolFilter(); + + private final Set services =3D new HashSet(); + + public SimpleServiceRegistry() throws IOException + { + socketIoAcceptor.addFilter( IoHandlerFilter.MAX_PRIORITY, + ioThreadPoolFilter ); + datagramIoAcceptor.addFilter( IoHandlerFilter.MAX_PRIORITY, + ioThreadPoolFilter ); + socketProtocolAcceptor.addFilter( ProtocolHandlerFilter.MAX_PRIORI= TY, + protocolThreadPoolFilter ); + datagramProtocolAcceptor.addFilter( + ProtocolHandlerFilter.MAX_PRIORITY, protocolThreadPoolFilt= er ); + vmPipeAcceptor.addFilter( ProtocolHandlerFilter.MAX_PRIORITY, + protocolThreadPoolFilter ); + } + + public synchronized void bind( Service service, IoHandler ioHandler ) + throws IOException + { + IoAcceptor acceptor =3D findIoAcceptor( service.getTransportType()= ); + acceptor.bind( new InetSocketAddress( service.getPort() ), ioHandl= er ); + startThreadPools(); + services.add( service ); + } + + public synchronized void bind( Service service, + ProtocolProvider protocolProvider ) + throws IOException + { + ProtocolAcceptor acceptor =3D 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 =3D 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 filt= er ) + { + boolean s =3D false; + boolean d =3D false; + try + { + socketIoAcceptor.addFilter( priority, filter ); + s =3D true; + datagramIoAcceptor.addFilter( priority, filter ); + d =3D 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 =3D false; + boolean d =3D false; + boolean v =3D false; + try + { + socketProtocolAcceptor.addFilter( priority, filter ); + s =3D true; + datagramProtocolAcceptor.addFilter( priority, filter ); + d =3D true; + vmPipeAcceptor.addFilter( priority, filter ); + v =3D 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 filte= r ) + { + IoAcceptor acceptor =3D findIoAcceptor( transportType ); + acceptor.addFilter( priority, filter ); + } + + public synchronized void addFilter( TransportType transportType, + int priority, + ProtocolHandlerFilter filter ) + { + ProtocolAcceptor acceptor =3D 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 =3D findIoAcceptor( transportType ); + acceptor.removeFilter( filter ); + } + + public synchronized void removeFilter( TransportType transportType, + ProtocolHandlerFilter filter ) + { + ProtocolAcceptor acceptor =3D findProtocolAcceptor( transportType = ); + acceptor.removeFilter( filter ); + } + + public synchronized Set getAllServices() + { + return new HashSet( services ); + } + + public synchronized Set getServices( String name ) + { + Set result =3D new HashSet(); + Iterator it =3D services.iterator(); + while( it.hasNext() ) + { + Service s =3D ( Service ) it.next(); + if( name.equals( s.getName() ) ) + { + result.add( s ); + } + } + return result; + } + + public Set getServices( TransportType transportType ) + { + Set result =3D new HashSet(); + Iterator it =3D services.iterator(); + while( it.hasNext() ) + { + Service s =3D ( Service ) it.next(); + if( s.getTransportType() =3D=3D transportType ) + { + result.add( s ); + } + } + return result; + } + + public Set getServices( int port ) + { + Set result =3D new HashSet(); + Iterator it =3D services.iterator(); + while( it.hasNext() ) + { + Service s =3D ( Service ) it.next(); + if( s.getPort() =3D=3D port ) + { + result.add( s ); + } + } + return result; + } + + protected IoAcceptor findIoAcceptor( TransportType transportType ) + { + if( transportType =3D=3D TransportType.SOCKET ) + return socketIoAcceptor; + else if( transportType =3D=3D TransportType.DATAGRAM ) + return datagramIoAcceptor; + else + throw new IllegalArgumentException( + "Unsupported transport type: " + transportType ); + + } + + protected ProtocolAcceptor findProtocolAcceptor( + TransportType transpor= tType ) + { + if( transportType =3D=3D TransportType.SOCKET ) + return socketProtocolAcceptor; + else if( transportType =3D=3D TransportType.DATAGRAM ) + return datagramProtocolAcceptor; + else if( transportType =3D=3D 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 =3D HeadURL Id LastChangedBy LastChangedDate LastChangedRe= vision Modified: incubator/directory/network/mina/trunk/src/java/org/apache/mina/r= egistry/package.html URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/s= rc/java/org/apache/mina/registry/package.html?view=3Ddiff&r1=3D151710&r2=3D= 151711 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/package.html (original) +++ incubator/directory/network/mina/trunk/src/java/org/apache/mina/registr= y/package.html Mon Feb 7 00:19:28 2005 @@ -3,6 +3,6 @@ -This package is not yet implemented. +A frontend package that makes setting up MINA easier. Modified: incubator/directory/network/mina/trunk/xdocs/index.xml URL: http://svn.apache.org/viewcvs/incubator/directory/network/mina/trunk/x= docs/index.xml?view=3Ddiff&r1=3D151710&r2=3D151711 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- 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 @@ Both + Registry + A frontend package that makes setting up MINA = easier. + Server (registry) + + SumUp Migration from Netty SumUp example= . Both