directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r582712 [1/3] - in /directory: apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/ apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ apacheds/branches/bigbang...
Date Mon, 08 Oct 2007 05:54:47 GMT
Author: akarasulu
Date: Sun Oct  7 22:54:38 2007
New Revision: 582712

URL: http://svn.apache.org/viewvc?rev=582712&view=rev
Log:
Cleaning up LDAP protocol provider and the codec

Added:
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAbandonHandler.java   (contents, props changed)
      - copied, changed from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAddHandler.java   (contents, props changed)
      - copied, changed from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java   (contents, props changed)
      - copied, changed from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultCompareHandler.java   (contents, props changed)
      - copied, changed from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultDeleteHandler.java   (contents, props changed)
      - copied, changed from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultExtendedHandler.java   (contents, props changed)
      - copied, changed from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyDnHandler.java   (contents, props changed)
      - copied, changed from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyHandler.java   (contents, props changed)
      - copied, changed from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java   (contents, props changed)
      - copied, changed from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultUnbindHandler.java   (contents, props changed)
      - copied, changed from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/spi/BinaryAttributeDetector.java
Modified:
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java
    directory/apacheds/branches/bigbang/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java
    directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
    directory/shared/branches/bigbang/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecDecoder.java
    directory/shared/branches/bigbang/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecEncoder.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixDecoder.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixProvider.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/MessageDecoder.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/MessageEncoder.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/message/spi/Provider.java

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/LdapProtocolProvider.java Sun Oct  7 22:54:38 2007
@@ -22,11 +22,14 @@
 
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.ldap.support.*;
+import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.asn1.codec.Asn1CodecDecoder;
 import org.apache.directory.shared.asn1.codec.Asn1CodecEncoder;
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.message.*;
 import org.apache.directory.shared.ldap.message.extended.NoticeOfDisconnect;
+import org.apache.directory.shared.ldap.message.spi.BinaryAttributeDetector;
+import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
@@ -36,10 +39,11 @@
 import org.apache.mina.filter.codec.ProtocolDecoder;
 import org.apache.mina.filter.codec.ProtocolEncoder;
 import org.apache.mina.handler.demux.DemuxingIoHandler;
-import org.apache.mina.handler.demux.MessageHandler;
 import org.apache.mina.util.SessionLog;
 
 import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.ldap.Control;
 import java.util.*;
 
 
