directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1073143 - in /directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras: ./ extended/ extended/ads_impl/
Date Mon, 21 Feb 2011 21:23:38 GMT
Author: akarasulu
Date: Mon Feb 21 21:23:37 2011
New Revision: 1073143

URL: http://svn.apache.org/viewvc?rev=1073143&view=rev
Log:
DIRSHARED-86: properly implemented the graceful shutdown plumbing

Added:
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IGracefulShutdownRequest.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IGracefulShutdownResponse.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownRequestDecorator.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownResponseDecorator.java
Modified:
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulShutdownRequest.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulShutdownResponse.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownFactory.java

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java?rev=1073143&r1=1073142&r2=1073143&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java
(original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java
Mon Feb 21 21:23:37 2011
@@ -37,9 +37,9 @@ import org.apache.directory.shared.ldap.
 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.GracefulDisconnectResponse;
-import org.apache.directory.shared.ldap.extras.extended.GracefulShutdownRequest;
 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.IGracefulShutdownRequest;
 import org.apache.directory.shared.ldap.extras.extended.StoredProcedureRequest;
 import org.apache.directory.shared.ldap.extras.extended.ads_impl.CancelFactory;
 import org.apache.directory.shared.ldap.extras.extended.ads_impl.CertGenerationFactory;
@@ -152,7 +152,7 @@ public class ExtrasBundleActivator imple
         
         codec.unregisterExtendedRequest( CancelRequest.EXTENSION_OID );
         codec.unregisterExtendedRequest( CertGenerationRequest.EXTENSION_OID );
-        codec.unregisterExtendedRequest( GracefulShutdownRequest.EXTENSION_OID );
+        codec.unregisterExtendedRequest( IGracefulShutdownRequest.EXTENSION_OID );
         codec.unregisterExtendedRequest( StoredProcedureRequest.EXTENSION_OID );
         
         codec.unregisterUnsolicitedResponse( GracefulDisconnectResponse.EXTENSION_OID );

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulShutdownRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulShutdownRequest.java?rev=1073143&r1=1073142&r2=1073143&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulShutdownRequest.java
(original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulShutdownRequest.java
Mon Feb 21 21:23:37 2011
@@ -20,18 +20,7 @@
 package org.apache.directory.shared.ldap.extras.extended;
 
 
-import javax.naming.NamingException;
-import javax.naming.ldap.ExtendedResponse;
-
-import org.apache.directory.shared.asn1.DecoderException;
-import org.apache.directory.shared.asn1.EncoderException;
-import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.GracefulShutdown;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.GracefulShutdownDecoder;
-import org.apache.directory.shared.ldap.model.message.ExtendedRequestImpl;
-import org.apache.directory.shared.ldap.model.message.ResultResponse;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.directory.shared.ldap.model.message.AbstractExtendedRequest;
 
 
 /**
@@ -43,23 +32,13 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class GracefulShutdownRequest extends ExtendedRequestImpl
+public class GracefulShutdownRequest extends AbstractExtendedRequest<IGracefulShutdownResponse>
implements IGracefulShutdownRequest
 {
-    /** The logger. */
-    private static final Logger LOG = LoggerFactory.getLogger( GracefulShutdownRequest.class
);
-
     /** The serialVersionUID. */
     private static final long serialVersionUID = -4682291068700593492L;
 
-    /** The OID for the graceful shutdown extended operation request. */
-    public static final String EXTENSION_OID = "1.3.6.1.4.1.18060.0.1.3";
-
-    /** Undetermined value used for offline time */
-    public static final int UNDETERMINED = 0;
-
-    /** The shutdown is immediate */
-    public static final int NOW = 0;
-
+    private IGracefulShutdownResponse response;
+    
     /** Offline time after disconnection */
     private int timeOffline;
 
@@ -105,96 +84,13 @@ public class GracefulShutdownRequest ext
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
-    public void setRequestValue( byte[] requestValue )
-    {
-        GracefulShutdownDecoder decoder = new GracefulShutdownDecoder();
-
-        try
-        {
-            GracefulShutdown gs = (GracefulShutdown) decoder.decode( requestValue );
-
-            if ( requestValue != null )
-            {
-                this.requestValue = new byte[requestValue.length];
-                System.arraycopy( requestValue, 0, this.requestValue, 0, requestValue.length
);
-            }
-            else
-            {
-                this.requestValue = null;
-            }
-
-            this.timeOffline = gs.getTimeOffline();
-            this.delay = gs.getDelay();
-        }
-        catch ( DecoderException e )
-        {
-            LOG.error( I18n.err( I18n.ERR_04165 ), e );
-            throw new RuntimeException( e );
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public ExtendedResponse createExtendedResponse( String id, byte[] berValue, int offset,
int length )
-        throws NamingException
-    {
-        return ( ExtendedResponse ) getResultResponse();
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public byte[] getRequestValue()
-    {
-        if ( requestValue == null )
-        {
-            try
-            {
-                GracefulShutdown gs = new GracefulShutdown();
-                gs.setDelay( this.delay );
-                gs.setTimeOffline( this.timeOffline );
-                requestValue = gs.encode().array();
-            }
-            catch ( EncoderException e )
-            {
-                LOG.error( I18n.err( I18n.ERR_04164 ), e );
-                throw new RuntimeException( e );
-            }
-        }
-
-        return requestValue;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public ResultResponse getResultResponse()
-    {
-        if ( response == null )
-        {
-            GracefulShutdownResponse gsr = new GracefulShutdownResponse( getMessageId() );
-            response = gsr;
-        }
-
-        return response;
-    }
-
-
     // -----------------------------------------------------------------------
     // Parameters of the Extended Request Payload
     // -----------------------------------------------------------------------
 
+
     /**
-     * Gets the delay before disconnection, in seconds.
-     *
-     * @return the delay before disconnection
+     * {@inheritDoc}
      */
     public int getDelay()
     {
@@ -203,9 +99,7 @@ public class GracefulShutdownRequest ext
 
 
     /**
-     * Sets the delay befor disconnection, in seconds.
-     *
-     * @param delay the new delay before disconnection
+     * {@inheritDoc}
      */
     public void setDelay( int delay )
     {
@@ -214,9 +108,7 @@ public class GracefulShutdownRequest ext
 
 
     /**
-     * Gets the offline time after disconnection, in minutes.
-     *
-     * @return the offline time after disconnection
+     * {@inheritDoc}
      */
     public int getTimeOffline()
     {
@@ -225,12 +117,22 @@ public class GracefulShutdownRequest ext
 
 
     /**
-     * Sets the time offline after disconnection, in minutes.
-     *
-     * @param timeOffline the new time offline after disconnection
+     * {@inheritDoc}
      */
     public void setTimeOffline( int timeOffline )
     {
         this.timeOffline = timeOffline;
     }
+
+
+    @Override
+    public IGracefulShutdownResponse getResultResponse()
+    {
+        if ( response == null )
+        {
+            response = new GracefulShutdownResponse();
+        }
+        
+        return response;
+    }
 }

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulShutdownResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulShutdownResponse.java?rev=1073143&r1=1073142&r2=1073143&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulShutdownResponse.java
(original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/GracefulShutdownResponse.java
Mon Feb 21 21:23:37 2011
@@ -32,17 +32,11 @@ import org.apache.directory.shared.ldap.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class GracefulShutdownResponse extends ExtendedResponseImpl
+public class GracefulShutdownResponse extends ExtendedResponseImpl implements IGracefulShutdownResponse
 {
     /** The Constant serialVersionUID. */
     private static final long serialVersionUID = -3824715470944544189L;
 
-    /** The OID for the graceful shutdown extended operation response. */
-    public static final String EXTENSION_OID = "1.3.6.1.4.1.18060.0.1.4";
-
-    /** The empty response. */
-    private static final byte[] EMPTY_RESPONSE = new byte[0];
-
 
     /**
      * Instantiates a new graceful shutdown response.
@@ -103,28 +97,6 @@ public class GracefulShutdownResponse ex
     // ExtendedResponse Interface Method Implementations
     // ------------------------------------------------------------------------
 
-    /**
-     * Gets the reponse OID specific encoded response values.
-     * 
-     * @return the response specific encoded response values.
-     */
-    public byte[] getResponse()
-    {
-        return EMPTY_RESPONSE;
-    }
-
-
-    /**
-     * Sets the reponse OID specific encoded response values.
-     * 
-     * @param value
-     *            the response specific encoded response values.
-     */
-    public void setResponse( byte[] value )
-    {
-        // do nothing here instead
-    }
-
 
     /**
      * Gets the OID uniquely identifying this extended response (a.k.a. its

Added: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IGracefulShutdownRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IGracefulShutdownRequest.java?rev=1073143&view=auto
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IGracefulShutdownRequest.java
(added)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IGracefulShutdownRequest.java
Mon Feb 21 21:23:37 2011
@@ -0,0 +1,79 @@
+/*
+ *  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;
+
+
+import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
+
+
+/**
+ * An extended operation requesting the server to shutdown it's LDAP service
+ * port while allowing established clients to complete or abandon operations
+ * already in progress. More information about this extended request is
+ * available here: <a href="http://docs.safehaus.org:8080/x/GR">LDAP Extensions
+ * for Graceful Shutdown</a>.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface IGracefulShutdownRequest extends ExtendedRequest<IGracefulShutdownResponse>
+{
+
+    /** The OID for the graceful shutdown extended operation request. */
+    String EXTENSION_OID = "1.3.6.1.4.1.18060.0.1.3";
+    
+    /** Undetermined value used for offline time */
+    int UNDETERMINED = 0;
+    
+    /** The shutdown is immediate */
+    int NOW = 0;
+
+
+    /**
+     * Gets the delay before disconnection, in seconds.
+     *
+     * @return the delay before disconnection
+     */
+    int getDelay();
+
+
+    /**
+     * Sets the delay befor disconnection, in seconds.
+     *
+     * @param delay the new delay before disconnection
+     */
+    void setDelay( int delay );
+
+
+    /**
+     * Gets the offline time after disconnection, in minutes.
+     *
+     * @return the offline time after disconnection
+     */
+    int getTimeOffline();
+
+
+    /**
+     * Sets the time offline after disconnection, in minutes.
+     *
+     * @param timeOffline the new time offline after disconnection
+     */
+    void setTimeOffline( int timeOffline );
+
+}
\ No newline at end of file

Added: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IGracefulShutdownResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IGracefulShutdownResponse.java?rev=1073143&view=auto
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IGracefulShutdownResponse.java
(added)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IGracefulShutdownResponse.java
Mon Feb 21 21:23:37 2011
@@ -0,0 +1,18 @@
+package org.apache.directory.shared.ldap.extras.extended;
+
+
+import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
+
+
+/**
+ * The response sent back from the server when a {@link GracefulShutdownRequest}
+ * extended operation is sent. Delivery of this response may block until all
+ * connected clients are sent a GracefulDisconnect unsolicited notification.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface IGracefulShutdownResponse extends ExtendedResponse
+{
+    /** The OID for the graceful shutdown extended operation response. */
+    String EXTENSION_OID = "1.3.6.1.4.1.18060.0.1.4";
+}
\ No newline at end of file

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownFactory.java?rev=1073143&r1=1073142&r2=1073143&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownFactory.java
(original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownFactory.java
Mon Feb 21 21:23:37 2011
@@ -22,8 +22,11 @@ package org.apache.directory.shared.ldap
 
 import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.ldap.codec.api.ExtendedRequestFactory;
+import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
 import org.apache.directory.shared.ldap.extras.extended.GracefulShutdownRequest;
 import org.apache.directory.shared.ldap.extras.extended.GracefulShutdownResponse;
+import org.apache.directory.shared.ldap.extras.extended.IGracefulShutdownRequest;
+import org.apache.directory.shared.ldap.extras.extended.IGracefulShutdownResponse;
 
 
 /**
@@ -33,21 +36,30 @@ import org.apache.directory.shared.ldap.
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class GracefulShutdownFactory 
-    implements ExtendedRequestFactory<GracefulShutdownRequest, GracefulShutdownResponse>
+    implements ExtendedRequestFactory<IGracefulShutdownRequest, IGracefulShutdownResponse>
 {
+    private LdapCodecService codec;
+    
+    
+    public GracefulShutdownFactory( LdapCodecService codec )
+    {
+        this.codec = codec;
+    }
+    
+    
     /**
      * {@inheritDoc}
      */
     public String getOid()
     {
-        return GracefulShutdownRequest.EXTENSION_OID;
+        return IGracefulShutdownRequest.EXTENSION_OID;
     }
 
     
     /**
      * {@inheritDoc}
      */
-    public GracefulShutdownRequest newRequest()
+    public IGracefulShutdownRequest newRequest()
     {
         return new GracefulShutdownRequest();
     }
@@ -56,9 +68,10 @@ public class GracefulShutdownFactory 
     /**
      * {@inheritDoc}
      */
-    public GracefulShutdownResponse newResponse( byte[] encodedValue ) throws DecoderException
+    public IGracefulShutdownResponse newResponse( byte[] encodedValue ) throws DecoderException
     {
-        GracefulShutdownResponse response = new GracefulShutdownResponse();
+        GracefulShutdownResponseDecorator response = new GracefulShutdownResponseDecorator(

+            codec, new GracefulShutdownResponse() );
         response.setResponseValue( encodedValue );
         return response;
     }

Added: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownRequestDecorator.java?rev=1073143&view=auto
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownRequestDecorator.java
(added)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownRequestDecorator.java
Mon Feb 21 21:23:37 2011
@@ -0,0 +1,148 @@
+/*
+ *   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.asn1.EncoderException;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.api.ExtendedRequestDecorator;
+import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.extras.extended.IGracefulShutdownRequest;
+import org.apache.directory.shared.ldap.extras.extended.IGracefulShutdownResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A Decorator for GracefulShutdownRequests.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class GracefulShutdownRequestDecorator extends ExtendedRequestDecorator<IGracefulShutdownRequest,IGracefulShutdownResponse>

+    implements IGracefulShutdownRequest
+{
+    private static final Logger LOG = LoggerFactory.getLogger( GracefulShutdownRequestDecorator.class
);
+    
+
+    /**
+     * Creates a new instance of GracefulShutdownRequestDecorator.
+     *
+     * @param codec
+     * @param decoratedMessage
+     */
+    public GracefulShutdownRequestDecorator( LdapCodecService codec, IGracefulShutdownRequest
decoratedMessage )
+    {
+        super( codec, decoratedMessage );
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setRequestValue( byte[] requestValue )
+    {
+        GracefulShutdownDecoder decoder = new GracefulShutdownDecoder();
+
+        try
+        {
+            GracefulShutdown gs = (GracefulShutdown) decoder.decode( requestValue );
+
+            if ( requestValue != null )
+            {
+                this.requestValue = new byte[requestValue.length];
+                System.arraycopy( requestValue, 0, this.requestValue, 0, requestValue.length
);
+            }
+            else
+            {
+                this.requestValue = null;
+            }
+
+            setTimeOffline( gs.getTimeOffline() );
+            setDelay( gs.getDelay() );
+        }
+        catch ( DecoderException e )
+        {
+            LOG.error( I18n.err( I18n.ERR_04165 ), e );
+            throw new RuntimeException( e );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public byte[] getRequestValue()
+    {
+        if ( requestValue == null )
+        {
+            try
+            {
+                GracefulShutdown gs = new GracefulShutdown();
+                gs.setDelay( getDecorated().getDelay() );
+                gs.setTimeOffline( getDecorated().getTimeOffline() );
+                requestValue = gs.encode().array();
+            }
+            catch ( EncoderException e )
+            {
+                LOG.error( I18n.err( I18n.ERR_04164 ), e );
+                throw new RuntimeException( e );
+            }
+        }
+
+        return requestValue;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getDelay()
+    {
+        return getDecorated().getDelay();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setDelay( int delay )
+    {
+        getDecorated().setDelay( delay );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getTimeOffline()
+    {
+        return getDecorated().getTimeOffline();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setTimeOffline( int timeOffline )
+    {
+        getDecorated().setTimeOffline( timeOffline );
+    }
+}

Added: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownResponseDecorator.java?rev=1073143&view=auto
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownResponseDecorator.java
(added)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownResponseDecorator.java
Mon Feb 21 21:23:37 2011
@@ -0,0 +1,45 @@
+/*
+ *   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.ldap.codec.api.ExtendedResponseDecorator; 
+import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.extras.extended.IGracefulShutdownResponse;
+
+
+/**
+ * A Decorator for CancelResponses.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class GracefulShutdownResponseDecorator extends ExtendedResponseDecorator<IGracefulShutdownResponse>
implements IGracefulShutdownResponse
+{
+    /**
+     * Creates a new instance of CancelResponseDecorator.
+     *
+     * @param codec
+     * @param decoratedMessage
+     */
+    public GracefulShutdownResponseDecorator( LdapCodecService codec, IGracefulShutdownResponse
decoratedMessage )
+    {
+        super( codec, decoratedMessage );
+    }
+}



Mime
View raw message