Return-Path: Delivered-To: apmail-incubator-directory-cvs-archive@www.apache.org Received: (qmail 1835 invoked from network); 3 Mar 2005 15:19:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 3 Mar 2005 15:19:25 -0000 Received: (qmail 48524 invoked by uid 500); 3 Mar 2005 15:19:24 -0000 Delivered-To: apmail-incubator-directory-cvs-archive@incubator.apache.org Received: (qmail 48489 invoked by uid 500); 3 Mar 2005 15:19:24 -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 48476 invoked by uid 99); 3 Mar 2005 15:19:24 -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; Thu, 03 Mar 2005 07:19:24 -0800 Received: (qmail 1799 invoked by uid 65534); 3 Mar 2005 15:19:23 -0000 Message-ID: <20050303151923.1798.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: Thu, 03 Mar 2005 15:19:23 -0000 Subject: svn commit: r156048 - incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java 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: Thu Mar 3 07:19:22 2005 New Revision: 156048 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D156048 Log: Fixed DIREVE-143: Use EnvKeys.PASSTHRU property properly Modified: incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/s= erver/jndi/ServerContextFactory.java Modified: incubator/directory/apacheds/trunk/core/src/main/java/org/apache/= ldap/server/jndi/ServerContextFactory.java URL: http://svn.apache.org/viewcvs/incubator/directory/apacheds/trunk/core/= src/main/java/org/apache/ldap/server/jndi/ServerContextFactory.java?view=3D= diff&r1=3D156047&r2=3D156048 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/apacheds/trunk/core/src/main/java/org/apache/ldap/s= erver/jndi/ServerContextFactory.java (original) +++ incubator/directory/apacheds/trunk/core/src/main/java/org/apache/ldap/s= erver/jndi/ServerContextFactory.java Thu Mar 3 07:19:22 2005 @@ -20,11 +20,10 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.net.InetSocketAddress; +import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; -import java.lang.reflect.Constructor; =20 import javax.naming.Context; import javax.naming.Name; @@ -47,7 +46,11 @@ import org.apache.ldap.common.util.DateUtils; import org.apache.ldap.common.util.PropertiesUtils; import org.apache.ldap.common.util.StringTools; -import org.apache.ldap.server.*; +import org.apache.ldap.server.ApplicationPartition; +import org.apache.ldap.server.ContextPartition; +import org.apache.ldap.server.ContextPartitionConfig; +import org.apache.ldap.server.RootNexus; +import org.apache.ldap.server.SystemPartition; import org.apache.ldap.server.db.Database; import org.apache.ldap.server.db.DefaultSearchEngine; import org.apache.ldap.server.db.ExpressionEnumerator; @@ -68,9 +71,10 @@ import org.apache.ldap.server.schema.OidRegistry; import org.apache.ldap.server.schema.bootstrap.BootstrapRegistries; import org.apache.ldap.server.schema.bootstrap.BootstrapSchemaLoader; -import org.apache.mina.io.socket.SocketAcceptor; -import org.apache.mina.protocol.ProtocolAcceptor; -import org.apache.mina.protocol.io.IoProtocolAcceptor; +import org.apache.mina.common.TransportType; +import org.apache.mina.registry.Service; +import org.apache.mina.registry.ServiceRegistry; +import org.apache.mina.registry.SimpleServiceRegistry; =20 =20 /** @@ -138,9 +142,9 @@ =20 private RootNexus nexus; =20 - private InetSocketAddress serverAddress; + private Service minaService; =20 - private ProtocolAcceptor acceptor; + private ServiceRegistry minaRegistry; =20 =20 /** @@ -183,9 +187,9 @@ { this.provider.shutdown(); =20 - if ( this.acceptor !=3D null ) + if ( this.minaRegistry !=3D null ) { - this.acceptor.unbind( serverAddress ); + this.minaRegistry.unbind( minaService ); } } catch ( Throwable t ) @@ -353,7 +357,6 @@ * Returns true if we had to create the admin account since this is th= e first time we started the server. Otherwise * if the account exists then we are not starting for the first time. * - * @return * @throws NamingException */ private boolean createAdminAccount() throws NamingException @@ -561,28 +564,40 @@ =20 private void startUpWireProtocol() throws NamingException { - // TODO MINA registry package is not implemented yet, - // so we don't use PASSTHRU property yet. - // if ( initialEnv.containsKey( EnvKeys.PASSTHRU ) ) - // { - // fe =3D ( DefaultFrontend ) initialEnv.get( EnvKeys.PASSTHRU= ); - //=20 - // if ( fe !=3D null ) - // { - // initialEnv.put( EnvKeys.PASSTHRU, "Handoff Succeeded!" = ); - // } - // } + ServiceRegistry registry =3D null; + if ( initialEnv.containsKey( EnvKeys.PASSTHRU ) ) + { + registry =3D ( ServiceRegistry ) initialEnv.get( EnvKeys.PASST= HRU ); =20 - serverAddress =3D new InetSocketAddress( PropertiesUtils.get( init= ialEnv, EnvKeys.LDAP_PORT, LDAP_PORT ) ); + if ( registry !=3D null ) + { + initialEnv.put( EnvKeys.PASSTHRU, "Handoff Succeeded!" ); + } + } + =20 + =20 + Service service =3D new Service( "ldap", TransportType.SOCKET, + PropertiesUtils.get( initialEnv, EnvKeys.LDAP_PORT, + LDAP_PORT ) ); try { - acceptor =3D new IoProtocolAcceptor( new SocketAcceptor() ); - acceptor.bind( serverAddress, new LdapProtocolProvider( ( Hash= table ) initialEnv.clone() ) ); + if( registry =3D=3D null ) + { + registry =3D new SimpleServiceRegistry(); + } + + registry.bind( service, + new LdapProtocolProvider( + ( Hashtable ) initialEnv.clone() ) ); + =20 + minaService =3D service; + minaRegistry =3D registry; } catch ( IOException e ) { e.printStackTrace(); - String msg =3D "Could not recognize the host!"; + String msg =3D "Failed to bind the service to the service regi= stry: " + + service; LdapConfigurationException e2 =3D new LdapConfigurationExcepti= on( msg ); e2.setRootCause( e ); }