[ice4j] r138 committed - Moved all configuration property names to StackProperties

ice4j at googlecode.com ice4j at googlecode.com
Sun Apr 25 17:33:36 CEST 2010


Revision: 138
Author: emcho at sip-communicator.org
Date: Sun Apr 25 07:43:56 2010
Log: Moved all configuration property names to StackProperties
http://code.google.com/p/ice4j/source/detail?r=138

Modified:
  /trunk/src/org/ice4j/StackProperties.java
  /trunk/src/org/ice4j/TransportAddress.java
  /trunk/src/org/ice4j/ice/Agent.java
  /trunk/src/org/ice4j/ice/harvest/HostCandidateHarvester.java
  /trunk/src/org/ice4j/ice/harvest/StunCandidateHarvester.java
  /trunk/src/org/ice4j/message/Message.java
  /trunk/src/org/ice4j/stack/Connector.java
  /trunk/src/org/ice4j/stack/StunClientTransaction.java
  /trunk/src/org/ice4j/stack/StunStack.java

=======================================
--- /trunk/src/org/ice4j/StackProperties.java	Tue Jan 26 04:08:19 2010
+++ /trunk/src/org/ice4j/StackProperties.java	Sun Apr 25 07:43:56 2010
@@ -12,6 +12,7 @@
  /**
   * The class contains a number of property names and their default values  
that
   * we use to configure the behavior of the ice4j stack.
+ *
   * @author Emil Ivov
   */
  public class StackProperties
@@ -27,8 +28,7 @@
       * should execute in case a port is already bound to (each retry would  
be on
       * a new random port).
       */
-    public static final String BIND_RETRIES_PROPERTY_NAME
-        = "org.ice4j.BIND_RETRIES";
+    public static final String BIND_RETRIES = "org.ice4j.BIND_RETRIES";

      /**
       * The default number of binds that we would try
@@ -37,6 +37,60 @@
       */
      public static final int BIND_RETRIES_DEFAULT_VALUE = 50;

+    /**
+     * The number of milliseconds a client transaction should wait before
+     * retransmitting, after it has sent a request for the first time.
+     */
+    public static final String FIRST_CTRAN_RETRANS_AFTER
+                                         
= "org.ice4j.FIRST_CTRAN_RETRANS_AFTER";
+
+    /**
+     * The maximum number of milliseconds that an exponential client
+     * retransmission timer can reach.
+     */
+    public static final String MAX_CTRAN_RETRANS_TIMER
+                                    = "org.ice4j.MAX_CTRAN_RETRANS_TIMER";
+
+    /**
+     * Indicates whether a client transaction should be kept after a  
response
+     * is received rather than destroying it which is the default.
+     */
+    public static final String KEEP_CRANS_AFTER_A_RESPONSE
+                                = "org.ice4j.KEEP_CRANS_AFTER_A_RESPONSE";
+
+    /**
+     * The maximum number of retransmissions a client transaction should  
send.
+     */
+    public static final String MAX_CTRAN_RETRANSMISSIONS
+                                = "org.ice4j.MAX_RETRANSMISSIONS";
+
+    /**
+     * The name of the System property that allows us to set a custom  
maximum
+     * for check list sizes.
+     */
+    public static final String MAX_CHECK_LIST_SIZE
+                                        = "org.ice4j.MAX_CHECK_LIST_SIZE";
+
+    /**
+     * The value of the SOFTWARE attribute that ice4j should include in all
+     * outgoing messages.
+     */
+    public static final String SOFTWARE = "org.ice4j.SOFTWARE";
+
+    /**
+     * The name of the property that tells the stack whether or not it  
should
+     * let the application see retransmissions of incoming requests.
+     */
+    public static final String PROPAGATE_RECEIVED_RETRANSMISSIONS
+                        = "org.ice4j.PROPAGATE_RECEIVED_RETRANSMISSIONS";
+
+    /**
+     * A property that allows us to specify whether we would expect link  
local
+     * IPv6 addresses to be able to reach globally routable ones.
+     */
+    public static final String ALLOW_LINK_TO_GLOBAL_REACHABILITY
+                                 
= "org.ice4j.ALLOW_LINK_TO_GLOBAL_REACHABILITY";
+
      /**
       * Returns the String value of the specified property (minus all
       * encompassing whitespaces)and null in case no property value was  
mapped
=======================================
--- /trunk/src/org/ice4j/TransportAddress.java	Sun Feb 28 08:15:14 2010
+++ /trunk/src/org/ice4j/TransportAddress.java	Sun Apr 25 07:43:56 2010
@@ -24,13 +24,6 @@
       */
      private static final long serialVersionUID = 5076001401234631237L;