@@ -52,74 +56,28 @@
  */
 public class LdapProtocolProvider
 {
-    //TM private static long cumul = 0L;
-    //TM private static long count = 0;
-    //TM private static Object lock = new Object();
-
     /** the constant service name of this ldap protocol provider **/
     public static final String SERVICE_NAME = "ldap";
-    /** a map of the default request object class name to the handler class name */
-    private static final Map<String,Class> DEFAULT_HANDLERS;
-    /** a set of supported controls */
-    private static final Set SUPPORTED_CONTROLS;
-    /** configuration for the LDAP protocol provider **/
-    private LdapConfiguration cfg;
-    private DirectoryService directoryService;
-
-    static
-    {
-        Map<String, Class> map = new HashMap<String, Class>();
-
-        /*
-         * Note:
-         *
-         * By mapping the implementation class in addition to the interface
-         * for the request type to the handler Class we're bypassing the need
-         * to iterate through Interface[] looking for handlers.  For the default
-         * cases here the name of the request object's class will look up
-         * immediately.
-         */
-
-        map.put( AbandonRequest.class.getName(), AbandonHandler.class );
-        map.put( AbandonRequestImpl.class.getName(), AbandonHandler.class );
-
-        map.put( AddRequest.class.getName(), AddHandler.class );
-        map.put( AddRequestImpl.class.getName(), AddHandler.class );
-
-        map.put( BindRequest.class.getName(), BindHandler.class );
-        map.put( BindRequestImpl.class.getName(), BindHandler.class );
 
-        map.put( CompareRequest.class.getName(), CompareHandler.class );
-        map.put( CompareRequestImpl.class.getName(), CompareHandler.class );
-
-        map.put( DeleteRequest.class.getName(), DeleteHandler.class );
-        map.put( DeleteRequestImpl.class.getName(), DeleteHandler.class );
-
-        map.put( ExtendedRequest.class.getName(), ExtendedHandler.class );
-        map.put( ExtendedRequestImpl.class.getName(), ExtendedHandler.class );
-
-        map.put( ModifyRequest.class.getName(), ModifyHandler.class );
-        map.put( ModifyRequestImpl.class.getName(), ModifyHandler.class );
-
-        map.put( ModifyDnRequest.class.getName(), ModifyDnHandler.class );
-        map.put( ModifyDnRequestImpl.class.getName(), ModifyDnHandler.class );
+    /** a set of supported controls */
+    private Set<String> supportedControls;
 
-        map.put( SearchRequest.class.getName(), SearchHandler.class );
-        map.put( SearchRequestImpl.class.getName(), SearchHandler.class );
+    /** configuration for the LDAP protocol provider **/
+    private LdapConfiguration ldapConfiguration;
 
-        map.put( UnbindRequest.class.getName(), UnbindHandler.class );
-        map.put( UnbindRequestImpl.class.getName(), UnbindHandler.class );
+    private DirectoryService directoryService;
 
-        DEFAULT_HANDLERS = Collections.unmodifiableMap( map );
+    private AbandonHandler abandonHandler;
+    private AddHandler addHandler;
+    private BindHandler bindHandler;
+    private CompareHandler compareHandler;
+    private DeleteHandler deleteHandler;
+    private ExtendedHandler extendedHandler;
+    private ModifyHandler modifyHandler;
+    private ModifyDnHandler modifyDnHandler;
+    private SearchHandler searchHandler;
+    private UnbindHandler unbindHandler;
 
-        Set<Object> set = new HashSet<Object>();
-        set.add( PersistentSearchControl.CONTROL_OID );
-        set.add( EntryChangeControl.CONTROL_OID );
-        set.add( SubentriesControl.CONTROL_OID );
-        set.add( ManageDsaITControl.CONTROL_OID );
-        set.add( CascadeControl.CONTROL_OID );
-        SUPPORTED_CONTROLS = Collections.unmodifiableSet( set );
-    }
 
     /** the underlying provider codec factory */
     private final ProtocolCodecFactory codecFactory;
@@ -132,24 +90,23 @@
     // C O N S T R U C T O R S
     // ------------------------------------------------------------------------
 
+
+
     /**
      * Creates a MINA LDAP protocol provider.
      *
-     * @param env environment properties used to configure the provider and
      * underlying codec providers if any
      * @param cfg the ldap configuration
      * @param directoryService the directory service core
      *
      * @throws LdapNamingException if there are problems setting up the protocol provider
      */
-    public LdapProtocolProvider( DirectoryService directoryService, LdapConfiguration cfg,
-                                 Hashtable<String,Object> env ) throws LdapNamingException
+    public LdapProtocolProvider( DirectoryService directoryService, LdapConfiguration cfg ) throws LdapNamingException
     {
-        this.cfg = cfg;
+        this.ldapConfiguration = cfg;
         this.directoryService = directoryService;
 
-        Hashtable<String,Object> copy = new Hashtable<String,Object>( env.size() );
-        copy.putAll( env );
+        Hashtable<String,Object> copy = new Hashtable<String,Object>();
         copy.put( Context.PROVIDER_URL, "" );
         copy.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.directory.server.core.jndi.CoreContextFactory" );
         copy.put( DirectoryService.JNDI_KEY, directoryService );
@@ -157,56 +114,25 @@
         SessionRegistry.releaseSingleton();
         new SessionRegistry( cfg, copy );
 
-        for ( String type : DEFAULT_HANDLERS.keySet() )
-        {
-            MessageHandler handler;
-            Class clazz = null;
-
-            if ( copy.containsKey( type ) )
-            {
-                try
-                {
-                    clazz = Class.forName( ( String ) copy.get( type ) );
-                }
-                catch ( ClassNotFoundException e )
-                {
-                    LdapNamingException lne;
-                    String msg = "failed to load class " + clazz;
-                    msg += " for processing " + type + " objects.";
-                    lne = new LdapNamingException( msg, ResultCodeEnum.OTHER );
-                    lne.setRootCause( e );
-                    throw lne;
-                }
-            }
-            else
-            {
-                clazz = ( Class ) DEFAULT_HANDLERS.get( type );
-            }
-
-            try
-            {
-                Class typeClass = Class.forName( type );
-                handler = ( MessageHandler ) clazz.newInstance();
-
-                if ( handler instanceof BindHandler )
-                {
-                    ( ( BindHandler ) handler ).setDirectoryService( directoryService );
-                }
-
-                this.handler.addMessageHandler( typeClass, handler );
-            }
-            catch ( Exception e )
-            {
-                LdapNamingException lne;
-                String msg = "failed to create handler instance of " + clazz;
-                msg += " for processing " + type + " objects.";
-                lne = new LdapNamingException( msg, ResultCodeEnum.OTHER );
-                lne.setRootCause( e );
-                throw lne;
-            }
-        }
+        this.supportedControls = new HashSet<String>();
+        this.supportedControls.add( PersistentSearchControl.CONTROL_OID );
+        this.supportedControls.add( EntryChangeControl.CONTROL_OID );
+        this.supportedControls.add( SubentriesControl.CONTROL_OID );
+        this.supportedControls.add( ManageDsaITControl.CONTROL_OID );
+        this.supportedControls.add( CascadeControl.CONTROL_OID );
+
+        setAbandonHandler( new DefaultAbandonHandler() );
+        setAddHandler( new DefaultAddHandler() );
+        setBindHandler( new DefaultBindHandler() );
+        setCompareHandler( new DefaultCompareHandler() );
+        setDeleteHandler( new DefaultDeleteHandler() );
+        setExtendedHandler( new DefaultExtendedHandler() );
+        setModifyHandler( new DefaultModifyHandler() );
+        setModifyDnHandler( new DefaultModifyDnHandler() );
+        setSearchHandler( new DefaultSearchHandler() );
+        setUnbindHandler( new DefaultUnbindHandler() );
 
-        this.codecFactory = new ProtocolCodecFactoryImpl( copy );
+        this.codecFactory = new ProtocolCodecFactoryImpl( directoryService );
     }
 
 
@@ -214,6 +140,7 @@
     // ProtocolProvider Methods
     // ------------------------------------------------------------------------
 
+
     public String getName()
     {
         return SERVICE_NAME;
@@ -235,98 +162,275 @@
     /**
      * Registeres the specified {@link ExtendedOperationHandler} to this
      * protocol provider to provide a specific LDAP extended operation.
+     *
+     * @param eoh an extended operation handler
      */
     public void addExtendedOperationHandler( ExtendedOperationHandler eoh )
     {
-        ExtendedHandler eh = ( ExtendedHandler ) handler.getMessageHandler( ExtendedRequest.class );
-        eh.addHandler( eoh );
-        eh = ( ExtendedHandler ) handler.getMessageHandler( ExtendedRequestImpl.class );
-        eh.addHandler( eoh );
+        extendedHandler.addHandler( eoh );
     }
 
 
     /**
      * Deregisteres an {@link ExtendedOperationHandler} with the specified <tt>oid</tt>
      * from this protocol provider.
+     *
+     * @param oid the numeric identifier for the extended operation associated with
+     * the handler to remove
      */
     public void removeExtendedOperationHandler( String oid )
     {
-        ExtendedHandler eh = ( ExtendedHandler ) handler.getMessageHandler( ExtendedRequest.class );
-        eh.removeHandler( oid );
-        eh = ( ExtendedHandler ) handler.getMessageHandler( ExtendedRequestImpl.class );
-        eh.removeHandler( oid );
+        extendedHandler.removeHandler( oid );
     }
 
 
     /**
      * Returns an {@link ExtendedOperationHandler} with the specified <tt>oid</tt>
      * which is registered to this protocol provider.
+     *
+     * @param oid the oid of the extended request of associated with the extended
+     * request handler
+     * @return the exnteded operation handler
      */
     public ExtendedOperationHandler getExtendedOperationHandler( String oid )
     {
-        ExtendedHandler eh = ( ExtendedHandler ) handler.getMessageHandler( ExtendedRequest.class );
-        return eh.getHandler( oid );
+        return extendedHandler.getHandler( oid );
     }
 
 
     /**
      * Returns a {@link Map} of all registered OID-{@link ExtendedOperationHandler}
      * pairs.
+     *
+     * @return map of all extended operation handlers
      */
-    public Map getExtendedOperationHandlerMap()
+    public Map<String,ExtendedOperationHandler> getExtendedOperationHandlerMap()
     {
-        ExtendedHandler eh = ( ExtendedHandler ) handler.getMessageHandler( ExtendedRequest.class );
-        return eh.getHandlerMap();
+        return extendedHandler.getHandlerMap();
     }
 
-    /**
-     * A snickers based BER Decoder factory.
-     */
-    private static final class ProtocolCodecFactoryImpl implements ProtocolCodecFactory
+
+    public DirectoryService getDirectoryService()
     {
-        final Hashtable env;
+        return directoryService;
+    }
 
 
-        public ProtocolCodecFactoryImpl()
+    public void setDirectoryService( DirectoryService directoryService )
+    {
+        this.directoryService = directoryService;
+
+        if ( bindHandler != null )
         {
-            this.env = null;
+            this.bindHandler.setDirectoryService( directoryService );
         }
+    }
+
+
+    public Set<String> getSupportedControls()
+    {
+        return supportedControls;
+    }
+
+
+    public void setSupportedControls( Set<String> supportedControls )
+    {
+        this.supportedControls = supportedControls;
+    }
+
+
+    public AbandonHandler getAbandonHandler()
+    {
+        return abandonHandler;
+    }
+
+
+    public void setAbandonHandler( AbandonHandler abandonHandler )
+    {
+        this.handler.removeMessageHandler( AbandonRequest.class );
+        this.abandonHandler = abandonHandler;
+        //noinspection unchecked
+        this.handler.addMessageHandler( AbandonRequest.class, this.abandonHandler );
+    }
+
+
+    public AddHandler getAddHandler()
+    {
+        return addHandler;
+    }
+
+
+    public void setAddHandler( AddHandler addHandler )
+    {
+        this.handler.removeMessageHandler( AddRequest.class );
+        this.addHandler = addHandler;
+        //noinspection unchecked
+        this.handler.addMessageHandler( AddRequest.class, this.addHandler );
+    }
 
 
-        ProtocolCodecFactoryImpl(Hashtable env)
+    public BindHandler getBindHandler()
+    {
+        return bindHandler;
+    }
+
+
+    public void setBindHandler( BindHandler bindHandler )
+    {
+        this.handler.removeMessageHandler( BindRequest.class );
+        this.bindHandler = bindHandler;
+        if ( directoryService != null )
+        {
+            this.bindHandler.setDirectoryService( directoryService );
+        }
+        //noinspection unchecked
+        this.handler.addMessageHandler( BindRequest.class, this.bindHandler );
+    }
+
+
+    public CompareHandler getCompareHandler()
+    {
+        return compareHandler;
+    }
+
+
+    public void setCompareHandler( CompareHandler compareHandler )
+    {
+        this.handler.removeMessageHandler( CompareRequest.class );
+        this.compareHandler = compareHandler;
+        //noinspection unchecked
+        this.handler.addMessageHandler( CompareRequest.class, this.compareHandler );
+    }
+
+
+    public DeleteHandler getDeleteHandler()
+    {
+        return deleteHandler;
+    }
+
+
+    public void setDeleteHandler( DeleteHandler deleteHandler )
+    {
+        this.handler.removeMessageHandler( DeleteRequest.class );
+        this.deleteHandler = deleteHandler;
+        //noinspection unchecked
+        this.handler.addMessageHandler( DeleteRequest.class, this.deleteHandler );
+    }
+
+
+    public ExtendedHandler getExtendedHandler()
+    {
+        return extendedHandler;
+    }
+
+
+    public void setExtendedHandler( ExtendedHandler extendedHandler )
+    {
+        this.handler.removeMessageHandler( ExtendedRequest.class );
+        this.extendedHandler = extendedHandler;
+        //noinspection unchecked
+        this.handler.addMessageHandler( ExtendedRequest.class, this.extendedHandler );
+    }
+
+
+    public ModifyHandler getModifyHandler()
+    {
+        return modifyHandler;
+    }
+
+
+    public void setModifyHandler( ModifyHandler modifyHandler )
+    {
+        this.handler.removeMessageHandler( ModifyRequest.class );
+        this.modifyHandler = modifyHandler;
+        //noinspection unchecked
+        this.handler.addMessageHandler( ModifyRequest.class, this.modifyHandler );
+    }
+
+
+    public ModifyDnHandler getModifyDnHandler()
+    {
+        return modifyDnHandler;
+    }
+
+
+    public void setModifyDnHandler( ModifyDnHandler modifyDnHandler )
+    {
+        this.handler.removeMessageHandler( ModifyDnRequest.class );
+        this.modifyDnHandler = modifyDnHandler;
+        //noinspection unchecked
+        this.handler.addMessageHandler( ModifyDnRequest.class, this.modifyDnHandler );
+    }
+
+
+    public SearchHandler getSearchHandler()
+    {
+        return searchHandler;
+    }
+
+
+    public void setSearchHandler( SearchHandler searchHandler )
+    {
+        this.handler.removeMessageHandler( SearchRequest.class );
+        this.searchHandler = searchHandler;
+        //noinspection unchecked
+        this.handler.addMessageHandler( SearchRequest.class, this.searchHandler );
+    }
+
+
+    public UnbindHandler getUnbindHandler()
+    {
+        return unbindHandler;
+    }
+
+
+    public void setUnbindHandler( UnbindHandler unbindHandler )
+    {
+        this.handler.removeMessageHandler( UnbindRequest.class );
+        this.unbindHandler = unbindHandler;
+        //noinspection unchecked
+        this.handler.addMessageHandler( UnbindRequest.class, this.unbindHandler );
+    }
+
+
+    /**
+     * A snickers based BER Decoder factory.
+     */
+    private static final class ProtocolCodecFactoryImpl implements ProtocolCodecFactory
+    {
+        final DirectoryService directoryService;
+
+
+        public ProtocolCodecFactoryImpl( DirectoryService directoryService )
         {
-            this.env = env;
+            this.directoryService = directoryService;
         }
 
 
         public ProtocolEncoder getEncoder()
         {
-            return new Asn1CodecEncoder( new MessageEncoder( env ) );
+            return new Asn1CodecEncoder( new MessageEncoder() );
         }
 
 
         public ProtocolDecoder getDecoder()
         {
-            //TM long t0 = System.nanoTime();
-            
-            ProtocolDecoder decoder = new Asn1CodecDecoder( new MessageDecoder( env ) );
-            
-            //TM long t1 = System.nanoTime();
-            //TM System.out.println( "New Asn1Decoder cost : " + (t1-t0) );
-
-            //TM synchronized (lock)
-            //TM {
-            //TM     cumul += (t1 - t0);
-            //TM     count++;
-            //TM    
-            //TM     if ( count % 1000L == 0)
-            //TM     {
-            //TM         System.out.println( "New Asn1Decoder cost : " + (cumul/count) );
-            //TM         cumul = 0L;
-            //TM     }
-            //TM }
-
-            return decoder;
+            return new Asn1CodecDecoder( new MessageDecoder( new BinaryAttributeDetector()
+            {
+                public boolean isBinary( String id )
+                {
+                    AttributeTypeRegistry attrRegistry = directoryService.getRegistries().getAttributeTypeRegistry();
+                    try
+                    {
+                        AttributeType type = attrRegistry.lookup( id );
+                        return ! type.getSyntax().isHumanReadable();
+                    }
+                    catch ( NamingException e )
+                    {
+                        return false;
+                    }
+                }
+            }) );
         }
     }
 
@@ -334,8 +438,7 @@
     {
         public void sessionCreated( IoSession session ) throws Exception
         {
-            session.setAttribute( LdapConfiguration.class.toString(), cfg );
-
+            session.setAttribute( LdapConfiguration.class.toString(), ldapConfiguration );
             IoFilterChain filters = session.getFilterChain();
             filters.addLast( "codec", new ProtocolCodecFilter( codecFactory ) );
         }
@@ -378,11 +481,10 @@
             if ( ( ( Request ) message ).getControls().size() > 0 && message instanceof ResultResponseRequest )
             {
                 ResultResponseRequest req = ( ResultResponseRequest ) message;
-                Iterator controls = req.getControls().values().iterator();
-                while ( controls.hasNext() )
+                for ( Control control1 : req.getControls().values() )
                 {
-                    MutableControl control = ( MutableControl ) controls.next();
-                    if ( control.isCritical() && !SUPPORTED_CONTROLS.contains( control.getID() ) )
+                    MutableControl control = ( MutableControl ) control1;
+                    if ( control.isCritical() && !supportedControls.contains( control.getID() ) )
                     {
                         ResultResponse resp = req.getResultResponse();
                         resp.getLdapResult().setErrorMessage( "Unsupport critical control: " + control.getID() );

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java Sun Oct  7 22:54:38 2007
@@ -20,14 +20,9 @@
 package org.apache.directory.server.ldap.support;
 
 
-import org.apache.directory.server.ldap.SessionRegistry;
 import org.apache.directory.shared.ldap.message.AbandonRequest;
-import org.apache.directory.shared.ldap.message.AbandonableRequest;
-import org.apache.directory.shared.ldap.message.Request;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -36,56 +31,13 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class AbandonHandler implements MessageHandler
+public abstract class AbandonHandler implements MessageHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( AbandonHandler.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
-
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public final void messageReceived( IoSession session, Object request ) throws Exception
     {
-        AbandonRequest req = ( AbandonRequest ) request;
-        int abandonedId = req.getAbandoned();
-
-        if ( abandonedId < 0 )
-        {
-            return;
-        }
-
-        Request abandonedRequest = SessionRegistry.getSingleton().getOutstandingRequest( session, abandonedId );
-
-        if ( abandonedRequest == null )
-        {
-            if ( log.isWarnEnabled() )
-            {
-                log.warn( "Got abandon request from client " + session + " but request must have already "
-                    + "terminated.  Abandon request " + req + " had no effect." );
-            }
-            return;
-        }
+        abandonMessageReceived( session, ( AbandonRequest ) request );
+    }
 
-        if ( abandonedRequest instanceof AbandonableRequest )
-        {
-            log
-                .warn( "Abandon, Bind, Unbind, and StartTLS operations cannot be abandoned.  Abandon request will be ignored." );
-        }
 
-        ( ( AbandonableRequest ) abandonedRequest ).abandon();
-        if ( SessionRegistry.getSingleton().removeOutstandingRequest( session, abandonedId ) == null )
-        {
-            if ( log.isWarnEnabled() )
-            {
-                log.warn( "Got abandon request from client " + session + " but request must have already "
-                    + "terminated." );
-            }
-        }
-        else
-        {
-            if ( IS_DEBUG )
-            {
-                log.debug( "Abandoned request:  ", req );
-            }
-        }
-    }
+    protected abstract void abandonMessageReceived( IoSession session, AbandonRequest abandonRequest ) throws Exception;
 }

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java Sun Oct  7 22:54:38 2007
@@ -20,27 +20,11 @@
 package org.apache.directory.server.ldap.support;
 
 
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.ReferralException;
-import javax.naming.ldap.LdapContext;
-
-import org.apache.directory.server.ldap.SessionRegistry;
-import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.AddRequest;
-import org.apache.directory.shared.ldap.message.LdapResult;
-import org.apache.directory.shared.ldap.message.ManageDsaITControl;
-import org.apache.directory.shared.ldap.message.ReferralImpl;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
 
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 
 /**
  * A single reply handler for {@link org.apache.directory.shared.ldap.message.AddRequest}s.
@@ -48,89 +32,13 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class AddHandler extends AbstractLdapHandler implements MessageHandler
+public abstract class AddHandler extends AbstractLdapHandler implements MessageHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( AddHandler.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
-
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public final void messageReceived( IoSession session, Object request ) throws Exception
     {
-        AddRequest req = ( AddRequest ) request;
-        LdapResult result = req.getResultResponse().getLdapResult();
-
-        if ( IS_DEBUG )
-        {
-            log.debug( "Received an Add message:  {}", req.toString() );
-        }
-
-        try
-        {
-            LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
-            
-            if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
-            {
-                ctx.addToEnvironment( Context.REFERRAL, "ignore" );
-            }
-            else
-            {
-                ctx.addToEnvironment( Context.REFERRAL, "throw" );
-            }
-            
-            // Inject controls into the context
-            setRequestControls( ctx, req );
-            ctx.createSubcontext( req.getEntry(), req.getAttributes() );
-            result.setResultCode( ResultCodeEnum.SUCCESS );
-            req.getResultResponse().addAll( ctx.getResponseControls() );
-            session.write( req.getResultResponse() );
-        }
-        catch ( ReferralException e )
-        {
-            ReferralImpl refs = new ReferralImpl();
-            result.setReferral( refs );
-            result.setResultCode( ResultCodeEnum.REFERRAL );
-            result.setErrorMessage( "Encountered referral attempting to handle add request." );
-            /* coming up null causing a NPE */
-            // result.setMatchedDn( e.getResolvedName().toString() );
-            do
-            {
-                refs.addLdapUrl( ( String ) e.getReferralInfo() );
-            }
-            while ( e.skipReferral() );
-            session.write( req.getResultResponse() );
-        }
-        catch ( NamingException e )
-        {
-            String msg = "failed to add entry " + req.getEntry() + ": " + e.getMessage();
-
-            if ( log.isDebugEnabled() )
-            {
-                msg += ":\n" + ExceptionUtils.getStackTrace( e );
-            }
-
-            ResultCodeEnum code;
-
-            if ( e instanceof LdapException )
-            {
-                code = ( ( LdapException ) e ).getResultCode();
-            }
-            else
-            {
-                code = ResultCodeEnum.getBestEstimate( e, req.getType() );
-            }
-
-            result.setResultCode( code );
-            result.setErrorMessage( msg );
+        addMessageReceived( session, ( AddRequest ) request );
+    }
 
-            if ( ( e.getResolvedName() != null )
-                && ( ( code == ResultCodeEnum.NO_SUCH_OBJECT ) || ( code == ResultCodeEnum.ALIAS_PROBLEM )
-                    || ( code == ResultCodeEnum.INVALID_DN_SYNTAX ) || ( code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM ) ) )
-            {
-                result.setMatchedDn( (LdapDN)e.getResolvedName() );
-            }
 
-            session.write( req.getResultResponse() );
-        }
-    }
+    protected abstract void addMessageReceived( IoSession session, AddRequest req ) throws Exception;
 }

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java Sun Oct  7 22:54:38 2007
@@ -21,27 +21,9 @@
 
 
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.jndi.ServerLdapContext;
-import org.apache.directory.server.ldap.LdapConfiguration;
-import org.apache.directory.server.ldap.SessionRegistry;
-import org.apache.directory.server.ldap.support.bind.BindHandlerChain;
-import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.*;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.chain.IoHandlerCommand;
 import org.apache.mina.handler.demux.MessageHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.ldap.InitialLdapContext;
-import javax.naming.ldap.LdapContext;
-import javax.naming.spi.InitialContextFactory;
-import java.util.Hashtable;
-import java.util.Set;
 
 
 /**
@@ -52,244 +34,17 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class BindHandler extends AbstractLdapHandler implements MessageHandler
+public abstract class BindHandler extends AbstractLdapHandler implements MessageHandler
 {
-    private static final Logger LOG = LoggerFactory.getLogger( BindHandler.class );
-
-    /** A class to handle SASL bind requests */
-    private IoHandlerCommand saslBindHandler;
-    
-    /** Definition of SIMPLE and STRONG authentication constants */
-    private static final String SIMPLE_AUTHENTICATION_LEVEL = "simple";
-        
-    //private static final String STRONG_AUTHENTICATION_LEVEL = "strong";
-    
-    /** An empty Contol array used to get back the controls if any */
-    private static final MutableControl[] EMPTY_CONTROL = new MutableControl[0];
-
-
-    /**
-     * Creates a new instance of BindHandler.
-     */                                                                      
-    public BindHandler()
-    {
-    }
-
-
-    public void setDirectoryService( DirectoryService directoryService )
-    {
-        saslBindHandler = new BindHandlerChain( directoryService );
-    }
-
-
-    /**
-     * Create an environment object and inject the Bond informations collected
-     * from the BindRequest message :
-     *  - the principal : the user's who issued the Bind request
-     *  - the credentials : principal's password, if auth level is 'simple'
-     *  - the authentication level : either 'simple' or 'strong'
-     *  - how to handle referral : either 'ignore' or 'throw'
-     */
-    private Hashtable<String, Object> getEnvironment( IoSession session, BindRequest bindRequest, String authenticationLevel )
-    {
-        LdapDN principal = bindRequest.getName();
-
-        /**
-         * For simple, this is a password.  For strong, this is unused.
-         */
-        Object credentials = bindRequest.getCredentials();
-
-        if ( LOG.isDebugEnabled() )
-        {
-            LOG.debug( "{} {}", Context.SECURITY_PRINCIPAL, principal );
-            LOG.debug( "{} {}", Context.SECURITY_CREDENTIALS, credentials );
-            LOG.debug( "{} {}", Context.SECURITY_AUTHENTICATION, authenticationLevel );
-        }
-
-        // clone the environment first then add the required security settings
-        Hashtable<String, Object> env = SessionRegistry.getSingleton().getEnvironmentByCopy();
-        
-        // Store the principal
-        env.put( Context.SECURITY_PRINCIPAL, principal );
-
-        // Store the credentials
-        if ( credentials != null )
-        {
-            env.put( Context.SECURITY_CREDENTIALS, credentials );
-        }
-
-        // Store the authentication level
-        env.put( Context.SECURITY_AUTHENTICATION, authenticationLevel );
-
-        // Store the referral handling method
-        if ( bindRequest.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
-        {
-            env.put( Context.REFERRAL, "ignore" );
-        }
-        else
-        {
-            env.put( Context.REFERRAL, "throw" );
-        }
+    public abstract void setDirectoryService( DirectoryService directoryService );
+    protected abstract void bindMessageReceived( IoSession session, BindRequest req ) throws Exception;
 
-        return env;
-    }
-
-    /**
-     * Create the Context associated with the BindRequest.
-     */
-    private LdapContext getLdapContext( IoSession session, BindRequest bindRequest, Hashtable<String, Object> env )
-    {
-        LdapResult result = bindRequest.getResultResponse().getLdapResult();
-        LdapContext ctx = null;
-
-        try
-        {
-            if ( env.containsKey( "server.use.factory.instance" ) )
-            {
-                InitialContextFactory factory = ( InitialContextFactory ) env.get( "server.use.factory.instance" );
-
-                if ( factory == null )
-                {
-                    LOG.error( "The property 'server.use.factory.instance'  was set in env but was null" );
-                    throw new NullPointerException( "server.use.factory.instance was set in env but was null" );
-                }
-
-                // Bind is a special case where we have to use the referral property to deal
-                ctx = ( LdapContext ) factory.getInitialContext( env );
-            }
-            else
-            {
-                MutableControl[] connCtls = bindRequest.getControls().values().toArray( EMPTY_CONTROL );
-                ctx = new InitialLdapContext( env, connCtls );
-            }
-        }
-        catch ( NamingException e )
-        {
-            ResultCodeEnum code;
-
-            if ( e instanceof LdapException )
-            {
-                code = ( ( LdapException ) e ).getResultCode();
-                result.setResultCode( code );
-            }
-            else
-            {
-                code = ResultCodeEnum.getBestEstimate( e, bindRequest.getType() );
-                result.setResultCode( code );
-            }
-
-            String msg = "Bind failed: " + e.getMessage();
-
-            if ( LOG.isDebugEnabled() )
-            {
-                msg += ":\n" + ExceptionUtils.getStackTrace( e );
-                msg += "\n\nBindRequest = \n" + bindRequest.toString();
-                LOG.debug(  msg  );
-            }
-
-            if ( ( e.getResolvedName() != null )
-                && ( ( code == ResultCodeEnum.NO_SUCH_OBJECT ) || ( code == ResultCodeEnum.ALIAS_PROBLEM )
-                    || ( code == ResultCodeEnum.INVALID_DN_SYNTAX ) || ( code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM ) ) )
-            {
-                result.setMatchedDn( ( LdapDN ) e.getResolvedName() );
-            }
-
-            result.setErrorMessage( msg );
-            session.write( bindRequest.getResultResponse() );
-            ctx = null;
-        }
-        
-        return ctx;
-    }
-
-    /**
-     * This method handle a 'simple' authentication. Of course, the 'SIMPLE' mechanism 
-     * must have been allowed in the configuration, otherwise an error is thrown.
-     * 
-     */
-    private void handleSimpleAuth( IoSession session, BindRequest bindRequest ) throws NamingException
-    {
-        LdapConfiguration config = ( LdapConfiguration ) session.getAttribute( LdapConfiguration.class.toString() );
-        
-        @SuppressWarnings( "unchecked" )
-        Set<String> supportedMechanisms = config.getSupportedMechanisms();
-        LdapResult bindResult = bindRequest.getResultResponse().getLdapResult();
-
-        // First, deal with Simple Authentication
-        // Guard clause:  Reject SIMPLE mechanism.
-        if ( !supportedMechanisms.contains( "SIMPLE" ) )
-        {
-            LOG.error( "Bind error : SIMPLE authentication not supported. Please check the server.xml configuration file (supportedMechanisms field)" );
-
-            bindResult.setResultCode( ResultCodeEnum.STRONG_AUTH_REQUIRED );
-            bindResult.setErrorMessage( "Simple binds are disabled." );
-            session.write( bindRequest.getResultResponse() );
-            return;
-        }
-
-        // Initialize the environment which will be used to create the context
-        Hashtable<String, Object> env = getEnvironment( session, bindRequest, SIMPLE_AUTHENTICATION_LEVEL );
-        
-        // Now, get the context
-        LdapContext ctx = getLdapContext( session, bindRequest, env );
-        
-        // Test that we successfully got one. If not, an error has already been returned.
-        if ( ctx != null )
-        {
-            ServerLdapContext newCtx = ( ServerLdapContext ) ctx.lookup( "" );
-            setRequestControls( newCtx, bindRequest );
-            SessionRegistry.getSingleton().setLdapContext( session, newCtx );
-            bindResult.setResultCode( ResultCodeEnum.SUCCESS );
-            BindResponse response = ( BindResponse ) bindRequest.getResultResponse();
-            response.addAll( newCtx.getResponseControls() );
-            session.write( response );
-            LOG.debug( "Returned SUCCESS message." );
-        }
-    }
 
     /**
      * Deal with a received BindRequest
      */
-    public void messageReceived( IoSession session, Object message ) throws Exception
+    public final void messageReceived( IoSession session, Object message ) throws Exception
     {
-        BindRequest bindRequest = ( BindRequest ) message;
-
-        if ( LOG.isDebugEnabled() )
-        {
-        	LOG.debug( "User {} is binding", bindRequest.getName() );
-        	
-            if ( bindRequest.isSimple() )
-            {
-                LOG.debug( "Using simple authentication." );
-                
-            }
-            else
-            {
-                LOG.debug( "Using SASL authentication with mechanism:  {}", bindRequest.getSaslMechanism() );
-            }
-        }
-        
-        // Guard clause:  LDAP version 3
-        if ( !bindRequest.getVersion3() )
-        {
-            LOG.error( "Bind error : Only LDAP v3 is supported." );
-            LdapResult bindResult = bindRequest.getResultResponse().getLdapResult();
-            bindResult.setResultCode( ResultCodeEnum.PROTOCOL_ERROR );
-            bindResult.setErrorMessage( "Only LDAP v3 is supported." );
-            session.write( bindRequest.getResultResponse() );
-            return;
-        }
-        
-        // Deal with the two kinds of authen :
-        // - if it's simple, handle it in this class for speed
-        // - for sasl, we go through a chain right now (but it may change in the near future)
-        if ( bindRequest.isSimple() )
-        {
-            handleSimpleAuth( session, bindRequest );
-        }
-        else
-        {
-            saslBindHandler.execute( null, session, message );
-        }
+        bindMessageReceived( session, ( BindRequest ) message );
     }
 }

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java Sun Oct  7 22:54:38 2007
@@ -20,25 +20,9 @@
 package org.apache.directory.server.ldap.support;
 
 
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.ReferralException;
-import javax.naming.ldap.LdapContext;
-
-import org.apache.directory.server.core.jndi.ServerLdapContext;
-import org.apache.directory.server.ldap.SessionRegistry;
-import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.CompareRequest;
-import org.apache.directory.shared.ldap.message.LdapResult;
-import org.apache.directory.shared.ldap.message.ManageDsaITControl;
-import org.apache.directory.shared.ldap.message.ReferralImpl;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -47,100 +31,13 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class CompareHandler extends AbstractLdapHandler implements MessageHandler
+public abstract class CompareHandler extends AbstractLdapHandler implements MessageHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( CompareHandler.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
-
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public final void messageReceived( IoSession session, Object request ) throws Exception
     {
-        CompareRequest req = ( CompareRequest ) request;
-        LdapResult result = req.getResultResponse().getLdapResult();
-
-        try
-        {
-            LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
-            ServerLdapContext newCtx = ( ServerLdapContext ) ctx.lookup( "" );
-            
-            if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
-            {
-                newCtx.addToEnvironment( Context.REFERRAL, "ignore" );
-            }
-            else
-            {
-                newCtx.addToEnvironment( Context.REFERRAL, "throw" );
-            }
-            
-            // Inject controls into the context
-            setRequestControls( newCtx, req );
-
-            if ( newCtx.compare( req.getName(), req.getAttributeId(), req.getAssertionValue() ) )
-            {
-                result.setResultCode( ResultCodeEnum.COMPARE_TRUE );
-            }
-            else
-            {
-                result.setResultCode( ResultCodeEnum.COMPARE_FALSE );
-            }
-
-            result.setMatchedDn( req.getName() );
-            req.getResultResponse().addAll( newCtx.getResponseControls() );
-            session.write( req.getResultResponse() );
-        }
-        catch ( ReferralException e )
-        {
-            ReferralImpl refs = new ReferralImpl();
-            result.setReferral( refs );
-            result.setResultCode( ResultCodeEnum.REFERRAL );
-            result.setErrorMessage( "Encountered referral attempting to handle compare request." );
-
-            result.setMatchedDn( (LdapDN)e.getResolvedName() );
-            
-            do
-            {
-                refs.addLdapUrl( ( String ) e.getReferralInfo() );
-            }
-            while ( e.skipReferral() );
-            session.write( req.getResultResponse() );
-        }
-        catch ( Exception e )
-        {
-            String msg = "failed to compare entry " + req.getName() + ": " + e.getMessage();
-
-            if ( IS_DEBUG )
-            {
-                msg += ":\n" + ExceptionUtils.getStackTrace( e );
-            }
-
-            ResultCodeEnum code;
-
-            if ( e instanceof LdapException )
-            {
-                code = ( ( LdapException ) e ).getResultCode();
-            }
-            else
-            {
-                code = ResultCodeEnum.getBestEstimate( e, req.getType() );
-            }
-
-            result.setResultCode( code );
-            result.setErrorMessage( msg );
-
-            if ( e instanceof NamingException )
-            {
-                NamingException ne = ( NamingException ) e;
+        compareMessageReceived( session, ( CompareRequest ) request );
+    }
 
-                if ( ( ne.getResolvedName() != null )
-                    && ( ( code == ResultCodeEnum.NO_SUCH_OBJECT ) || ( code == ResultCodeEnum.ALIAS_PROBLEM )
-                        || ( code == ResultCodeEnum.INVALID_DN_SYNTAX ) || ( code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM ) ) )
-                {
-                    result.setMatchedDn( (LdapDN)ne.getResolvedName() );
-                }
-            }
 
-            session.write( req.getResultResponse() );
-        }
-    }
+    protected abstract void compareMessageReceived( IoSession session, CompareRequest compareRequest ) throws Exception;
 }

