You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/12/30 02:22:36 UTC

svn commit: r730026 [1/2] - in /directory/apacheds/trunk: protocol-changepw/src/main/java/org/apache/directory/server/changepw/ protocol-dns/src/main/java/org/apache/directory/server/dns/ protocol-kerberos/src/main/java/org/apache/directory/server/kerb...

Author: elecharny
Date: Mon Dec 29 17:22:35 2008
New Revision: 730026

URL: http://svn.apache.org/viewvc?rev=730026&view=rev
Log:
Refactored the way the transport are described into the configuration
o Created Transport, AbstractTrabsport, TcpTransport and UdpTransport for that purpose
o Changed the code in the servers and services to accept this new elements
o Changed the server.xml files to reflect those changes

Added:
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/Transport.java
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/UdpTransport.java
Modified:
    directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
    directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/DnsServer.java
    directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java
    directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java
    directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
    directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpITest.java
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java
    directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java
    directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java
    directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/PasswordPolicyServiceIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/StoredProcedureIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/IndexedNegationSearchIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/search/ReferralSearchIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/LdapsIT.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/ssl/StartTlsIT.java
    directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/CapacityTestCommand.java
    directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/DiagnosticCommand.java
    directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/DisconnectNotificationCommand.java
    directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/GracefulShutdownCommand.java
    directory/apacheds/trunk/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
    directory/apacheds/trunk/server-unit/src/main/java/org/apache/directory/server/unit/AbstractServerTest.java
    directory/apacheds/trunk/server-xml/src/main/resources/server.xml
    directory/apacheds/trunk/server-xml/src/main/resources/serverAuthenticatorInAuthenticationInterceptor.xml
    directory/apacheds/trunk/server-xml/src/main/resources/serverJdbmPartition.xml
    directory/apacheds/trunk/server-xml/src/main/resources/serverReplicationInterceptor.xml

Modified: directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java (original)
+++ directory/apacheds/trunk/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java Mon Dec 29 17:22:35 2008
@@ -33,6 +33,8 @@
 import org.apache.directory.server.kerberos.shared.store.DirectoryPrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.protocol.shared.DirectoryBackedService;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.server.protocol.shared.transport.UdpTransport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,7 +61,7 @@
     private static final String REALM_DEFAULT = "EXAMPLE.COM";
 
     /** The default change password port. */
-    private static final int IP_PORT_DEFAULT = 464;
+    private static final int DEFAULT_IP_PORT = 464;
 
     /** The default encryption types. */
     public static final String[] ENCRYPTION_TYPES_DEFAULT = new String[]
@@ -117,9 +119,10 @@
     public ChangePasswordServer()
     {
         super.setServiceName( SERVICE_NAME_DEFAULT );
-        super.setIpPort( IP_PORT_DEFAULT );
         super.setServiceId( SERVICE_PID_DEFAULT );
         super.setSearchBaseDn( ServerDNConstants.USER_EXAMPLE_COM_DN );
+        setTcpTransport( new TcpTransport( DEFAULT_IP_PORT ) );
+        setUdpTransport( new UdpTransport( DEFAULT_IP_PORT ) );
 
         prepareEncryptionTypes();
     }
@@ -268,7 +271,8 @@
         if ( getDatagramAcceptor() != null )
         {
             getDatagramAcceptor().setHandler( new ChangePasswordProtocolHandler( this, store ) );
-            getDatagramAcceptor().bind( new InetSocketAddress( getIpPort() ) );
+            getDatagramAcceptor().bind( 
+                new InetSocketAddress( getUdpTransport().getAddress(), getUdpTransport().getPort() ) );
         }
 
         if ( getSocketAcceptor() != null )
@@ -276,7 +280,8 @@
             getSocketAcceptor().setCloseOnDeactivation( false );
             getSocketAcceptor().setReuseAddress( true );
             getSocketAcceptor().setHandler( new ChangePasswordProtocolHandler( this, store ) );
-            getSocketAcceptor().bind( new InetSocketAddress( getIpPort() ) );
+            getSocketAcceptor().bind( 
+                new InetSocketAddress( getTcpTransport().getAddress(), getTcpTransport().getPort() ) );
         }
         
         LOG.info( "ChangePassword service started." );
@@ -288,11 +293,13 @@
     {
         if ( getDatagramAcceptor() != null )
         {
-            getDatagramAcceptor().unbind( new InetSocketAddress( getIpPort() ));
+            getDatagramAcceptor().unbind( 
+                new InetSocketAddress( getUdpTransport().getAddress(), getUdpTransport().getPort() ) );
         }
         if ( getSocketAcceptor() != null )
         {
-            getSocketAcceptor().unbind( new InetSocketAddress( getIpPort() ));
+            getSocketAcceptor().unbind( 
+                new InetSocketAddress( getTcpTransport().getAddress(), getTcpTransport().getPort() ) );
         }
 
         LOG.info( "ChangePassword service stopped." );

Modified: directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/DnsServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/DnsServer.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/DnsServer.java (original)
+++ directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/DnsServer.java Mon Dec 29 17:22:35 2008
@@ -27,6 +27,8 @@
 import org.apache.directory.server.dns.store.RecordStore;
 import org.apache.directory.server.dns.store.jndi.JndiRecordStoreImpl;
 import org.apache.directory.server.protocol.shared.DirectoryBackedService;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.server.protocol.shared.transport.UdpTransport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -47,7 +49,7 @@
     private static final Logger LOG = LoggerFactory.getLogger( DnsServer.class.getName() );
     
     /** The default IP port. */
-    private static final int IP_PORT_DEFAULT = 53;
+    private static final int DEFAULT_IP_PORT = 53;
 
     /** The default service pid. */
     private static final String SERVICE_PID_DEFAULT = "org.apache.directory.server.dns";
@@ -61,9 +63,10 @@
      */
     public DnsServer()
     {
-        super.setIpPort( IP_PORT_DEFAULT );
         super.setServiceId( SERVICE_PID_DEFAULT );
         super.setServiceName( SERVICE_NAME_DEFAULT );
+        setTcpTransport( new TcpTransport( DEFAULT_IP_PORT ) );
+        setUdpTransport( new UdpTransport( DEFAULT_IP_PORT ) );
     }
 
 
@@ -77,7 +80,8 @@
         if ( getDatagramAcceptor() != null )
         {
             getDatagramAcceptor().setHandler( new DnsProtocolHandler( this, store ) );
-            getDatagramAcceptor().bind( new InetSocketAddress( getIpPort() ) );
+            getDatagramAcceptor().bind( 
+                new InetSocketAddress( getUdpTransport().getAddress(), getUdpTransport().getPort() ) );
         }
 
         if ( getSocketAcceptor() != null )
@@ -85,7 +89,8 @@
             getSocketAcceptor().setCloseOnDeactivation( false );
             getSocketAcceptor().setReuseAddress( true );
             getSocketAcceptor().setHandler( new DnsProtocolHandler( this, store ) );
-            getSocketAcceptor().bind( new InetSocketAddress( getIpPort() ) );
+            getSocketAcceptor().bind(
+                new InetSocketAddress( getTcpTransport().getAddress(), getTcpTransport().getPort() ) );
         }
         
         LOG.info( "DSN service started." );