-    /**
-     * A property that allows us to specify whether we would expect link  
local
-     * IPv6 addresses to be able to reach globally routable ones.
-     */
-    public static final String PNAME_ALLOW_LINK_TO_GLOBAL_REACHABILITY
-                                 
= "org.ice4j.ALLOW_LINK_TO_GLOBAL_REACHABILITY";
-
      /**
       * The variable that we are using to store the transport that this  
address
       * is pertaining to.
@@ -260,10 +253,15 @@
                  //trying to reach a distant global address through one of  
our
                  //own. Therefore we would return false here by default.

-                 
if(Boolean.getBoolean(PNAME_ALLOW_LINK_TO_GLOBAL_REACHABILITY))
+                if(Boolean.getBoolean(
+                             
StackProperties.ALLOW_LINK_TO_GLOBAL_REACHABILITY))
+                {
                      return true;
+                }
                  else
+                {
                      return false;
+                }
              }
          }

=======================================
--- /trunk/src/org/ice4j/ice/Agent.java	Sun Apr 25 07:42:38 2010
+++ /trunk/src/org/ice4j/ice/Agent.java	Sun Apr 25 07:43:56 2010
@@ -37,13 +37,6 @@
      private static final Logger logger
          = Logger.getLogger(Agent.class.getName());

-    /**
-     * The name of the System property that allows us to set a custom  
maximum
-     * for check list sizes.
-     */
-    public static final String PNAME_MAX_CHECK_LIST_SIZE
-                                        = "org.ice4j.MAX_CHECK_LIST_SIZE";
-
      /**
       * The default maximum size for check lists.
       */
@@ -267,7 +260,8 @@

          //init the maximum number of check list entries per stream.
          int maxCheckListSize = Integer.getInteger(
-                        PNAME_MAX_CHECK_LIST_SIZE,  
DEFAULT_MAX_CHECK_LIST_SIZE);
+               StackProperties.MAX_CHECK_LIST_SIZE,
+               DEFAULT_MAX_CHECK_LIST_SIZE);

          int maxPerStreamSize = maxCheckListSize / streams.size();

=======================================
--- /trunk/src/org/ice4j/ice/harvest/HostCandidateHarvester.java	Sun Apr 25  
07:40:11 2010
+++ /trunk/src/org/ice4j/ice/harvest/HostCandidateHarvester.java	Sun Apr 25  
07:43:56 2010
@@ -192,7 +192,7 @@
          }

          int bindRetries = StackProperties.getInt(
-                        StackProperties.BIND_RETRIES_PROPERTY_NAME,
+                        StackProperties.BIND_RETRIES,
                          StackProperties.BIND_RETRIES_DEFAULT_VALUE);

          int port = preferredPort;
=======================================
--- /trunk/src/org/ice4j/ice/harvest/StunCandidateHarvester.java	Sun Apr 25  
07:40:11 2010
+++ /trunk/src/org/ice4j/ice/harvest/StunCandidateHarvester.java	Sun Apr 25  
07:43:56 2010
@@ -78,8 +78,8 @@
          this.stunServer = stunServer;

          //these should be configurable.
