directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r760055 - in /directory/apacheds/branches/apacheds-replication/syncrepl: ./ src.main.java/ src.main.java/org/ src.main.java/org/apache/ src.main.java/org/apache/directory/ src.main.java/org/apache/directory/server/ src.main.java/org/apache/...
Date Mon, 30 Mar 2009 17:19:41 GMT
Author: elecharny
Date: Mon Mar 30 17:19:41 2009
New Revision: 760055

URL: http://svn.apache.org/viewvc?rev=760055&view=rev
Log:
Moved mitosis to syncrepl

Added:
    directory/apacheds/branches/apacheds-replication/syncrepl/   (with props)
    directory/apacheds/branches/apacheds-replication/syncrepl/pom.xml
    directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/
    directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/
    directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/
    directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/
    directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/
    directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/
    directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/LdapConnection.java
    directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/SearchListener.java
    directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/
    directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolCodecFactory.java
    directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolDecoder.java
    directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolEncoder.java
    directory/apacheds/branches/apacheds-replication/syncrepl/src.test.java/

Propchange: directory/apacheds/branches/apacheds-replication/syncrepl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 30 17:19:41 2009
@@ -0,0 +1,4 @@
+target
+.classpath
+.project
+.settings

Added: directory/apacheds/branches/apacheds-replication/syncrepl/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/syncrepl/pom.xml?rev=760055&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-replication/syncrepl/pom.xml (added)
+++ directory/apacheds/branches/apacheds-replication/syncrepl/pom.xml Mon Mar 30 17:19:41 2009
@@ -0,0 +1,293 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.directory.server</groupId>
+    <artifactId>apacheds-parent</artifactId>
+    <version>1.5.5-SNAPSHOT</version>
+  </parent>
+  <artifactId>syncrepl</artifactId>
+  <name>ApacheDS replication</name>
+  <packaging>jar</packaging>
+
+  <description>
+     Syncrepl is the multi-master replications service included into Apache
+     Directory Server
+  </description>
+  
+  <repositories>
+    <repository>
+      <id>safehauS-m1-repository</id>
+      <name>SafeHaus.org Maven 1.x Repository</name>
+      <url>http://maven.safehaus.org/</url>
+      <layout>legacy</layout>
+    </repository>
+  </repositories>
+
+  <!-- =======  Dependencies are declared here  ======= -->
+  <dependencies>
+
+    <dependency>
+      <groupId>commons-collections</groupId>
+      <artifactId>commons-collections</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-dbcp</groupId>
+      <artifactId>commons-dbcp</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-pool</groupId>
+      <artifactId>commons-pool</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>jug</groupId>
+      <artifactId>jug-asl</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.mina</groupId>
+      <artifactId>mina-core</artifactId>
+    </dependency>
+
+    <!-- TODO remove dependency on JNDI core -->
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-core-jndi</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-core-shared</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-bootstrap-partition</artifactId>
+      <version>${pom.version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>opensymphony</groupId>
+      <artifactId>quartz</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.derby</groupId>
+      <artifactId>derby</artifactId>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-core-cursor</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-protocol-ldap</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+    
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-source-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>attach-sources</id>
+            <phase>verify</phase>
+            <goals>
+              <goal>jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+    <id>no-integration-or-perf-tests</id>
+    <activation>
+      <activeByDefault>true</activeByDefault>
+    </activation>
+    <build>
+      <plugins>
+        <plugin>
+          <artifactId>maven-surefire-plugin</artifactId>
+          <configuration>
+            <excludes>
+              <exclude>**/*ITest.java</exclude>
+              <exclude>**/*PTest.java</exclude>
+            </excludes>
+            <argLine>-Xmx1024m</argLine>
+          </configuration>
+        </plugin>
+
+        <plugin>
+          <artifactId>maven-antrun-plugin</artifactId>
+            <executions>
+              <execution>
+                <phase>validate</phase>
+                <configuration>
+                  <tasks>
+                    <echo>
+=================================================================
+                          W A R N I N G
+                          -------------
+
+Integration and performance tests have been disabled.  To enable
+integration tests run maven with the -Dintegration switch.  To
+enable performance tests run maven with the -Dperformance switch.
+=================================================================
+                    </echo>
+                  </tasks>
+                </configuration>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+    <profile>
+      <id>integration</id>
+      <activation>
+        <property><name>integration</name></property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <forkMode>pertest</forkMode>
+              <excludes>
+                <exclude>**/*PTest.java</exclude>
+              </excludes>
+              <argLine>-Xmx1024m</argLine>
+            </configuration>
+          </plugin>
+
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <executions>
+              <execution>
+                <phase>validate</phase>
+                <configuration>
+                  <tasks>
+                    <echo>
+=================================================================
+                   I N T E G R A T I O N
+                   ---------------------
+
+Performance tests have been disabled.  To enable
+performance tests run maven with the -Dperformance switch.
+=================================================================
+                    </echo>
+                  </tasks>
+                </configuration>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+ 
+    <profile>
+      <id>performance</id>
+      <activation>
+        <property><name>performance</name></property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <systemProperties>
+                <property>
+                  <name>outputDirectory</name>
+                  <value>${basedir}/target</value>
+                </property>
+              </systemProperties>
+              <excludes>
+                <exclude>**/*ITest.java</exclude>
+              </excludes>
+              <argLine>-Xmx1024m</argLine>
+            </configuration>
+          </plugin>
+
+          <plugin>
+            <artifactId>maven-antrun-plugin</artifactId>
+            <executions>
+              <execution>
+                <phase>validate</phase>
+                <configuration>
+                  <tasks>
+                    <echo>
+=================================================================
+                   P E R F O R M A N C E
+                   ---------------------
+
+Integration tests have been disabled.  To enable integration
+tests run maven with the -Dintegration switch.
+=================================================================
+                    </echo>
+                  </tasks>
+                </configuration>
+                <goals>
+                  <goal>run</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>
+

Added: directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/LdapConnection.java?rev=760055&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/LdapConnection.java (added)
+++ directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/LdapConnection.java Mon Mar 30 17:19:41 2009
@@ -0,0 +1,761 @@
+/*
+ *  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.syncrepl;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.text.ParseException;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+import javax.naming.InvalidNameException;
+import javax.net.ssl.SSLContext;
+
+import org.apache.directory.server.syncrepl.protocol.LdapProtocolCodecFactory;
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.ldap.codec.LdapConstants;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.codec.TwixTransformer;
+import org.apache.directory.shared.ldap.codec.bind.BindRequest;
+import org.apache.directory.shared.ldap.codec.bind.SimpleAuthentication;
+import org.apache.directory.shared.ldap.codec.search.Filter;
+import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.codec.search.SearchResultDone;
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
+import org.apache.directory.shared.ldap.codec.search.SearchResultReference;
+import org.apache.directory.shared.ldap.codec.unbind.UnBindRequest;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.FilterParser;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.mina.core.filterchain.IoFilter;
+import org.apache.mina.core.future.ConnectFuture;
+import org.apache.mina.core.service.IoHandlerAdapter;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.filter.ssl.SslFilter;
+import org.apache.mina.transport.socket.nio.NioSocketConnector;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * An implementation of a Ldap connection
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapConnection extends IoHandlerAdapter
+{
+    /** logger for reporting errors that might not be handled properly upstream */
+    private static final Logger LOG = LoggerFactory.getLogger( LdapConnection.class );
+
+    /** Define the default ports for LDAP and LDAPS */
+    private static final int DEFAULT_LDAP_PORT = 389; 
+    private static final int DEFAULT_LDAPS_PORT = 686;
+    
+    /** The default host : localhost */
+    private static final String DEFAULT_LDAP_HOST = "127.0.0.1";
+    
+    /** The LDAP version */
+    private static int LDAP_V3 = 3;
+    
+    private static final String LDAP_RESPONSE = "LdapReponse";
+    
+    /** A flag indicating if we are using SSL or not */
+    private boolean useSsl = false;
+    
+    /** The default timeout for operation : 30 seconds */
+    private static final long DEFAULT_TIMEOUT = 30000L;
+    
+    /** The timeout used for response we are waiting for */ 
+    private long timeOut = DEFAULT_TIMEOUT;
+    
+    /** The selected LDAP port */
+    private int ldapPort;
+    
+    /** the remote LDAP host */
+    private String ldapHost;
+    
+    /** The connector open with the remote server */
+    private NioSocketConnector connector;
+    
+    /** The Ldap codec */
+    private IoFilter ldapProtocolFilter = new ProtocolCodecFilter(
+            new LdapProtocolCodecFactory() );
+
+    /**  
+     * The created session, created when we open a connection with
+     * the Ldap server.
+     */
+    private IoSession ldapSession;
+    
+    /** A Message ID which is incremented for each operation */
+    private int messageId;
+    
+    /** A queue used to store the incoming responses */
+    private BlockingQueue<LdapMessage> responseQueue;
+    
+    /** An operation mutex to guarantee the operation order */
+    private Semaphore operationMutex;
+    
+    /** the agent which created this connection */
+    private SearchListener listener;
+
+    //------------------------- The constructors --------------------------//
+    /**
+     * Create a new instance of a LdapConnection on localhost,
+     * port 389.
+     */
+    public LdapConnection()
+    {
+        useSsl = false;
+        ldapPort = DEFAULT_LDAP_PORT;
+        ldapHost = DEFAULT_LDAP_HOST;
+        messageId = 1;
+        operationMutex = new Semaphore(1);
+    }
+    
+    
+    /**
+     * Create a new instance of a LdapConnection on localhost,
+     * port 389 if the SSL flag is off, or 686 otherwise.
+     * 
+     * @param useSsl A flag to tell if it's a SSL connection or not.
+     */
+    public LdapConnection( boolean useSsl )
+    {
+        this.useSsl = useSsl;
+        ldapPort = ( useSsl ? DEFAULT_LDAPS_PORT : DEFAULT_LDAP_PORT );
+        ldapHost = DEFAULT_LDAP_HOST;
+        messageId = 1;
+        operationMutex = new Semaphore(1);
+    }
+    
+    
+    /**
+     * Create a new instance of a LdapConnection on a given
+     * server, using the default port (389)
+     *
+     * @param server The server we want to be connected to
+     * @param port The port the server is listening to
+     */
+    public LdapConnection( String server )
+    {
+        useSsl = false;
+        ldapPort = DEFAULT_LDAP_PORT;
+        ldapHost = server;
+        messageId = 1;
+        operationMutex = new Semaphore(1);
+    }
+    
+    
+    /**
+     * Create a new instance of a LdapConnection on a given
+     * server, using the default port (389)
+     *
+     * @param server The server we want to be connected to
+     * @param port The port the server is listening to
+     * @param useSsl A flag to tell if it's a SSL connection or not.
+     */
+    public LdapConnection( String server, boolean useSsl )
+    {
+        this.useSsl = useSsl;
+        ldapPort = ( useSsl ? DEFAULT_LDAPS_PORT : DEFAULT_LDAP_PORT );
+        ldapHost = DEFAULT_LDAP_HOST;
+        messageId = 1;
+        operationMutex = new Semaphore(1);
+    }
+    
+    
+    /**
+     * Create a new instance of a LdapConnection
+     *
+     * @param server The server we want to be connected to
+     * @param port The port the server is listening to
+     */
+    public LdapConnection( String server, int port )
+    {
+        useSsl = false;
+        ldapPort = port;
+        ldapHost = server;
+        messageId = 1;
+        operationMutex = new Semaphore(1);
+    }
+    
+    
+    /**
+     * Create a new instance of a LdapConnection
+     *
+     * @param server The server we want to be connected to
+     * @param port The port the server is listening to
+     * @param useSsl A flag to tell if it's a SSL connection or not.
+     */
+    public LdapConnection( String server, int port, boolean useSsl )
+    {
+        this.useSsl = useSsl;
+        ldapPort = port;
+        ldapHost = server;
+        messageId = 1;
+        operationMutex = new Semaphore(1);
+    }
+    
+    
+    //----------------------- The generic operations ----------------------//
+    /**
+     * Set the timeOut for the responses. We wont wait longer than this 
+     * value.
+     *
+     * @param timeOut The timeout, in milliseconds
+     */
+    public void setTimeOut( long timeOut )
+    {
+        this.timeOut = timeOut;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean connect() throws IOException 
+    {
+        if ( connector == null )
+        {
+            // Create the connector
+            connector = new NioSocketConnector();
+            
+            if ( ( ldapSession != null ) && ldapSession.isConnected() ) 
+            {
+                throw new IllegalStateException( "Already connected. Disconnect first." );
+            }
+    
+            // Add the codec to the chain
+            connector.getFilterChain().addLast( "ldapCodec", ldapProtocolFilter );
+    
+            // If we use SSL, we have to add the SslFilter to the chain
+            if (useSsl) 
+            {
+                SSLContext sslContext = null; // BogusSslContextFactory.getInstance( false );
+                SslFilter sslFilter = new SslFilter( sslContext );
+                sslFilter.setUseClientMode(true);
+                connector.getFilterChain().addLast( "sslFilter", sslFilter );
+            }
+        }
+
+        // Inject the protocolHandler
+        connector.setHandler( this );
+        
+        // Build the connection address
+        SocketAddress address = new InetSocketAddress( ldapHost , ldapPort );
+        
+        // And create the connection future
+        ConnectFuture connectionFuture = connector.connect( address );
+        
+        // Wait until it's established
+        connectionFuture.awaitUninterruptibly();
+        
+        if ( !connectionFuture.isConnected() ) 
+        {
+            return false;
+        }
+        
+        // Get back the session
+        ldapSession = connectionFuture.getSession();
+        
+        // And inject the current Ldap container into the session
+        IAsn1Container ldapMessageContainer = new LdapMessageContainer();
+        
+        // Store the container into the session 
+        ldapSession.setAttribute( "LDAP-Container", ldapMessageContainer );
+        
+        // Create the responses queue
+        responseQueue = new LinkedBlockingQueue<LdapMessage>();
+        
+        // And return
+        return true;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean close() throws IOException 
+    {
+        if ( ldapSession != null ) 
+        {
+            if ( ldapSession.isConnected() )
+            {
+                ldapSession.close( true );
+            }
+            
+            ldapSession = null;
+        }
+        
+        // Release the connector
+        connector.dispose();
+        
+        return true;
+    }
+    
+    
+    //------------------------ The LDAP operations ------------------------//
+    // Bind operations                                                     //
+    //---------------------------------------------------------------------//
+    /**
+     * Anonymous Bind on a server. 
+     *
+     * @return The BindResponse LdapResponse 
+     */
+    public LdapResponse bind() throws Exception
+    {
+        LOG.debug( " Unauthenticated Authentication bind" );
+        
+        LdapResponse response = bind( (String)null, (byte[])null );
+        
+        if (response.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+        {
+            LOG.debug( " Unauthenticated Authentication bind successfull" );
+        }
+        else
+        {
+            LOG.debug( " Unauthenticated Authentication bind failure {}", response );
+        }
+        
+        return response;
+    }
+    
+    
+    /**
+     * An Unauthenticated Authentication Bind on a server. (cf RFC 4513,
+     * par 5.1.2)
+     *
+     * @param name The name we use to authenticate the user. It must be a 
+     * valid DN
+     * @return The BindResponse LdapResponse 
+     */
+    public LdapResponse bind( String name ) throws Exception
+    {
+        LOG.debug( "Anonymous bind" );
+        
+        LdapResponse response = bind( name, (byte[])null );
+        
+        if (response.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS )
+        {
+            LOG.debug( "Anonymous bind successfull" );
+        }
+        else
+        {
+            LOG.debug( "Anonymous bind failure {}", response );
+        }
+        
+        return response;
+    }
+    
+    
+    /**
+     * Simple Bind on a server
+     *
+     * @param name The name we use to authenticate the user. It must be a 
+     * valid DN
+     * @param credentials The password.
+     * @return The BindResponse LdapResponse 
+     */
+    public LdapResponse bind( String name, String credentials ) throws Exception
+    {
+        return bind( name, StringTools.getBytesUtf8( credentials ) );
+    }
+    
+    
+    /**
+     * Simple Bind on a server
+     *
+     * @param name The name we use to authenticate the user. It must be a 
+     * valid DN
+     * @param credentials The password.
+     * @return The BindResponse LdapResponse 
+     */
+    public LdapResponse bind( String name, byte[] credentials ) throws Exception
+    {
+        // If the session has not been establish, or is closed, we get out immediately
+        checkSession();
+
+        // Guarantee that for this session, we don't have more than one operation
+        // running at the same time
+        operationMutex.acquire();
+        
+        // Create the BindRequest
+        LdapDN dn = new LdapDN( name );
+        
+        BindRequest bindRequest = new BindRequest();
+        bindRequest.setName( dn );
+        bindRequest.setVersion( LDAP_V3 );
+        
+        // Create the Simple authentication
+        SimpleAuthentication simpleAuth = new SimpleAuthentication();
+        simpleAuth.setSimple( credentials );
+
+        bindRequest.setAuthentication( simpleAuth );
+        
+        // Encode the request
+        LdapMessage message = new LdapMessage();
+        message.setMessageId( messageId++ );
+        message.setProtocolOP( bindRequest );
+        
+        LOG.debug( "-----------------------------------------------------------------" );
+        LOG.debug( "Sending request \n{}", message );
+
+        // Send the request to the server
+        ldapSession.write( message );
+
+        // Read the response, waiting for it if not available immediately
+        LdapMessage response = responseQueue.poll( timeOut, TimeUnit.MILLISECONDS );
+    
+        // Check that we didn't get out because of a timeout
+        if ( response == null )
+        {
+            // We didn't received anything : this is an error
+            operationMutex.release();
+            LOG.warn( "Cannot bind to the server, timeout" );
+            throw new Exception( "TimeOut occured" );
+        }
+        
+        operationMutex.release();
+        
+        // Everything is fine, return the response
+        LdapResponse resp = response.getBindResponse();
+        
+        LOG.debug( "BindRequest successful : {}", resp );
+        
+        return resp;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void unBind() throws Exception
+    {
+        // If the session has not been establish, or is closed, we get out immediately
+        checkSession();
+        
+        // Guarantee that for this session, we don't have more than one operation
+        // running at the same time
+        operationMutex.acquire();
+        
+        // Create the UnBindRequest
+        UnBindRequest unBindRequest = new UnBindRequest();
+        
+        // Encode the request
+        LdapMessage message = new LdapMessage();
+        message.setMessageId( messageId );
+        message.setProtocolOP( unBindRequest );
+        
+        LOG.debug( "-----------------------------------------------------------------" );
+        LOG.debug( "Sending request \n{}", message );
+        
+        // Send the request to the server
+        ldapSession.write( message );
+
+        // We don't have to wait for a response. Reset the messageId counter to 0
+        messageId = 0;
+        
+        // We also have to reset the response queue
+        responseQueue.clear();
+        
+        operationMutex.release();
+    }
+    
+
+    /**
+     * {@inheritDoc}
+     */
+    public void search( String baseObject, String filterString ) throws Exception
+    {
+        // If the session has not been establish, or is closed, we get out immediately
+        checkSession();
+        
+        LdapDN baseDN = null;
+        Filter filter = null;
+        
+        // Check that the baseObject is not null or empty, 
+        // and is a valid DN
+        if ( StringTools.isEmpty( baseObject ) )
+        {
+            throw new Exception( "Cannot search on RootDSE when the scope is not BASE" );
+        }
+        
+        try
+        {
+            baseDN = new LdapDN( baseObject );
+        }
+        catch ( InvalidNameException ine )
+        {
+            throw new Exception( "The baseObject is not a valid DN" );
+        }
+        
+        // Check that the filter is valid
+        try
+        {
+            ExprNode filterNode = FilterParser.parse( filterString );
+            
+            filter = TwixTransformer.transformFilter( filterNode );
+        }
+        catch ( ParseException pe )
+        {
+            throw new Exception( "The filter is invalid" );
+        }
+        
+        SearchRequest searchRequest = new SearchRequest();
+        searchRequest.setBaseObject( baseDN );
+        searchRequest.setFilter( filter );
+        
+        // Fill the default values
+        searchRequest.setSizeLimit( 0 );
+        searchRequest.setTimeLimit( 0 );
+        searchRequest.setDerefAliases( LdapConstants.DEREF_ALWAYS );
+        searchRequest.setScope( SearchScope.ONELEVEL );
+        searchRequest.setTypesOnly( false );
+        searchRequest.addAttribute( SchemaConstants.ALL_USER_ATTRIBUTES );
+
+        search( searchRequest );
+    }
+    
+
+    /**
+     * {@inheritDoc}
+     */
+    public void search( SearchRequest searchRequest ) throws Exception
+    {
+        // First check the session
+        checkSession();
+        
+        // Guarantee that for this session, we don't have more than one operation
+        // running at the same time
+        operationMutex.acquire();
+        
+        // Encode the request
+        LdapMessage message = new LdapMessage();
+        message.setMessageId( messageId++ );
+        message.setProtocolOP( searchRequest );
+        message.addControl( searchRequest.getCurrentControl() );
+        
+        //LOG.debug( "-----------------------------------------------------------------" );
+        //LOG.debug( "Sending request \n{}", message );
+    
+        // Loop and get all the responses
+        // Send the request to the server
+        ldapSession.write( message );
+
+        operationMutex.release();
+//        int i = 0;
+//        
+//        List<SearchResultEntry> searchResults = new ArrayList<SearchResultEntry>();
+        
+        // Now wait for the responses
+        // Loop until we got all the responses
+        
+/*        do
+        {
+            // If we get out before the timeout, check that the response 
+            // is there, and get it
+            LdapMessage response = responseQueue.poll( timeOut, TimeUnit.MILLISECONDS );
+            
+            if ( response == null )
+            {
+                // No response, get out
+                operationMutex.release();
+                
+                // We didn't received anything : this is an error
+                throw new Exception( "TimeOut occured" );
+            }
+            
+            i++;
+
+            // Print the response
+//            System.out.println( "Result[" + i + "]" + response );
+            
+            if( response.getMessageType() == LdapConstants.INTERMEDIATE_RESPONSE )
+            {
+                consumer.handleSyncInfo( response.getIntermediateResponse().getResponseValue() );
+            }
+            
+            if ( response.getMessageType() == LdapConstants.SEARCH_RESULT_DONE )
+            {
+                SearchResultDone resDone = response.getSearchResultDone();
+                resDone.addControl( response.getCurrentControl() );
+                
+                operationMutex.release();
+                consumer.handleSearchDone( resDone );
+                
+                return;
+            }
+       
+            if( response.getMessageType() == LdapConstants.SEARCH_RESULT_ENTRY )
+            {
+                SearchResultEntry sre = response.getSearchResultEntry();
+                sre.addControl( response.getCurrentControl() );
+                consumer.handleSearchResult( sre );
+            }
+            
+            if( response.getMessageType() == LdapConstants.SEARCH_RESULT_REFERENCE )
+            {
+                SearchResultReference searchRef = response.getSearchResultReference();
+                searchRef.addControl( response.getCurrentControl() );
+                
+                consumer.handleSearchReference( searchRef );
+            }
+        }
+        while ( true );
+*/    }
+
+    //--------------------------- Helper methods ---------------------------//
+    /**
+     * Check if the connection is valid : created and connected
+     *
+     * @return <code>true</code> if the session is valid.
+     */
+    private boolean isSessionValid()
+    {
+        return ( ldapSession != null ) && ldapSession.isConnected();
+    }
+
+    
+    /**
+     * Check that a session is valid, ie we can send requests to the
+     * server
+     *
+     * @throws Exception If the session is not valid
+     */
+    private void checkSession() throws Exception
+    {
+        if ( !isSessionValid() )
+        {
+            throw new Exception( "Cannot connect on the server, the connection is invalid" );
+        }
+    }
+    
+    /**
+     * Return the response stored into the current session.
+     *
+     * @return The last request response
+     */
+    public LdapMessage getResponse()
+    {
+        return (LdapMessage)ldapSession.getAttribute( LDAP_RESPONSE );
+    }
+
+    
+    //----------------- ProtocolHandler implemented methods -----------------//
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void sessionCreated( IoSession session ) throws Exception 
+    {
+        LOG.debug( "-------> New session created <-------" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void sessionOpened( IoSession session ) throws Exception 
+    {
+        LOG.debug( "-------> Session opened <-------" );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void sessionClosed(IoSession session) throws Exception 
+    {
+        LOG.debug( "-------> Session Closed <-------" );
+        //consumer.handleSessionClosed();
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void messageReceived( IoSession session, Object message) throws Exception 
+    {
+        // Feed the response and store it into the session
+        LdapMessage response = (LdapMessage)message;
+
+        LOG.debug( "-------> {} Message received <-------", response.getMessageTypeName() );
+        
+        switch( response.getMessageType() )
+        {
+            case LdapConstants.BIND_RESPONSE: 
+                       
+                       responseQueue.add( response ); // Store the response into the responseQueue
+                       break;
+
+            case LdapConstants.INTERMEDIATE_RESPONSE:
+            
+                       //consumer.handleSyncInfo( response.getIntermediateResponse().getResponseValue() );
+                       break;
+            
+            case LdapConstants.SEARCH_RESULT_DONE:
+            
+                       SearchResultDone resDone = response.getSearchResultDone();
+                       resDone.addControl( response.getCurrentControl() );
+                       //consumer.handleSearchDone( resDone );
+                       break;
+            
+            case LdapConstants.SEARCH_RESULT_ENTRY:
+            
+                       SearchResultEntry sre = response.getSearchResultEntry();
+                       sre.addControl( response.getCurrentControl() );
+                       //consumer.handleSearchResult( sre );
+                       break;
+                       
+            case LdapConstants.SEARCH_RESULT_REFERENCE:
+            
+                       SearchResultReference searchRef = response.getSearchResultReference();
+                       searchRef.addControl( response.getCurrentControl() );
+                       //consumer.handleSearchReference( searchRef );
+                       break;
+                       
+             default: LOG.error( "~~~~~~~~~~~~~~~~~~~~~ Unknown message type {} ~~~~~~~~~~~~~~~~~~~~~", response.getMessageTypeName() );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addConsumer( SearchListener listener )
+    {
+        this.listener = listener;
+    }
+}

Added: directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/SearchListener.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/SearchListener.java?rev=760055&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/SearchListener.java (added)
+++ directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/SearchListener.java Mon Mar 30 17:19:41 2009
@@ -0,0 +1,46 @@
+/*
+ *  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.syncrepl;
+
+import org.apache.directory.shared.ldap.entry.Entry;
+
+/**
+ * A listener used for the syncrepl search.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface SearchListener
+{
+    /**
+     * A message sent when an entry has been found as the result of a search request.
+     *
+     * @return The found Entry
+     */
+    Entry entryFound();
+    
+    /**
+     * A message called when the search is terminated
+     *
+     * @return true when the search is done
+     */
+    boolean searchDone();
+    
+}

Added: directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolCodecFactory.java?rev=760055&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolCodecFactory.java (added)
+++ directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolCodecFactory.java Mon Mar 30 17:19:41 2009
@@ -0,0 +1,73 @@
+/*
+ *  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.syncrepl.protocol;
+
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+
+/**
+ * 
+ * The factory used to create the LDAP encoder and decoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapProtocolCodecFactory implements ProtocolCodecFactory
+{
+    /** The Ldap encoder */
+    private ProtocolEncoder ldapEncoder;
+    
+    /** The Ldap decoder */
+    private ProtocolDecoder ldapDecoder;
+
+    
+    /**
+     * 
+     * Creates a new instance of LdapProtocolCodecFactory. It
+     * creates the encoded an decoder instances.
+     *
+     */
+    public LdapProtocolCodecFactory()
+    {
+        // Create the encoder.
+        ldapEncoder = new LdapProtocolEncoder();
+        ldapDecoder = new LdapProtocolDecoder();
+    }
+    
+    
+    /**
+     * Get the Ldap decoder. 
+     */
+    public ProtocolDecoder getDecoder( IoSession session ) throws Exception
+    {
+        return ldapDecoder;
+    }
+    
+
+    /**
+     * Get the Ldap encoder.
+     */
+    public ProtocolEncoder getEncoder( IoSession session ) throws Exception
+    {
+        return ldapEncoder;
+    }    
+}

Added: directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolDecoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolDecoder.java?rev=760055&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolDecoder.java (added)
+++ directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolDecoder.java Mon Mar 30 17:19:41 2009
@@ -0,0 +1,137 @@
+/*
+ *  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.syncrepl.protocol;
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.shared.asn1.ber.Asn1Decoder;
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.tlv.TLVStateEnum;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapDecoder;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * A LDAP message decoder. It is based on shared-ldap decoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapProtocolDecoder implements ProtocolDecoder
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( LdapProtocolDecoder.class );
+    
+    /** A speedup for logger */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+    /**
+     * Decode a Ldap request and write it to the remote server.
+     * 
+     * @param session The session containing the LdapMessageContainer
+     * @param buffer The ByteBuffer containing the incoming bytes to decode
+     * to a LDAP message
+     * @param out The callback we have to invoke when the message has been decoded 
+     */
+    public void decode( IoSession session, IoBuffer buffer, ProtocolDecoderOutput out ) throws Exception
+    {
+        // Allocate a LdapMessage Container
+        Asn1Decoder ldapDecoder = new LdapDecoder();
+        IAsn1Container ldapMessageContainer = (LdapMessageContainer)session.getAttribute( "LDAP-Container" );
+        ByteBuffer buf = buffer.buf();
+        int currentPos = 0;
+        
+        while ( buf.hasRemaining() )
+        {
+            try
+            {
+                ldapDecoder.decode( buf, ldapMessageContainer );
+    
+                if ( IS_DEBUG )
+                {
+                    LOG.debug( "Decoding the PDU : " );
+                    int pos = buf.position();
+                    
+                    byte[] b = new byte[pos-currentPos];
+                    
+                    System.arraycopy( buf.array(), currentPos, b, 0, pos-currentPos );
+                    currentPos = pos;
+                    System.out.println( "Received buffer : " + StringTools.dumpBytes( b ) );
+                }
+                
+                if ( ldapMessageContainer.getState() == TLVStateEnum.PDU_DECODED )
+                {
+                    // get back the decoded message
+                    LdapMessage message = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
+                    
+                    if ( IS_DEBUG )
+                    {
+                        LOG.debug( "Decoded LdapMessage : " + 
+                                ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage() );
+                        buf.mark();
+                    }
+    
+                    // Clean the container for the next decoding
+                    ( ( LdapMessageContainer ) ldapMessageContainer).clean();
+                    
+                    if( IS_DEBUG )
+                    {
+//                        LOG.debug( "######################Decoded message : " + message );
+//                        LOG.debug( "####################################################" );
+                    }
+                    
+                    // Send back the message
+                    out.write( message );
+                }
+            }
+            catch ( DecoderException de )
+            {
+                buf.clear();
+                ( ( LdapMessageContainer ) ldapMessageContainer).clean();
+                throw de;
+            }
+        }
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void finishDecode( IoSession session, ProtocolDecoderOutput out ) throws Exception
+    {
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose( IoSession session ) throws Exception
+    {
+    }
+}

Added: directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolEncoder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolEncoder.java?rev=760055&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolEncoder.java (added)
+++ directory/apacheds/branches/apacheds-replication/syncrepl/src.main.java/org/apache/directory/server/syncrepl/protocol/LdapProtocolEncoder.java Mon Mar 30 17:19:41 2009
@@ -0,0 +1,75 @@
+/*
+ *  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.syncrepl.protocol;
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.mina.core.buffer.IoBuffer;
+import org.apache.mina.core.session.IoSession;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+
+/**
+ * 
+ * A LDAP encoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LdapProtocolEncoder implements ProtocolEncoder
+{
+    /**
+     * Encode a Ldap request and write it to the remote server.
+     * 
+     * @param session The session containing the LdapMessageContainer
+     * @param request The LDAP message we have to encode to a Byte stream
+     * @param out The callback we have to invoke when the message has been encoded 
+     */
+    public void encode( IoSession session, Object request, ProtocolEncoderOutput out ) throws Exception
+    {
+        if ( request instanceof LdapMessage )
+        {
+            LdapMessage ldapRequest = (LdapMessage)request;
+            ByteBuffer bb = ldapRequest.encode( null );
+            bb.flip();
+            
+            IoBuffer buffer = IoBuffer.allocate( bb.limit(), false );
+            buffer.setAutoExpand( false );
+            buffer.put( bb );
+            buffer.flip();
+            
+            out.write( buffer );
+        }
+        else
+        {
+            throw new Exception();
+        }
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void dispose( IoSession session ) throws Exception
+    {
+        // Nothing to dispose
+    }
+}



Mime
View raw message