@@ -96,11 +101,13 @@
     public void stop() {
         if ( getDatagramAcceptor() != null )
         {
-            getDatagramAcceptor().unbind( new InetSocketAddress( getIpPort() ));
+            getDatagramAcceptor().unbind( 
+                new InetSocketAddress( getUdpTransport().getAddress(), getUdpTransport().getPort() ) );
         }
         if ( getSocketAcceptor() != null )
         {
-            getSocketAcceptor().unbind( new InetSocketAddress( getIpPort() ));
+            getSocketAcceptor().unbind( 
+                new InetSocketAddress( getTcpTransport().getAddress(), getUdpTransport().getPort() ) );
         }
         
         LOG.info( "DSN service stopped." );

Modified: directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java (original)
+++ directory/apacheds/trunk/protocol-dns/src/main/java/org/apache/directory/server/dns/Main.java Mon Dec 29 17:22:35 2008
@@ -21,11 +21,14 @@
 
 
 import java.io.IOException;
+import java.net.InetSocketAddress;
 
 import javax.naming.NamingException;
 
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.server.protocol.shared.transport.UdpTransport;
 import org.apache.mina.transport.socket.nio.NioDatagramAcceptor;
 import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.slf4j.Logger;
@@ -70,7 +73,8 @@
         dnsConfiguration.setSocketAcceptor( socketAcceptor );
         dnsConfiguration.setDirectoryService( directoryService );
         dnsConfiguration.setEnabled( true );
-        dnsConfiguration.setIpPort( 10053 );
+        dnsConfiguration.setTcpTransport( new TcpTransport( 10053 ) );
+        dnsConfiguration.setUdpTransport( new UdpTransport( 10053 ) );
         dnsConfiguration.start();
     }
 

Modified: directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java (original)
+++ directory/apacheds/trunk/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KdcServer.java Mon Dec 29 17:22:35 2008
@@ -35,6 +35,9 @@
 import org.apache.directory.server.kerberos.shared.store.DirectoryPrincipalStore;
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.directory.server.protocol.shared.DirectoryBackedService;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.server.protocol.shared.transport.Transport;
+import org.apache.directory.server.protocol.shared.transport.UdpTransport;
 import org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder;
 import org.apache.mina.core.filterchain.IoFilterChainBuilder;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
@@ -157,9 +160,11 @@
     public KdcServer()
     {
         super.setServiceName( DEFAULT_NAME );
-        super.setIpPort( DEFAULT_IP_PORT );
         super.setServiceId( DEFAULT_PID );
         super.setSearchBaseDn( ServerDNConstants.USER_EXAMPLE_COM_DN );
+        setTcpTransport( new TcpTransport( DEFAULT_IP_PORT ) );
+        setUdpTransport( new UdpTransport( DEFAULT_IP_PORT ) );
+        
 
         prepareEncryptionTypes();
     }
@@ -440,11 +445,13 @@
         // TODO - for now ignoring this catelog crap
         store = new DirectoryPrincipalStore( getDirectoryService() );
         
+        Transport udpTransport = getTcpTransport();
+
         // Kerberos can use UDP or TCP
-        if ( getUdpPort() != -1 )
+        if ( udpTransport != null )
         {
             // Actually, this is not used for Datagram. But it should !
-            int nbUdpThreads = getNbUdpThreads();
+            //int nbUdpThreads = getNbUdpThreads();
             
             // Create the acceptor
             DatagramAcceptor udpAcceptor = new NioDatagramAcceptor();
@@ -466,13 +473,15 @@
             udpAcceptor.setHandler( new KerberosProtocolHandler( this, store ) );
             
             // Bind to the configured address
-            udpAcceptor.bind( new InetSocketAddress( getUdpPort() ) );
+            udpAcceptor.bind( new InetSocketAddress( udpTransport.getPort() ) );
         }
 
-        if ( getTcpPort() != -1 )
+        Transport tcpTransport = getTcpTransport();
+
+        if ( tcpTransport != null )
         {
             // First, create the acceptor with the configured number of threads (if defined)
-            int nbTcpThreads = getNbTcpThreads();
+            int nbTcpThreads = tcpTransport.getNbThreads();
             SocketAcceptor tcpAcceptor;
             
             if ( nbTcpThreads > 0 )
@@ -509,7 +518,7 @@
             tcpAcceptor.setHandler( new KerberosProtocolHandler( this, store ) );
             
             // Bind to the configured address
-            tcpAcceptor.bind( new InetSocketAddress( getTcpPort() ) );
+            tcpAcceptor.bind( new InetSocketAddress( tcpTransport.getPort() ) );
         }
         
         LOG.info( "Kerberos service started." );