-        System.setProperty("org.ice4j.MAX_WAIT_INTERVAL", "400");
-        System.setProperty("org.ice4j.MAX_RETRANSMISSIONS", "2");
+        System.setProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER, "400");
+        System.setProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS, "2");
      }

      /**
=======================================
--- /trunk/src/org/ice4j/message/Message.java	Sun Apr 25 07:42:55 2010
+++ /trunk/src/org/ice4j/message/Message.java	Sun Apr 25 07:43:56 2010
@@ -89,10 +89,10 @@
      public static final byte TRANSACTION_ID_LENGTH = 12;

      /**
-     * The list of attributes contained by the message. We are using a  
hastable
+     * The list of attributes contained by the message. We are using a Map
       * rather than a uni-dimensional list, in order to facilitate attribute
       * search (even though it introduces some redundancies). Order is  
important
-     * so we'll be using a LinkedHashMap
+     * so we'll be using a <tt>LinkedHashMap</tt>
       */
      //not sure this is the best solution but I'm trying to keep entry order
      protected LinkedHashMap<Character, Attribute> attributes
@@ -302,29 +302,22 @@
      {
          return attributes.get(new Character(attributeType));
      }
-
-    /*
-     * Returns an enumeration containing all message attributes.
-     * @return an enumeration containing all message attributes..
-     */
-    /*
-    public Iterator getAttributes()
-    {
-        return attributes.entrySet().iterator();
-    }
-    */

      /**
       * Removes the specified attribute.
+     *
       * @param attributeType the attribute to remove.
+     *
+     * @return the <tt>Attribute</tt> we've just removed.
       */