Copied: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAbandonHandler.java (from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAbandonHandler.java?p2=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAbandonHandler.java&p1=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java&r1=582695&r2=582712&rev=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AbandonHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAbandonHandler.java Sun Oct  7 22:54:38 2007
@@ -25,27 +25,26 @@
 import org.apache.directory.shared.ldap.message.AbandonableRequest;
 import org.apache.directory.shared.ldap.message.Request;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
- * Handler for {@link org.apache.directory.shared.ldap.message.AbandonRequest}s.
+ * Handler for {@link AbandonRequest}s.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class AbandonHandler implements MessageHandler
+public class DefaultAbandonHandler extends AbandonHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( AbandonHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( AbandonHandler.class );
 
     /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    
+    public void abandonMessageReceived( IoSession session, AbandonRequest req ) throws Exception
     {
-        AbandonRequest req = ( AbandonRequest ) request;
         int abandonedId = req.getAbandoned();
 
         if ( abandonedId < 0 )
@@ -57,9 +56,9 @@
 
         if ( abandonedRequest == null )
         {
-            if ( log.isWarnEnabled() )
+            if ( LOG.isWarnEnabled() )
             {
-                log.warn( "Got abandon request from client " + session + " but request must have already "
+                LOG.warn( "Got abandon request from client " + session + " but request must have already "
                     + "terminated.  Abandon request " + req + " had no effect." );
             }
             return;
@@ -67,16 +66,16 @@
 
         if ( abandonedRequest instanceof AbandonableRequest )
         {
-            log
+            LOG
                 .warn( "Abandon, Bind, Unbind, and StartTLS operations cannot be abandoned.  Abandon request will be ignored." );
         }
 
         ( ( AbandonableRequest ) abandonedRequest ).abandon();
         if ( SessionRegistry.getSingleton().removeOutstandingRequest( session, abandonedId ) == null )
         {
-            if ( log.isWarnEnabled() )
+            if ( LOG.isWarnEnabled() )
             {
-                log.warn( "Got abandon request from client " + session + " but request must have already "
+                LOG.warn( "Got abandon request from client " + session + " but request must have already "
                     + "terminated." );
             }
         }
@@ -84,8 +83,8 @@
         {
             if ( IS_DEBUG )
             {
-                log.debug( "Abandoned request:  ", req );
+                LOG.debug( "Abandoned request:  ", req );
             }
         }
     }
-}
+}
\ No newline at end of file

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAbandonHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAbandonHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Oct  7 22:54:38 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Copied: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAddHandler.java (from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAddHandler.java?p2=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAddHandler.java&p1=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java&r1=582695&r2=582712&rev=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/AddHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAddHandler.java Sun Oct  7 22:54:38 2007
@@ -36,39 +36,38 @@
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 
 import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
- * A single reply handler for {@link org.apache.directory.shared.ldap.message.AddRequest}s.
+ * A single reply handler for {@link AddRequest}s.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class AddHandler extends AbstractLdapHandler implements MessageHandler
+public class DefaultAddHandler extends AddHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( AddHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( AddHandler.class );
 
     /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
-    public void messageReceived( IoSession session, Object request ) throws Exception
+
+    protected void addMessageReceived( IoSession session, AddRequest req ) throws Exception
     {
-        AddRequest req = ( AddRequest ) request;
         LdapResult result = req.getResultResponse().getLdapResult();
 
         if ( IS_DEBUG )
         {
-            log.debug( "Received an Add message:  {}", req.toString() );
+            LOG.debug( "Received an Add message:  {}", req.toString() );
         }
 
         try
         {
             LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
-            
+
             if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
             {
                 ctx.addToEnvironment( Context.REFERRAL, "ignore" );
@@ -77,7 +76,7 @@
             {
                 ctx.addToEnvironment( Context.REFERRAL, "throw" );
             }
-            
+
             // Inject controls into the context
             setRequestControls( ctx, req );
             ctx.createSubcontext( req.getEntry(), req.getAttributes() );
@@ -104,7 +103,7 @@
         {
             String msg = "failed to add entry " + req.getEntry() + ": " + e.getMessage();
 
-            if ( log.isDebugEnabled() )
+            if ( LOG.isDebugEnabled() )
             {
                 msg += ":\n" + ExceptionUtils.getStackTrace( e );
             }
@@ -133,4 +132,4 @@
             session.write( req.getResultResponse() );
         }
     }
-}
+}
\ No newline at end of file

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAddHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultAddHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Oct  7 22:54:38 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Copied: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java (from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java?p2=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java&p1=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java&r1=582695&r2=582712&rev=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/BindHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java Sun Oct  7 22:54:38 2007
@@ -45,33 +45,33 @@
 
 
 /**
- * A single reply handler for {@link org.apache.directory.shared.ldap.message.BindRequest}s.
- * 
+ * A single reply handler for {@link BindRequest}s.
+ *
  * Implements server-side of RFC 2222, sections 4.2 and 4.3.
- * 
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class BindHandler extends AbstractLdapHandler implements MessageHandler
+public class DefaultBindHandler extends BindHandler
 {
     private static final Logger LOG = LoggerFactory.getLogger( BindHandler.class );
 
     /** A class to handle SASL bind requests */
     private IoHandlerCommand saslBindHandler;
-    
+
     /** Definition of SIMPLE and STRONG authentication constants */
     private static final String SIMPLE_AUTHENTICATION_LEVEL = "simple";
-        
+
     //private static final String STRONG_AUTHENTICATION_LEVEL = "strong";
-    
+
     /** An empty Contol array used to get back the controls if any */
     private static final MutableControl[] EMPTY_CONTROL = new MutableControl[0];
 
 
     /**
      * Creates a new instance of BindHandler.
-     */                                                                      
-    public BindHandler()
+     */
+    public DefaultBindHandler()
     {
     }
 
@@ -108,7 +108,7 @@
 
         // clone the environment first then add the required security settings
         Hashtable<String, Object> env = SessionRegistry.getSingleton().getEnvironmentByCopy();
-        
+
         // Store the principal
         env.put( Context.SECURITY_PRINCIPAL, principal );
 
@@ -198,19 +198,19 @@
             session.write( bindRequest.getResultResponse() );
             ctx = null;
         }
-        
+
         return ctx;
     }
 
     /**
-     * This method handle a 'simple' authentication. Of course, the 'SIMPLE' mechanism 
+     * This method handle a 'simple' authentication. Of course, the 'SIMPLE' mechanism
      * must have been allowed in the configuration, otherwise an error is thrown.
-     * 
+     *
      */
     private void handleSimpleAuth( IoSession session, BindRequest bindRequest ) throws NamingException
     {
         LdapConfiguration config = ( LdapConfiguration ) session.getAttribute( LdapConfiguration.class.toString() );
-        
+
         @SuppressWarnings( "unchecked" )
         Set<String> supportedMechanisms = config.getSupportedMechanisms();
         LdapResult bindResult = bindRequest.getResultResponse().getLdapResult();
@@ -229,10 +229,10 @@
 
         // Initialize the environment which will be used to create the context
         Hashtable<String, Object> env = getEnvironment( session, bindRequest, SIMPLE_AUTHENTICATION_LEVEL );
-        
+
         // Now, get the context
         LdapContext ctx = getLdapContext( session, bindRequest, env );
-        
+
         // Test that we successfully got one. If not, an error has already been returned.
         if ( ctx != null )
         {
@@ -247,28 +247,27 @@
         }
     }
 
+    
     /**
      * Deal with a received BindRequest
      */
-    public void messageReceived( IoSession session, Object message ) throws Exception
+    protected void bindMessageReceived( IoSession session, BindRequest bindRequest ) throws Exception
     {
-        BindRequest bindRequest = ( BindRequest ) message;
-
         if ( LOG.isDebugEnabled() )
         {
         	LOG.debug( "User {} is binding", bindRequest.getName() );
-        	
+
             if ( bindRequest.isSimple() )
             {
                 LOG.debug( "Using simple authentication." );
-                
+
             }
             else
             {
                 LOG.debug( "Using SASL authentication with mechanism:  {}", bindRequest.getSaslMechanism() );
             }
         }
-        
+
         // Guard clause:  LDAP version 3
         if ( !bindRequest.getVersion3() )
         {
@@ -279,7 +278,7 @@
             session.write( bindRequest.getResultResponse() );
             return;
         }
-        
+
         // Deal with the two kinds of authen :
         // - if it's simple, handle it in this class for speed
         // - for sasl, we go through a chain right now (but it may change in the near future)
@@ -289,7 +288,7 @@
         }
         else
         {
-            saslBindHandler.execute( null, session, message );
+            saslBindHandler.execute( null, session, bindRequest );
         }
     }
-}
+}
\ No newline at end of file

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultBindHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Oct  7 22:54:38 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Copied: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultCompareHandler.java (from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultCompareHandler.java?p2=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultCompareHandler.java&p1=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java&r1=582695&r2=582712&rev=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/CompareHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultCompareHandler.java Sun Oct  7 22:54:38 2007
@@ -36,34 +36,32 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
- * A single reply handler for {@link org.apache.directory.shared.ldap.message.CompareRequest}s.
+ * A single reply handler for {@link CompareRequest}s.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class CompareHandler extends AbstractLdapHandler implements MessageHandler
+public class DefaultCompareHandler extends CompareHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( CompareHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( CompareHandler.class );
 
     /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public void compareMessageReceived( IoSession session, CompareRequest req ) throws Exception
     {
-        CompareRequest req = ( CompareRequest ) request;
         LdapResult result = req.getResultResponse().getLdapResult();
 
         try
         {
             LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
             ServerLdapContext newCtx = ( ServerLdapContext ) ctx.lookup( "" );
-            
+
             if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
             {
                 newCtx.addToEnvironment( Context.REFERRAL, "ignore" );
@@ -72,7 +70,7 @@
             {
                 newCtx.addToEnvironment( Context.REFERRAL, "throw" );
             }
-            
+
             // Inject controls into the context
             setRequestControls( newCtx, req );
 
@@ -97,7 +95,7 @@
             result.setErrorMessage( "Encountered referral attempting to handle compare request." );
 
             result.setMatchedDn( (LdapDN)e.getResolvedName() );
-            
+
             do
             {
                 refs.addLdapUrl( ( String ) e.getReferralInfo() );
@@ -143,4 +141,4 @@
             session.write( req.getResultResponse() );
         }
     }
-}
+}
\ No newline at end of file

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultCompareHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultCompareHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Oct  7 22:54:38 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Copied: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultDeleteHandler.java (from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultDeleteHandler.java?p2=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultDeleteHandler.java&p1=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java&r1=582695&r2=582712&rev=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultDeleteHandler.java Sun Oct  7 22:54:38 2007
@@ -35,27 +35,26 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
- * A single reply handler for {@link org.apache.directory.shared.ldap.message.DeleteRequest}s.
+ * A single reply handler for {@link DeleteRequest}s.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class DeleteHandler extends AbstractLdapHandler implements MessageHandler
+public class DefaultDeleteHandler extends DeleteHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( DeleteHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( DeleteHandler.class );
 
     /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
-    public void messageReceived( IoSession session, Object request ) throws Exception
+
+    public void deleteMessageReceived( IoSession session, DeleteRequest req ) throws Exception
     {
-        DeleteRequest req = ( DeleteRequest ) request;
         LdapResult result = req.getResultResponse().getLdapResult();
 
         try
@@ -69,7 +68,7 @@
             {
                 ctx.addToEnvironment( Context.REFERRAL, "throw" );
             }
-            
+
             // Inject controls into the context
             setRequestControls( ctx, req );
 
@@ -124,4 +123,4 @@
             session.write( req.getResultResponse() );
         }
     }
-}
+}
\ No newline at end of file

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultDeleteHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultDeleteHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Oct  7 22:54:38 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Copied: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultExtendedHandler.java (from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultExtendedHandler.java?p2=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultExtendedHandler.java&p1=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java&r1=582695&r2=582712&rev=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultExtendedHandler.java Sun Oct  7 22:54:38 2007
@@ -20,10 +20,6 @@
 package org.apache.directory.server.ldap.support;
 
 
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.directory.server.ldap.ExtendedOperationHandler;
 import org.apache.directory.server.ldap.SessionRegistry;
 import org.apache.directory.shared.ldap.message.ExtendedRequest;
@@ -32,54 +28,19 @@
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
 
 
 /**
- * A single reply handler for {@link org.apache.directory.shared.ldap.message.ExtendedRequest}s.
+* A single reply handler for {@link ExtendedRequest}s.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ExtendedHandler extends AbstractLdapHandler implements MessageHandler
+public class DefaultExtendedHandler extends ExtendedHandler
 {
-    private Map<String, ExtendedOperationHandler> handlers = new HashMap<String, ExtendedOperationHandler>();
-
-
-    public ExtendedOperationHandler addHandler( ExtendedOperationHandler eoh )
-    {
-        synchronized ( handlers )
-        {
-            return handlers.put( eoh.getOid(), eoh );
-        }
-    }
-
-
-    public ExtendedOperationHandler removeHandler( String oid )
-    {
-        synchronized ( handlers )
-        {
-            return handlers.remove( oid );
-        }
-    }
-
-
-    public ExtendedOperationHandler getHandler( String oid )
-    {
-        return handlers.get( oid );
-    }
-
-
-    public Map getHandlerMap()
-    {
-        return Collections.unmodifiableMap( handlers );
-    }
-
-
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public void extendedMessageReceived( IoSession session, ExtendedRequest req ) throws Exception
     {
-        ExtendedRequest req = ( ExtendedRequest ) request;
-        ExtendedOperationHandler handler = handlers.get( req.getOid() );
+        ExtendedOperationHandler handler = getHandler( req.getOid() );
 
         if ( handler == null )
         {
@@ -106,7 +67,7 @@
                 ExtendedResponse resp = ( ExtendedResponse ) req.getResultResponse();
                 resp.setResponse( new byte[0] );
                 session.write( req.getResultResponse() );
-            } 
+            }
         }
     }
-}
+}
\ No newline at end of file

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultExtendedHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultExtendedHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Oct  7 22:54:38 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Copied: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyDnHandler.java (from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyDnHandler.java?p2=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyDnHandler.java&p1=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java&r1=582695&r2=582712&rev=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyDnHandler.java Sun Oct  7 22:54:38 2007
@@ -36,48 +36,46 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
- * A single reply handler for {@link org.apache.directory.shared.ldap.message.ModifyDnRequest}s.
- * 
+ * A single reply handler for {@link ModifyDnRequest}s.
+ *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ModifyDnHandler extends AbstractLdapHandler implements MessageHandler
+public class DefaultModifyDnHandler extends ModifyDnHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( ModifyDnHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( ModifyDnHandler.class );
 
     /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
     /**
      * Deal with a ModifyDN request received from a client.
-     * 
+     *
      * A ModifyDN operation has more than one semantic, depending on its parameters.
-     * 
+     *
      * In any case, the first argument is the DN entry to be changed. We then
      * have the new relative DN for this entry.
-     * 
+     *
      * Two other arguments can be provided :
      * - deleteOldRdn : if the old RDN attributes should be removed from the
-     * new entry or not (for instance, if the old RDN was cn=acme, and the new 
+     * new entry or not (for instance, if the old RDN was cn=acme, and the new
      * one is sn=acme, then we may have to remove the cn: acme from the attributes
      * list)
      * - newSuperior : this is a move operation. The entry is removed from its
      * current location, and created in the new one.
      */
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public void modifyDnMessageReceived( IoSession session, ModifyDnRequest req ) throws Exception
     {
-        ModifyDnRequest req = ( ModifyDnRequest ) request;
         LdapResult result = req.getResultResponse().getLdapResult();
 
         if ( IS_DEBUG )
         {
-            log.debug( "req.getName() == [{}]", req.getName() );
+            LOG.debug( "req.getName() == [{}]", req.getName() );
         }
 
         if ( req.getName().isEmpty() )
@@ -93,7 +91,7 @@
             try
             {
                 LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
-                
+
                 if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
                 {
                     ctx.addToEnvironment( Context.REFERRAL, "ignore" );
@@ -102,10 +100,10 @@
                 {
                     ctx.addToEnvironment( Context.REFERRAL, "throw" );
                 }
-                
+
                 // Inject controls into the context
                 setRequestControls( ctx, req );
-                
+
                 String deleteRDN = String.valueOf( req.getDeleteOldRdn() );
                 ctx.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DELETE_RDN, deleteRDN );
 
@@ -114,7 +112,7 @@
                 if ( ( newSuperior != null ) && ( !newSuperior.isEmpty() ) )
                 {
                     LdapDN oldDn = req.getName();
-                    LdapDN newDn = null;
+                    LdapDN newDn;
 
                     newDn = newSuperior;
 
@@ -154,20 +152,20 @@
                     refs.addLdapUrl( ( String ) e.getReferralInfo() );
                 }
                 while ( e.skipReferral() );
-                
+
                 session.write( req.getResultResponse() );
             }
             catch ( NamingException e )
             {
                 String msg = "failed to modify DN of entry " + req.getName() + ": " + e.getMessage();
-                
+
                 if ( IS_DEBUG )
                 {
                     msg += ":\n" + ExceptionUtils.getStackTrace( e );
                 }
 
                 ResultCodeEnum code;
-                
+
                 if ( e instanceof LdapException )
                 {
                     code = ( ( LdapException ) e ).getResultCode();
@@ -179,7 +177,7 @@
 
                 result.setResultCode( code );
                 result.setErrorMessage( msg );
-                
+
                 if ( ( e.getResolvedName() != null )
                     && ( ( code == ResultCodeEnum.NO_SUCH_OBJECT ) || ( code == ResultCodeEnum.ALIAS_PROBLEM )
                         || ( code == ResultCodeEnum.INVALID_DN_SYNTAX ) || ( code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM ) ) )
@@ -191,4 +189,4 @@
             }
         }
     }
-}
+}
\ No newline at end of file

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyDnHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyDnHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Oct  7 22:54:38 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id



Mime
View raw message