directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1072235 - in /directory/shared/branches/m1: ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/ ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ ldap-codec/src/main/java/org/apache/dir...
Date Sat, 19 Feb 2011 03:22:07 GMT
Author: akarasulu
Date: Sat Feb 19 03:22:03 2011
New Revision: 1072235

URL: http://svn.apache.org/viewvc?rev=1072235&view=rev
Log:
DIRSHARED-86: fixing design issues around unsolicited extended responses

  o seems the old model of having a single factory for both req/resp does not
    work so well since we have responses that are unsolicited like graceful
    disconnect
  o created a new UnsolicitedResponseFactory for Unsolicited ExtendedRequests
  o code cleanup
  o added additional interfaces to the codec API and methods to the codec 
    service interface
  o cleaned up and fixed old factories
  o added default constructors to some of the extended op req/resp pairs


Added:
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedRequestFactory.java
      - copied, changed from r1072211, directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedOpFactory.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/UnsolicitedResponseFactory.java
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelFactory.java
      - copied, changed from r1072220, directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelExtendedOpFactory.java
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationFactory.java
      - copied, changed from r1072222, directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationExtendedOpFactory.java
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulDisconnectFactory.java
Removed:
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedOpFactory.java
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelExtendedOpFactory.java
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationExtendedOpFactory.java
Modified:
    directory/shared/branches/m1/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/osgi/DefaultLdapCodecService.java
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/CancelResponse.java
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/CertGenerationResponse.java
    directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulDisconnect.java

Modified: directory/shared/branches/m1/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java?rev=1072235&r1=1072234&r2=1072235&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
(original)
+++ directory/shared/branches/m1/ldap-codec-standalone/src/main/java/org/apache/directory/shared/ldap/codec/standalone/StandaloneLdapCodecService.java
Sat Feb 19 03:22:03 2011
@@ -36,8 +36,9 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.api.CodecControl;
 import org.apache.directory.shared.ldap.codec.api.ControlFactory;
-import org.apache.directory.shared.ldap.codec.api.ExtendedOpFactory;
+import org.apache.directory.shared.ldap.codec.api.ExtendedRequestFactory;
 import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.codec.api.UnsolicitedResponseFactory;
 import org.apache.directory.shared.ldap.codec.controls.cascade.CascadeFactory;
 import org.apache.directory.shared.ldap.codec.controls.manageDsaIT.ManageDsaITFactory;
 import org.apache.directory.shared.ldap.codec.controls.search.entryChange.EntryChangeFactory;
@@ -47,6 +48,8 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
 import org.apache.directory.shared.ldap.codec.protocol.mina.LdapProtocolCodecFactory;
 import org.apache.directory.shared.ldap.model.message.Control;
+import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
+import org.apache.directory.shared.ldap.model.message.ExtendedResponseImpl;
 import org.apache.directory.shared.ldap.model.message.Message;
 import org.apache.directory.shared.ldap.model.message.controls.OpaqueControl;
 import org.apache.directory.shared.util.exception.NotImplementedException;
@@ -111,8 +114,11 @@ public class StandaloneLdapCodecService 
     /** The map of registered {@link org.apache.directory.shared.ldap.codec.api.ControlFactory}'s
*/
     private Map<String,ControlFactory<?,?>> controlFactories = new HashMap<String,
ControlFactory<?,?>>();
 
-    /** The map of registered {@link org.apache.directory.shared.ldap.codec.api.ExtendedOpFactory}'s
by request OID */
-    private Map<String,ExtendedOpFactory<?>> extReqFactories = new HashMap<String,
ExtendedOpFactory<?>>();
+    /** The map of registered {@link org.apache.directory.shared.ldap.codec.api.ExtendedRequestFactory}'s
by request OID */
+    private Map<String,ExtendedRequestFactory<?,?>> extReqFactories = new HashMap<String,
ExtendedRequestFactory<?,?>>();
+
+    /** The map of registered {@link UnsolicitedResponseFactory}'s by request OID */
+    private Map<String,UnsolicitedResponseFactory<?>> unsolicitedFactories =
new HashMap<String, UnsolicitedResponseFactory<?>>();
     
     /** The codec's {@link BundleActivator} */
     private CodecHostActivator activator;
@@ -502,18 +508,18 @@ public class StandaloneLdapCodecService 
     /**
      * {@inheritDoc}
      */