-    public void removeAttribute(char attributeType)
-    {
-        attributes.remove(new Character(attributeType));
+    public Attribute removeAttribute(char attributeType)
+    {
+        return attributes.remove(new Character(attributeType));
      }

      /**
       * Returns the number of attributes, currently contained by the  
message.
+     *
       * @return the number of attributes, currently contained by the  
message.
       */
      public int getAttributeCount()
@@ -339,6 +332,7 @@
       * as it should not permit changing the type of message once it has  
been
       * initialized (could provoke attribute discrepancies). Called by
       * messageFactory.
+     *
       * @param messageType the message type.
       */
      protected void setMessageType(char messageType)
@@ -348,6 +342,7 @@

      /**
       * The message type of this message.
+     *
       * @return the message type of the message.
       */
      public char getMessageType()
@@ -357,7 +352,9 @@

      /**
       * Copies the specified tranID and sets it as this message's  
transactionID.
+     *
       * @param tranID the transaction id to set in this message.
+     *
       * @throws StunException ILLEGAL_ARGUMENT if the transaction id is not  
valid.
       */
      public void setTransactionID(byte[] tranID)
@@ -375,6 +372,7 @@

      /**
       * Returns a reference to this message's transaction id.
+     *
       * @return a reference to this message's transaction id.
       */
      public byte[] getTransactionID()
@@ -384,7 +382,9 @@

      /**
       * Returns whether an attribute could be present in this message.
+     *
       * @param attributeType the id of the attribute to check .
+     *
       * @return Message.N_A - for not applicable <br/>
       *         Message.C   - for case depending <br/>
       *         Message.N_A - for not applicable <br/>
@@ -451,6 +451,7 @@
       * Returns the human readable name of this message. Message names do
       * not really matter from the protocol point of view. They are only  
used
       * for debugging and readability.
+     *
       * @return this message's name.
       */
      public String getName()
@@ -473,6 +474,7 @@
       * type, length, and all their attributes are equal.
       *
       * @param obj the object to compare this message with.
+     *
       * @return true if the messages are equal and false otherwise.
       */
      public boolean equals(Object obj)
@@ -504,12 +506,16 @@
       * Returns a binary representation of this message.
       *
       * @return a binary representation of this message.
+     *
       * @throws IllegalStateException if the message does not have all
       * required attributes.
       */
      public byte[] encode()
          throws IllegalStateException
      {
+        prepareForEncoding();
+
+        //make sure that
          //make sure we have everything necessary to encode a proper message
          validateAttributePresentity();
          char dataLength = getDataLength();
@@ -553,6 +559,32 @@

          return binMsg;
      }
+
+    /**
+     * Adds attributes that have been requested vis configuration  
properties.
+     * Asserts attribute order where necessary.
+     */
+    private void prepareForEncoding()
+    {
+        //remove MESSAGE-INTEGRITY and FINGERPRINT attributes so that we  
can
+        //make sure they are added at the end.
+        Attribute msgIntegrity =  
removeAttribute(Attribute.MESSAGE_INTEGRITY);
+        Attribute fingerprint  = removeAttribute(Attribute.FINGERPRINT);
+
+        //add a SOFTWARE attribute if the user said so, and unless they  
did it
+        //themselves.
+        String software = System.getProperty(StackProperties.SOFTWARE);
+
+        if (getAttribute(Attribute.SOFTWARE) == null
+            && software != null)
+        {
+            addAttribute(AttributeFactory
+                            .createSoftwareAttribute(software.getBytes()));
+        }
+
+
+        //if ( getAttribute(Attribute.SOFTWARE) != null )
+    }

      /**
       * Constructs a message from its binary representation.
=======================================
--- /trunk/src/org/ice4j/stack/Connector.java	Tue Mar  2 01:12:33 2010
+++ /trunk/src/org/ice4j/stack/Connector.java	Sun Apr 25 07:43:56 2010
@@ -221,7 +221,7 @@
      @Override
      public String toString()
      {
-        return "org.ice4j.stack.AccessPoint@"
+        return "ice4j.Connector@"
                  + listenAddress
                  +" status: "
                  + (isRunning? "not":"")
=======================================
--- /trunk/src/org/ice4j/stack/StunClientTransaction.java	Fri Feb 19  
00:35:15 2010
+++ /trunk/src/org/ice4j/stack/StunClientTransaction.java	Sun Apr 25  
07:43:56 2010
@@ -312,7 +312,7 @@
      void handleResponse(StunMessageEvent evt)
      {
          String keepTran = System.getProperty(
-            "org.ice4j.KEEP_CLIENT_TRANS_AFTER_A_RESPONSE");
+                        StackProperties.KEEP_CRANS_AFTER_A_RESPONSE);

          if( keepTran == null || !keepTran.trim().equalsIgnoreCase("true"))
              this.cancel();
@@ -337,8 +337,8 @@
      private void initTransactionConfiguration()
      {
          //Max Retransmissions
-        String maxRetransmissionsStr =
-            System.getProperty("org.ice4j.MAX_RETRANSMISSIONS");
+        String maxRetransmissionsStr
+            =  
System.getProperty(StackProperties.MAX_CTRAN_RETRANSMISSIONS);

          if(maxRetransmissionsStr != null
             && maxRetransmissionsStr.trim().length() > 0){
@@ -356,8 +356,8 @@
          }

          //Original Wait Interval
-        String originalWaitIntervalStr =
-            System.getProperty("org.ice4j.ORIGINAL_WAIT_INTERVAL");
+        String originalWaitIntervalStr
+            =  
System.getProperty(StackProperties.FIRST_CTRAN_RETRANS_AFTER);

          if(originalWaitIntervalStr != null
             && originalWaitIntervalStr.trim().length() > 0){
@@ -376,8 +376,8 @@
          }

          //Max Wait Interval
-        String maxWaitIntervalStr =
-            System.getProperty("org.ice4j.MAX_WAIT_INTERVAL");
+        String maxWaitIntervalStr
+                =  
System.getProperty(StackProperties.MAX_CTRAN_RETRANS_TIMER);

          if(maxWaitIntervalStr != null
             && maxWaitIntervalStr.trim().length() > 0){
=======================================
--- /trunk/src/org/ice4j/stack/StunStack.java	Sun Apr 25 07:42:10 2010
+++ /trunk/src/org/ice4j/stack/StunStack.java	Sun Apr 25 07:43:56 2010
@@ -400,10 +400,8 @@
                                 "Failed to retransmit a stun response", ex);
                  }

-                String propagate = System.getProperty(
-                    "org.ice4j.PROPAGATE_RECEIVED_RETRANSMISSIONS");
-                if(propagate == null
-                    || !propagate.trim().equalsIgnoreCase("true"))
+                if(Boolean.getBoolean(
+                         
StackProperties.PROPAGATE_RECEIVED_RETRANSMISSIONS))
                  {
                      return;
                  }

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe at sip-communicator.dev.java.net
For additional commands, e-mail: commits-help at sip-communicator.dev.java.net





More information about the commits mailing list