directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r371294 - in /directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations: GracefulAction.java GracefulDisconnect.java GracefulShutdown.java
Date Sun, 22 Jan 2006 13:59:13 GMT
Author: elecharny
Date: Sun Jan 22 05:59:08 2006
New Revision: 371294

URL: http://svn.apache.org/viewcvs?rev=371294&view=rev
Log:
- Updated the javadoco
- Added a common class

Added:
    directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulAction.java
Modified:
    directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulDisconnect.java
    directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulShutdown.java

Added: directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulAction.java
URL: http://svn.apache.org/viewcvs/directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulAction.java?rev=371294&view=auto
==============================================================================
--- directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulAction.java
(added)
+++ directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulAction.java
Sun Jan 22 05:59:08 2006
@@ -0,0 +1,80 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.ldap.common.codec.extended.operations;
+
+import org.apache.asn1.Asn1Object;
+
+/**
+ * A common class for graceful Disconnect and Shutdown extended operations.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public abstract class GracefulAction extends Asn1Object
+{
+    /** Undetermined value used for timeOffline */ 
+    public static final int UNDETERMINED = 0;
+    
+    /** The shutdown is immediate */
+    public static final int NOW = 0;
+
+    /** offline Time after disconnection */ 
+    protected int timeOffline;
+    
+    /** Delay before disconnection */
+    protected int delay;
+    
+    /**
+     * Default constructor. The time offline will be set to UNDETERMINED
+     * and there is no delay.
+     */
+    public GracefulAction()
+    {
+        timeOffline = UNDETERMINED;
+        delay = NOW;
+    }
+
+    /**
+     * Create a GracefulAction object, with a timeOffline and a delay
+     * @param timeOffline The time the server will be offline
+     * @param delay The delay before the disconnection
+     */
+    public GracefulAction( int timeOffline, int delay )
+    {
+        this.timeOffline = timeOffline;
+        this.delay = delay;
+    }
+
+    public int getDelay() {
+        return delay;
+    }
+
+
+    public void setDelay(int delay) {
+        this.delay = delay;
+    }
+
+
+    public int getTimeOffline() {
+        return timeOffline;
+    }
+
+
+    public void setTimeOffline(int timeOffline) {
+        this.timeOffline = timeOffline;
+    }
+}

Modified: directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulDisconnect.java
URL: http://svn.apache.org/viewcvs/directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulDisconnect.java?rev=371294&r1=371293&r2=371294&view=diff
==============================================================================
--- directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulDisconnect.java
(original)
+++ directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulDisconnect.java
Sun Jan 22 05:59:08 2006
@@ -21,7 +21,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.asn1.Asn1Object;
 import org.apache.asn1.ber.tlv.Length;
 import org.apache.asn1.ber.tlv.UniversalTag;
 import org.apache.asn1.ber.tlv.Value;