-    public void registerControl( ControlFactory<?,?> factory )
+    public ControlFactory<?,?> registerControl( ControlFactory<?,?> factory )
     {
-        controlFactories.put( factory.getOid(), factory );
+        return controlFactories.put( factory.getOid(), factory );
     }
     
 
     /**
      * {@inheritDoc}
      */
-    public void unregisterControl( String oid )
+    public ControlFactory<?,?> unregisterControl( String oid )
     {
-        controlFactories.remove( oid );
+        return controlFactories.remove( oid );
     }
 
     
@@ -547,9 +553,9 @@ public class StandaloneLdapCodecService 
     /**
      * {@inheritDoc}
      */
-    public void registerExtendedOp( ExtendedOpFactory<?> factory )
+    public ExtendedRequestFactory<?, ?> registerExtendedRequest( ExtendedRequestFactory<?,?>
factory )
     {
-        extReqFactories.put( factory.getOid(), factory );
+        return extReqFactories.put( factory.getOid(), factory );
     }
 
     
@@ -683,4 +689,92 @@ public class StandaloneLdapCodecService 
     {
         return pluginDirectory;
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<String> registeredUnsolicitedResponses()
+    {
+        return Collections.unmodifiableSet( unsolicitedFactories.keySet() ).iterator();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public UnsolicitedResponseFactory<?> registerUnsolicitedResponse( UnsolicitedResponseFactory<?>
factory )
+    {
+        return unsolicitedFactories.put( factory.getOid(), factory );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public javax.naming.ldap.ExtendedResponse toJndi( final ExtendedResponse modelResponse
) throws EncoderException
+    {
+        final byte[] encodedValue = new byte[ modelResponse.getEncodedValue().length ];
+        System.arraycopy( modelResponse.getEncodedValue(), 0, encodedValue, 0, modelResponse.getEncodedValue().length
);
+        
+        return new javax.naming.ldap.ExtendedResponse()
+        {
+            private static final long serialVersionUID = 2955142105375495493L;
+
+            public String getID()
+            {
+                return modelResponse.getID();
+            }
+
+            public byte[] getEncodedValue()
+            {
+                return encodedValue;
+            }
+        };
+    }
+    
+
+    /**
+     * {@inheritDoc}
+     */
+    public ExtendedResponse fromJndi( javax.naming.ldap.ExtendedResponse jndiResponse ) throws
DecoderException
+    {   
+        ExtendedResponse modelResponse;
+        ExtendedRequestFactory<?,?> extendedRequestFactory = extReqFactories.get( jndiResponse.getID()
);
+        UnsolicitedResponseFactory<?> unsolicitedResponseFactory = unsolicitedFactories.get(
jndiResponse.getID() );
+        
+        if ( unsolicitedResponseFactory != null )
+        {
+            modelResponse = unsolicitedResponseFactory.newResponse( jndiResponse.getEncodedValue()
);
+        }
+        else if ( extendedRequestFactory != null )
+        {
+            modelResponse = extendedRequestFactory.newResponse( jndiResponse.getEncodedValue()
);
+        }
+        else
+        {
+            modelResponse = new ExtendedResponseImpl( jndiResponse.getID() );
+            modelResponse.setResponseValue( jndiResponse.getEncodedValue() );
+        }
+        
+        return modelResponse;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ExtendedRequestFactory<?, ?> unregisterExtendedRequest( String oid )
+    {
+        return extReqFactories.remove( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public UnsolicitedResponseFactory<?> unregisterUnsolicitedResponse( String oid
)
+    {
+        return unsolicitedFactories.remove( oid );
+    }
 }

Copied: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedRequestFactory.java
(from r1072211, directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedOpFactory.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedRequestFactory.java?p2=directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedRequestFactory.java&p1=directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedOpFactory.java&r1=1072211&r2=1072235&rev=1072235&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedOpFactory.java
(original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/ExtendedRequestFactory.java
Sat Feb 19 03:22:03 2011
@@ -20,16 +20,19 @@
 package org.apache.directory.shared.ldap.codec.api;
 
 
+import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
+import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
 
 
 /**
- * The LdapCodec interface, defined by the codec API.
+ * The factor interface, defined by the codec API for creating new 
+ * ExtendedRequests.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public interface ExtendedOpFactory<Q extends ExtendedRequest>
+public interface ExtendedRequestFactory<Q extends ExtendedRequest,P extends ExtendedResponse>
 {
     /**
      * Gets the OID of the extended requests this factory generates.
@@ -43,4 +46,14 @@ public interface ExtendedOpFactory<Q ext
      *  @return A new instance of the ExtendedRequest.
      */
     Q newRequest();
+    
+    
+    /**
+     * Creates a new ExtendedResponse, for the ExtendedRequest with a specific
+     * encoded value.
+     * 
+     * @param encodedValue The encoded value for the ExtendedResponse instance.
+     * @return The new ExtendedResponse.
+     */
+    P newResponse( byte[] encodedValue ) throws DecoderException;
 }

Modified: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java?rev=1072235&r1=1072234&r2=1072235&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java
(original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/LdapCodecService.java
Sat Feb 19 03:22:03 2011
@@ -26,6 +26,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.ldap.model.message.Control;
+import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 
 
@@ -37,6 +38,12 @@ import org.apache.mina.filter.codec.Prot
  */
 public interface LdapCodecService
 {
+    
+    // ------------------------------------------------------------------------
+    // Control Methods
+    // ------------------------------------------------------------------------
+
+    
     /**
      * Returns an Iterator over the OID Strings of registered controls.
      * 
@@ -54,20 +61,11 @@ public interface LdapCodecService
     
     
     /**
-     * Returns an Iterator over the OID Strings of registered extended 
-     * requests.
-     *
-     * @return The registered extended request OID Strings
-     */
-    Iterator<String> registeredExtendedRequests();
-    
-    
-    /**
      * Registers an {@link ControlFactory} with this service.
      * 
      * @param factory The control factory
      */
-    void registerControl( ControlFactory<?,?> factory );
+    ControlFactory<?,?> registerControl( ControlFactory<?,?> factory );
     
     
     /**
@@ -75,16 +73,7 @@ public interface LdapCodecService
      * 
      * @param oid The oid of the control the factory is associated with.
      */
-    void unregisterControl( String oid );
-    
-    
-    /**
-     * Registers an {@link ExtendedOpFactory} for generating extended request 
-     * response pairs.
-     * 
-     * @param factory The extended operation factory
-     */
-    void registerExtendedOp( ExtendedOpFactory<?> factory );
+    ControlFactory<?,?> unregisterControl( String oid );
     
     
     /**
@@ -106,16 +95,6 @@ public interface LdapCodecService
     
     
     /**
-     * Creates a new LDAP {@link ProtocolCodecFactory}.
-     *
-     * @param client if true a factory designed for clients is returned, 
-     * otherwise one for servers is returned.
-     * @return the client or server specific {@link ProtocolCodecFactory}
-     */
-    ProtocolCodecFactory newProtocolCodecFactory( boolean client );
-    
-    
-    /**
      * Creates a JNDI control from the ldap model's control.
      *
      * @param modelControl The model's control.
@@ -134,6 +113,115 @@ public interface LdapCodecService
      */
     Control fromJndiControl( javax.naming.ldap.Control jndiControl ) throws DecoderException;
 
+    
+    // ------------------------------------------------------------------------
+    // Extended Request Methods
+    // ------------------------------------------------------------------------
+
+    
+    /**
+     * Returns an Iterator over the OID Strings of registered extended 
+     * requests.
+     *
+     * @return The registered extended request OID Strings
+     */
+    Iterator<String> registeredExtendedRequests();
+    
+    
+    /**
+     * Registers an {@link ExtendedRequestFactory} for generating extended request 
+     * response pairs.
+     * 
+     * @param factory The extended request factory
+     * @return The displaced factory if one existed for the oid
+     */
+    ExtendedRequestFactory<?,?> registerExtendedRequest( ExtendedRequestFactory<?,?>
factory );
+    
+    
+    /**
+     * Unregisters an {@link ExtendedRequestFactory} for generating extended 
+     * request response pairs.
+     * 
+     * @param oid The extended request oid
+     * @return The displaced factory if one existed for the oid
+     */
+    ExtendedRequestFactory<?,?> unregisterExtendedRequest( String oid );
+    
+    
+    // ------------------------------------------------------------------------
+    // Extended Response Methods
+    // ------------------------------------------------------------------------
+
+    
+    /**
+     * Returns an Iterator over the OID Strings of registered unsolicited 
+     * extended responses.
+     *
+     * @return The registered unsolicited extended response OID Strings
+     */
+    Iterator<String> registeredUnsolicitedResponses();
+    
+    
+    /**
+     * Registers an {@link UnsolicitedResponseFactory} for generating extended
+     * responses sent by servers without an extended request.
+     * 
+     * @param factory The unsolicited response creating factory
+     * @return The displaced factory if one existed for the oid
+     */
+    UnsolicitedResponseFactory<?> registerUnsolicitedResponse( UnsolicitedResponseFactory<?>
factory );
+
+    
+    /**
+     * Unregisters an {@link UnsolicitedResponseFactory} for generating 
+     * extended responses sent by servers without an extended request.
+     * 
+     * @param oid The unsolicited response oid
+     */
+    UnsolicitedResponseFactory<?> unregisterUnsolicitedResponse( String oid );
+
+    
+    /**
+     * Creates a model ExtendedResponse from the JNDI ExtendedResponse.
+     *
+     * @param jndiResponse The JNDI ExtendedResponse 
+     * @return The model ExtendedResponse
+     * @throws DecoderException if the response value cannot be decoded.
+     */
+    ExtendedResponse fromJndi( javax.naming.ldap.ExtendedResponse jndiResponse ) throws DecoderException;
+    
+    
+    /**
+     * Creates a JNDI {@link javax.naming.ldap.ExtendedResponse} from the model 
+     * {@link ExtendedResponse}.
+     * 
+     * @param modelResponse
+     * @return
+     * @throws EncoderException
+     */
+    javax.naming.ldap.ExtendedResponse toJndi( ExtendedResponse modelResponse ) throws EncoderException;
+    
+    
+    // ------------------------------------------------------------------------
+    // Extended Request/Response Methods
+    // ------------------------------------------------------------------------
+
+    
+    /**
+     * Creates a new LDAP {@link ProtocolCodecFactory}.
+     *
+     * @param client if true a factory designed for clients is returned, 
+     * otherwise one for servers is returned.
+     * @return the client or server specific {@link ProtocolCodecFactory}
+     */
+    ProtocolCodecFactory newProtocolCodecFactory( boolean client );
 
+    
+    /**
+     * Creates a new MessageContainer.
+     *
+     * @TODO akarasulu - Wondering why is this not an LdapMessageContainer?
+     * @return The newly created LDAP MessageContainer instance.
+     */
     Asn1Container newMessageContainer();
 }

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/UnsolicitedResponseFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/UnsolicitedResponseFactory.java?rev=1072235&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/UnsolicitedResponseFactory.java
(added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/api/UnsolicitedResponseFactory.java
Sat Feb 19 03:22:03 2011
@@ -0,0 +1,48 @@
+/*
+ *   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.shared.ldap.codec.api;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
+
+
+/**
+ * A factory which generates unsolicited server ExtendedResponses without 
+ * requiring an initiating client ExtendedRequest.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface UnsolicitedResponseFactory<R extends ExtendedResponse>
+{
+    /**
+     * Gets the OID of the {@link ExtendedResponse} this factory generates.
+     *
+     * @return the extended response OID
+     */
+    String getOid();
+    
+    
+    /**
+     *  @return A new instance of the ExtendedResponse.
+     */
+    R newResponse( byte[] encodedValue ) throws DecoderException;
+}

Modified: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/osgi/DefaultLdapCodecService.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/osgi/DefaultLdapCodecService.java?rev=1072235&r1=1072234&r2=1072235&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/osgi/DefaultLdapCodecService.java
(original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/osgi/DefaultLdapCodecService.java
Sat Feb 19 03:22:03 2011
@@ -27,8 +27,9 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.api.CodecControl;
 import org.apache.directory.shared.ldap.codec.api.ControlFactory;
-import org.apache.directory.shared.ldap.codec.api.ExtendedOpFactory;
+import org.apache.directory.shared.ldap.codec.api.ExtendedRequestFactory;
 import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.codec.api.UnsolicitedResponseFactory;
 import org.apache.directory.shared.ldap.codec.controls.cascade.CascadeFactory;
 import org.apache.directory.shared.ldap.codec.controls.manageDsaIT.ManageDsaITFactory;
 import org.apache.directory.shared.ldap.codec.controls.search.entryChange.EntryChangeFactory;
@@ -38,6 +39,8 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
 import org.apache.directory.shared.ldap.codec.protocol.mina.LdapProtocolCodecFactory;
 import org.apache.directory.shared.ldap.model.message.Control;
+import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
+import org.apache.directory.shared.ldap.model.message.ExtendedResponseImpl;
 import org.apache.directory.shared.ldap.model.message.Message;
 import org.apache.directory.shared.ldap.model.message.controls.OpaqueControl;
 import org.apache.directory.shared.util.exception.NotImplementedException;
@@ -66,8 +69,11 @@ public class DefaultLdapCodecService imp
     /** The map of registered {@link org.apache.directory.shared.ldap.codec.api.ControlFactory}'s
*/
     private Map<String,ControlFactory<?,?>> controlFactories = new HashMap<String,
ControlFactory<?,?>>();
 
-    /** The map of registered {@link org.apache.directory.shared.ldap.codec.api.ExtendedOpFactory}'s
by request OID */
-    private Map<String,ExtendedOpFactory<?>> extReqFactories = new HashMap<String,
ExtendedOpFactory<?>>();
+    /** The map of registered {@link org.apache.directory.shared.ldap.codec.api.ExtendedRequestFactory}'s
by request OID */
+    private Map<String,ExtendedRequestFactory<?,?>> extReqFactories = new HashMap<String,
ExtendedRequestFactory<?,?>>();
+
+    /** The map of registered {@link UnsolicitedResponseFactory}'s by request OID */
+    private Map<String,UnsolicitedResponseFactory<?>> unsolicitedFactories =
new HashMap<String, UnsolicitedResponseFactory<?>>();
 
 
     /**
@@ -118,18 +124,18 @@ public class DefaultLdapCodecService imp
     /**
      * {@inheritDoc}
      */
-    public void registerControl( ControlFactory<?,?> factory )
+    public ControlFactory<?, ?> registerControl( ControlFactory<?,?> factory
)
     {
-        controlFactories.put(factory.getOid(), factory);
+        return controlFactories.put(factory.getOid(), factory);
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public void unregisterControl( String oid )
+    public ControlFactory<?, ?>  unregisterControl( String oid )
     {
-        controlFactories.remove( oid );
+        return controlFactories.remove( oid );
     }
 
 
@@ -163,9 +169,9 @@ public class DefaultLdapCodecService imp
     /**
      * {@inheritDoc}
      */
-    public void registerExtendedOp( ExtendedOpFactory<?> factory )
+    public ExtendedRequestFactory<?, ?> registerExtendedRequest( ExtendedRequestFactory<?,?>
factory )
     {
-        extReqFactories.put( factory.getOid(), factory );
+        return extReqFactories.put( factory.getOid(), factory );
     }
 
 
@@ -285,4 +291,92 @@ public class DefaultLdapCodecService imp
     {
         return new LdapMessageContainer<MessageDecorator<? extends Message>>(
this );
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ExtendedRequestFactory<?, ?> unregisterExtendedRequest( String oid )
+    {
+        return extReqFactories.remove( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<String> registeredUnsolicitedResponses()
+    {
+        return Collections.unmodifiableSet( unsolicitedFactories.keySet() ).iterator();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public UnsolicitedResponseFactory<?> registerUnsolicitedResponse( UnsolicitedResponseFactory<?>
factory )
+    {
+        return unsolicitedFactories.put( factory.getOid(), factory );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public UnsolicitedResponseFactory<?> unregisterUnsolicitedResponse( String oid
)
+    {
+        return unsolicitedFactories.remove( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public javax.naming.ldap.ExtendedResponse toJndi( final ExtendedResponse modelResponse
) throws EncoderException
+    {
+        final byte[] encodedValue = new byte[ modelResponse.getEncodedValue().length ];
+        System.arraycopy( modelResponse.getEncodedValue(), 0, encodedValue, 0, modelResponse.getEncodedValue().length
);
+        
+        return new javax.naming.ldap.ExtendedResponse()
+        {
+            private static final long serialVersionUID = 2955142105375495493L;
+
+            public String getID()
+            {
+                return modelResponse.getID();
+            }
+
+            public byte[] getEncodedValue()
+            {
+                return encodedValue;
+            }
+        };
+    }
+    
+
+    /**
+     * {@inheritDoc}
+     */
+    public ExtendedResponse fromJndi( javax.naming.ldap.ExtendedResponse jndiResponse ) throws
DecoderException
+    {   
+        ExtendedResponse modelResponse;
+        ExtendedRequestFactory<?,?> extendedRequestFactory = extReqFactories.get( jndiResponse.getID()
);
+        UnsolicitedResponseFactory<?> unsolicitedResponseFactory = unsolicitedFactories.get(
jndiResponse.getID() );
+        
+        if ( unsolicitedResponseFactory != null )
+        {
+            modelResponse = unsolicitedResponseFactory.newResponse( jndiResponse.getEncodedValue()
);
+        }
+        else if ( extendedRequestFactory != null )
+        {
+            modelResponse = extendedRequestFactory.newResponse( jndiResponse.getEncodedValue()
);
+        }
+        else
+        {
+            modelResponse = new ExtendedResponseImpl( jndiResponse.getID() );
+            modelResponse.setResponseValue( jndiResponse.getEncodedValue() );
+        }
+        
+        return modelResponse;
+    }
 }

Modified: directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java?rev=1072235&r1=1072234&r2=1072235&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java
(original)
+++ directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java
Sat Feb 19 03:22:03 2011
@@ -21,16 +21,27 @@ package org.apache.directory.shared.ldap
 
 
 import org.apache.directory.shared.ldap.codec.api.ControlFactory;
-import org.apache.directory.shared.ldap.codec.api.ExtendedOpFactory;
+import org.apache.directory.shared.ldap.codec.api.ExtendedRequestFactory;
 import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.codec.api.UnsolicitedResponseFactory;
+import org.apache.directory.shared.ldap.extras.controls.PasswordPolicy;
+import org.apache.directory.shared.ldap.extras.controls.SyncDoneValue;
+import org.apache.directory.shared.ldap.extras.controls.SyncInfoValue;
+import org.apache.directory.shared.ldap.extras.controls.SyncModifyDn;
+import org.apache.directory.shared.ldap.extras.controls.SyncRequestValue;
+import org.apache.directory.shared.ldap.extras.controls.SyncStateValue;
 import org.apache.directory.shared.ldap.extras.controls.ppolicy_impl.PasswordPolicyFactory;
 import org.apache.directory.shared.ldap.extras.controls.syncrepl_impl.SyncDoneValueFactory;
 import org.apache.directory.shared.ldap.extras.controls.syncrepl_impl.SyncInfoValueFactory;
 import org.apache.directory.shared.ldap.extras.controls.syncrepl_impl.SyncModifyDnFactory;
 import org.apache.directory.shared.ldap.extras.controls.syncrepl_impl.SyncRequestValueFactory;
 import org.apache.directory.shared.ldap.extras.controls.syncrepl_impl.SyncStateValueFactory;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.CancelExtendedOpFactory;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.CertGenerationExtendedOpFactory;
+import org.apache.directory.shared.ldap.extras.extended.CancelRequest;
+import org.apache.directory.shared.ldap.extras.extended.CertGenerationRequest;
+import org.apache.directory.shared.ldap.extras.extended.GracefulDisconnect;
+import org.apache.directory.shared.ldap.extras.extended.ads_impl.CancelFactory;
+import org.apache.directory.shared.ldap.extras.extended.ads_impl.CertGenerationFactory;
+import org.apache.directory.shared.ldap.extras.extended.ads_impl.GracefulDisconnectFactory;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -44,15 +55,16 @@ import org.osgi.framework.ServiceReferen
  */
 public class ExtrasBundleActivator implements BundleActivator
 {
+    private ServiceReference codecServiceRef;
+    
+    
     /**
      * {@inheritDoc}
      */
     public void start( BundleContext context ) throws Exception
     {
-        ServiceReference reference = 
-            context.getServiceReference( LdapCodecService.class.getName() );
-        
-        LdapCodecService codec = ( LdapCodecService ) context.getService( reference );
+        codecServiceRef = context.getServiceReference( LdapCodecService.class.getName() );
+        LdapCodecService codec = ( LdapCodecService ) context.getService( codecServiceRef
);
         registerExtrasControls( codec );
         registerExtrasExtendedOps( codec );
     }
@@ -92,19 +104,45 @@ public class ExtrasBundleActivator imple
      */
     private void registerExtrasExtendedOps( LdapCodecService codec )
     {
-        ExtendedOpFactory<?> factory = new CancelExtendedOpFactory();
-        codec.registerExtendedOp( factory );
+        // --------------------------------------------------------------------
+        // Register Extended Request Factories
+        // --------------------------------------------------------------------
+        
+        
+        ExtendedRequestFactory<?,?> extReqfactory = new CancelFactory();
+        codec.registerExtendedRequest( extReqfactory );
+        
+        extReqfactory = new CertGenerationFactory();
+        codec.registerExtendedRequest( extReqfactory );
+        
         
-        factory = new CertGenerationExtendedOpFactory();
-        codec.registerExtendedOp( factory );
+        // --------------------------------------------------------------------
+        // Register Unsolicited Response Factories
+        // --------------------------------------------------------------------
+        
+        
+        UnsolicitedResponseFactory<?> unsolicitedResponseFactory = new GracefulDisconnectFactory();
+        codec.registerUnsolicitedResponse( unsolicitedResponseFactory );
     }
     
     
-    
     /**
      * {@inheritDoc}
      */
     public void stop( BundleContext context ) throws Exception
     {
+        LdapCodecService codec = ( LdapCodecService ) context.getService( codecServiceRef
);
+        
+        codec.unregisterControl( SyncDoneValue.OID );
+        codec.unregisterControl( SyncInfoValue.OID );
+        codec.unregisterControl( SyncModifyDn.OID );
+        codec.unregisterControl( SyncRequestValue.OID );
+        codec.unregisterControl( SyncStateValue.OID );
+        codec.unregisterControl( PasswordPolicy.OID );
+        
+        codec.unregisterExtendedRequest( CancelRequest.EXTENSION_OID );
+        codec.unregisterExtendedRequest( CertGenerationRequest.EXTENSION_OID );
+        
+        codec.unregisterUnsolicitedResponse( GracefulDisconnect.EXTENSION_OID );
     }
 }

Modified: directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/CancelResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/CancelResponse.java?rev=1072235&r1=1072234&r2=1072235&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/CancelResponse.java
(original)
+++ directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/CancelResponse.java
Sat Feb 19 03:22:03 2011
@@ -74,6 +74,14 @@ public class CancelResponse extends Exte
     }
 
 
+    public CancelResponse()
+    {
+        super( CancelRequest.EXTENSION_OID );
+        super.getLdapResult().setMatchedDn( null );
+        super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
+    }
+
+
     // ------------------------------------------------------------------------
     // ExtendedResponse Interface Method Implementations
     // ------------------------------------------------------------------------

Modified: directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/CertGenerationResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/CertGenerationResponse.java?rev=1072235&r1=1072234&r2=1072235&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/CertGenerationResponse.java
(original)
+++ directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/CertGenerationResponse.java
Sat Feb 19 03:22:03 2011
@@ -70,6 +70,14 @@ public class CertGenerationResponse exte
     }
 
 
+    public CertGenerationResponse()
+    {
+        super( EXTENSION_OID );
+        super.getLdapResult().setMatchedDn( null );
+        super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
+    }
+
+
     // ------------------------------------------------------------------------
     // ExtendedResponse Interface Method Implementations
     // ------------------------------------------------------------------------

Modified: directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulDisconnect.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulDisconnect.java?rev=1072235&r1=1072234&r2=1072235&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulDisconnect.java
(original)
+++ directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulDisconnect.java
Sat Feb 19 03:22:03 2011
@@ -95,6 +95,16 @@ public class GracefulDisconnect extends 
 
     /**
      * Instantiates a new graceful disconnect.
+     */
+    public GracefulDisconnect()
+    {
+        super( 0, EXTENSION_OID );
+        this.responseValue = null;
+    }
+
+
+    /**
+     * Instantiates a new graceful disconnect.
      *
      * @param timeOffline the offline time after disconnect, in minutes
      * @param delay the delay before disconnect, in seconds
@@ -203,12 +213,21 @@ public class GracefulDisconnect extends 
 
 
     /**
-     * Sets the reponse OID specific encoded response values.
+     * Sets the response OID specific encoded response values.
      * 
      * @param responseValue the response specific encoded response values.
      */
     public void setResponseValue( byte[] responseValue )
     {
+        if ( responseValue == null )
+        {
+            this.responseValue = null;
+            this.delay = 0;
+            this.timeOffline = 0;
+            this.replicatedContexts = new ReferralImpl();
+            return;
+        }
+        
         ByteBuffer bb = ByteBuffer.wrap( responseValue );
         GracefulDisconnectContainer container = new GracefulDisconnectContainer();
         Asn1Decoder decoder = new Asn1Decoder();
@@ -232,15 +251,8 @@ public class GracefulDisconnect extends 
             replicatedContexts.addLdapUrl( ldapUrl.toString() );
         }
 
-        if ( responseValue != null )
-        {
-            this.responseValue = new byte[responseValue.length];
-            System.arraycopy( responseValue, 0, this.responseValue, 0, responseValue.length
);
-        }
-        else
-        {
-            this.responseValue = null;
-        }
+        this.responseValue = new byte[responseValue.length];
+        System.arraycopy( responseValue, 0, this.responseValue, 0, responseValue.length );
     }
 
 

Copied: directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelFactory.java
(from r1072220, directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelExtendedOpFactory.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelFactory.java?p2=directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelFactory.java&p1=directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelExtendedOpFactory.java&r1=1072220&r2=1072235&rev=1072235&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelExtendedOpFactory.java
(original)
+++ directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CancelFactory.java
Sat Feb 19 03:22:03 2011
@@ -20,17 +20,19 @@
 package org.apache.directory.shared.ldap.extras.extended.ads_impl;
 
 
-import org.apache.directory.shared.ldap.codec.api.ExtendedOpFactory;
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.ldap.codec.api.ExtendedRequestFactory;
 import org.apache.directory.shared.ldap.extras.extended.CancelRequest;
+import org.apache.directory.shared.ldap.extras.extended.CancelResponse;
 
 
 /**
- * An {@link ExtendedOpFactory} for creating cancel extended request response 
+ * An {@link ExtendedRequestFactory} for creating cancel extended request response 
  * pairs.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CancelExtendedOpFactory implements ExtendedOpFactory<CancelRequest>
+public class CancelFactory implements ExtendedRequestFactory<CancelRequest, CancelResponse>
 {
     /**
      * {@inheritDoc}
@@ -48,4 +50,15 @@ public class CancelExtendedOpFactory imp
     {
         return new CancelRequest();
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public CancelResponse newResponse( byte[] encodedValue ) throws DecoderException
+    {
+        CancelResponse response = new CancelResponse();
+        response.setResponseValue( encodedValue );
+        return response;
+    }
 }

Copied: directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationFactory.java
(from r1072222, directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationExtendedOpFactory.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationFactory.java?p2=directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationFactory.java&p1=directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationExtendedOpFactory.java&r1=1072222&r2=1072235&rev=1072235&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationExtendedOpFactory.java
(original)
+++ directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/CertGenerationFactory.java
Sat Feb 19 03:22:03 2011
@@ -20,17 +20,20 @@
 package org.apache.directory.shared.ldap.extras.extended.ads_impl;
 
 
-import org.apache.directory.shared.ldap.codec.api.ExtendedOpFactory;
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.ldap.codec.api.ExtendedRequestFactory;
 import org.apache.directory.shared.ldap.extras.extended.CertGenerationRequest;
+import org.apache.directory.shared.ldap.extras.extended.CertGenerationResponse;
 
 
 /**
- * An {@link ExtendedOpFactory} for creating cancel extended request response 
+ * An {@link ExtendedRequestFactory} for creating cancel extended request response 
  * pairs.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CertGenerationExtendedOpFactory implements ExtendedOpFactory<CertGenerationRequest>
+public class CertGenerationFactory 
+    implements ExtendedRequestFactory<CertGenerationRequest, CertGenerationResponse>
 {
     /**
      * {@inheritDoc}
@@ -48,4 +51,15 @@ public class CertGenerationExtendedOpFac
     {
         return new CertGenerationRequest();
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public CertGenerationResponse newResponse( byte[] encodedValue ) throws DecoderException
+    {
+        CertGenerationResponse response = new CertGenerationResponse();
+        response.setResponseValue( encodedValue );
+        return response;
+    }
 }

Added: directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulDisconnectFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulDisconnectFactory.java?rev=1072235&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulDisconnectFactory.java
(added)
+++ directory/shared/branches/m1/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulDisconnectFactory.java
Sat Feb 19 03:22:03 2011
@@ -0,0 +1,59 @@
+/*
+ *   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.shared.ldap.extras.extended.ads_impl;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.ldap.codec.api.ExtendedRequestFactory;
+import org.apache.directory.shared.ldap.codec.api.UnsolicitedResponseFactory;
+import org.apache.directory.shared.ldap.extras.extended.GracefulDisconnect;
+
+
+/**
+ * An {@link ExtendedRequestFactory} for creating cancel extended request response 
+ * pairs.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class GracefulDisconnectFactory implements UnsolicitedResponseFactory<GracefulDisconnect>
+{
+    /**
+     * {@inheritDoc}
+     */
+    public String getOid()
+    {
+        return GracefulDisconnect.EXTENSION_OID;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public GracefulDisconnect newRequest()
+    {
+        return new GracefulDisconnect();
+    }
+
+
+    public GracefulDisconnect newResponse( byte[] encodedValue ) throws DecoderException
+    {
+        return new GracefulDisconnect( encodedValue );
+    }
+}



Mime
View raw message