flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cd...@apache.org
Subject [40/51] [partial] FLEX-34306 - [BlazeDS] Make the BlazeDS build run on Windows machines - Added some mkdir commands to the ANT Build.java - Did some fine-tuning to resolve some compile errors
Date Mon, 05 May 2014 20:08:54 GMT
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/common/src/flex/messaging/util/UUIDUtils.java
----------------------------------------------------------------------
diff --git a/modules/common/src/flex/messaging/util/UUIDUtils.java b/modules/common/src/flex/messaging/util/UUIDUtils.java
old mode 100755
new mode 100644
index 8df82e3..9fd3c57
--- a/modules/common/src/flex/messaging/util/UUIDUtils.java
+++ b/modules/common/src/flex/messaging/util/UUIDUtils.java
@@ -1,330 +1,330 @@
-/*
- * 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 flex.messaging.util;
-
-import java.util.Random;
-import java.util.UUID;
-
-public class UUIDUtils
-{
-    private static Random _weakRand = new Random();
-	
-    /**
-     * The spec indicates that our time value should be based on 100 nano
-     * second increments but our time granularity is in milliseconds.
-     * The spec also says we can approximate the time by doing an increment
-     * when we dole out new ids in the same millisecond.  We can fit 10,000
-     * 100 nanos into a single millisecond.
-     */
-    private static final int MAX_IDS_PER_MILLI = 10000;
-	
-    /**
-     *  Any given time-of-day value can only be used once; remember the last used
-     *  value so we don't reuse them.
-     *  <p>NOTE: this algorithm assumes the clock will not be turned back.
-     */
-    private static long lastUsedTOD = 0;
-    /** Counter to use when we need more than one id in the same millisecond. */
-    private static int numIdsThisMilli = 0;
-	
-    /**  Hex digits, used for padding UUID strings with random characters. */
-    private static final String alphaNum = "0123456789ABCDEF";
-	
-    /** 4 bits per hex character. */
-    private static final int BITS_PER_DIGIT = 4;
-	
-    private static final int BITS_PER_INT = 32;
-    private static final int BITS_PER_LONG = 64;
-    private static final int DIGITS_PER_INT = BITS_PER_INT / BITS_PER_DIGIT;
-    private static final int DIGITS_PER_LONG = BITS_PER_LONG / BITS_PER_DIGIT;
-	
-    /**
-     *  @private
-     */
-    private static char[] UPPER_DIGITS = new char[] {
-	'0', '1', '2', '3', '4', '5', '6', '7',
-	'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
-    };
-	
-    /**
-     * Private constructor to prevent instances from being created.
-     */
-    private UUIDUtils()
-    {
-    }
-	
-    /**
-     *
-     * Use the createUUID function when you need a unique string that you will
-     * use as a persistent identifier in a distributed environment. To a very
-     * high degree of certainty, this function returns a unique value; no other
-     * invocation on the same or any other system should return the same value.
-     *
-     * @return a Universally Unique Identifier (UUID)
-     * Proper Format: `XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
-     * where `X' stands for a hexadecimal digit (0-9 or A-F).
-     */
-    public static String createUUID()
-    {
-		return createUUID(false);
-	}
-	
-    public static String createUUID(boolean secure) throws Error
-    {
-        Random rand = _weakRand;
-		if (secure)
-			throw new Error("Secure UUIDs not implemented");
-		
-        StringBuffer s = new StringBuffer(36);
-		
-        appendHexString(uniqueTOD(), false, 11, s);
-		
-        //  Just use random padding characters, but ensure that the high bit
-        //  is set to eliminate chances of collision with an IEEE 802 address.
-        s.append(  alphaNum.charAt( rand.nextInt(16) | 8 ) );
-		
-        //  Add random padding characters.
-        appendRandomHexChars(32 - s.length(), rand, s);
-		
-        //insert dashes in proper position. so the format matches CF
-        s.insert(8,"-");
-        s.insert(13,"-");
-        s.insert(18,"-");
-        s.insert(23,"-");
-		
-        return s.toString();
-    }
-
-    /**
-     * Converts a 128-bit UID encoded as a byte[] to a String representation.
-     * The format matches that generated by createUID. If a suitable byte[]
-     * is not provided, null is returned.
-     *
-     * @param ba byte[] 16 bytes in length representing a 128-bit UID.
-     *
-     * @return String representation of the UID, or null if an invalid
-     * byte[] is provided.
-     */
-    public static String fromByteArray(byte[] ba)
-    {
-        if (ba == null || ba.length != 16)
-            return null;
-
-        StringBuffer result = new StringBuffer(36);
-        for (int i = 0; i < 16; i++)
-        {
-            if (i == 4 || i == 6 || i == 8 || i == 10)
-                result.append('-');
-
-            result.append(UPPER_DIGITS[(ba[i] & 0xF0) >>> 4]);
-            result.append(UPPER_DIGITS[(ba[i] & 0x0F)]);
-        }
-        return result.toString();
-    }
-
-	
-    /**
-     * A utility method to check whether a String value represents a
-     * correctly formatted UID value. UID values are expected to be
-     * in the format generated by createUID(), implying that only
-     * capitalized A-F characters in addition to 0-9 digits are
-     * supported.
-     *
-     * @param uid The value to test whether it is formatted as a UID.
-     *
-     * @return Returns true if the value is formatted as a UID.
-     */
-    public static boolean isUID(String uid)
-    {
-        if (uid == null || uid.length() != 36)
-            return false;
-
-        char[] chars = uid.toCharArray();
-        for (int i = 0; i < 36; i++)
-        {
-            char c = chars[i];
-
-            // Check for correctly placed hyphens
-            if (i == 8 || i == 13 || i == 18 || i == 23)
-            {
-                if (c != '-')
-                    return false;
-            }
-            // We allow capital alpha-numeric hex digits only
-            else if (c < 48 || c > 70 || (c > 57 && c < 65))
-            {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    /**
-     * Converts a UID formatted String to a byte[]. The UID must be in the
-     * format generated by createUID, otherwise null is returned.
-     *
-     * @param uid String representing a 128-bit UID.
-     *
-     * @return byte[] 16 bytes in length representing the 128-bits of the
-     * UID or null if the uid could not be converted.
-     */
-    public static byte[] toByteArray(String uid)
-    {
-        if (!isUID(uid))
-            return null;
-
-        byte[] result = new byte[16];
-        char[] chars = uid.toCharArray();
-        int r = 0;
-
-        for (int i = 0; i < chars.length; i++)
-        {
-            if (chars[i] == '-')
-                continue;
-            int h1 = Character.digit(chars[i], 16);
-            i++;
-            int h2 = Character.digit(chars[i], 16);
-            result[r++] = (byte)(((h1 << 4) | h2) & 0xFF);
-        }
-        return result;
-    }
-
-    private static void appendRandomHexChars(int n, Random rand, StringBuffer result)
-    {
-        int digitsPerInt = DIGITS_PER_INT;
-        while (n > 0)
-        {
-            int digitsToUse = Math.min(n, digitsPerInt);
-            n -= digitsToUse;
-            appendHexString(rand.nextInt(), true, digitsToUse, result);
-        }
-    }
-
-    private static void appendHexString
-        (long value, boolean prependZeroes, int nLeastSignificantDigits,
-         StringBuffer result)
-    {
-        int bitsPerDigit = BITS_PER_DIGIT;
-
-        long mask = (1L << bitsPerDigit) - 1;
-
-        if (nLeastSignificantDigits < DIGITS_PER_LONG)
-        {
-            // Clear the bits that we don't care about.
-            value &= (1L << (bitsPerDigit * nLeastSignificantDigits)) - 1;
-        }
-
-        // Reorder the sequence so that the first set of bits will become the
-        // last set of bits.
-        int i = 0;
-        long reorderedValue = 0;
-        if (value == 0)
-        {
-            // One zero is dumped.
-            i++;
-        }
-        else
-        {
-            do
-            {
-                reorderedValue = (reorderedValue << bitsPerDigit) | (value & mask);
-                value >>>= bitsPerDigit;
-                i++;
-            } while (value != 0);
-        }
-
-        if (prependZeroes)
-        {
-            for (int j = nLeastSignificantDigits - i; j > 0; j--)
-            {
-                result.append('0');
-            }
-        }
-
-
-        // Dump the reordered sequence, with the most significant character
-        // first.
-        for (; i > 0; i--)
-        {
-            result.append(alphaNum.charAt((int) (reorderedValue & mask)));
-            reorderedValue >>>= bitsPerDigit;
-        }
-    }
-
-    private static String createInsecureUUID()
-    {
-        StringBuffer s = new StringBuffer(36);
-
-        appendHexString(uniqueTOD(), false, 11, s);
-
-        //  Just use random padding characters, but ensure that the high bit
-        //  is set to eliminate chances of collision with an IEEE 802 address.
-        s.append(  alphaNum.charAt( _weakRand.nextInt(16) | 8 ) );
-
-        //  Add random padding characters.
-        appendRandomHexChars(32 - s.length(), _weakRand, s);
-
-        //insert dashes in proper position. so the format matches CF
-        s.insert(8,"-");
-        s.insert(13,"-");
-        s.insert(18,"-");
-        s.insert(23,"-");
-
-        return s.toString();
-    }
-
-    /**
-     *  @return a time value, unique for calls to this method loaded by the same classloader.
-     */
-    private static synchronized long uniqueTOD()
-    {
-        long currentTOD = System.currentTimeMillis();
-
-        // Clock was set back... do not hang in this case waiting to catch up.
-        // Instead, rely on the random number part to differentiate the ids.
-        if (currentTOD < lastUsedTOD)
-            lastUsedTOD = currentTOD;
-
-        if (currentTOD == lastUsedTOD)
-        {
-            numIdsThisMilli++;
-            /*
-             * Fall back to the old technique of sleeping if we allocate
-             * too many ids in one time interval.
-             */
-            if (numIdsThisMilli >= MAX_IDS_PER_MILLI)
-            {
-                while ( currentTOD == lastUsedTOD )
-                {
-                    try { Thread.sleep(1); } catch ( Exception interrupt ) { /* swallow, wake up */ }
-                    currentTOD = System.currentTimeMillis();
-                }
-                lastUsedTOD = currentTOD;
-                numIdsThisMilli = 0;
-            }
-        }
-        else
-        {
-            //  We have a new TOD, reset the counter
-            lastUsedTOD = currentTOD;
-            numIdsThisMilli = 0;
-        }
-
-        return lastUsedTOD * MAX_IDS_PER_MILLI + (long)numIdsThisMilli;
-    }
-}
+/*
+ * 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 flex.messaging.util;
+
+import java.util.Random;
+import java.util.UUID;
+
+public class UUIDUtils
+{
+    private static Random _weakRand = new Random();
+	
+    /**
+     * The spec indicates that our time value should be based on 100 nano
+     * second increments but our time granularity is in milliseconds.
+     * The spec also says we can approximate the time by doing an increment
+     * when we dole out new ids in the same millisecond.  We can fit 10,000
+     * 100 nanos into a single millisecond.
+     */
+    private static final int MAX_IDS_PER_MILLI = 10000;
+	
+    /**
+     *  Any given time-of-day value can only be used once; remember the last used
+     *  value so we don't reuse them.
+     *  <p>NOTE: this algorithm assumes the clock will not be turned back.
+     */
+    private static long lastUsedTOD = 0;
+    /** Counter to use when we need more than one id in the same millisecond. */
+    private static int numIdsThisMilli = 0;
+	
+    /**  Hex digits, used for padding UUID strings with random characters. */
+    private static final String alphaNum = "0123456789ABCDEF";
+	
+    /** 4 bits per hex character. */
+    private static final int BITS_PER_DIGIT = 4;
+	
+    private static final int BITS_PER_INT = 32;
+    private static final int BITS_PER_LONG = 64;
+    private static final int DIGITS_PER_INT = BITS_PER_INT / BITS_PER_DIGIT;
+    private static final int DIGITS_PER_LONG = BITS_PER_LONG / BITS_PER_DIGIT;
+	
+    /**
+     *  @private
+     */
+    private static char[] UPPER_DIGITS = new char[] {
+	'0', '1', '2', '3', '4', '5', '6', '7',
+	'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
+    };
+	
+    /**
+     * Private constructor to prevent instances from being created.
+     */
+    private UUIDUtils()
+    {
+    }
+	
+    /**
+     *
+     * Use the createUUID function when you need a unique string that you will
+     * use as a persistent identifier in a distributed environment. To a very
+     * high degree of certainty, this function returns a unique value; no other
+     * invocation on the same or any other system should return the same value.
+     *
+     * @return a Universally Unique Identifier (UUID)
+     * Proper Format: `XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
+     * where `X' stands for a hexadecimal digit (0-9 or A-F).
+     */
+    public static String createUUID()
+    {
+		return createUUID(false);
+	}
+	
+    public static String createUUID(boolean secure) throws Error
+    {
+        Random rand = _weakRand;
+		if (secure)
+			throw new Error("Secure UUIDs not implemented");
+		
+        StringBuffer s = new StringBuffer(36);
+		
+        appendHexString(uniqueTOD(), false, 11, s);
+		
+        //  Just use random padding characters, but ensure that the high bit
+        //  is set to eliminate chances of collision with an IEEE 802 address.
+        s.append(  alphaNum.charAt( rand.nextInt(16) | 8 ) );
+		
+        //  Add random padding characters.
+        appendRandomHexChars(32 - s.length(), rand, s);
+		
+        //insert dashes in proper position. so the format matches CF
+        s.insert(8,"-");
+        s.insert(13,"-");
+        s.insert(18,"-");
+        s.insert(23,"-");
+		
+        return s.toString();
+    }
+
+    /**
+     * Converts a 128-bit UID encoded as a byte[] to a String representation.
+     * The format matches that generated by createUID. If a suitable byte[]
+     * is not provided, null is returned.
+     *
+     * @param ba byte[] 16 bytes in length representing a 128-bit UID.
+     *
+     * @return String representation of the UID, or null if an invalid
+     * byte[] is provided.
+     */
+    public static String fromByteArray(byte[] ba)
+    {
+        if (ba == null || ba.length != 16)
+            return null;
+
+        StringBuffer result = new StringBuffer(36);
+        for (int i = 0; i < 16; i++)
+        {
+            if (i == 4 || i == 6 || i == 8 || i == 10)
+                result.append('-');
+
+            result.append(UPPER_DIGITS[(ba[i] & 0xF0) >>> 4]);
+            result.append(UPPER_DIGITS[(ba[i] & 0x0F)]);
+        }
+        return result.toString();
+    }
+
+	
+    /**
+     * A utility method to check whether a String value represents a
+     * correctly formatted UID value. UID values are expected to be
+     * in the format generated by createUID(), implying that only
+     * capitalized A-F characters in addition to 0-9 digits are
+     * supported.
+     *
+     * @param uid The value to test whether it is formatted as a UID.
+     *
+     * @return Returns true if the value is formatted as a UID.
+     */
+    public static boolean isUID(String uid)
+    {
+        if (uid == null || uid.length() != 36)
+            return false;
+
+        char[] chars = uid.toCharArray();
+        for (int i = 0; i < 36; i++)
+        {
+            char c = chars[i];
+
+            // Check for correctly placed hyphens
+            if (i == 8 || i == 13 || i == 18 || i == 23)
+            {
+                if (c != '-')
+                    return false;
+            }
+            // We allow capital alpha-numeric hex digits only
+            else if (c < 48 || c > 70 || (c > 57 && c < 65))
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * Converts a UID formatted String to a byte[]. The UID must be in the
+     * format generated by createUID, otherwise null is returned.
+     *
+     * @param uid String representing a 128-bit UID.
+     *
+     * @return byte[] 16 bytes in length representing the 128-bits of the
+     * UID or null if the uid could not be converted.
+     */
+    public static byte[] toByteArray(String uid)
+    {
+        if (!isUID(uid))
+            return null;
+
+        byte[] result = new byte[16];
+        char[] chars = uid.toCharArray();
+        int r = 0;
+
+        for (int i = 0; i < chars.length; i++)
+        {
+            if (chars[i] == '-')
+                continue;
+            int h1 = Character.digit(chars[i], 16);
+            i++;
+            int h2 = Character.digit(chars[i], 16);
+            result[r++] = (byte)(((h1 << 4) | h2) & 0xFF);
+        }
+        return result;
+    }
+
+    private static void appendRandomHexChars(int n, Random rand, StringBuffer result)
+    {
+        int digitsPerInt = DIGITS_PER_INT;
+        while (n > 0)
+        {
+            int digitsToUse = Math.min(n, digitsPerInt);
+            n -= digitsToUse;
+            appendHexString(rand.nextInt(), true, digitsToUse, result);
+        }
+    }
+
+    private static void appendHexString
+        (long value, boolean prependZeroes, int nLeastSignificantDigits,
+         StringBuffer result)
+    {
+        int bitsPerDigit = BITS_PER_DIGIT;
+
+        long mask = (1L << bitsPerDigit) - 1;
+
+        if (nLeastSignificantDigits < DIGITS_PER_LONG)
+        {
+            // Clear the bits that we don't care about.
+            value &= (1L << (bitsPerDigit * nLeastSignificantDigits)) - 1;
+        }
+
+        // Reorder the sequence so that the first set of bits will become the
+        // last set of bits.
+        int i = 0;
+        long reorderedValue = 0;
+        if (value == 0)
+        {
+            // One zero is dumped.
+            i++;
+        }
+        else
+        {
+            do
+            {
+                reorderedValue = (reorderedValue << bitsPerDigit) | (value & mask);
+                value >>>= bitsPerDigit;
+                i++;
+            } while (value != 0);
+        }
+
+        if (prependZeroes)
+        {
+            for (int j = nLeastSignificantDigits - i; j > 0; j--)
+            {
+                result.append('0');
+            }
+        }
+
+
+        // Dump the reordered sequence, with the most significant character
+        // first.
+        for (; i > 0; i--)
+        {
+            result.append(alphaNum.charAt((int) (reorderedValue & mask)));
+            reorderedValue >>>= bitsPerDigit;
+        }
+    }
+
+    private static String createInsecureUUID()
+    {
+        StringBuffer s = new StringBuffer(36);
+
+        appendHexString(uniqueTOD(), false, 11, s);
+
+        //  Just use random padding characters, but ensure that the high bit
+        //  is set to eliminate chances of collision with an IEEE 802 address.
+        s.append(  alphaNum.charAt( _weakRand.nextInt(16) | 8 ) );
+
+        //  Add random padding characters.
+        appendRandomHexChars(32 - s.length(), _weakRand, s);
+
+        //insert dashes in proper position. so the format matches CF
+        s.insert(8,"-");
+        s.insert(13,"-");
+        s.insert(18,"-");
+        s.insert(23,"-");
+
+        return s.toString();
+    }
+
+    /**
+     *  @return a time value, unique for calls to this method loaded by the same classloader.
+     */
+    private static synchronized long uniqueTOD()
+    {
+        long currentTOD = System.currentTimeMillis();
+
+        // Clock was set back... do not hang in this case waiting to catch up.
+        // Instead, rely on the random number part to differentiate the ids.
+        if (currentTOD < lastUsedTOD)
+            lastUsedTOD = currentTOD;
+
+        if (currentTOD == lastUsedTOD)
+        {
+            numIdsThisMilli++;
+            /*
+             * Fall back to the old technique of sleeping if we allocate
+             * too many ids in one time interval.
+             */
+            if (numIdsThisMilli >= MAX_IDS_PER_MILLI)
+            {
+                while ( currentTOD == lastUsedTOD )
+                {
+                    try { Thread.sleep(1); } catch ( Exception interrupt ) { /* swallow, wake up */ }
+                    currentTOD = System.currentTimeMillis();
+                }
+                lastUsedTOD = currentTOD;
+                numIdsThisMilli = 0;
+            }
+        }
+        else
+        {
+            //  We have a new TOD, reset the counter
+            lastUsedTOD = currentTOD;
+            numIdsThisMilli = 0;
+        }
+
+        return lastUsedTOD * MAX_IDS_PER_MILLI + (long)numIdsThisMilli;
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/build.xml
----------------------------------------------------------------------
diff --git a/modules/core/build.xml b/modules/core/build.xml
index 8812542..9053766 100755
--- a/modules/core/build.xml
+++ b/modules/core/build.xml
@@ -21,26 +21,17 @@
 
     <!-- properties -->
     <property file="${basedir}/build.properties"/>
-    <property name="module.dir" value="${basedir}/modules/core"/>
-    <property name="test.dir" value="${module.dir}/test/src"/>
-
-    <!-- to exclude tests, add test.excludes to local.properties -->
-    <property file="${test.dir}/local.properties"/>
-    <!-- Set up feature to can run subset of tests -->
-    <property file="${qa.dir}/features/${feature}.properties" /> <!-- includes only feature -->
-    <property file="${qa.dir}/features/full.properties" />       <!-- includes all filesets -->
-
     <property name="lib.dir" value="${basedir}/lib"/>
-    <property name="module.lib.dir" location="${module.dir}/lib"/>
+
+    <property name="module.dir" value="${basedir}/modules/core"/>
+    <property name="module.lib.dir" location="${module.dir}/lib"/>
     <property name="tomcat.lib.dir" location="${basedir}/servers/apache-tomcat-6.0.29/lib" />
     <property name="module.src" value="${module.dir}/src"/>
     <property name="module.classes" value="${module.dir}/classes"/>
     <property name="module.jar" value="${lib.dir}/flex-messaging-core.jar"/>
-    <property name="module.test.src" value="${module.dir}/test/src"/>
-    <property name="module.test.classes" value="${module.dir}/test/classes"/>
     <property name="module.dist.dir" value="${basedir}/dist/source"/>
-    <property name="common.src" value="${basedir}/modules/common/src"/>
 
+    <property name="common.src" value="${basedir}/modules/common/src"/>
     <property name="remoting.src" value="${basedir}/modules/remoting/src"/>
     <property name="proxy.src" value="${basedir}/modules/proxy/src"/>
     <property name="opt.src" value="${basedir}/modules/opt/src"/>    
@@ -49,14 +40,9 @@
 
     <!-- j2ee apis required to compile -->
     <path id="classpath">
-        <fileset dir="${lib.dir}" includes="**/*.jar"/>
-        <fileset dir="${module.lib.dir}" includes="**/*.jar"/>
-        <fileset dir="${tomcat.lib.dir}" includes="**/*.jar"/>
-    </path>
-
-    <path id="test.classpath">
-        <fileset dir="${lib.dir}" includes="**/*.jar" excludes="adt.jar" />
-        <pathelement location="${module.test.classes}"/>
+        <fileset dir="${lib.dir}" erroronmissingdir="false" includes="**/*.jar"/>
+        <fileset dir="${module.lib.dir}" erroronmissingdir="false" includes="**/*.jar"/>
+        <fileset dir="${tomcat.lib.dir}" erroronmissingdir="false" includes="**/*.jar"/>
     </path>
 
     <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
@@ -81,9 +67,8 @@
            	<exclude name="flex/messaging/cluster/JGroupsCluster.java" />
            	<exclude name="flex/messaging/cluster/ClusterNode.java" />
            	<exclude name="flex/messaging/cluster/ClusterMembershipListener.java" />
-            </javac>
+        </javac>
         <echo file="${module.classes}/flex/messaging/version.properties" append="false">build=${build.number}</echo>
-			
         <copy todir="${module.classes}/flex/messaging" overwrite="true">
             <fileset dir="${module.src}/flex/messaging" includes="*.properties"/>
         </copy>
@@ -107,7 +92,6 @@
 
     <!-- jar containing messaging core infrastructure -->
     <target name="jar" depends="compile,compile-jgroups">
-
         <jar destfile="${module.jar}" basedir="${module.classes}">
             <include name="AdobeInfo.xml"/>
             <include name="flex/management/**"/>
@@ -121,11 +105,9 @@
 			    <attribute name="Implementation-Vendor" value="${manifest.Implementation-Vendor}"/>
             </manifest>
         </jar>
-
         <delete failonerror="false">
             <fileset dir="${module.classes}/flex/messaging" includes="*.properties"/>
         </delete>
-
     </target>
 
     <target name="clean" description="clean">
@@ -137,81 +119,14 @@
                 <exclude name=".dependency-info/**"/>
             </fileset>
         </delete>
-        <delete dir="${module.test.classes}" failonerror="false" includeEmptyDirs="true"/>
-        <delete dir="${module.classes}" failonerror="false" includeEmptyDirs="true"/>
-    </target>
-
-	<!-- only run unit tests if junit present -->
-    <condition property="junit.available">
-        <available file="${junit.jar}" />
-    </condition>
-
-    <target name="startserver" description="Start Tomcat Server">
-        <ant antfile="${basedir}/build.xml" target="startserver"/>
-    </target>
-
-    <target name="stopserver" description="Stop Tomcat Server">
-        <ant antfile="${basedir}/build.xml" target="stopserver"/>
-    </target>
-
- 	<target name="waitforAppserverToStart">
-        <ant antfile="${basedir}/build.xml" target="waitforAppserverToStart"/>
-    </target>
-    
-    <target name="unit" depends="startserver, waitforAppserverToStart, runtests, stopserver, check-test-results" description="runs unit tests">
-        <if>
-            <not>
-                <equals arg1="${junit.available}" arg2="true"/>
-            </not>
-            <then>
-                <echo>Unit test can not be run as junit.jar was not found in ${ant.home}/lib. See http://www.junit.org</echo>
-            </then>
-        </if>
-    </target>
-
-    <target name="compile-tests" if="junit.available">
-        <echo message="Compiling test code..."/>
-        <mkdir dir="${module.test.classes}"/>
-
-        <javac srcdir="${module.test.src}" destdir="${module.test.classes}" debug="true">
-            <classpath refid="classpath"/>
-        </javac>
-
-        <copy todir="${module.test.classes}">
-            <fileset dir="${module.test.src}" includes="**/*.xml,**/*.xsd"/>
-        </copy>
-    </target>
-
-    <target name="runtests" depends="compile-tests" if="junit.available">
-        <junit printsummary="yes" dir="${test.dir}" fork="yes" maxmemory="1024m" timeout="90000" showoutput="yes"
-            haltonerror="false"
-            haltonfailure="false" 
-            failureproperty="test-failed">
-            <sysproperty key="royale.home" value="${basedir}"/>
-            <classpath refid="test.classpath"/>
-            <formatter type="xml" usefile="true"/>
-            <batchtest fork="yes">
-                <fileset dir="${module.test.src}"
-                    includes="${junit.core.includes}"
-                    excludes="${junit.core.excludes}"/>
-            </batchtest>
-        </junit>
-    </target>
-
-    <!-- If one of more unit tests fail, runtests sets unit-test-failed property
-         which gets checked by this target and reported
-    -->
-    <target name="check-test-results">
-        <fail if="test-failed" message="One or more unit tests failed."/>
+        <delete dir="${module.classes}" failonerror="false" includeEmptyDirs="true"/>
     </target>
 
    <target name="javadoc">
-
         <path id="javadoc.classpath">
             <path refid="classpath"/>
             <fileset dir="${basedir}/modules/opt/lib" includes="*.jar" excludes="catalina-708.jar"/>
         </path>
-
         <mkdir dir="${basedir}/docs"/>
         <mkdir dir="${basedir}/docs/api"/>
         <javadoc
@@ -236,9 +151,9 @@
              <group title="Configuration APIs" packages="flex.messaging.config:flex.messaging.security"/>
              <group title="Management APIs" packages="flex.management, flex.management.jmx, flex.management.runtime.*"/>
              <link offline="false" href="http://java.sun.com/j2se/1.5.0/docs/api/" packagelistLoc="C:\tmp"/>
-</javadoc>
-  <zip destfile="${basedir}/docs/javadoc.zip" basedir="${basedir}/docs/api" />
-</target>
+        </javadoc>
+        <zip destfile="${basedir}/docs/javadoc.zip" basedir="${basedir}/docs/api" />
+    </target>
 
 </project>
 

http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/pom.xml
----------------------------------------------------------------------
diff --git a/modules/core/pom.xml b/modules/core/pom.xml
index 00bb179..d4654d5 100755
--- a/modules/core/pom.xml
+++ b/modules/core/pom.xml
@@ -23,7 +23,7 @@ limitations under the License.
 	<parent>
         <groupId>org.apache.flex.blazeds</groupId>
 		<artifactId>blazeds</artifactId>
-		<version>4.6.0.0-SNAPSHOT</version>
+		<version>4.7.0.0-SNAPSHOT</version>
 		<relativePath>../pom.xml</relativePath>
 	</parent>
 
@@ -64,27 +64,18 @@ limitations under the License.
 			<scope>provided</scope>
 		</dependency>
 
-
-		<dependency>
-			<groupId>junit</groupId>
-			<artifactId>junit</artifactId>
-			<version>3.8.2</version>
-			<scope>test</scope>
-		</dependency>
+        <!-- needed in order to build the ExcludeDoclet -->
+        <dependency>
+            <groupId>com.sun</groupId>
+            <artifactId>tools</artifactId>
+            <version>jdk-version</version>
+            <scope>system</scope>
+            <systemPath>${java.home}/../lib/tools.jar</systemPath>
+        </dependency>
 	</dependencies>
 
 	<build>
 		<sourceDirectory>src</sourceDirectory>
-		<testSourceDirectory>test/src</testSourceDirectory>
-        <testResources>
-            <testResource>
-                <directory>test/src</directory>
-                <includes>
-                    <include>**/*.xml</include>
-                    <include>**/*.xsd</include>
-                </includes>
-            </testResource>
-        </testResources>
 		<plugins>
 			<plugin>
 				<groupId>org.codehaus.mojo</groupId>

http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/BaseControl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/BaseControl.java b/modules/core/src/flex/management/BaseControl.java
old mode 100755
new mode 100644
index 321649f..5877286
--- a/modules/core/src/flex/management/BaseControl.java
+++ b/modules/core/src/flex/management/BaseControl.java
@@ -1,512 +1,512 @@
-/*
- * 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 flex.management;
-
-import flex.management.runtime.AdminConsoleDisplayRegistrar;
-import flex.messaging.FlexContext;
-
-import java.util.Date;
-import java.util.List;
-import java.util.ArrayList;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MalformedObjectNameException;
-import javax.management.MBeanRegistration;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-import javax.servlet.ServletConfig;
-
-/**
- * The implementation of the <code>BaseControlMBean</code> interface. This
- * abstract class provides the core functionality that all Flex control MBeans
- * require.
- * <p>
- * Defining concrete implementations of <code>getId()</code> and
- * <code>getType()</code> are left to subclasses, but this base class does
- * provide access to the parent MBean for each instance. This class also
- * implements the <code>MBeanRegistration</code> interface, and it
- * automatically stores a reference to the MBean server in each instance upon
- * registration. Subclasses may choose to override none, any, or all of the
- * methods defined by the <code>MBeanRegistration</code> interface, but any
- * overrides should be sure to invoke the overridden method with a call to their
- * superclass.
- * </p><p>
- * The <code>register()</code> method provides a simple and consistent way to
- * register instances with the MBean server, and the
- * <code>getObjectName()</code> method gaurantees consistent, well-formed
- * <code>ObjectName</code>s for all MBean instances.</p>
- *
- * @author shodgson
- */
-public abstract class BaseControl implements BaseControlMBean,
-        MBeanRegistration
-{
-    /**
-     * The prefix used for the domain part of control MBean names.
-     */
-    public static final String DOMAIN_PREFIX = "flex.runtime";
-    private static final int MALFORMED_OBJECTNAME = 10400;
-    private static final int UNREG_EXCEPTION = 10401;
-    private static final int UNREG_NOTFOUND = 10402;
-    private static final int REG_EXCEPTION = 10403;
-    private static final int REG_ALREADYEXISTS = 10404;
-    private static final int REG_NOTCOMPLIANT = 10405;
-    private static final int DISABLE_MANAGEMENT = 10426;    
-
-    protected Date startTimestamp;
-    private BaseControl parent;
-    private ObjectName objectName;
-    private ObjectName registeredObjectName;
-    private MBeanServer server;
-    private boolean registered = false;
-
-    private AdminConsoleDisplayRegistrar registrar;
-
-    // Implements flex.management.BaseControlMBean.getId; inherits javadoc
-    // specification.
-    public abstract String getId();
-
-    // Implements flex.management.BaseControlMBean.getType; inherits javadoc
-    // specification.
-    public abstract String getType();
-
-    // Implements flex.management.BaseControlMBean.getParent; inherits javadoc
-    // specification.
-    public final ObjectName getParent()
-    {
-        return (parent != null) ? parent.getObjectName() : null;
-    }
-
-    /**
-     * Returns an identifier for the application that hosts the component that
-     * this control manages.
-     *
-     * @return An identifier for the application that hosts the component this
-     *         control manages.
-     */
-    public String getApplicationId()
-    {
-        String id = null;
-        // Our base implementation attempts to use the current servlet context
-        // name as our application identifier.
-        ServletConfig config = FlexContext.getServletConfig();
-        if (config != null)
-        {
-            id = config.getServletContext().getServletContextName();
-        }
-        return (id != null) ? id.replace(":", "") : "";
-    }
-
-    /**
-     * Set the register object. 
-     * @param registar the registrar to set
-     */
-    protected void setRegistrar(AdminConsoleDisplayRegistrar registrar)
-    {
-        this.registrar = registrar;
-    }
-
-    /**
-     * Return the registar object.
-     * @return the registrar
-     */
-    public AdminConsoleDisplayRegistrar getRegistrar()
-    {
-        if ((parent == null) && (this.registrar == null))
-        {
-            return new AdminConsoleDisplayRegistrar(null);
-        }
-
-        return (this.registrar != null) ? this.registrar : parent.getRegistrar();
-    }
-
-    /**
-     * Constructs a <code>BaseControl</code> instance that references its
-     * parent; the parent may be null for root control MBeans.
-     *
-     * @param parent The parent <code>BaseControl</code> for this instance or
-     *        null if this instance is the root of a control hierarchy.
-     */
-    public BaseControl(BaseControl parent)
-    {
-        this.parent = parent;
-    }
-
-    /**
-     * Returns the parent <code>BaseControl</code> of this instance.
-     *
-     * @return The parent <code>BaseControl</code>.
-     */
-    public final BaseControl getParentControl()
-    {
-        return parent;
-    }
-
-    /**
-     * The <code>MBeanServer</code> that this instance is registered with. If
-     * this instance has not been registered this method returns
-     * <code>null</code>.
-     *
-     * @return The <code>MBeanServer</code> that this instance is registered
-     *         with.
-     */
-    public final MBeanServer getMBeanServer()
-    {
-        return server;
-    }
-
-    /**
-     * Registers this instance with the MBean server.
-     *
-     * It may throw ManagementException If an <code>MBeanRegistrationException</code>
-     *         or <code>InstanceAlreadyExistsException</code> is thrown while
-     *         registering this MBean, the typed exception is wrapped in a
-     *         runtime <code>ManagementException</code> and rethrown.
-     */
-    public final void register()
-    {
-        if (!registered)
-        {
-            MBeanServer server = MBeanServerLocatorFactory.getMBeanServerLocator().getMBeanServer();
-            ObjectName name = getObjectName();
-            try
-            {
-                if (server.isRegistered(name))
-                {
-                    server.unregisterMBean(name);
-                }
-
-                registeredObjectName = server.registerMBean(this, name).getObjectName();
-                registered = true;
-                onRegistrationComplete();
-
-            }
-            catch (ManagementException me)
-            {
-                throw me;
-            }
-            catch (MBeanRegistrationException mre)
-            {
-                // Rethrow with useful message if this ever happens.
-                ManagementException me = new ManagementException();
-                me.setMessage(REG_EXCEPTION, new Object[] {name.toString()});
-                me.setRootCause(mre);
-                throw me;
-            }
-            catch (InstanceAlreadyExistsException iaee)
-            {
-                // If registration is not working at all, inform the user that
-                // they may
-                // work around the issue by disabling management (no MBeans will
-                // be registered).
-                if (!server.isRegistered(name))
-                {
-                    ManagementException me = new ManagementException();
-                    me.setMessage(DISABLE_MANAGEMENT, new Object[] {name.toString()});
-                    throw me;
-                }
-                else
-                {
-                    // Rethrow with useful message if this ever happens.
-                    ManagementException me = new ManagementException();
-                    me.setMessage(REG_ALREADYEXISTS, new Object[] {name.toString()});
-                    throw me;
-                }
-            }
-            catch (NotCompliantMBeanException ncme)
-            {
-                // Rethrow with useful message if this ever happens.
-                ManagementException me = new ManagementException();
-                me.setMessage(REG_NOTCOMPLIANT, new Object[] {name.toString()});
-                throw me;
-            }
-            catch (InstanceNotFoundException infe)
-            {
-                // Rethrow with useful message if this ever happens.
-                ManagementException me = new ManagementException();
-                me.setMessage(UNREG_NOTFOUND, new Object[] {name.toString()});
-                throw me;
-            }
-        }
-    }
-
-    /**
-     * This method is called after the MBean has been registered and after the
-     * MBean server has returned the registeredObjectName. Classes that need
-     * access to the actual Object name should override this method rather than
-     * the postRegister method.
-     */
-    protected void onRegistrationComplete()
-    {
-
-    }
-
-    /**
-     * Unregisters this instance from the MBean server if it has been registered
-     * previously.
-     */
-    public final void unregister()
-    {
-        if (registered)
-        {
-            // This method may be called when the JVM is being unloaded, so if
-            // our
-            // external error strings are loaded as missing, fall back to
-            // hard-coded
-            // strings.
-            try
-            {
-                if (server.isRegistered(registeredObjectName))
-                {
-                    server.unregisterMBean(registeredObjectName);
-                }
-
-                registeredObjectName = null;
-                registered = false;
-            }
-            catch (ManagementException me)
-            {
-                throw me;
-            }
-            catch (MBeanRegistrationException mre)
-            {
-                // Rethrow with useful message if this ever happens.
-                ManagementException me = new ManagementException();
-                me.setMessage(UNREG_EXCEPTION, new Object[] {registeredObjectName.toString()});
-                if (me.getMessage().indexOf(Integer.toString(UNREG_EXCEPTION)) != -1)
-                {
-                    me.setMessage("The MBean named, '" + registeredObjectName.toString() + "', could not be unregistered because its preDeregister() method threw an exception.");
-                }
-                me.setRootCause(mre);
-                throw me;
-            }
-            catch (InstanceNotFoundException infe)
-            {
-                // Rethrow with useful message if this ever happens.
-                ManagementException me = new ManagementException();
-                me.setMessage(UNREG_NOTFOUND, new Object[] {registeredObjectName.toString()});
-                if (me.getMessage().indexOf(Integer.toString(UNREG_NOTFOUND)) != -1)
-                {
-                    me.setMessage("The MBean named, '" + registeredObjectName.toString() + "', could not be unregistered because it is not currently registered.");
-                }
-                throw me;
-            }
-        }
-    }
-
-    /**
-     * Returns the <code>ObjectName</code> for this instance, according to the
-     * following format:
-     * <code>{domain}[&amp;#46;{appId}]:type={type}[&amp;#44;{parent type}={parent id}]*[&amp;#44;server={server}]&amp;#63;&amp;#44;id={id}</code>.
-     * <ul>
-     * <li><code>domain</code>: The domain specified by the DOMAIN_PREFIX
-     * constant followed by the application identifier if one is available.</li>
-     * <li><code>type</code>: The short type name of the resource managed by
-     * the MBean.<br /> - The <code>MessageBrokerControlMBean</code> manages
-     * the <code>flex.messaging.MessageBroker</code> so:
-     * <code>type=MessageBroker</code> </li>
-     * <li><code>id</code>: The id value for the resource managed by this
-     * MBean. If no name or id is available on the resource, an id will be
-     * fabricated according to this strategy:<br />
-     * <em>id = {type} + N</em> (where N is a numeric increment for instances
-     * of this type) </li>
-     * <li>* optional containment keys</li>
-     * </ul>
-     * The runtime MBean model is hierarchical, with all MBeans ultimately
-     * contained by the root <code>MessageBrokerControlMBean</code>. The 
-     * <code>ObjectName</code>s used for these MBeans describe this
-     * containment in the following fashion. First, the 'type' key for a
-     * contained MBean indicates the containment hierarchy for the bean. So, the
-     * <code>ObjectName</code> for an <code>RTMPEndpointControlMBean</code>
-     * would be: <code>type=MessageBroker.RTMPEndpoint</code><br />
-     * In addition to the hierarchical 'type' key, the full
-     * <code>ObjectName</code> for this <code>RTMPEndpointControlMBean</code>
-     * also contains a containment key:
-     * <code>MessageBroker=MessageBroker1</code><br />
-     * Optional containment keys have the format:
-     * <em>{parent type}={parent name}</em>. A containment key is added for
-     * each ancestor up to the root of the hierarchy and these keys allow the
-     * <code>ObjectName</code> for any MBean instance to fully describe its
-     * specific location in the hierarchy. To complete the example, the full
-     * <code>ObjectName</code> for the example
-     * <code>RTMPEndpointControlMBean</code> would be:
-     * <code>flex:type=MessageBroker.RTMPEndpoint,MessageBroker=MessageBroker1,id=RTMPEndpoint1</code>
-     * <p>
-     * If the MBean is registered with the MBean server, this method returns the
-     * <code>ObjectName</code> that the MBean was registered under and this
-     * value may contain additional key-value pairs injected by the container or
-     * MBean server.
-     * </p>
-     *
-     * @return The <code>ObjectName</code> for this instance.
-     */
-    public final ObjectName getObjectName()
-    {
-        if (registered)
-            return registeredObjectName;
-
-        if (objectName == null)
-        {
-            StringBuffer buffer = new StringBuffer();
-            buffer.append(DOMAIN_PREFIX);
-            String appId = getApplicationId();
-            if (appId != null && appId.length() > 0)
-            {
-                buffer.append('.');
-                buffer.append(appId);
-            }
-            buffer.append(":type=");
-            // Build hierarchical type value.
-            List types = new ArrayList();
-            List ids = new ArrayList();
-            types.add(getType());
-            ids.add(getId());
-            BaseControl ancestor = parent;
-            while (ancestor != null)
-            {
-                types.add(ancestor.getType());
-                ids.add(ancestor.getId());
-                ancestor = ancestor.getParentControl();
-            }
-            for (int i = types.size() - 1; i >= 0; --i)
-            {
-                buffer.append((String)types.get(i));
-                if (i > 0)
-                {
-                    buffer.append('.');
-                }
-            }
-            buffer.append(',');
-            // Add containment keys.
-            for (int i = ids.size() - 1; i >= 1; --i)
-            {
-                buffer.append((String)types.get(i));
-                buffer.append('=');
-                buffer.append((String)ids.get(i));
-                buffer.append(',');
-            }
-            buffer.append("id=");
-            buffer.append(getId());
-            String name = buffer.toString();
-            // TODO: Seth: add server identifier key if we're running in a
-            // cluster?
-            try
-            {
-                objectName = new ObjectName(name);
-            }
-            catch (MalformedObjectNameException mone)
-            {
-                // Rethrow with useful message if this ever happens.
-                ManagementException me = new ManagementException();
-                me.setMessage(MALFORMED_OBJECTNAME, new Object[] {name});
-                throw me;
-            }
-        }
-        return objectName;
-    }
-
-    /**
-     * Implements <code>javax.management.MBeanRegistration.preRegister</code>.
-     * Allows the MBean to perform any operations it needs before being
-     * registered in the MBean server. This base implementation stores a
-     * reference to the MBean server that may be accessed via
-     * <code>getMBeanServer()</code>. If subclasses override, they must call
-     * <code>super.preRegister()</code>.
-     *
-     * @param server The Mbean server in which the MBean will be registered.
-     * @param name The object name of the MBean.
-     * @return The name the MBean will be registered under.
-     * @throws Exception when the process failed
-     */
-    public ObjectName preRegister(MBeanServer server, ObjectName name)
-            throws Exception
-    {
-        this.server = server;
-        return (name == null) ? getObjectName() : name;
-    }
-
-    /**
-     * Implements <code>javax.management.MBeanRegistration.postRegister</code>.
-     * Allows the MBean to perform any operations needed after having been
-     * registered in the MBean server or after the registration has failed. This
-     * base implementation is a no-op that may be overridden.
-     *
-     * @param registrationDone Indicates whether or not the MBean was
-     *        successfully registered in the MBean server.
-     */
-    public void postRegister(Boolean registrationDone)
-    {
-        // No-op.
-    }
-
-    /**
-     * Implements <code>javax.management.MBeanRegistration.preDeregister</code>.
-     * Allows the MBean to perform any operations needed after having been
-     * unregistered in the MBean server. This base implementation is a no-op
-     * that may be overridden.
-     * @throws Exception when the process failed
-     */
-    public void preDeregister() throws Exception
-    {
-        // No-op.
-    }
-
-    /**
-     * Implements <code>javax.management.MBeanRegistration.postDeregister</code>.
-     * Allows the MBean to perform any operations it needs before being
-     * unregistered by the MBean server. This base implementation is a no-op
-     * that may be overridden.
-     */
-    public void postDeregister()
-    {
-        // No-op.
-    }
-
-    /**
-     * Sets the start timestamp for the managed component.
-     *
-     * @param value The start timestamp for the managed component.
-     */
-    public void setStartTimestamp(Date value)
-    {
-        startTimestamp = value;
-    }
-
-    /**
-     * @exclude Returns the difference between a start and end timestamps in
-     *          minutes. Differences of less than one minute are rounded up to
-     *          one minute to avoid frequency calculations reporting infinite
-     *          message frequencies.
-     * @param startTime The start timestamp in milliseconds.
-     * @param endTime The end timestamp in milliseconds.
-     * @return The difference between a start and end timestamps in minutes.
-     */
-    protected double differenceInMinutes(long startTime, long endTime)
-    {
-        double minutes = (endTime - startTime) / 60000d;
-        if (minutes > 1d)
-        {
-            return minutes;
-        }
-        else
-        {
-            return 1d;
-        }
-    }
-}
+/*
+ * 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 flex.management;
+
+import flex.management.runtime.AdminConsoleDisplayRegistrar;
+import flex.messaging.FlexContext;
+
+import java.util.Date;
+import java.util.List;
+import java.util.ArrayList;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MalformedObjectNameException;
+import javax.management.MBeanRegistration;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import javax.servlet.ServletConfig;
+
+/**
+ * The implementation of the <code>BaseControlMBean</code> interface. This
+ * abstract class provides the core functionality that all Flex control MBeans
+ * require.
+ * <p>
+ * Defining concrete implementations of <code>getId()</code> and
+ * <code>getType()</code> are left to subclasses, but this base class does
+ * provide access to the parent MBean for each instance. This class also
+ * implements the <code>MBeanRegistration</code> interface, and it
+ * automatically stores a reference to the MBean server in each instance upon
+ * registration. Subclasses may choose to override none, any, or all of the
+ * methods defined by the <code>MBeanRegistration</code> interface, but any
+ * overrides should be sure to invoke the overridden method with a call to their
+ * superclass.
+ * </p><p>
+ * The <code>register()</code> method provides a simple and consistent way to
+ * register instances with the MBean server, and the
+ * <code>getObjectName()</code> method gaurantees consistent, well-formed
+ * <code>ObjectName</code>s for all MBean instances.</p>
+ *
+ * @author shodgson
+ */
+public abstract class BaseControl implements BaseControlMBean,
+        MBeanRegistration
+{
+    /**
+     * The prefix used for the domain part of control MBean names.
+     */
+    public static final String DOMAIN_PREFIX = "flex.runtime";
+    private static final int MALFORMED_OBJECTNAME = 10400;
+    private static final int UNREG_EXCEPTION = 10401;
+    private static final int UNREG_NOTFOUND = 10402;
+    private static final int REG_EXCEPTION = 10403;
+    private static final int REG_ALREADYEXISTS = 10404;
+    private static final int REG_NOTCOMPLIANT = 10405;
+    private static final int DISABLE_MANAGEMENT = 10426;    
+
+    protected Date startTimestamp;
+    private BaseControl parent;
+    private ObjectName objectName;
+    private ObjectName registeredObjectName;
+    private MBeanServer server;
+    private boolean registered = false;
+
+    private AdminConsoleDisplayRegistrar registrar;
+
+    // Implements flex.management.BaseControlMBean.getId; inherits javadoc
+    // specification.
+    public abstract String getId();
+
+    // Implements flex.management.BaseControlMBean.getType; inherits javadoc
+    // specification.
+    public abstract String getType();
+
+    // Implements flex.management.BaseControlMBean.getParent; inherits javadoc
+    // specification.
+    public final ObjectName getParent()
+    {
+        return (parent != null) ? parent.getObjectName() : null;
+    }
+
+    /**
+     * Returns an identifier for the application that hosts the component that
+     * this control manages.
+     *
+     * @return An identifier for the application that hosts the component this
+     *         control manages.
+     */
+    public String getApplicationId()
+    {
+        String id = null;
+        // Our base implementation attempts to use the current servlet context
+        // name as our application identifier.
+        ServletConfig config = FlexContext.getServletConfig();
+        if (config != null)
+        {
+            id = config.getServletContext().getServletContextName();
+        }
+        return (id != null) ? id.replace(":", "") : "";
+    }
+
+    /**
+     * Set the register object. 
+     * @param registar the registrar to set
+     */
+    protected void setRegistrar(AdminConsoleDisplayRegistrar registrar)
+    {
+        this.registrar = registrar;
+    }
+
+    /**
+     * Return the registar object.
+     * @return the registrar
+     */
+    public AdminConsoleDisplayRegistrar getRegistrar()
+    {
+        if ((parent == null) && (this.registrar == null))
+        {
+            return new AdminConsoleDisplayRegistrar(null);
+        }
+
+        return (this.registrar != null) ? this.registrar : parent.getRegistrar();
+    }
+
+    /**
+     * Constructs a <code>BaseControl</code> instance that references its
+     * parent; the parent may be null for root control MBeans.
+     *
+     * @param parent The parent <code>BaseControl</code> for this instance or
+     *        null if this instance is the root of a control hierarchy.
+     */
+    public BaseControl(BaseControl parent)
+    {
+        this.parent = parent;
+    }
+
+    /**
+     * Returns the parent <code>BaseControl</code> of this instance.
+     *
+     * @return The parent <code>BaseControl</code>.
+     */
+    public final BaseControl getParentControl()
+    {
+        return parent;
+    }
+
+    /**
+     * The <code>MBeanServer</code> that this instance is registered with. If
+     * this instance has not been registered this method returns
+     * <code>null</code>.
+     *
+     * @return The <code>MBeanServer</code> that this instance is registered
+     *         with.
+     */
+    public final MBeanServer getMBeanServer()
+    {
+        return server;
+    }
+
+    /**
+     * Registers this instance with the MBean server.
+     *
+     * It may throw ManagementException If an <code>MBeanRegistrationException</code>
+     *         or <code>InstanceAlreadyExistsException</code> is thrown while
+     *         registering this MBean, the typed exception is wrapped in a
+     *         runtime <code>ManagementException</code> and rethrown.
+     */
+    public final void register()
+    {
+        if (!registered)
+        {
+            MBeanServer server = MBeanServerLocatorFactory.getMBeanServerLocator().getMBeanServer();
+            ObjectName name = getObjectName();
+            try
+            {
+                if (server.isRegistered(name))
+                {
+                    server.unregisterMBean(name);
+                }
+
+                registeredObjectName = server.registerMBean(this, name).getObjectName();
+                registered = true;
+                onRegistrationComplete();
+
+            }
+            catch (ManagementException me)
+            {
+                throw me;
+            }
+            catch (MBeanRegistrationException mre)
+            {
+                // Rethrow with useful message if this ever happens.
+                ManagementException me = new ManagementException();
+                me.setMessage(REG_EXCEPTION, new Object[] {name.toString()});
+                me.setRootCause(mre);
+                throw me;
+            }
+            catch (InstanceAlreadyExistsException iaee)
+            {
+                // If registration is not working at all, inform the user that
+                // they may
+                // work around the issue by disabling management (no MBeans will
+                // be registered).
+                if (!server.isRegistered(name))
+                {
+                    ManagementException me = new ManagementException();
+                    me.setMessage(DISABLE_MANAGEMENT, new Object[] {name.toString()});
+                    throw me;
+                }
+                else
+                {
+                    // Rethrow with useful message if this ever happens.
+                    ManagementException me = new ManagementException();
+                    me.setMessage(REG_ALREADYEXISTS, new Object[] {name.toString()});
+                    throw me;
+                }
+            }
+            catch (NotCompliantMBeanException ncme)
+            {
+                // Rethrow with useful message if this ever happens.
+                ManagementException me = new ManagementException();
+                me.setMessage(REG_NOTCOMPLIANT, new Object[] {name.toString()});
+                throw me;
+            }
+            catch (InstanceNotFoundException infe)
+            {
+                // Rethrow with useful message if this ever happens.
+                ManagementException me = new ManagementException();
+                me.setMessage(UNREG_NOTFOUND, new Object[] {name.toString()});
+                throw me;
+            }
+        }
+    }
+
+    /**
+     * This method is called after the MBean has been registered and after the
+     * MBean server has returned the registeredObjectName. Classes that need
+     * access to the actual Object name should override this method rather than
+     * the postRegister method.
+     */
+    protected void onRegistrationComplete()
+    {
+
+    }
+
+    /**
+     * Unregisters this instance from the MBean server if it has been registered
+     * previously.
+     */
+    public final void unregister()
+    {
+        if (registered)
+        {
+            // This method may be called when the JVM is being unloaded, so if
+            // our
+            // external error strings are loaded as missing, fall back to
+            // hard-coded
+            // strings.
+            try
+            {
+                if (server.isRegistered(registeredObjectName))
+                {
+                    server.unregisterMBean(registeredObjectName);
+                }
+
+                registeredObjectName = null;
+                registered = false;
+            }
+            catch (ManagementException me)
+            {
+                throw me;
+            }
+            catch (MBeanRegistrationException mre)
+            {
+                // Rethrow with useful message if this ever happens.
+                ManagementException me = new ManagementException();
+                me.setMessage(UNREG_EXCEPTION, new Object[] {registeredObjectName.toString()});
+                if (me.getMessage().indexOf(Integer.toString(UNREG_EXCEPTION)) != -1)
+                {
+                    me.setMessage("The MBean named, '" + registeredObjectName.toString() + "', could not be unregistered because its preDeregister() method threw an exception.");
+                }
+                me.setRootCause(mre);
+                throw me;
+            }
+            catch (InstanceNotFoundException infe)
+            {
+                // Rethrow with useful message if this ever happens.
+                ManagementException me = new ManagementException();
+                me.setMessage(UNREG_NOTFOUND, new Object[] {registeredObjectName.toString()});
+                if (me.getMessage().indexOf(Integer.toString(UNREG_NOTFOUND)) != -1)
+                {
+                    me.setMessage("The MBean named, '" + registeredObjectName.toString() + "', could not be unregistered because it is not currently registered.");
+                }
+                throw me;
+            }
+        }
+    }
+
+    /**
+     * Returns the <code>ObjectName</code> for this instance, according to the
+     * following format:
+     * <code>{domain}[&amp;#46;{appId}]:type={type}[&amp;#44;{parent type}={parent id}]*[&amp;#44;server={server}]&amp;#63;&amp;#44;id={id}</code>.
+     * <ul>
+     * <li><code>domain</code>: The domain specified by the DOMAIN_PREFIX
+     * constant followed by the application identifier if one is available.</li>
+     * <li><code>type</code>: The short type name of the resource managed by
+     * the MBean.<br /> - The <code>MessageBrokerControlMBean</code> manages
+     * the <code>flex.messaging.MessageBroker</code> so:
+     * <code>type=MessageBroker</code> </li>
+     * <li><code>id</code>: The id value for the resource managed by this
+     * MBean. If no name or id is available on the resource, an id will be
+     * fabricated according to this strategy:<br />
+     * <em>id = {type} + N</em> (where N is a numeric increment for instances
+     * of this type) </li>
+     * <li>* optional containment keys</li>
+     * </ul>
+     * The runtime MBean model is hierarchical, with all MBeans ultimately
+     * contained by the root <code>MessageBrokerControlMBean</code>. The 
+     * <code>ObjectName</code>s used for these MBeans describe this
+     * containment in the following fashion. First, the 'type' key for a
+     * contained MBean indicates the containment hierarchy for the bean. So, the
+     * <code>ObjectName</code> for an <code>RTMPEndpointControlMBean</code>
+     * would be: <code>type=MessageBroker.RTMPEndpoint</code><br />
+     * In addition to the hierarchical 'type' key, the full
+     * <code>ObjectName</code> for this <code>RTMPEndpointControlMBean</code>
+     * also contains a containment key:
+     * <code>MessageBroker=MessageBroker1</code><br />
+     * Optional containment keys have the format:
+     * <em>{parent type}={parent name}</em>. A containment key is added for
+     * each ancestor up to the root of the hierarchy and these keys allow the
+     * <code>ObjectName</code> for any MBean instance to fully describe its
+     * specific location in the hierarchy. To complete the example, the full
+     * <code>ObjectName</code> for the example
+     * <code>RTMPEndpointControlMBean</code> would be:
+     * <code>flex:type=MessageBroker.RTMPEndpoint,MessageBroker=MessageBroker1,id=RTMPEndpoint1</code>
+     * <p>
+     * If the MBean is registered with the MBean server, this method returns the
+     * <code>ObjectName</code> that the MBean was registered under and this
+     * value may contain additional key-value pairs injected by the container or
+     * MBean server.
+     * </p>
+     *
+     * @return The <code>ObjectName</code> for this instance.
+     */
+    public final ObjectName getObjectName()
+    {
+        if (registered)
+            return registeredObjectName;
+
+        if (objectName == null)
+        {
+            StringBuffer buffer = new StringBuffer();
+            buffer.append(DOMAIN_PREFIX);
+            String appId = getApplicationId();
+            if (appId != null && appId.length() > 0)
+            {
+                buffer.append('.');
+                buffer.append(appId);
+            }
+            buffer.append(":type=");
+            // Build hierarchical type value.
+            List types = new ArrayList();
+            List ids = new ArrayList();
+            types.add(getType());
+            ids.add(getId());
+            BaseControl ancestor = parent;
+            while (ancestor != null)
+            {
+                types.add(ancestor.getType());
+                ids.add(ancestor.getId());
+                ancestor = ancestor.getParentControl();
+            }
+            for (int i = types.size() - 1; i >= 0; --i)
+            {
+                buffer.append((String)types.get(i));
+                if (i > 0)
+                {
+                    buffer.append('.');
+                }
+            }
+            buffer.append(',');
+            // Add containment keys.
+            for (int i = ids.size() - 1; i >= 1; --i)
+            {
+                buffer.append((String)types.get(i));
+                buffer.append('=');
+                buffer.append((String)ids.get(i));
+                buffer.append(',');
+            }
+            buffer.append("id=");
+            buffer.append(getId());
+            String name = buffer.toString();
+            // TODO: Seth: add server identifier key if we're running in a
+            // cluster?
+            try
+            {
+                objectName = new ObjectName(name);
+            }
+            catch (MalformedObjectNameException mone)
+            {
+                // Rethrow with useful message if this ever happens.
+                ManagementException me = new ManagementException();
+                me.setMessage(MALFORMED_OBJECTNAME, new Object[] {name});
+                throw me;
+            }
+        }
+        return objectName;
+    }
+
+    /**
+     * Implements <code>javax.management.MBeanRegistration.preRegister</code>.
+     * Allows the MBean to perform any operations it needs before being
+     * registered in the MBean server. This base implementation stores a
+     * reference to the MBean server that may be accessed via
+     * <code>getMBeanServer()</code>. If subclasses override, they must call
+     * <code>super.preRegister()</code>.
+     *
+     * @param server The Mbean server in which the MBean will be registered.
+     * @param name The object name of the MBean.
+     * @return The name the MBean will be registered under.
+     * @throws Exception when the process failed
+     */
+    public ObjectName preRegister(MBeanServer server, ObjectName name)
+            throws Exception
+    {
+        this.server = server;
+        return (name == null) ? getObjectName() : name;
+    }
+
+    /**
+     * Implements <code>javax.management.MBeanRegistration.postRegister</code>.
+     * Allows the MBean to perform any operations needed after having been
+     * registered in the MBean server or after the registration has failed. This
+     * base implementation is a no-op that may be overridden.
+     *
+     * @param registrationDone Indicates whether or not the MBean was
+     *        successfully registered in the MBean server.
+     */
+    public void postRegister(Boolean registrationDone)
+    {
+        // No-op.
+    }
+
+    /**
+     * Implements <code>javax.management.MBeanRegistration.preDeregister</code>.
+     * Allows the MBean to perform any operations needed after having been
+     * unregistered in the MBean server. This base implementation is a no-op
+     * that may be overridden.
+     * @throws Exception when the process failed
+     */
+    public void preDeregister() throws Exception
+    {
+        // No-op.
+    }
+
+    /**
+     * Implements <code>javax.management.MBeanRegistration.postDeregister</code>.
+     * Allows the MBean to perform any operations it needs before being
+     * unregistered by the MBean server. This base implementation is a no-op
+     * that may be overridden.
+     */
+    public void postDeregister()
+    {
+        // No-op.
+    }
+
+    /**
+     * Sets the start timestamp for the managed component.
+     *
+     * @param value The start timestamp for the managed component.
+     */
+    public void setStartTimestamp(Date value)
+    {
+        startTimestamp = value;
+    }
+
+    /**
+     * @exclude Returns the difference between a start and end timestamps in
+     *          minutes. Differences of less than one minute are rounded up to
+     *          one minute to avoid frequency calculations reporting infinite
+     *          message frequencies.
+     * @param startTime The start timestamp in milliseconds.
+     * @param endTime The end timestamp in milliseconds.
+     * @return The difference between a start and end timestamps in minutes.
+     */
+    protected double differenceInMinutes(long startTime, long endTime)
+    {
+        double minutes = (endTime - startTime) / 60000d;
+        if (minutes > 1d)
+        {
+            return minutes;
+        }
+        else
+        {
+            return 1d;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/BaseControlMBean.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/BaseControlMBean.java b/modules/core/src/flex/management/BaseControlMBean.java
old mode 100755
new mode 100644
index 09ab6fe..3d3f2fd
--- a/modules/core/src/flex/management/BaseControlMBean.java
+++ b/modules/core/src/flex/management/BaseControlMBean.java
@@ -1,57 +1,57 @@
-/*
- * 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 flex.management;
-
-import java.io.IOException;
-import javax.management.ObjectName;
-
-/**
- * The base MBean interface for management beans that control aspects of
- * Flex behavior on the server.
- *
- * @author shodgson
- */
-public interface BaseControlMBean
-{
-    /**
-     * Returns the id for this MBean. This is the value that is set for the
-     * <code>id</code> key in the <code>ObjectName</code> for this MBean.
-     *
-     * @return The MBean instance id.
-     * @throws IOException Throws IOException.
-     */
-    String getId() throws IOException;
-
-    /**
-     * Returns the type for this MBean. This is the value that is set for the
-     * <code>type</code> key in the <code>ObjectName</code> for this MBean.
-     *
-     * @return The MBean instance type.
-     * @throws IOException Throws IOException.
-     */
-    String getType() throws IOException;
-
-    /**
-     * Returns the parent for this MBean. The value is the <code>ObjectName</code>
-     * for the parent MBean that conceptually contains this MBean instance. If no
-     * parent exists, this method returns <code>null</code>.
-     *
-     * @return The <code>ObjectName</code> for the parent of this MBean instance.
-     * @throws IOException Throws IOException.
-     */
-    ObjectName getParent() throws IOException;
-}
+/*
+ * 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 flex.management;
+
+import java.io.IOException;
+import javax.management.ObjectName;
+
+/**
+ * The base MBean interface for management beans that control aspects of
+ * Flex behavior on the server.
+ *
+ * @author shodgson
+ */
+public interface BaseControlMBean
+{
+    /**
+     * Returns the id for this MBean. This is the value that is set for the
+     * <code>id</code> key in the <code>ObjectName</code> for this MBean.
+     *
+     * @return The MBean instance id.
+     * @throws IOException Throws IOException.
+     */
+    String getId() throws IOException;
+
+    /**
+     * Returns the type for this MBean. This is the value that is set for the
+     * <code>type</code> key in the <code>ObjectName</code> for this MBean.
+     *
+     * @return The MBean instance type.
+     * @throws IOException Throws IOException.
+     */
+    String getType() throws IOException;
+
+    /**
+     * Returns the parent for this MBean. The value is the <code>ObjectName</code>
+     * for the parent MBean that conceptually contains this MBean instance. If no
+     * parent exists, this method returns <code>null</code>.
+     *
+     * @return The <code>ObjectName</code> for the parent of this MBean instance.
+     * @throws IOException Throws IOException.
+     */
+    ObjectName getParent() throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/MBeanLifecycleManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/MBeanLifecycleManager.java b/modules/core/src/flex/management/MBeanLifecycleManager.java
old mode 100755
new mode 100644
index 4bbfea9..164f8c4
--- a/modules/core/src/flex/management/MBeanLifecycleManager.java
+++ b/modules/core/src/flex/management/MBeanLifecycleManager.java
@@ -1,65 +1,65 @@
-/*
- * 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 flex.management;
-
-import flex.messaging.MessageBroker;
-
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-/**
- * Helper class for managing MBean lifecycles externally from the core server
- * components where necessary.
- * 
- * @author shodgson
- */
-public class MBeanLifecycleManager
-{
-    /**
-     * Unregisters all runtime MBeans that are registered in the same domain as the 
-     * MessageBrokerControl for the target MessageBroker. 
-     *  
-     * @param broker The MessageBroker component that has been stopped.
-     */
-    public static void unregisterRuntimeMBeans(MessageBroker broker)
-    {        
-        MBeanServer server = MBeanServerLocatorFactory.getMBeanServerLocator().getMBeanServer();
-        ObjectName brokerMBean = broker.getControl().getObjectName();
-        String domain = brokerMBean.getDomain();
-        try
-        {
-            ObjectName pattern = new ObjectName(domain + ":*");
-            Set names = server.queryNames(pattern, null);
-            Iterator iter = names.iterator();
-            while (iter.hasNext())
-            {
-                ObjectName on = (ObjectName)iter.next();
-                server.unregisterMBean(on);
-            }
-        }
-        catch (Exception e)
-        {
-            // We're generally unregistering these during shutdown (possibly JVM shutdown)
-            // so there's nothing to really do here because we aren't guaranteed access to
-            // resources like system log files, localized messaging, etc.
-        }
-    }
-    
-}
+/*
+ * 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 flex.management;
+
+import flex.messaging.MessageBroker;
+
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * Helper class for managing MBean lifecycles externally from the core server
+ * components where necessary.
+ * 
+ * @author shodgson
+ */
+public class MBeanLifecycleManager
+{
+    /**
+     * Unregisters all runtime MBeans that are registered in the same domain as the 
+     * MessageBrokerControl for the target MessageBroker. 
+     *  
+     * @param broker The MessageBroker component that has been stopped.
+     */
+    public static void unregisterRuntimeMBeans(MessageBroker broker)
+    {        
+        MBeanServer server = MBeanServerLocatorFactory.getMBeanServerLocator().getMBeanServer();
+        ObjectName brokerMBean = broker.getControl().getObjectName();
+        String domain = brokerMBean.getDomain();
+        try
+        {
+            ObjectName pattern = new ObjectName(domain + ":*");
+            Set names = server.queryNames(pattern, null);
+            Iterator iter = names.iterator();
+            while (iter.hasNext())
+            {
+                ObjectName on = (ObjectName)iter.next();
+                server.unregisterMBean(on);
+            }
+        }
+        catch (Exception e)
+        {
+            // We're generally unregistering these during shutdown (possibly JVM shutdown)
+            // so there's nothing to really do here because we aren't guaranteed access to
+            // resources like system log files, localized messaging, etc.
+        }
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/4f6a3052/modules/core/src/flex/management/MBeanServerLocator.java
----------------------------------------------------------------------
diff --git a/modules/core/src/flex/management/MBeanServerLocator.java b/modules/core/src/flex/management/MBeanServerLocator.java
old mode 100755
new mode 100644
index af3676f..bf34c97
--- a/modules/core/src/flex/management/MBeanServerLocator.java
+++ b/modules/core/src/flex/management/MBeanServerLocator.java
@@ -1,35 +1,35 @@
-/*
- * 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 flex.management;
-
-import javax.management.MBeanServer;
-
-/**
- * Interface for classes that locate MBeanServers to register MBeans with.
- * 
- * @author shodgson
- */
-public interface MBeanServerLocator
-{
-    /**
-     * Returns the MBeanServer to register our management MBeans with.
-     * 
-     * @return The MBeanServer to register our management MBeans with.
-     */
-    MBeanServer getMBeanServer();
-    
-}
+/*
+ * 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 flex.management;
+
+import javax.management.MBeanServer;
+
+/**
+ * Interface for classes that locate MBeanServers to register MBeans with.
+ * 
+ * @author shodgson
+ */
+public interface MBeanServerLocator
+{
+    /**
+     * Returns the MBeanServer to register our management MBeans with.
+     * 
+     * @return The MBeanServer to register our management MBeans with.
+     */
+    MBeanServer getMBeanServer();
+    
+}


Mime
View raw message