@@ -35,70 +34,64 @@
  * <pre>
  *  GracefulDisconnect ::= SEQUENCE 
  *  {
- *      timeOffline INTEGER (0..720) DEFAULT 0,
- *      delay [0] INTEGER (0..86400) DEFAULT 0,
- *      replicatedContexts Referral OPTIONAL
+ *      timeOffline           INTEGER (0..720) DEFAULT 0,
+ *      delay             [0] INTEGER (0..86400) DEFAULT 0,
+ *      replicatedContexts    Referral OPTIONAL
  *  }
  * </pre>
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class GracefulDisconnect extends Asn1Object
+public class GracefulDisconnect extends GracefulAction
 {
-    private int timeOffline;
-    private int delay;
+    /** List of the alternate servers to use */
     private List replicatedContexts;
+
+    /** Length of the sequence */
     private transient int gracefulDisconnectSequenceLength;
+    
+    /** Length of the replicated contexts */
     private transient int replicatedContextsLength;
     
+    /**
+     * Create a GracefulDisconnect object, with a timeOffline and a delay
+     * @param timeOffline The time the server will be offline
+     * @param delay The delay before the disconnection
+     */
     public GracefulDisconnect( int timeOffline, int delay )
     {
-        this.timeOffline = timeOffline;
-        this.delay = delay;
-        this.replicatedContexts = new ArrayList(2);
-    }
+        super( timeOffline, delay );
 
-    public GracefulDisconnect()
-    {
-        this.timeOffline = 0;
-        this.delay = 0;
+        // Two urls will be enough, generally
         this.replicatedContexts = new ArrayList(2);
     }
 
-    public int getDelay() 
-    {
-        return delay;
-    }
-
-
-    public void setDelay( int delay ) 
+    /**
+     * Default constructor.
+     *
+     */
+    public GracefulDisconnect()
     {
-        this.delay = delay;
-    }
+        super();
 
-
-    public int getTimeOffline() 
-    {
-        return timeOffline;
+        // Two urls will be enough, generally
+        this.replicatedContexts = new ArrayList(2);
     }
 
-
-    public void setTimeOffline( int timeOffline ) 
-    {
-        this.timeOffline = timeOffline;
-    }
-    
+    /**
+     * Get the list of replicated servers
+     * @return The list of replicated servers
+     */
     public List getReplicatedContexts() 
     {
         return replicatedContexts;
     }
 
-    public void setReplicatedContexts( List replicatedContexts ) 
-    {
-        this.replicatedContexts = replicatedContexts;
-    }
-
+    /** 
+     * Add a new URL of a replicated server
+     * @param replicatedContext The replictaed server to add.
+     */
     public void addReplicatedContexts( LdapURL replicatedContext ) 
     {
         replicatedContexts.add( replicatedContext );
@@ -106,6 +99,7 @@
 
     /**
      * Compute the GracefulDisconnect length
+     * 
      * 0x30 L1
      *  |
      *  +--> [ 0x02 0x0(1-4) [0..720] ]
@@ -113,7 +107,6 @@
      *  +--> [ 0x30 L2
      *          |
      *          +--> (0x04 L3 value) + 
-     *  
      */
     public int computeLength()
     {
@@ -153,7 +146,7 @@
     }
     
     /**
-     * Encodes the gracefulDisconnect extended request.
+     * Encodes the gracefulDisconnect extended operation.
      * 
      * @param buffer The encoded sink
      * @return A ByteBuffer that contains the encoded PDU
@@ -197,10 +190,14 @@
         return bb;
     }
     
+    /**
+     * Return a string representation of the graceful disconnect
+     */
     public String toString()
     {
         StringBuffer sb = new StringBuffer();
         
+        sb.append( "Graceful Disconnect extended operation" );
         sb.append( "    TimeOffline : " ).append( timeOffline ).append( '\n' );
         sb.append( "    Delay : ").append( delay ).append( '\n' );
         

Modified: directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulShutdown.java
URL: http://svn.apache.org/viewcvs/directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulShutdown.java?rev=371294&r1=371293&r2=371294&view=diff
==============================================================================
--- directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulShutdown.java
(original)
+++ directory/trunks/common/ldap/src/main/java/org/apache/ldap/common/codec/extended/operations/GracefulShutdown.java
Sun Jan 22 05:59:08 2006
@@ -18,7 +18,6 @@
 
 import java.nio.ByteBuffer;
 
-import org.apache.asn1.Asn1Object;
 import org.apache.asn1.ber.tlv.Length;
 import org.apache.asn1.ber.tlv.UniversalTag;
 import org.apache.asn1.ber.tlv.Value;
@@ -31,51 +30,19 @@
  * <pre>
  *  GracefulShutdown ::= SEQUENCE
  *  {
- *      timeOffline INTEGER DEFAULT 0,
- *      delay       [0] INTEGER DEFAULT 0 
+ *      timeOffline     INTEGER (0..720) DEFAULT 0,
+ *      delay       [0] INTEGER (0..86400) DEFAULT 0, 
  *  }
  * </pre>
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class GracefulShutdown extends Asn1Object
+public class GracefulShutdown extends GracefulAction
 {
-    private int timeOffline;
-    private int delay;
+    /** Length of the sequence */
     private transient int gracefulSequenceLength;
-    
-    public GracefulShutdown( int timeOffline, int delay )
-    {
-        this.timeOffline = timeOffline;
-        this.delay = delay;
-    }
-
-    public GracefulShutdown()
-    {
-        this.timeOffline = 0;
-        this.delay = 0;
-    }
-
-    public int getDelay() {
-        return delay;
-    }
-
-
-    public void setDelay(int delay) {
-        this.delay = delay;
-    }
 
-
-    public int getTimeOffline() {
-        return timeOffline;
-    }
-
-
-    public void setTimeOffline(int timeOffline) {
-        this.timeOffline = timeOffline;
-    }
-    
     /**
      * Compute the GracefulShutdown length
      * 0x30 L1
@@ -104,7 +71,7 @@
     }
     
     /**
-     * Encodes the gracefulShutdown extended request.
+     * Encodes the gracefulShutdown extended operation.
      * 
      * @param buffer The encoded sink
      * @return A ByteBuffer that contains the encoded PDU
@@ -132,8 +99,17 @@
         return bb;
     }
     
+    /**
+     * Return a string representation of the graceful shutdown
+     */
     public String toString()
     {
-        return "    TimeOffline : " + timeOffline + "\n    Delay : " + delay;
+        StringBuffer sb = new StringBuffer();
+        
+        sb.append( "Graceful Shiutdown extended operation" );
+        sb.append( "    TimeOffline : " ).append( timeOffline ).append( '\n' );
+        sb.append( "    Delay : ").append( delay ).append( '\n' );
+
+        return sb.toString();
     }
 }



Mime
View raw message