@@ -521,11 +530,11 @@
     {
         if ( getDatagramAcceptor() != null )
         {
-            getDatagramAcceptor().unbind( new InetSocketAddress( getIpPort() ));
+            getDatagramAcceptor().unbind( new InetSocketAddress( getUdpTransport().getPort() ));
         }
         if ( getSocketAcceptor() != null )
         {
-            getSocketAcceptor().unbind( new InetSocketAddress( getIpPort() ));
+            getSocketAcceptor().unbind( new InetSocketAddress( getTcpTransport().getPort() ));
         }
         
         LOG.info( "Kerberos service stopped." );

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapService.java Mon Dec 29 17:22:35 2008
@@ -215,7 +215,6 @@
      */
     public LdapService()
     {
-        super.setTcpPort( IP_PORT_DEFAULT );
         super.setEnabled( true );
         super.setServiceId( SERVICE_PID_DEFAULT );
         super.setServiceName( SERVICE_NAME_DEFAULT );
@@ -355,7 +354,7 @@
         // We use the same number of thread than the number of IoProcessor
         // (NOTE : this has to be double checked)
         ((DefaultIoFilterChainBuilder)chain).addLast( "executor", 
-                new ExecutorFilter( new OrderedThreadPoolExecutor( getNbTcpThreads() ), 
+                new ExecutorFilter( new OrderedThreadPoolExecutor( getTcpTransport().getNbThreads() ), 
                     IoEventType.WRITE ) );
 
         /*
@@ -365,7 +364,10 @@
          */ 
         installDefaultHandlers();      
 
-        startNetwork( getIpAddress(), getTcpPort(), getTcpBacklog(), chain );
+        startNetwork( 
+            getTcpTransport().getAddress(), 
+            getTcpTransport().getPort(), 
+            getTcpTransport().getBackLog(), chain );
         
         started = true;
         
@@ -403,15 +405,15 @@
             }
             catch ( IllegalArgumentException e )
             {
-                LOG.warn( "Seems like the LDAP service (" + getIpPort() + ") has already been unbound." );
+                LOG.warn( "Seems like the LDAP service (" + getPort() + ") has already been unbound." );
                 return;
             }
 
-            getSocketAcceptor().unbind( new InetSocketAddress( getIpPort() ) );
+            getSocketAcceptor().unbind( new InetSocketAddress( getPort() ) );
 
             if ( LOG.isInfoEnabled() )
             {
-                LOG.info( "Unbind of an LDAP service (" + getIpPort() + ") is complete." );
+                LOG.info( "Unbind of an LDAP service (" + getPort() + ") is complete." );
                 LOG.info( "Sending notice of disconnect to existing clients sessions." );
             }
 
@@ -474,7 +476,7 @@
         try
         {
             // First, create the acceptor with the configured number of threads (if defined)
-            int nbTcpThreads = getNbTcpThreads();
+            int nbTcpThreads = getTcpTransport().getNbThreads();
             SocketAcceptor acceptor;
             
             if ( nbTcpThreads > 0 )
@@ -1132,6 +1134,16 @@
     {
         return unbindHandler;
     }
+    
+    
+    /**
+     * @return The underlying TCP transport port, or -1 if no transport has been 
+     * initialized
+     */
+    public int getPort()
+    {
+        return getTcpTransport() == null ? -1 : getTcpTransport().getPort();
+    }
 
 
     /**

Modified: directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java (original)
+++ directory/apacheds/trunk/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java Mon Dec 29 17:22:35 2008
@@ -23,6 +23,9 @@
 import org.apache.directory.server.ntp.protocol.NtpProtocolCodecFactory;
 import org.apache.directory.server.ntp.protocol.NtpProtocolHandler;
 import org.apache.directory.server.protocol.shared.AbstractProtocolService;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.server.protocol.shared.transport.Transport;
+import org.apache.directory.server.protocol.shared.transport.UdpTransport;
 import org.apache.mina.core.filterchain.DefaultIoFilterChainBuilder;
 import org.apache.mina.core.service.IoHandler;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
@@ -66,7 +69,6 @@
      */
     public NtpServer()
     {
-        super.setIpPort( IP_PORT_DEFAULT );
         super.setServiceId( SERVICE_PID_DEFAULT );
         super.setServiceName( SERVICE_NAME_DEFAULT );
     }
@@ -87,10 +89,12 @@
         DefaultIoFilterChainBuilder ntpChain = new DefaultIoFilterChainBuilder();
         ntpChain.addLast( "codec", new ProtocolCodecFilter( NtpProtocolCodecFactory.getInstance() ) );
         
-        if ( getUdpPort() > 0 )
+        Transport udpTransport = getTcpTransport();
+        
+        if ( udpTransport != null )
         {
             // We have to create a DatagramAcceptor
-            DatagramAcceptor acceptor = new  NioDatagramAcceptor();
+            DatagramAcceptor acceptor = new NioDatagramAcceptor();
             setDatagramAcceptor( (NioDatagramAcceptor)acceptor );
         
             // Set the handler
@@ -101,12 +105,14 @@
     
             // Inject the chain
             acceptor.setFilterChainBuilder( ntpChain );
-                
+            
             // Start the listener
-            acceptor.bind( new InetSocketAddress( getUdpPort() ) );
+            acceptor.bind( new InetSocketAddress( udpTransport.getAddress(), udpTransport.getPort() ) );
         }
+
+        Transport tcpTransport = getTcpTransport();
         
-        if ( getTcpPort() > 0 )
+        if ( tcpTransport != null )
         {
             // It's a SocketAcceptor
             SocketAcceptor acceptor = new NioSocketAcceptor();
@@ -127,9 +133,12 @@
             acceptor.setFilterChainBuilder( ntpChain );
 
             setSocketAcceptor( acceptor );
-            
+
+            // Set the backlog size
+            acceptor.setBacklog( tcpTransport.getBackLog() );
+
             // Start the listener
-            acceptor.bind( new InetSocketAddress( getTcpPort() ) );
+            acceptor.bind( new InetSocketAddress( tcpTransport.getAddress(), tcpTransport.getPort() ) );
         }
     }
 
@@ -138,12 +147,14 @@
     {
         if ( getDatagramAcceptor() != null )
         {
-            getDatagramAcceptor().unbind( new InetSocketAddress( getIpPort() ));
+            getDatagramAcceptor().unbind( new InetSocketAddress( 
+                getUdpTransport().getAddress(), getUdpTransport().getPort() ) );
         }
         
         if ( getSocketAcceptor() != null )
         {
-            getSocketAcceptor().unbind( new InetSocketAddress( getIpPort() ));
+            getSocketAcceptor().unbind( new InetSocketAddress( 
+                getTcpTransport().getAddress(), getTcpTransport().getPort() ) );
         }
     }
     
@@ -157,14 +168,14 @@
         
         sb.append( "NTPServer[" ).append( getServiceName() ).append( "] :" ).append( '\n' );
         
-        if ( getUdpPort() > 0 )
+        if ( getUdpTransport() != null )
         {
-            sb.append( "  Listening on UDP:" ).append( getUdpPort() ).append( '\n' );
+            sb.append( "  Listening on UDP:" ).append( getUdpTransport().getPort() ).append( '\n' );
         }
 
-        if ( getTcpPort() > 0 )
+        if ( getTcpTransport() != null )
         {
-            sb.append( "  Listening on TCP:" ).append( getTcpPort() ).append( '\n' );
+            sb.append( "  Listening on TCP:" ).append( getTcpTransport().getPort() ).append( '\n' );
         }
         
         return sb.toString();

Modified: directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpITest.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpITest.java (original)
+++ directory/apacheds/trunk/protocol-ntp/src/test/java/org/apache/directory/server/ntp/NtpITest.java Mon Dec 29 17:22:35 2008
@@ -21,12 +21,15 @@
 
 
 import java.net.InetAddress;
+import java.net.InetSocketAddress;
 import java.util.concurrent.Executors;
 
 import junit.framework.Assert;
 import junit.framework.TestCase;
 import org.apache.commons.net.ntp.NTPUDPClient;
 import org.apache.commons.net.ntp.TimeInfo;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.server.protocol.shared.transport.UdpTransport;
 import org.apache.directory.server.unit.AbstractServerTest;
 import org.apache.mina.filter.executor.ExecutorFilter;
 import org.apache.mina.transport.socket.nio.NioDatagramAcceptor;
@@ -52,12 +55,12 @@
     {
         NioDatagramAcceptor datagramAcceptor = new NioDatagramAcceptor( null );
         datagramAcceptor.getFilterChain().addLast( "executor", new ExecutorFilter( Executors.newCachedThreadPool() ) );
-        //datagramAcceptor.getFilterChain().addlast( "decoder", )
         ntpConfig = new NtpServer();
+        port = AvailablePortFinder.getNextAvailable( 10123 );
+        ntpConfig.setTcpTransport( new TcpTransport( port ) );
+        ntpConfig.setUdpTransport( new UdpTransport( port ) );
         ntpConfig.setDatagramAcceptor( datagramAcceptor );
         ntpConfig.setEnabled( true );
-        port = AvailablePortFinder.getNextAvailable( 10123 );
-        ntpConfig.setIpPort( port );
         ntpConfig.start();
 
     }

Modified: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java (original)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/AbstractProtocolService.java Mon Dec 29 17:22:35 2008
@@ -20,6 +20,8 @@
 
 
 import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
+import org.apache.directory.server.protocol.shared.transport.UdpTransport;
 import org.apache.mina.transport.socket.DatagramAcceptor;
 import org.apache.mina.transport.socket.SocketAcceptor;
 
@@ -49,49 +51,53 @@
     /** The service name */
     private String serviceName;
     
+    protected TcpTransport tcpTransport;
+    
+    protected UdpTransport udpTransport;
+    
     /** The server IP address */
-    private String ipAddress;
+    //private String ipAddress;
     
     /** The service's port, if there is only one (TCP or UDP) */
-    private int ipPort = -1;
+    //private int ipPort = -1;
     
     /** The TCP port, if defined. */
-    private int tcpPort = -1;
+    //private int tcpPort = -1;
     
     /** The UDP port, if defined. */
-    private int udpPort = -1;
+    //private int udpPort = -1;
     
     private Set<TransportProtocol> transportProtocols;
     
     /** The IoAcceptor used to accept UDP requests */
-    private DatagramAcceptor datagramAcceptor;
+    //private DatagramAcceptor datagramAcceptor;
     
     /** The IoAcceptor used to accept TCP requests */
-    private SocketAcceptor socketAcceptor;
+    //private SocketAcceptor socketAcceptor;
     
     /** The number of threads to use for the IoAcceptor executor */
-    private int nbThreads;
+    //private int nbThreads;
     
     /** 
      * The number of threads to use for the TCP transport
      * protocol based IoAcceptor executor 
      **/
-    private int nbTcpThreads;
+    //private int nbTcpThreads;
     
     /** 
      * The number of threads to use for the UDP transport
      * protocol based IoAcceptor executor 
      **/
-    private int nbUdpThreads;
+    //private int nbUdpThreads;
     
     /** The backlog for all the transport services */
-    private int ipBacklog;
+    //private int ipBacklog;
     
     /** The backlog for the TCP transport services */
-    private int tcpBacklog;
+    //private int tcpBacklog;
     
     /** The backlog for the UDP transport services */
-    private int udpBacklog;
+    //private int udpBacklog;
     
     /** directory service core where protocol data is backed */
     private DirectoryService directoryService;
@@ -177,6 +183,7 @@
     }
 
 
+    /*
     public String getIpAddress()
     {
         return ipAddress;
@@ -191,7 +198,7 @@
 
     /**
      * {@inheritDoc}
-     */
+     *
     public int getIpPort()
     {
         return ipPort;
@@ -200,7 +207,7 @@
 
     /**
      * {@inheritDoc}
-     */
+     *
     public int getTcpPort()
     {
         return tcpPort;
@@ -209,16 +216,16 @@
 
     /**
      * {@inheritDoc}
-     */
+     *
     public int getUdpPort()
     {
         return udpPort;
     }
-
+    */
 
     /**
      * {@inheritDoc}
-     */
+     *
     public void setIpPort( int ipPort )
     {
         if ( ( ipPort < 0 ) || ( ipPort > 65535 ) )
@@ -236,7 +243,7 @@
 
     /**
      * {@inheritDoc}
-     */
+     *
     public void setTcpPort( int tcpPort )
     {
         if ( ( tcpPort < 0 ) || ( tcpPort > 65535 ) )
@@ -250,7 +257,7 @@
     
     /**
      * {@inheritDoc}
-     */
+     *
     public void setUdpPort( int udpPort )
     {
         if ( ( udpPort < 0 ) || ( udpPort > 65535 ) )
@@ -266,6 +273,45 @@
     {
         return transportProtocols;
     }
+    */
+    
+    
+    /**
+     * @return the TCP transport
+     */
+    public TcpTransport getTcpTransport()
+    {
+        return tcpTransport;
+    }
+
+
+    /**
+     * Set the underlying TCP transport
+     * @param transport The TCP transport
+     */
+    public void setTcpTransport( TcpTransport transport )
+    {
+        tcpTransport = transport;
+    }
+    
+    
+    /**
+     * Set the underlying UDP transport
+     * @param transport The UDP transport
+     */
+    public void setUdpTransport( UdpTransport transport )
+    {
+        udpTransport = transport;
+    }
+    
+    
+    /**
+     * @return the UDP transport
+     */
+    public UdpTransport getUdpTransport()
+    {
+        return udpTransport;
+    }
 
 
     /**
@@ -284,7 +330,7 @@
      */
     public DatagramAcceptor getDatagramAcceptor()
     {
-        return datagramAcceptor;
+        return (DatagramAcceptor)udpTransport.getAcceptor();
     }
 
 
@@ -294,7 +340,7 @@
      */
     public void setDatagramAcceptor( DatagramAcceptor datagramAcceptor )
     {
-        this.datagramAcceptor = datagramAcceptor;
+        udpTransport.setAcceptor( datagramAcceptor );
     }
 
 
@@ -303,7 +349,7 @@
      */
     public SocketAcceptor getSocketAcceptor()
     {
-        return socketAcceptor;
+        return (SocketAcceptor)tcpTransport.getAcceptor();
     }
 
 
@@ -313,7 +359,7 @@
      */
     public void setSocketAcceptor( SocketAcceptor socketAcceptor )
     {
-        this.socketAcceptor = socketAcceptor;
+        tcpTransport.setAcceptor( socketAcceptor );
     }
 
     
@@ -322,7 +368,7 @@
      * used if no specific transport protocol is defined, and will be
      * overloaded by the specific NbUdpThreads or nbTcpThreads if those
      * transport protocols are defined.
-     */
+     *
     public int getNbThreads() 
     {
         return nbThreads;
@@ -332,7 +378,7 @@
     /**
      * @return The number of thread used in the IoAcceptor executor for
      * a TCP transport protocol based Acceptor.
-     */
+     *
     public int getNbTcpThreads() 
     {
         return nbTcpThreads;
@@ -342,7 +388,7 @@
     /**
      * @return The number of thread used in the IoAcceptor executor for
      * a UDP transport protocol based Acceptor.
-     */
+     *
     public int getNbUdpThreads() 
     {
         return nbUdpThreads;
@@ -353,7 +399,7 @@
      * @param nbThreads The number of thread to affect to the IoAcceptor
      * executor. This number will be injected into the UDP and TCP
      * nbThreads value.
-     */
+     *
     public void setNbThreads(int nbThreads) 
     {
         this.nbThreads = nbThreads;
@@ -365,7 +411,7 @@
     /**
      * @param nbThreads The number of thread to affect to the 
      * TCP transport protocol based IoAcceptor executor
-     */
+     *
     public void setNbTcpThreads(int nbTcpThreads) 
     {
         this.nbTcpThreads = nbTcpThreads;
@@ -375,7 +421,7 @@
     /**
      * @param nbThreads The number of thread to affect to the 
      * UDP transport protocol based IoAcceptor executor
-     */
+     *
     public void setNbUdpThreads(int nbUdpThreads) 
     {
         this.nbUdpThreads = nbUdpThreads;
@@ -384,7 +430,7 @@
 
     /**
      * @return the ipBacklog
-     */
+     *
     public int getIpBacklog() {
         return ipBacklog;
     }
@@ -392,7 +438,7 @@
 
     /**
      * @param ipBacklog the ipBacklog to set
-     */
+     *
     public void setIpBacklog(int ipBacklog) {
         if ( ipBacklog < 0  )
         {
@@ -409,7 +455,7 @@
 
     /**
      * @return the tcpBacklog
-     */
+     *
     public int getTcpBacklog() {
         return tcpBacklog;
     }
@@ -417,7 +463,7 @@
 
     /**
      * @param tcpBacklog the tcpBacklog to set
-     */
+     *
     public void setTcpBacklog(int tcpBacklog) {
         this.tcpBacklog = tcpBacklog;
     }
@@ -425,7 +471,7 @@
 
     /**
      * @return the udpBacklog
-     */
+     *
     public int getUdpBacklog() {
         return udpBacklog;
     }
@@ -433,8 +479,8 @@
 
     /**
      * @param udpBacklog the udpBacklog to set
-     */
+     *
     public void setUdpBacklog(int udpBacklog) {
         this.udpBacklog = udpBacklog;
-    }
+    }*/
 }

Modified: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java (original)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/ProtocolService.java Mon Dec 29 17:22:35 2008
@@ -128,82 +128,13 @@
 
 
     /**
-     * Gets the IP address of this service.
-     *
-     * @return the IP address for this service.
-     */
-    String getIpAddress();
-
-
-    /**
-     * Gets the IP address of this service.
-     *
-     * @param ipAddress the Internet Protocol address for this service.
-     */
-    void setIpAddress( String ipAddress );
-
-
-    /**
-     * Gets the IP port for this service. This is just a temporary
-     * storage for the service port, as we will move it to either
-     * TCP or UDP port.
-     *
-     * @return the IP port for this service
-     */
-    int getIpPort();
-
-
-    /**
-     * Gets the UDP port for this service.
-     *
-     * @return the UDP port for this service
-     */
-    int getUdpPort();
-
-
-    /**
-     * Gets the TCP port for this service.
-     *
-     * @return the TCP port for this service
-     */
-    int getTcpPort();
-
-
-    /**
-     * Sets the IP port for this service.
-     *
-     * @param ipPort the ip port for this service
-     * @throws IllegalArgumentException if the port number is not within a valid range
-     */
-    void setIpPort( int ipPort );
-
-
-    /**
-     * Sets the UDP port for this service.
-     *
-     * @param ipPort the udp port for this service
-     * @throws IllegalArgumentException if the port number is not within a valid range
-     */
-    void setUdpPort( int udpPort );
-
-
-    /**
-     * Sets the TCP port for this service.
-     *
-     * @param tcpPort the tcp port for this service
-     * @throws IllegalArgumentException if the port number is not within a valid range
-     */
-    void setTcpPort( int tcpPort );
-
-
-    /**
      * Gets the transport protocols used by this service. At this point services
      * which support more than one transport are configured to bind to that transport
      * on the same port.
      *
      * @return the transport protocols used by this service
      */
-    Set<TransportProtocol> getTransportProtocols();
+    //Set<TransportProtocol> getTransportProtocols();
 
 
     /**

Added: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java?rev=730026&view=auto
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java (added)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/AbstractTransport.java Mon Dec 29 17:22:35 2008
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.server.protocol.shared.transport;
+
+
+import org.apache.mina.core.service.IoAcceptor;
+
+public abstract class AbstractTransport implements Transport
+{
+    /** The server address */
+    private String address;
+    
+    /** The service's port */
+    private int port = -1;
+    
+    /** The number of threads to use for the IoAcceptor executor */
+    private int nbThreads;
+    
+    /** The backlog for the transport services */
+    private int backlog;
+    
+    /** The IoAcceptor used to accept requests */
+    protected IoAcceptor acceptor;
+
+    /**
+     * Creates an instance of an Abstract Transport class.
+     */
+    public AbstractTransport()
+    {
+        address = "localHost";
+    }
+    
+    
+    /**
+     * Creates an instance of an Abstract Transport class, using localhost
+     * and port.
+     * 
+     * @param port The port
+     */
+    public AbstractTransport( int port )
+    {
+       this.address = "localhost";
+       this.port = port;
+    }
+    
+    
+    /**
+     * Creates an instance of an Abstract Transport class, using the given address
+     * and port.
+     * 
+     * @param address The address
+     * @param port The port
+     */
+    public AbstractTransport( String address, int port )
+    {
+       this.address = address;
+       this.port = port;
+    }
+    
+    
+    /**
+     * Creates an instance of the AbstractTransport class on LocalHost
+     * @param tcpPort The port
+     * @param nbThreads The number of threads to create in the acceptor
+     * @param backlog The queue size for incoming messages, waiting for the
+     * acceptor to be ready
+     */
+    public AbstractTransport( int port, int nbThreads, int backLog )
+    {
+        this.address ="localHost";
+        this.port = port;
+        this.nbThreads = nbThreads;
+        this.backlog = backLog;
+    }
+    
+    
+    /**
+     * Creates an instance of the AbstractTransport class 
+     * @param address The address
+     * @param tcpPort The port
+     * @param nbThreads The number of threads to create in the acceptor
+     * @param backlog The queue size for incoming messages, waiting for the
+     * acceptor to be ready
+     */
+    public AbstractTransport( String address, int port, int nbThreads, int backLog )
+    {
+        this.address = address;
+        this.port = port;
+        this.nbThreads = nbThreads;
+        this.backlog = backLog;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public int getPort()
+    {
+        return port;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setPort( int port )
+    {
+        this.port = port;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String getAddress()
+    {
+        return address;
+    }
+    
+    
+    /**
+     * Stores the Address in this transport
+     * 
+     * @param address the Address to store
+     */
+    public void setAddress( String address )
+    {
+        this.address = address;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public IoAcceptor getAcceptor()
+    {
+        return acceptor;
+    }
+    
+    
+    /**
+     * Set the IoAcceptor
+     * @param acceptor The IoAcceptor to set
+     */
+    public void setAcceptor ( IoAcceptor acceptor )
+    {
+        this.acceptor = acceptor;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public int getNbThreads() 
+    {
+        return nbThreads;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setNbThreads( int nbThreads )
+    {
+        this.nbThreads = nbThreads;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public int getBackLog()
+    {
+        return backlog;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setBackLog( int backLog )
+    {
+        this.backlog = backLog;
+    }
+}

Added: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java?rev=730026&view=auto
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java (added)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/TcpTransport.java Mon Dec 29 17:22:35 2008
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.server.protocol.shared.transport;
+
+import org.apache.mina.transport.socket.SocketAcceptor;
+
+/**
+ * @org.apache.xbean.XBean
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class TcpTransport extends AbstractTransport
+{
+    /**
+     * Creates an instance of the TcpTransport class 
+     */
+    public TcpTransport()
+    {
+        super();
+    }
+    
+    
+    /**
+     * Creates an instance of the TcpTransport class on localhost
+     * @param port The port
+     */
+    public TcpTransport( int port )
+    {
+        super( port );
+    }
+    
+    
+    /**
+     * Creates an instance of the TcpTransport class 
+     * @param address The address
+     * @param port The port
+     */
+    public TcpTransport( String address, int port )
+    {
+        super( address, port );
+    }
+    
+    
+    /**
+     * Creates an instance of the TcpTransport class on localhost
+     * @param tcpPort The port
+     * @param nbThreads The number of threads to create in the acceptor
+     * @param backlog The queue size for incoming messages, waiting for the
+     * acceptor to be ready
+     */
+    public TcpTransport( int tcpPort, int nbThreads, int backLog )
+    {
+        super( tcpPort, nbThreads, backLog );
+    }
+    
+    
+    /**
+     * Creates an instance of the TcpTransport class 
+     * @param address The address
+     * @param tcpPort The port
+     * @param nbThreads The number of threads to create in the acceptor
+     * @param backlog The queue size for incoming messages, waiting for the
+     * acceptor to be ready
+     */
+    public TcpTransport( String address, int tcpPort, int nbThreads, int backLog )
+    {
+        super( address, tcpPort, nbThreads, backLog );
+    }
+    
+    
+    /**
+     * @return The associated SocketAcceptor
+     */
+    public SocketAcceptor getSocketAcceptor()
+    {
+        return acceptor == null ? null : (SocketAcceptor)acceptor;
+    }
+}

Added: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/Transport.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/Transport.java?rev=730026&view=auto
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/Transport.java (added)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/Transport.java Mon Dec 29 17:22:35 2008
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.server.protocol.shared.transport;
+
+import org.apache.mina.core.service.IoAcceptor;
+
+public interface Transport
+{
+    /**
+     * @return The associated Address
+     */
+    String getAddress();
+    
+    
+    /**
+     * Set the InetAddress for this transport.
+     * @param address The address to set
+     */
+    void setAddress( String address );
+    
+    
+    /**
+     * Gets the port for this service.
+     *
+     * @return the port for this service
+     */
+    int getPort();
+    
+    
+    /**
+     * Sets the port for this service.
+     *
+     * @param port the port for this service
+     * @throws IllegalArgumentException if the port number is not within a valid range
+     */
+    void setPort( int port );
+    
+    
+    /**
+     * @return The associated IoAcceptor
+     */
+    IoAcceptor getAcceptor();
+    
+    
+    /**
+     * Set the IoAcceptor
+     * @param acceptor The IoAcceptor to set
+     */
+    void setAcceptor ( IoAcceptor acceptor );
+
+
+    /**
+     * @return The number of processing threads for this acceptor
+     */
+    int getNbThreads(); 
+    
+    
+    /**
+     * Set the number of processing threads for the acceptor
+     * @param nbThreads The number of threads to create in the acceptor
+     */
+    void setNbThreads( int nbThreads );
+    
+    
+    /**
+     * @return The number of messages stored into the backlog when the 
+     * acceptor is being busy processing the current messages
+     */
+    int getBackLog();
+    
+    
+    /**
+     * Set the size of the messages queue waiting for the acceptor to
+     * be ready.
+     * @param backLog The queue size
+     */
+    void setBackLog( int backLog );
+}

Added: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/UdpTransport.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/UdpTransport.java?rev=730026&view=auto
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/UdpTransport.java (added)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/transport/UdpTransport.java Mon Dec 29 17:22:35 2008
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.server.protocol.shared.transport;
+
+import org.apache.mina.transport.socket.DatagramAcceptor;
+
+/**
+ * @org.apache.xbean.XBean
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class UdpTransport extends AbstractTransport
+{
+    /**
+     * Creates an instance of the UdpTransport class 
+     */
+    public UdpTransport()
+    {
+        super();
+    }
+    
+    
+    /**
+     * Creates an instance of the UdpTransport class on localhost
+     * @param port The port
+     */
+    public UdpTransport( int port )
+    {
+        super( port );
+    }
+    
+    
+    /**
+     * Creates an instance of the UdpTransport class 
+     * @param address The address
+     * @param port The port
+     */
+    public UdpTransport( String address, int port )
+    {
+        super( address, port );
+    }
+    
+    
+    /**
+     * Creates an instance of the UdpTransport class 
+     * @param address The address
+     * @param udpPort The port
+     * @param nbThreads The number of threads to create in the acceptor
+     * @param backlog The queue size for incoming messages, waiting for the
+     * acceptor to be ready
+     */
+    UdpTransport( String address, int udpPort, int nbThreads, int backLog )
+    {
+        super( address, udpPort, nbThreads, backLog );
+    }
+    
+    
+    /**
+     * @return The associated DatagramAcceptor
+     */
+    public DatagramAcceptor getDatagramAcceptor()
+    {
+        return acceptor == null ? null : (DatagramAcceptor)acceptor;
+    }
+}

Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/LdapServerFactory.java Mon Dec 29 17:22:35 2008
@@ -34,6 +34,7 @@
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StartTlsHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
 import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
@@ -69,9 +70,10 @@
 
             LdapService ldapService = new LdapService();
             ldapService.setDirectoryService( service );
+            int port = AvailablePortFinder.getNextAvailable( 1024 );
+            ldapService.setTcpTransport( new TcpTransport( port ) );
+            ldapService.getTcpTransport().setNbThreads( 3 );
             ldapService.setSocketAcceptor( new NioSocketAcceptor() );
-            ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
-            ldapService.setNbTcpThreads( 3 );
             ldapService.addExtendedOperationHandler( new StartTlsHandler() );
             ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
 

Modified: directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java (original)
+++ directory/apacheds/trunk/server-integ/src/main/java/org/apache/directory/server/integ/ServerIntegrationUtils.java Mon Dec 29 17:22:35 2008
@@ -75,10 +75,10 @@
     public static LdapContext getWiredContext( LdapService ldapService, String principalDn, String password ) 
         throws Exception
     {
-        LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapService.getIpPort() );
+        LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapService.getPort() );
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
         env.put( Context.SECURITY_PRINCIPAL, principalDn );
         env.put( Context.SECURITY_CREDENTIALS, password );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
@@ -97,10 +97,10 @@
      */
     public static LdapContext getWiredContext( LdapService ldapService, Control[] controls ) throws Exception
     {
-        LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapService.getIpPort() );
+        LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapService.getPort() );
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
         env.put( Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
@@ -119,10 +119,10 @@
      */
     public static LdapContext getWiredContextThrowOnRefferal( LdapService ldapService ) throws Exception
     {
-        LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapService.getIpPort() );
+        LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapService.getPort() );
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
         env.put( Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
@@ -142,10 +142,10 @@
      */
     public static LdapContext getWiredContextRefferalIgnore( LdapService ldapService ) throws Exception
     {
-        LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapService.getIpPort() );
+        LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapService.getPort() );
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
         env.put( Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
@@ -165,10 +165,10 @@
      */
     public static LdapContext getWiredContextFollowOnRefferal( LdapService ldapService ) throws Exception
     {
-        LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapService.getIpPort() );
+        LOG.debug( "Creating a wired context to local LDAP server on port {}", ldapService.getPort() );
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, CTX_FACTORY );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
         env.put( Context.SECURITY_PRINCIPAL, ServerDNConstants.ADMIN_SYSTEM_DN );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
@@ -210,7 +210,7 @@
         throws Exception
     {
         LDAPConnection conn = new LDAPConnection();
-        conn.connect( 3, "localhost", ldapService.getIpPort(), principalDn, password );
+        conn.connect( 3, "localhost", ldapService.getPort(), principalDn, password );
         return conn;
     }
 }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/KeyDerivationServiceIT.java Mon Dec 29 17:22:35 2008
@@ -49,6 +49,7 @@
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.bind.plain.PlainMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
 import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
@@ -142,11 +143,12 @@
 
              LdapService ldapService = new LdapService();
              ldapService.setDirectoryService( service );
+             int port = AvailablePortFinder.getNextAvailable( 1024 );
+             ldapService.setTcpTransport( new TcpTransport( port ) );
              ldapService.setSocketAcceptor( new NioSocketAcceptor() );
-             ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
              ldapService.setAllowAnonymousAccess( false );
              ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
-             ldapService.setNbTcpThreads( 3 );
+             ldapService.getTcpTransport().setNbThreads( 3 );
 
              // Setup SASL Mechanisms
              
@@ -225,7 +227,7 @@
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=hnelson,ou=users,dc=example,dc=com" );
@@ -296,7 +298,7 @@
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=hnelson,ou=users,dc=example,dc=com" );
@@ -434,7 +436,7 @@
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=hnelson,ou=users,dc=example,dc=com" );
@@ -564,7 +566,7 @@
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( "java.naming.provider.url", "ldap://localhost:" + ldapService.getIpPort() + "/ou=users,dc=example,dc=com" );
+        env.put( "java.naming.provider.url", "ldap://localhost:" + ldapService.getPort() + "/ou=users,dc=example,dc=com" );
         env.put( "java.naming.security.principal", "uid=admin,ou=system" );
         env.put( "java.naming.security.credentials", "secret" );
         env.put( "java.naming.security.authentication", "simple" );

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/PasswordPolicyServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/PasswordPolicyServiceIT.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/PasswordPolicyServiceIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/kerberos/PasswordPolicyServiceIT.java Mon Dec 29 17:22:35 2008
@@ -44,6 +44,7 @@
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.bind.plain.PlainMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
 import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
 import org.apache.mina.util.AvailablePortFinder;
@@ -131,9 +132,10 @@
 
             LdapService ldapService = new LdapService();
             ldapService.setDirectoryService( service );
+            int port = AvailablePortFinder.getNextAvailable( 1024 );
+            ldapService.setTcpTransport( new TcpTransport( port ) );
             ldapService.setSocketAcceptor( new NioSocketAcceptor() );
-            ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
-            ldapService.setNbTcpThreads( 3 );
+            ldapService.getTcpTransport().setNbThreads( 3 );
             ldapService.setAllowAnonymousAccess( false );
             ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
 
@@ -173,7 +175,7 @@
         Attributes attrs;
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( "java.naming.factory.initial", "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( "java.naming.provider.url", "ldap://localhost:" + ldapService.getIpPort() + "/dc=example,dc=com" );
+        env.put( "java.naming.provider.url", "ldap://localhost:" + ldapService.getPort() + "/dc=example,dc=com" );
         env.put( "java.naming.security.principal", "uid=admin,ou=system" );
         env.put( "java.naming.security.credentials", "secret" );
         env.put( "java.naming.security.authentication", "simple" );

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/add/AddIT.java Mon Dec 29 17:22:35 2008
@@ -506,7 +506,7 @@
         ne = containerCtx.search( "ou=bestFruit", "(objectClass=*)", controls );
         assertTrue( ne.hasMore() );
         sr = ne.next();
-        assertEquals( "ldap://localhost:"+ ldapService.getIpPort() +"/ou=favorite,ou=Fruits,ou=system", sr.getName() );
+        assertEquals( "ldap://localhost:"+ ldapService.getPort() +"/ou=favorite,ou=Fruits,ou=system", sr.getName() );
         assertFalse( ne.hasMore() );
         
         // Remove alias and entry

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/BindIT.java Mon Dec 29 17:22:35 2008
@@ -143,7 +143,7 @@
         try
         {
             conn = new LDAPConnection();
-            conn.connect( 100, "localhost", ldapService.getIpPort(), "uid=admin,ou=system", "secret" );
+            conn.connect( 100, "localhost", ldapService.getPort(), "uid=admin,ou=system", "secret" );
             fail( "try to connect with illegal version number should fail" );
         }
         catch ( LDAPException e )
@@ -174,7 +174,7 @@
         
         try
         {
-            conn.connect( 3, "localhost", ldapService.getIpPort(), 
+            conn.connect( 3, "localhost", ldapService.getPort(), 
                 "uid=akarasuluref,ou=users,ou=system", "secret", constraints );
             fail( "try to connect with illegal version number should fail" );
         }
@@ -185,7 +185,7 @@
         
         try
         {
-            conn.connect( 3, "localhost", ldapService.getIpPort(), 
+            conn.connect( 3, "localhost", ldapService.getPort(), 
                 "uid=akarasuluref,ou=users,ou=system", "secret" );
             fail( "try to connect with illegal version number should fail" );
         }

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/MiscBindIT.java Mon Dec 29 17:22:35 2008
@@ -56,6 +56,7 @@
 import org.apache.directory.server.ldap.handlers.bind.gssapi.GssapiMechanismHandler;
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.shared.asn1.util.Asn1StringUtils;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
@@ -122,9 +123,10 @@
 
             LdapService ldapService = new LdapService();
             ldapService.setDirectoryService( service );
+            int port = AvailablePortFinder.getNextAvailable( 1024 );
+            ldapService.setTcpTransport( new TcpTransport( port ) );
             ldapService.setSocketAcceptor( new NioSocketAcceptor() );
-            ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
-            ldapService.setNbTcpThreads( 3 );
+            ldapService.getTcpTransport().setNbThreads( 3 );
             ldapService.setAllowAnonymousAccess( true );
             ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
 
@@ -188,7 +190,7 @@
         InitialDirContext ic = null;
         final Hashtable<String, Object> env = new Hashtable<String, Object>();
 
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() + "/ou=system" );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() + "/ou=system" );
         env.put( Context.SECURITY_AUTHENTICATION, "none" );
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
 
@@ -248,7 +250,7 @@
         // Use the SUN JNDI provider to hit server port and bind as anonymous
         Hashtable<String, Object> env = new Hashtable<String, Object>();
 
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() + "/" );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() + "/" );
         env.put( Context.SECURITY_AUTHENTICATION, "none" );
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
 
@@ -286,7 +288,7 @@
         // Use the SUN JNDI provider to hit server port and bind as anonymous
         Hashtable<String, Object> env = new Hashtable<String, Object>();
 
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() + "/" );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() + "/" );
         env.put( Context.SECURITY_AUTHENTICATION, "none" );
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
 
@@ -324,7 +326,7 @@
 
         final Hashtable<String, Object> env = new Hashtable<String, Object>();
 
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
         env.put( "java.naming.ldap.version", "3" );
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
 
@@ -363,7 +365,7 @@
 
         Hashtable<String, Object> env = new Hashtable<String, Object>();
 
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() + "/dc=aPache,dc=org" );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() + "/dc=aPache,dc=org" );
         env.put( "java.naming.ldap.version", "3" );
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
         InitialDirContext ctx = new InitialDirContext( env );
@@ -452,7 +454,7 @@
         
         Hashtable<String, Object> env = new Hashtable<String, Object>();
 
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() + "/ou=system" );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() + "/ou=system" );
         env.put( "java.naming.ldap.version", "3" );
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SaslBindIT.java Mon Dec 29 17:22:35 2008
@@ -59,6 +59,7 @@
 import org.apache.directory.server.ldap.handlers.bind.ntlm.NtlmProvider;
 import org.apache.directory.server.ldap.handlers.bind.plain.PlainMechanismHandler;
 import org.apache.directory.server.ldap.handlers.extended.StoredProcedureExtendedOperationHandler;
+import org.apache.directory.server.protocol.shared.transport.TcpTransport;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.shared.ldap.constants.SupportedSaslMechanisms;
 import org.apache.directory.shared.ldap.message.BindRequestImpl;
@@ -151,10 +152,11 @@
              // or somewhere in a temp area of the machine.
 
              LdapService ldapService = new LdapService();
+             int port = AvailablePortFinder.getNextAvailable( 1024 );
+             ldapService.setTcpTransport( new TcpTransport( port ) );
+             ldapService.getTcpTransport().setNbThreads( 3 );
              ldapService.setDirectoryService( service );
              ldapService.setSocketAcceptor( new NioSocketAcceptor() );
-             ldapService.setIpPort( AvailablePortFinder.getNextAvailable( 1024 ) );
-             ldapService.setNbTcpThreads( 3 );
              ldapService.setAllowAnonymousAccess( false );
              ldapService.addExtendedOperationHandler( new StoredProcedureExtendedOperationHandler() );
 
@@ -211,7 +213,7 @@
              DirContext context = new InitialDirContext();
 
              Attributes attrs = context.getAttributes( "ldap://localhost:" 
-                 + ldapService.getIpPort(), new String[]
+                 + ldapService.getPort(), new String[]
                  { "supportedSASLMechanisms" } );
 
              NamingEnumeration<? extends Attribute> answer = attrs.getAll();
@@ -241,7 +243,7 @@
          {
              Hashtable<String, String> env = new Hashtable<String, String>();
              env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
              env.put( Context.SECURITY_AUTHENTICATION, "PLAIN" );
              env.put( Context.SECURITY_PRINCIPAL, "uid=hnelson,ou=users,dc=example,dc=com" );
@@ -279,7 +281,7 @@
          {
              Hashtable<String, String> env = new Hashtable<String, String>();
              env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
              env.put( Context.SECURITY_AUTHENTICATION, "" );
              env.put( Context.SECURITY_PRINCIPAL, "uid=hnelson,ou=users,dc=example,dc=com" );
@@ -311,7 +313,7 @@
          {
              Hashtable<String, String> env = new Hashtable<String, String>();
              env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
              DirContext context = new InitialDirContext( env );
 
@@ -343,7 +345,7 @@
          {
              Hashtable<String, String> env = new Hashtable<String, String>();
              env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
              env.put( Context.SECURITY_AUTHENTICATION, "CRAM-MD5" );
              env.put( Context.SECURITY_PRINCIPAL, "hnelson" );
@@ -382,7 +384,7 @@
          {
              Hashtable<String, String> env = new Hashtable<String, String>();
              env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
              env.put( Context.SECURITY_AUTHENTICATION, "CRAM-MD5" );
              env.put( Context.SECURITY_PRINCIPAL, "hnelson" );
@@ -412,7 +414,7 @@
      {
          Hashtable<String, String> env = new Hashtable<String, String>();
          env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-         env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+         env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
          env.put( Context.SECURITY_AUTHENTICATION, "DIGEST-MD5" );
          env.put( Context.SECURITY_PRINCIPAL, "hnelson" );
@@ -452,7 +454,7 @@
          {
              Hashtable<String, String> env = new Hashtable<String, String>();
              env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
              env.put( Context.SECURITY_AUTHENTICATION, "DIGEST-MD5" );
              env.put( Context.SECURITY_PRINCIPAL, "hnelson" );
@@ -490,7 +492,7 @@
          {
              Hashtable<String, String> env = new Hashtable<String, String>();
              env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+             env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
              env.put( Context.SECURITY_AUTHENTICATION, "DIGEST-MD5" );
              env.put( Context.SECURITY_PRINCIPAL, "hnelson" );
@@ -599,8 +601,8 @@
          NtlmSaslBindClient( String mechanism ) throws Exception
          {
              this.mechanism = mechanism;
-             setDefaultPort( ldapService.getIpPort() );
-             connect( "localhost", ldapService.getIpPort() );
+             setDefaultPort( ldapService.getPort() );
+             connect( "localhost", ldapService.getPort() );
              setTcpNoDelay( false );
              
              LOG.debug( "isConnected() = {}", _isConnected_ );

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/bind/SimpleBindIT.java Mon Dec 29 17:22:35 2008
@@ -121,7 +121,7 @@
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=hnelson," + BASE );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
@@ -159,7 +159,7 @@
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=hnelson," + BASE );
         env.put( Context.SECURITY_CREDENTIALS, "badsecret" );
@@ -188,7 +188,7 @@
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "hnelson" );
@@ -218,7 +218,7 @@
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=unknown,ou=system" );
         env.put( Context.SECURITY_CREDENTIALS, "secret" );
@@ -250,7 +250,7 @@
 
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "" );
         env.put( Context.SECURITY_CREDENTIALS, "" );
@@ -308,7 +308,7 @@
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
         env.put( Context.SECURITY_CREDENTIALS, "" );
@@ -338,7 +338,7 @@
     {
         Hashtable<String, String> env = new Hashtable<String, String>();
         env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+        env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
         env.put( Context.SECURITY_AUTHENTICATION, "simple" );
         env.put( Context.SECURITY_PRINCIPAL, "" );
@@ -373,7 +373,7 @@
         {
             Hashtable<String, String> env = new Hashtable<String, String>();
             env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
-            env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getIpPort() );
+            env.put( Context.PROVIDER_URL, "ldap://localhost:" + ldapService.getPort() );
 
             DirContext context = new InitialDirContext( env );
 

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java?rev=730026&r1=730025&r2=730026&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java (original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/compare/CompareIT.java Mon Dec 29 17:22:35 2008
@@ -255,7 +255,7 @@
     {
         ldapService.getDirectoryService().setAllowAnonymousAccess( false );
         LDAPConnection conn = new LDAPConnection();
-        conn.connect( "localhost", ldapService.getIpPort() );
+        conn.connect( "localhost", ldapService.getPort() );
         LDAPAttribute attr = new LDAPAttribute( "uid", "admin" );
         
         try