servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r564607 [3/12] - in /incubator/servicemix/trunk/core/servicemix-core/src: main/java/org/apache/servicemix/ main/java/org/apache/servicemix/jbi/ main/java/org/apache/servicemix/jbi/framework/ main/java/org/apache/servicemix/jbi/framework/sup...
Date Fri, 10 Aug 2007 14:38:14 GMT
Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/XMLStreamHelper.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/XMLStreamHelper.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/XMLStreamHelper.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jaxp/XMLStreamHelper.java Fri Aug 10 07:37:46 2007
@@ -24,240 +24,193 @@
 import javax.xml.stream.XMLStreamWriter;
 
 /**
- * Utility methods for working with an XMLStreamWriter. Maybe push this back into
- * stax-utils project.
+ * Utility methods for working with an XMLStreamWriter. Maybe push this back
+ * into stax-utils project.
  * 
  * Code borrowed to XFire project.
  * 
  * @version $Revision: 1.16 $
  */
-public class XMLStreamHelper implements XMLStreamConstants {
+public final class XMLStreamHelper implements XMLStreamConstants {
+    
+    private XMLStreamHelper() {
+    }
 
     /**
-     * Copies the reader to the writer.  The start and end document
-     * methods must be handled on the writer manually.
+     * Copies the reader to the writer. The start and end document methods must
+     * be handled on the writer manually.
      * 
-     * TODO: if the namespace on the reader has been declared previously
-     * to where we are in the stream, this probably won't work.
+     * TODO: if the namespace on the reader has been declared previously to
+     * where we are in the stream, this probably won't work.
      * 
      * @param reader
      * @param writer
      * @throws XMLStreamException
      */
-    public static void copy( XMLStreamReader reader, XMLStreamWriter writer ) 
-        throws XMLStreamException
-    {
+    public static void copy(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
         int read = 0; // number of elements read in
         int event = reader.getEventType();
-        
-        while ( reader.hasNext() )
-        {
-            switch( event )
-            {
-                case XMLStreamConstants.START_ELEMENT:
-                    read++;
-                    writeStartElement( reader, writer );
-                    break;
-                case XMLStreamConstants.END_ELEMENT:
-                    writer.writeEndElement();
-                    read--;
-                    if ( read <= 0 )
-                        return;
-                    break;
-                case XMLStreamConstants.CHARACTERS:
-                    writer.writeCharacters( reader.getText() );  
-                    break;
-                case XMLStreamConstants.START_DOCUMENT:
-                case XMLStreamConstants.END_DOCUMENT:
-                case XMLStreamConstants.ATTRIBUTE:
-                case XMLStreamConstants.NAMESPACE:
-                    break;
-                default:
-                    break;
+
+        while (reader.hasNext()) {
+            switch (event) {
+            case XMLStreamConstants.START_ELEMENT:
+                read++;
+                writeStartElement(reader, writer);
+                break;
+            case XMLStreamConstants.END_ELEMENT:
+                writer.writeEndElement();
+                read--;
+                if (read <= 0) {
+                    return;
+                }
+                break;
+            case XMLStreamConstants.CHARACTERS:
+                writer.writeCharacters(reader.getText());
+                break;
+            case XMLStreamConstants.START_DOCUMENT:
+            case XMLStreamConstants.END_DOCUMENT:
+            case XMLStreamConstants.ATTRIBUTE:
+            case XMLStreamConstants.NAMESPACE:
+                break;
+            default:
+                break;
             }
             event = reader.next();
         }
     }
 
-    private static void writeStartElement(XMLStreamReader reader, XMLStreamWriter writer) 
-        throws XMLStreamException
-    {
+    private static void writeStartElement(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException {
         String local = reader.getLocalName();
         String uri = reader.getNamespaceURI();
         String prefix = reader.getPrefix();
-        if (prefix == null)
-        {
+        if (prefix == null) {
             prefix = "";
         }
-        if (uri == null)
-        {
+        if (uri == null) {
             uri = "";
         }
-        
+
         String boundPrefix = writer.getPrefix(uri);
         boolean writeElementNS = false;
-        if ( boundPrefix == null || !prefix.equals(boundPrefix) )
-        {   
+        if (boundPrefix == null || !prefix.equals(boundPrefix)) {
             writeElementNS = true;
         }
-        
+
         // Write out the element name
-        if (uri != null)
-        {
-            if (prefix.length() == 0) 
-            { 
-                
+        if (uri != null) {
+            if (prefix.length() == 0) {
+
                 writer.writeStartElement(local);
-                writer.setDefaultNamespace(uri); 
-                
-            } 
-            else 
-            { 
-                writer.writeStartElement(prefix, local, uri); 
-                writer.setPrefix(prefix, uri); 
-            } 
-        }
-        else
-        {
-            writer.writeStartElement( local );
+                writer.setDefaultNamespace(uri);
+
+            } else {
+                writer.writeStartElement(prefix, local, uri);
+                writer.setPrefix(prefix, uri);
+            }
+        } else {
+            writer.writeStartElement(local);
         }
 
         // Write out the namespaces
-        for ( int i = 0; i < reader.getNamespaceCount(); i++ )
-        {
+        for (int i = 0; i < reader.getNamespaceCount(); i++) {
             String nsURI = reader.getNamespaceURI(i);
             String nsPrefix = reader.getNamespacePrefix(i);
-            if (nsPrefix == null) nsPrefix = "";
-            
-            if ( nsPrefix.length() ==  0 )
-            {
-                writer.writeDefaultNamespace(nsURI);
+            if (nsPrefix == null) {
+                nsPrefix = "";
             }
-            else
-            {
+
+            if (nsPrefix.length() == 0) {
+                writer.writeDefaultNamespace(nsURI);
+            } else {
                 writer.writeNamespace(nsPrefix, nsURI);
             }
 
-            if (nsURI.equals(uri) && nsPrefix.equals(prefix))
-            {
+            if (nsURI.equals(uri) && nsPrefix.equals(prefix)) {
                 writeElementNS = false;
             }
         }
-        
+
         // Check if the namespace still needs to be written.
-        // We need this check because namespace writing works 
+        // We need this check because namespace writing works
         // different on Woodstox and the RI.
-        if (writeElementNS)
-        {
-            if ( prefix == null || prefix.length() ==  0 )
-            {
+        if (writeElementNS) {
+            if (prefix == null || prefix.length() == 0) {
                 writer.writeDefaultNamespace(uri);
-            }
-            else
-            {
+            } else {
                 writer.writeNamespace(prefix, uri);
             }
         }
 
         // Write out attributes
-        for ( int i = 0; i < reader.getAttributeCount(); i++ )
-        {
+        for (int i = 0; i < reader.getAttributeCount(); i++) {
             String ns = reader.getAttributeNamespace(i);
             String nsPrefix = reader.getAttributePrefix(i);
-            if ( ns == null || ns.length() == 0 )
-            {
-                writer.writeAttribute(
-                        reader.getAttributeLocalName(i),
-                        reader.getAttributeValue(i));
-            }
-            else if (nsPrefix == null || nsPrefix.length() == 0)
-            {
-                writer.writeAttribute(
-                    reader.getAttributeNamespace(i),
-                    reader.getAttributeLocalName(i),
-                    reader.getAttributeValue(i));
-            }
-            else
-            {
-                writer.writeAttribute(reader.getAttributePrefix(i),
-                                      reader.getAttributeNamespace(i),
-                                      reader.getAttributeLocalName(i),
-                                      reader.getAttributeValue(i));
+            if (ns == null || ns.length() == 0) {
+                writer.writeAttribute(reader.getAttributeLocalName(i), reader.getAttributeValue(i));
+            } else if (nsPrefix == null || nsPrefix.length() == 0) {
+                writer.writeAttribute(reader.getAttributeNamespace(i), reader.getAttributeLocalName(i), reader.getAttributeValue(i));
+            } else {
+                writer.writeAttribute(reader.getAttributePrefix(i), reader.getAttributeNamespace(i), reader.getAttributeLocalName(i),
+                                reader.getAttributeValue(i));
             }
-            
-            
+
         }
     }
-    
+
     /**
      * Write a start element with the specified parameters
+     * 
      * @param writer
      * @param uri
      * @param local
      * @param prefix
      * @throws XMLStreamException
      */
-    public static void writeStartElement( XMLStreamWriter writer, String uri, String local, String prefix ) 
-        throws XMLStreamException 
-    {
-        if (prefix == null)
-        {
+    public static void writeStartElement(XMLStreamWriter writer, String uri, String local, String prefix) throws XMLStreamException {
+        if (prefix == null) {
             prefix = "";
         }
-        if (uri == null)
-        {
+        if (uri == null) {
             uri = "";
         }
-        
+
         String boundPrefix = writer.getPrefix(uri);
         boolean writeElementNS = false;
-        if ( boundPrefix == null || !prefix.equals(boundPrefix) )
-        {   
+        if (boundPrefix == null || !prefix.equals(boundPrefix)) {
             writeElementNS = true;
         }
-        
+
         // Write out the element name
-        if (uri != null)
-        {
-            if (prefix.length() == 0) 
-            { 
-                
+        if (uri != null) {
+            if (prefix.length() == 0) {
+
                 writer.writeStartElement(local);
-                writer.setDefaultNamespace(uri); 
-                
-            } 
-            else 
-            { 
-                writer.writeStartElement(prefix, local, uri); 
-                writer.setPrefix(prefix, uri); 
-            } 
-        }
-        else
-        {
-            writer.writeStartElement( local );
+                writer.setDefaultNamespace(uri);
+
+            } else {
+                writer.writeStartElement(prefix, local, uri);
+                writer.setPrefix(prefix, uri);
+            }
+        } else {
+            writer.writeStartElement(local);
         }
 
         // Check if the namespace still needs to be written.
-        // We need this check because namespace writing works 
+        // We need this check because namespace writing works
         // different on Woodstox and the RI.
-        if (writeElementNS)
-        {
-            if ( prefix.length() ==  0 )
-            {
+        if (writeElementNS) {
+            if (prefix.length() == 0) {
                 writer.writeDefaultNamespace(uri);
-            }
-            else
-            {
+            } else {
                 writer.writeNamespace(prefix, uri);
             }
         }
     }
 
     /**
-     * Write a start element with the given QName.
-     * However, if a namespace has already been bound to a prefix,
-     * use the existing one, else default to the prefix
-     * in the QName (if specified).  Else, a prefix is generated.
+     * Write a start element with the given QName. However, if a namespace has
+     * already been bound to a prefix, use the existing one, else default to the
+     * prefix in the QName (if specified). Else, a prefix is generated.
      * 
      * @param writer
      * @param name
@@ -282,7 +235,7 @@
             out.writeCharacters(prefix + ":" + name.getLocalPart());
         }
     }
-    
+
     protected static String choosePrefix(XMLStreamWriter out, QName name, boolean declare) throws XMLStreamException {
         String uri = name.getNamespaceURI();
         // If no namespace
@@ -291,7 +244,7 @@
                 out.setPrefix(XMLConstants.DEFAULT_NS_PREFIX, XMLConstants.NULL_NS_URI);
             }
             return XMLConstants.DEFAULT_NS_PREFIX;
-        // Need to write a prefix
+            // Need to write a prefix
         } else {
             String defPrefix = name.getPrefix();
             // A prefix is specified
@@ -301,26 +254,26 @@
                     // if there is a prefix bound to the uri, use it
                     if (out.getNamespaceContext().getPrefix(uri) != null) {
                         defPrefix = out.getNamespaceContext().getPrefix(uri);
-                    // get prefix from the writer
+                        // get prefix from the writer
                     } else if (out.getPrefix(uri) != null) {
                         defPrefix = out.getPrefix(uri);
-                    // we need to bind the prefix
+                        // we need to bind the prefix
                     } else if (declare) {
                         out.setPrefix(defPrefix, uri);
                         out.writeNamespace(defPrefix, uri);
                     }
                 }
-            // No prefix specified
+                // No prefix specified
             } else {
                 // if there is a prefix bound to the uri, use it
                 if (out.getNamespaceContext().getPrefix(uri) != null) {
                     defPrefix = out.getNamespaceContext().getPrefix(uri);
-                // get prefix from the writer
+                    // get prefix from the writer
                 } else if (out.getPrefix(uri) != null) {
                     defPrefix = out.getPrefix(uri);
-                // we need to generate a prefix
+                    // we need to generate a prefix
                 } else {
-                    defPrefix = getUniquePrefix(out); 
+                    defPrefix = getUniquePrefix(out);
                     if (declare) {
                         out.setPrefix(defPrefix, uri);
                         out.writeNamespace(defPrefix, uri);
@@ -330,7 +283,7 @@
             return defPrefix;
         }
     }
-    
+
     protected static String getUniquePrefix(XMLStreamWriter writer) {
         int n = 1;
         while (true) {

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/ConnectorServerFactoryBean.java Fri Aug 10 07:37:46 2007
@@ -64,17 +64,18 @@
      */
     public static final int REGISTRATION_REPLACE_EXISTING = 2;
 
+    private static final Constants CONSTANTS = new Constants(ConnectorServerFactoryBean.class);
 
     private Log log = LogFactory.getLog(ConnectorServerFactoryBean.class);
-    private org.springframework.jmx.support.ConnectorServerFactoryBean csfb = new org.springframework.jmx.support.ConnectorServerFactoryBean();
+    private org.springframework.jmx.support.ConnectorServerFactoryBean csfb = 
+                    new org.springframework.jmx.support.ConnectorServerFactoryBean();
     private String serviceUrl = org.springframework.jmx.support.ConnectorServerFactoryBean.DEFAULT_SERVICE_URL;
-    private boolean daemon = false;
-    private boolean threaded = false;
+    private boolean daemon;
+    private boolean threaded;
     private Map environment;
     private Object objectName;
     private int registrationBehavior = REGISTRATION_FAIL_ON_EXISTING;
     private MBeanServer server;
-    private static final Constants constants = new Constants(ConnectorServerFactoryBean.class);
     
 
     /**
@@ -141,11 +142,11 @@
      * @see #REGISTRATION_FAIL_ON_EXISTING
      * @see #REGISTRATION_IGNORE_EXISTING
      * @see #REGISTRATION_REPLACE_EXISTING
-     * @param registrationBehavior
+     * @param behavior
      * @see org.springframework.jmx.support.MBeanRegistrationSupport#setRegistrationBehaviorName(java.lang.String)
      */
-    public void setRegistrationBehaviorName(String registrationBehavior) {
-        setRegistrationBehavior(constants.asNumber(registrationBehavior).intValue());
+    public void setRegistrationBehaviorName(String behavior) {
+        setRegistrationBehavior(CONSTANTS.asNumber(behavior).intValue());
     }
 
     /**

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/JaasAuthenticator.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/JaasAuthenticator.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/JaasAuthenticator.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/JaasAuthenticator.java Fri Aug 10 07:37:46 2007
@@ -69,8 +69,9 @@
      * @see javax.management.remote.JMXAuthenticator#authenticate(java.lang.Object)
      */
     public Subject authenticate(Object credentials) throws SecurityException {
-        if (credentials instanceof String[] == false) {
-            throw new IllegalArgumentException("Expected String[2], got " + (credentials != null ? credentials.getClass().getName() : null));
+        if (!(credentials instanceof String[])) {
+            throw new IllegalArgumentException("Expected String[2], got " 
+                            + (credentials != null ? credentials.getClass().getName() : null));
         }
         String[] params = (String[]) credentials;
         if (params.length != 2) {

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/PasswordAuthenticator.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/PasswordAuthenticator.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/PasswordAuthenticator.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/PasswordAuthenticator.java Fri Aug 10 07:37:46 2007
@@ -17,11 +17,11 @@
 package org.apache.servicemix.jbi.jmx;
 
 /*
- * Copyright (C) The MX4J Contributors.
- * All rights reserved.
- *
+ * Copyright (C) The MX4J Contributors. All rights reserved.
+ * 
  * This software is distributed under the terms of the MX4J License version 1.0.
- * See the terms of the MX4J License in the documentation provided with this software.
+ * See the terms of the MX4J License in the documentation provided with this
+ * software.
  */
 
 import java.io.File;
@@ -43,233 +43,221 @@
 import mx4j.util.Base64Codec;
 
 /**
- * Implementation of the JMXAuthenticator interface to be used on server side
- * to secure access to {@link javax.management.remote.JMXConnectorServer JMXConnectorServer}s. <br/>
- * Usage:
+ * Implementation of the JMXAuthenticator interface to be used on server side to
+ * secure access to
+ * {@link javax.management.remote.JMXConnectorServer JMXConnectorServer}s.
+ * <br/> Usage:
+ * 
  * <pre>
- * JMXAuthenticator authenticator = new PasswordAuthenticator(new File("users.properties"));
+ * JMXAuthenticator authenticator = new PasswordAuthenticator(new File(&quot;users.properties&quot;));
  * Map environment = new HashMap();
  * environment.put(JMXConnectorServer.AUTHENTICATOR, authenticator);
- * JMXServiceURL address = new JMXServiceURL("rmi", "localhost", 0);
+ * JMXServiceURL address = new JMXServiceURL(&quot;rmi&quot;, &quot;localhost&quot;, 0);
  * MBeanServer server = ...;
  * JMXConnectorServer cntorServer = JMXConnectorServerFactory.newJMXConnectorServer(address, environment, server);
  * </pre>
- * The format of the users.properties file is that of a standard properties file: <br/>
- * &lt;user&gt;=&lt;password&gt;<br/>
- * where &lt;password&gt; can be stored in 2 ways:
+ * 
+ * The format of the users.properties file is that of a standard properties
+ * file: <br/> &lt;user&gt;=&lt;password&gt;<br/> where &lt;password&gt; can be
+ * stored in 2 ways:
  * <ul>
  * <li>Clear text: the password is written in clear text</li>
  * <li>Obfuscated text: the password is obfuscated</li>
  * </ul>
  * The obfuscated form can be obtained running this class as a main class:
+ * 
  * <pre>
  * java -cp mx4j-remote.jar mx4j.tools.remote.PasswordAuthenticator
  * </pre>
- * and following the instructions printed on the console. The output will be a string that should be
- * copy/pasted as the password into the properties file.<br/>
- * The obfuscated password is obtained by digesting the clear text password using a
- * {@link java.security.MessageDigest} algorithm, and then by Base64-encoding the resulting bytes.<br/>
- * <br/>
- * On client side, you are allowed to connect to a server side secured with the PasswordAuthenticator
+ * 
+ * and following the instructions printed on the console. The output will be a
+ * string that should be copy/pasted as the password into the properties file.<br/>
+ * The obfuscated password is obtained by digesting the clear text password
+ * using a {@link java.security.MessageDigest} algorithm, and then by
+ * Base64-encoding the resulting bytes.<br/> <br/> On client side, you are
+ * allowed to connect to a server side secured with the PasswordAuthenticator
  * only if you provide the correct credentials:
+ * 
  * <pre>
  * String[] credentials = new String[2];
  * // The user will travel as clear text
- * credentials[0] = "user";
+ * credentials[0] = &quot;user&quot;;
  * // You may send the password in clear text, but it's better to obfuscate it
- * credentials[1] = PasswordAuthenticator.obfuscatePassword("password");
+ * credentials[1] = PasswordAuthenticator.obfuscatePassword(&quot;password&quot;);
  * Map environment = new HashMap();
  * environment.put(JMXConnector.CREDENTIALS, credentials);
  * JMXServiceURL address = ...;
  * JMXConnector cntor = JMXConnectorFactory.connect(address, environment);
  * </pre>
- * Note that {@link #obfuscatePassword(java.lang.String,java.lang.String) obfuscating} the passwords only works if the server side has been
- * setup with the PasswordAuthenticator.
- * However, the PasswordAuthenticator can be used with other JSR 160 implementations, such as Sun's reference
- * implementation.
- *
+ * 
+ * Note that
+ * {@link #obfuscatePassword(java.lang.String,java.lang.String) obfuscating} the
+ * passwords only works if the server side has been setup with the
+ * PasswordAuthenticator. However, the PasswordAuthenticator can be used with
+ * other JSR 160 implementations, such as Sun's reference implementation.
+ * 
  * @version $Revision: 1.3 $
  */
-public class PasswordAuthenticator implements JMXAuthenticator
-{
-   private static final String LEFT_DELIMITER = "OBF(";
-   private static final String RIGHT_DELIMITER = "):";
-
-   /**
-    * Runs this class as main class to obfuscate passwords.
-    * When no arguments are provided, it prints out the usage.
-    *
-    * @see #obfuscatePassword(java.lang.String,java.lang.String)
-    */
-   public static void main(String[] args) throws Exception
-   {
-      if (args.length == 1)
-      {
-         if (!"-help".equals(args[0]))
-         {
-            printPassword("MD5", args[0]);
-            return;
-         }
-      }
-      else if (args.length == 3)
-      {
-         if ("-alg".equals(args[0]))
-         {
-            printPassword(args[1], args[2]);
-            return;
-         }
-      }
-      printUsage();
-   }
-
-   private static void printPassword(String algorithm, String input)
-   {
-      String password = obfuscatePassword(input, algorithm);
-      System.out.println(password);
-   }
-
-   private static void printUsage()
-   {
-      System.out.println();
-      System.out.println("Usage: java -cp <lib>/mx4j-tools.jar mx4j.tools.remote.PasswordAuthenticator <options> <password>");
-      System.out.println("Where <options> is one of the following:");
-      System.out.println("   -help                     Prints this message");
-      System.out.println("   -alg <digest algorithm>   Specifies the digest algorithm (default is MD5)");
-      System.out.println();
-   }
-
-   /**
-    * Obfuscates the given password using MD5 as digest algorithm
-    *
-    * @see #obfuscatePassword(java.lang.String,java.lang.String)
-    */
-   public static String obfuscatePassword(String password)
-   {
-      return obfuscatePassword(password, "MD5");
-   }
-
-   /**
-    * Obfuscates the given password using the given digest algorithm.<br/>
-    * Obfuscation consists of 2 steps: first the clear text password is {@link java.security.MessageDigest#digest digested}
-    * using the specified algorithm, then the resulting bytes are Base64-encoded.<br/>
-    * For example, the obfuscated version of the password "password" is "OBF(MD5):X03MO1qnZdYdgyfeuILPmQ=="
-    * or "OBF(SHA-1):W6ph5Mm5Pz8GgiULbPgzG37mj9g=". <br/>
-    * OBF stands for "obfuscated", in parenthesis the algorithm used to digest the password.
-    */
-   public static String obfuscatePassword(String password, String algorithm)
-   {
-      try
-      {
-         MessageDigest digest = MessageDigest.getInstance(algorithm);
-         byte[] digestedBytes = digest.digest(password.getBytes());
-         byte[] obfuscatedBytes = Base64Codec.encodeBase64(digestedBytes);
-         return LEFT_DELIMITER + algorithm + RIGHT_DELIMITER + new String(obfuscatedBytes);
-      }
-      catch (NoSuchAlgorithmException x)
-      {
-         throw new SecurityException("Could not find digest algorithm " + algorithm);
-      }
-   }
-
-   private Map passwords;
-
-   /**
-    * Creates a new PasswordAuthenticator that reads user/password pairs from the specified properties file.
-    * The file format is described in the javadoc of this class.
-    *
-    * @see #obfuscatePassword
-    */
-   public PasswordAuthenticator(File passwordFile) throws IOException
-   {
-      this(new FileInputStream(passwordFile));
-   }
-
-   /**
-    * Creates a new PasswordAuthenticator that reads user/password pairs from the specified InputStream.
-    * The file format is described in the javadoc of this class.
-    *
-    * @see #obfuscatePassword
-    */
-   public PasswordAuthenticator(InputStream is) throws IOException
-   {
-      passwords = readPasswords(is);
-   }
-
-   private Map readPasswords(InputStream is) throws IOException
-   {
-      Properties properties = new Properties();
-      try
-      {
-         properties.load(is);
-      }
-      finally
-      {
-         is.close();
-      }
-      return new HashMap(properties);
-   }
-
-   public Subject authenticate(Object credentials) throws SecurityException
-   {
-      if (!(credentials instanceof String[])) throw new SecurityException("Bad credentials");
-      String[] creds = (String[])credentials;
-      if (creds.length != 2) throw new SecurityException("Bad credentials");
-
-      String user = creds[0];
-      String password = creds[1];
-
-      if (password == null) throw new SecurityException("Bad password");
-
-      if (!passwords.containsKey(user)) throw new SecurityException("Unknown user " + user);
-
-      String storedPassword = (String)passwords.get(user);
-      if (!isPasswordCorrect(password, storedPassword)) throw new SecurityException("Bad password");
-
-      Set principals = new HashSet();
-      principals.add(new JMXPrincipal(user));
-      return new Subject(true, principals, Collections.EMPTY_SET, Collections.EMPTY_SET);
-   }
-
-   private boolean isPasswordCorrect(String password, String storedPassword)
-   {
-      if (password.startsWith(LEFT_DELIMITER))
-      {
-         if (storedPassword.startsWith(LEFT_DELIMITER))
-         {
-            return password.equals(storedPassword);
-         }
-         else
-         {
-            String algorithm = getAlgorithm(password);
-            String obfuscated = obfuscatePassword(storedPassword, algorithm);
-            return password.equals(obfuscated);
-         }
-      }
-      else
-      {
-         if (storedPassword.startsWith(LEFT_DELIMITER))
-         {
-            // Password was sent in clear, bad practice
-            String algorithm = getAlgorithm(storedPassword);
-            String obfuscated = obfuscatePassword(password, algorithm);
-            return obfuscated.equals(storedPassword);
-         }
-         else
-         {
-            return password.equals(storedPassword);
-         }
-      }
-   }
-
-   private String getAlgorithm(String obfuscatedPassword)
-   {
-      try
-      {
-         return obfuscatedPassword.substring(LEFT_DELIMITER.length(), obfuscatedPassword.indexOf(RIGHT_DELIMITER));
-      }
-      catch (IndexOutOfBoundsException x)
-      {
-         throw new SecurityException("Bad password");
-      }
-   }
+public class PasswordAuthenticator implements JMXAuthenticator {
+
+    private static final String LEFT_DELIMITER = "OBF(";
+    private static final String RIGHT_DELIMITER = "):";
+
+    private Map passwords;
+
+    /**
+     * Creates a new PasswordAuthenticator that reads user/password pairs from
+     * the specified properties file. The file format is described in the
+     * javadoc of this class.
+     * 
+     * @see #obfuscatePassword
+     */
+    public PasswordAuthenticator(File passwordFile) throws IOException {
+        this(new FileInputStream(passwordFile));
+    }
+
+    /**
+     * Creates a new PasswordAuthenticator that reads user/password pairs from
+     * the specified InputStream. The file format is described in the javadoc of
+     * this class.
+     * 
+     * @see #obfuscatePassword
+     */
+    public PasswordAuthenticator(InputStream is) throws IOException {
+        passwords = readPasswords(is);
+    }
+
+    /**
+     * Runs this class as main class to obfuscate passwords. When no arguments
+     * are provided, it prints out the usage.
+     * 
+     * @see #obfuscatePassword(java.lang.String,java.lang.String)
+     */
+    public static void main(String[] args) throws Exception {
+        if (args.length == 1) {
+            if (!"-help".equals(args[0])) {
+                printPassword("MD5", args[0]);
+                return;
+            }
+        } else if (args.length == 3) {
+            if ("-alg".equals(args[0])) {
+                printPassword(args[1], args[2]);
+                return;
+            }
+        }
+        printUsage();
+    }
+
+    private static void printPassword(String algorithm, String input) {
+        String password = obfuscatePassword(input, algorithm);
+        System.out.println(password);
+    }
+
+    private static void printUsage() {
+        System.out.println();
+        System.out.println("Usage: java -cp <lib>/mx4j-tools.jar mx4j.tools.remote.PasswordAuthenticator <options> <password>");
+        System.out.println("Where <options> is one of the following:");
+        System.out.println("   -help                     Prints this message");
+        System.out.println("   -alg <digest algorithm>   Specifies the digest algorithm (default is MD5)");
+        System.out.println();
+    }
+
+    /**
+     * Obfuscates the given password using MD5 as digest algorithm
+     * 
+     * @see #obfuscatePassword(java.lang.String,java.lang.String)
+     */
+    public static String obfuscatePassword(String password) {
+        return obfuscatePassword(password, "MD5");
+    }
+
+    /**
+     * Obfuscates the given password using the given digest algorithm.<br/>
+     * Obfuscation consists of 2 steps: first the clear text password is
+     * {@link java.security.MessageDigest#digest digested} using the specified
+     * algorithm, then the resulting bytes are Base64-encoded.<br/> For
+     * example, the obfuscated version of the password "password" is
+     * "OBF(MD5):X03MO1qnZdYdgyfeuILPmQ==" or
+     * "OBF(SHA-1):W6ph5Mm5Pz8GgiULbPgzG37mj9g=". <br/> OBF stands for
+     * "obfuscated", in parenthesis the algorithm used to digest the password.
+     */
+    public static String obfuscatePassword(String password, String algorithm) {
+        try {
+            MessageDigest digest = MessageDigest.getInstance(algorithm);
+            byte[] digestedBytes = digest.digest(password.getBytes());
+            byte[] obfuscatedBytes = Base64Codec.encodeBase64(digestedBytes);
+            return LEFT_DELIMITER + algorithm + RIGHT_DELIMITER + new String(obfuscatedBytes);
+        } catch (NoSuchAlgorithmException x) {
+            throw new SecurityException("Could not find digest algorithm " + algorithm);
+        }
+    }
+
+    private Map readPasswords(InputStream is) throws IOException {
+        Properties properties = new Properties();
+        try {
+            properties.load(is);
+        } finally {
+            is.close();
+        }
+        return new HashMap(properties);
+    }
+
+    public Subject authenticate(Object credentials) throws SecurityException {
+        if (!(credentials instanceof String[])) {
+            throw new SecurityException("Bad credentials");
+        }
+        String[] creds = (String[]) credentials;
+        if (creds.length != 2) {
+            throw new SecurityException("Bad credentials");
+        }
+
+        String user = creds[0];
+        String password = creds[1];
+
+        if (password == null) {
+            throw new SecurityException("Bad password");
+        }
+
+        if (!passwords.containsKey(user)) {
+            throw new SecurityException("Unknown user " + user);
+        }
+
+        String storedPassword = (String) passwords.get(user);
+        if (!isPasswordCorrect(password, storedPassword)) {
+            throw new SecurityException("Bad password");
+        }
+
+        Set principals = new HashSet();
+        principals.add(new JMXPrincipal(user));
+        return new Subject(true, principals, Collections.EMPTY_SET, Collections.EMPTY_SET);
+    }
+
+    private boolean isPasswordCorrect(String password, String storedPassword) {
+        if (password.startsWith(LEFT_DELIMITER)) {
+            if (storedPassword.startsWith(LEFT_DELIMITER)) {
+                return password.equals(storedPassword);
+            } else {
+                String algorithm = getAlgorithm(password);
+                String obfuscated = obfuscatePassword(storedPassword, algorithm);
+                return password.equals(obfuscated);
+            }
+        } else {
+            if (storedPassword.startsWith(LEFT_DELIMITER)) {
+                // Password was sent in clear, bad practice
+                String algorithm = getAlgorithm(storedPassword);
+                String obfuscated = obfuscatePassword(password, algorithm);
+                return obfuscated.equals(storedPassword);
+            } else {
+                return password.equals(storedPassword);
+            }
+        }
+    }
+
+    private String getAlgorithm(String obfuscatedPassword) {
+        try {
+            return obfuscatedPassword.substring(LEFT_DELIMITER.length(), obfuscatedPassword.indexOf(RIGHT_DELIMITER));
+        } catch (IndexOutOfBoundsException x) {
+            throw new SecurityException("Bad password");
+        }
+    }
 }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/RmiRegistryFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/RmiRegistryFactoryBean.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/RmiRegistryFactoryBean.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/jmx/RmiRegistryFactoryBean.java Fri Aug 10 07:37:46 2007
@@ -30,13 +30,13 @@
  * @author gnodet
  * @org.apache.xbean.XBean element="rmiRegistry"
  */
-public class RmiRegistryFactoryBean implements FactoryBean, InitializingBean, DisposableBean{
+public class RmiRegistryFactoryBean implements FactoryBean, InitializingBean, DisposableBean {
 
     private int port = Registry.REGISTRY_PORT;
     private Registry registry;
-    private boolean locate = false;
+    private boolean locate;
     private boolean create = true;
-    private boolean locallyCreated = false;
+    private boolean locallyCreated;
     
     /**
      * @return the create

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogService.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogService.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogService.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogService.java Fri Aug 10 07:37:46 2007
@@ -16,19 +16,20 @@
  */
 package org.apache.servicemix.jbi.logging;
 
-import org.apache.servicemix.jbi.management.BaseSystemService;
-import org.apache.servicemix.jbi.management.OperationInfoHelper;
-import org.apache.servicemix.jbi.management.AttributeInfoHelper;
-import org.apache.servicemix.jbi.container.JBIContainer;
-import org.apache.log4j.Logger;
-import org.springframework.beans.factory.InitializingBean;
+import java.net.URL;
+import java.util.Timer;
 
 import javax.jbi.JBIException;
-import javax.management.MBeanOperationInfo;
 import javax.management.JMException;
 import javax.management.MBeanAttributeInfo;
-import java.util.Timer;
-import java.net.URL;
+import javax.management.MBeanOperationInfo;
+
+import org.apache.log4j.Logger;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.management.AttributeInfoHelper;
+import org.apache.servicemix.jbi.management.BaseSystemService;
+import org.apache.servicemix.jbi.management.OperationInfoHelper;
+import org.springframework.beans.factory.InitializingBean;
 
 /**
  * 
@@ -38,19 +39,24 @@
  */
 public class LogService extends BaseSystemService implements InitializingBean, LogServiceMBean {
 
-	private static String DEFAULT_LOG_FILE_NAME = "log4j.xml";
-	
+    private static final String DEFAULT_LOG_FILE_NAME = "log4j.xml";
+
+    private static final Logger LOG = Logger.getLogger(LogService.class);
+
     private boolean autoStart = true;
-    private boolean initialized = false;
+
+    private boolean initialized;
+
     private int refreshPeriod = 60; // 60sec
-    private URL configFileUrl = null;
+
+    private URL configFileUrl;
+
     private String configUrl = "file:conf/log4j.xml";
-    private LogTask logTask = null;
 
-    // timer in daemon mode
-    private Timer timer = null;
+    private LogTask logTask;
 
-    private static Logger logger = Logger.getLogger(LogService.class);
+    // timer in daemon mode
+    private Timer timer;
 
     public void afterPropertiesSet() throws Exception {
         if (this.container == null) {
@@ -87,7 +93,7 @@
                 start();
             }
         } catch (JBIException ex) {
-            logger.error("Error occured!", ex);
+            LOG.error("Error occured!", ex);
         }
     }
 
@@ -113,7 +119,7 @@
                 start();
             }
         } catch (JBIException ex) {
-            logger.error("Error occured!", ex);
+            LOG.error("Error occured!", ex);
         }
 
     }
@@ -134,8 +140,8 @@
      * reconfigure the log4j system if something has changed in the config file
      */
     public void reconfigureLogSystem() {
-        if (logger.isDebugEnabled()) {
-            logger.debug("try to reconfigure the log4j system");
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("try to reconfigure the log4j system");
         }
         if (logTask != null) {
             logTask.reconfigure();
@@ -147,7 +153,7 @@
     }
 
     public void start() throws JBIException {
-        setup();
+        setUp();
         super.start();
     }
 
@@ -164,51 +170,46 @@
         super.stop();
     }
 
-    public void setup() throws JBIException {
+    public void setUp() throws JBIException {
         if (!initialized) {
-        	configFileUrl = locateLoggingConfig();
+            configFileUrl = locateLoggingConfig();
 
             if (configFileUrl != null) {
                 // daemon mode
                 timer = new Timer(true);
                 logTask = new LogTask(configFileUrl);
                 logTask.run();
-                timer.schedule(logTask, 1000 * refreshPeriod,
-                        1000 * refreshPeriod);
+                timer.schedule(logTask, 1000 * refreshPeriod, 1000 * refreshPeriod);
                 initialized = true;
             }
         }
     }
 
-    /** 
-     * Grab the log4j.xml from the CLASSPATH 
+    /**
+     * Grab the log4j.xml from the CLASSPATH
      * 
-     * @return URL of the log4j.xml file 
+     * @return URL of the log4j.xml file
      */
     private URL locateLoggingConfig() {
-		URL log4jConfigUrl = ClassLoader.getSystemResource(DEFAULT_LOG_FILE_NAME);
-		
-		if (logger.isDebugEnabled()) 
-			logger.debug("Located logging configuration: " + log4jConfigUrl.toString());
-		
-		return log4jConfigUrl;
-	}
+        URL log4jConfigUrl = ClassLoader.getSystemResource(DEFAULT_LOG_FILE_NAME);
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Located logging configuration: " + log4jConfigUrl.toString());
+        }
+
+        return log4jConfigUrl;
+    }
 
-	public MBeanOperationInfo[] getOperationInfos() throws JMException {
+    public MBeanOperationInfo[] getOperationInfos() throws JMException {
         OperationInfoHelper helper = new OperationInfoHelper();
-        helper.addOperation(getObjectToManage(), "reconfigureLogSystem", 0,
-                "Reconfigure the log4j system");
-        return OperationInfoHelper.join(super.getOperationInfos(), helper
-                .getOperationInfos());
+        helper.addOperation(getObjectToManage(), "reconfigureLogSystem", 0, "Reconfigure the log4j system");
+        return OperationInfoHelper.join(super.getOperationInfos(), helper.getOperationInfos());
     }
 
     public MBeanAttributeInfo[] getAttributeInfos() throws JMException {
         AttributeInfoHelper helper = new AttributeInfoHelper();
-        helper.addAttribute(getObjectToManage(), "configUrl",
-                "the url for the log4j.xml config file");
-        helper.addAttribute(getObjectToManage(), "refreshPeriod",
-                "schedule time for scanning the log4j config file");
-        return AttributeInfoHelper.join(super.getAttributeInfos(), helper
-                .getAttributeInfos());
+        helper.addAttribute(getObjectToManage(), "configUrl", "the url for the log4j.xml config file");
+        helper.addAttribute(getObjectToManage(), "refreshPeriod", "schedule time for scanning the log4j config file");
+        return AttributeInfoHelper.join(super.getAttributeInfos(), helper.getAttributeInfos());
     }
 }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogServiceMBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogServiceMBean.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogServiceMBean.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogServiceMBean.java Fri Aug 10 07:37:46 2007
@@ -21,13 +21,13 @@
  */
 public interface LogServiceMBean {
 
-    public void setRefreshPeriod(int seconds);
+    void setRefreshPeriod(int seconds);
 
-    public int getRefreshPeriod();
+    int getRefreshPeriod();
 
-    public void setConfigUrl(String url);
+    void setConfigUrl(String url);
 
-    public String getConfigUrl();
+    String getConfigUrl();
 
-    public void reconfigureLogSystem();
+    void reconfigureLogSystem();
 }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogTask.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogTask.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogTask.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/logging/LogTask.java Fri Aug 10 07:37:46 2007
@@ -16,12 +16,12 @@
  */
 package org.apache.servicemix.jbi.logging;
 
-import org.apache.log4j.xml.DOMConfigurator;
-import org.apache.log4j.Logger;
-
-import java.util.TimerTask;
 import java.net.URL;
 import java.net.URLConnection;
+import java.util.TimerTask;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.xml.DOMConfigurator;
 
 public class LogTask extends TimerTask {
 

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/AttributeInfoHelper.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/AttributeInfoHelper.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/AttributeInfoHelper.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/AttributeInfoHelper.java Fri Aug 10 07:37:46 2007
@@ -16,16 +16,16 @@
  */
 package org.apache.servicemix.jbi.management;
 
-import org.apache.commons.beanutils.PropertyUtilsBean;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.management.IntrospectionException;
 import javax.management.MBeanAttributeInfo;
 import javax.management.ReflectionException;
 
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
+import org.apache.commons.beanutils.PropertyUtilsBean;
 
 /**
  * A Helper class to build a list of MBeanAttributInfos
@@ -34,6 +34,7 @@
  */
 public class AttributeInfoHelper {
     private PropertyUtilsBean beanUtil = new PropertyUtilsBean();
+
     private List<MBeanAttributeInfo> list = new ArrayList<MBeanAttributeInfo>();
 
     /**
@@ -43,7 +44,7 @@
      * @param name
      * @param description
      * @throws ReflectionException
-     
+     * 
      */
     public void addAttribute(Object theObject, String name, String description) throws ReflectionException {
         PropertyDescriptor pd;
@@ -51,21 +52,16 @@
             pd = beanUtil.getPropertyDescriptor(theObject, name);
             MBeanAttributeInfo info = new MBeanAttributeInfo(name, description, pd.getReadMethod(), pd.getWriteMethod());
             list.add(info);
-        }
-        catch(IntrospectionException e){
+        } catch (IntrospectionException e) {
             throw new ReflectionException(e);
-        }
-        catch (IllegalAccessException e) {
+        } catch (IllegalAccessException e) {
             throw new ReflectionException(e);
-        }
-        catch (InvocationTargetException e) {
+        } catch (InvocationTargetException e) {
             throw new ReflectionException(e);
-        }
-        catch (NoSuchMethodException e) {
+        } catch (NoSuchMethodException e) {
             throw new ReflectionException(e);
         }
-        
-        
+
     }
 
     /**
@@ -85,30 +81,32 @@
     public void clear() {
         list.clear();
     }
-    
+
     /**
      * Join two MBeanAttributeInfo[] arrays
+     * 
      * @param attrs1
      * @param attrs2
-     * @return new MBeanAttributeInfo array containing contents of attr1 and attr2
+     * @return new MBeanAttributeInfo array containing contents of attr1 and
+     *         attr2
      */
-    public static MBeanAttributeInfo[] join(MBeanAttributeInfo[] attrs1,MBeanAttributeInfo[] attrs2){
+    public static MBeanAttributeInfo[] join(MBeanAttributeInfo[] attrs1, MBeanAttributeInfo[] attrs2) {
         MBeanAttributeInfo[] result = null;
         int length = 0;
         int startPos = 0;
-        if (attrs1 != null){
+        if (attrs1 != null) {
             length = attrs1.length;
         }
-        if (attrs2 != null){
+        if (attrs2 != null) {
             length += attrs2.length;
         }
-        
+
         result = new MBeanAttributeInfo[length];
-        if (attrs1 != null){
+        if (attrs1 != null) {
             System.arraycopy(attrs1, 0, result, startPos, attrs1.length);
             startPos = attrs1.length;
         }
-        if(attrs2 != null){
+        if (attrs2 != null) {
             System.arraycopy(attrs2, 0, result, startPos, attrs2.length);
         }
         return result;

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseLifeCycle.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseLifeCycle.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseLifeCycle.java Fri Aug 10 07:37:46 2007
@@ -30,57 +30,60 @@
  * @version $Revision$
  */
 public abstract class BaseLifeCycle implements LifeCycleMBean, MBeanInfoProvider {
-    
+
     public static final String INITIALIZED = "Initialized";
-    
+
     protected String currentState = LifeCycleMBean.UNKNOWN;
-    
+
     protected PropertyChangeListener listener;
-    
-    
+
     /**
      * Get the name of the item
+     * 
      * @return the name
      */
     public String getName() {
         String name = getClass().getName();
         int index = name.lastIndexOf(".");
-        if (index >= 0 && (index+1) < name.length()) {
-            name = name.substring(index+1);
+        if (index >= 0 && (index + 1) < name.length()) {
+            name = name.substring(index + 1);
         }
         return name;
     }
-    
+
     /**
      * Get the type of the item
+     * 
      * @return the type
      */
     public String getType() {
         String name = getClass().getName();
         int index = name.lastIndexOf(".");
-        if (index >= 0 && (index+1) < name.length()) {
-            name = name.substring(index+1);
+        if (index >= 0 && (index + 1) < name.length()) {
+            name = name.substring(index + 1);
         }
         return name;
     }
-    
+
     public String getSubType() {
         return null;
     }
-    
+
     /**
      * set state to initialized
-     * @throws JBIException 
-     *
+     * 
+     * @throws JBIException
+     * 
      */
-    protected void init() throws JBIException{
+    protected void init() throws JBIException {
         setCurrentState(INITIALIZED);
     }
 
     /**
      * Start the item.
      * 
-     * @exception javax.jbi.JBIException if the item fails to start.
+     * @exception javax.jbi.JBIException
+     *                if the item fails to start.
      */
     public void start() throws javax.jbi.JBIException {
         setCurrentState(LifeCycleMBean.STARTED);
@@ -89,16 +92,19 @@
     /**
      * Stop the item. This suspends current messaging activities.
      * 
-     * @exception javax.jbi.JBIException if the item fails to stop.
+     * @exception javax.jbi.JBIException
+     *                if the item fails to stop.
      */
     public void stop() throws javax.jbi.JBIException {
         setCurrentState(LifeCycleMBean.STOPPED);
     }
 
     /**
-     * Shut down the item. The releases resources, preparatory to uninstallation.
+     * Shut down the item. The releases resources, preparatory to
+     * uninstallation.
      * 
-     * @exception javax.jbi.JBIException if the item fails to shut down.
+     * @exception javax.jbi.JBIException
+     *                if the item fails to shut down.
      */
     public void shutDown() throws javax.jbi.JBIException {
         setCurrentState(LifeCycleMBean.SHUTDOWN);
@@ -107,59 +113,60 @@
     /**
      * Get the current state of this managed compononent.
      * 
-     * @return the current state of this managed component (must be one of the string constants defined by this
-     * interface)
+     * @return the current state of this managed component (must be one of the
+     *         string constants defined by this interface)
      * @org.apache.xbean.Property hidden="true"
      */
     public String getCurrentState() {
         return currentState;
     }
-    
+
     /**
      * Set the current state
+     * 
      * @param newValue
      */
-    protected void setCurrentState(String newValue){
+    protected void setCurrentState(String newValue) {
         String oldValue = currentState;
         this.currentState = newValue;
-        firePropertyChanged("currentState",oldValue,newValue);
+        firePropertyChanged("currentState", oldValue, newValue);
     }
-    
+
     /**
      * @return true if the object is in the started state
      */
-    public boolean isStarted(){
+    public boolean isStarted() {
         return currentState != null && currentState.equals(LifeCycleMBean.STARTED);
     }
-    
+
     /**
-    * @return true if the object is stopped
-    */
-   public boolean isStopped(){
-       return currentState != null && currentState.equals(LifeCycleMBean.STOPPED);
-   }
-   
-   /**
-    * @return true if the object is shutDown
-    */
-   public boolean isShutDown(){
-       return currentState != null && currentState.equals(LifeCycleMBean.SHUTDOWN);
-   }
-   
-   /**
-    * @return true if the object is shutDown
-    */
-   public boolean isInitialized(){
-       return currentState != null && currentState.equals(INITIALIZED);
-   }
-   
-   /**
-    * @return true if the object is shutDown
-    */
-   public boolean isUnknown(){
-       return currentState == null || currentState.equals(LifeCycleMBean.UNKNOWN);
-   }
-    
+     * @return true if the object is stopped
+     */
+    public boolean isStopped() {
+        return currentState != null && currentState.equals(LifeCycleMBean.STOPPED);
+    }
+
+    /**
+     * @return true if the object is shutDown
+     */
+    public boolean isShutDown() {
+        return currentState != null && currentState.equals(LifeCycleMBean.SHUTDOWN);
+    }
+
+    /**
+     * @return true if the object is shutDown
+     */
+    public boolean isInitialized() {
+        return currentState != null && currentState.equals(INITIALIZED);
+    }
+
+    /**
+     * @return true if the object is shutDown
+     */
+    public boolean isUnknown() {
+        return currentState == null || currentState.equals(LifeCycleMBean.UNKNOWN);
+    }
+
     /**
      * Get an array of MBeanAttributeInfo
      * 
@@ -196,20 +203,21 @@
     public Object getObjectToManage() {
         return this;
     }
-    
+
     /**
      * Register for propertyChange events
+     * 
      * @param l
      * @org.apache.xbean.Property hidden="true"
      */
-    public void setPropertyChangeListener(PropertyChangeListener l){
+    public void setPropertyChangeListener(PropertyChangeListener l) {
         this.listener = l;
     }
-    
-    protected void firePropertyChanged(String name,Object oldValue, Object newValue){
+
+    protected void firePropertyChanged(String name, Object oldValue, Object newValue) {
         PropertyChangeListener l = listener;
-        if (l != null){
-            PropertyChangeEvent event = new PropertyChangeEvent(this,name,oldValue,newValue);
+        if (l != null) {
+            PropertyChangeEvent event = new PropertyChangeEvent(this, name, oldValue, newValue);
             l.propertyChange(event);
         }
     }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseStandardMBean.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseStandardMBean.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseStandardMBean.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseStandardMBean.java Fri Aug 10 07:37:46 2007
@@ -16,13 +16,16 @@
  */
 package org.apache.servicemix.jbi.management;
 
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.LinkedHashMap;
+import java.util.Map;
 import java.util.concurrent.ExecutorService;
 
-import org.apache.commons.beanutils.MethodUtils;
-import org.apache.commons.beanutils.PropertyUtilsBean;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 import javax.management.Attribute;
 import javax.management.AttributeChangeNotification;
 import javax.management.AttributeChangeNotificationFilter;
@@ -51,35 +54,49 @@
 import javax.management.modelmbean.ModelMBeanNotificationBroadcaster;
 import javax.management.modelmbean.ModelMBeanNotificationInfo;
 
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Date;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import org.apache.commons.beanutils.MethodUtils;
+import org.apache.commons.beanutils.PropertyUtilsBean;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * An MBean wrapper for an Existing Object
  * 
  * @version $Revision$
  */
-public class BaseStandardMBean extends StandardMBean
-        implements
-            ModelMBeanNotificationBroadcaster,
-            MBeanRegistration,
-            PropertyChangeListener {
-    private final static Log log = LogFactory.getLog(BaseStandardMBean.class);
-    private Map<String, CachedAttribute> cachedAttributes = new LinkedHashMap<String, CachedAttribute>();// used to maintain insertion ordering
+public class BaseStandardMBean extends StandardMBean implements ModelMBeanNotificationBroadcaster, MBeanRegistration,
+                PropertyChangeListener {
+
+    private static final Log LOG = LogFactory.getLog(BaseStandardMBean.class);
+
+    private static final Map<String, Class<?>> PRIMITIVE_CLASSES = new Hashtable<String, Class<?>>(8);
+    {
+        PRIMITIVE_CLASSES.put(Boolean.TYPE.toString(), Boolean.TYPE);
+        PRIMITIVE_CLASSES.put(Character.TYPE.toString(), Character.TYPE);
+        PRIMITIVE_CLASSES.put(Byte.TYPE.toString(), Byte.TYPE);
+        PRIMITIVE_CLASSES.put(Short.TYPE.toString(), Short.TYPE);
+        PRIMITIVE_CLASSES.put(Integer.TYPE.toString(), Integer.TYPE);
+        PRIMITIVE_CLASSES.put(Long.TYPE.toString(), Long.TYPE);
+        PRIMITIVE_CLASSES.put(Float.TYPE.toString(), Float.TYPE);
+        PRIMITIVE_CLASSES.put(Double.TYPE.toString(), Double.TYPE);
+    }
+
+    protected ExecutorService executorService;
+
+    private Map<String, CachedAttribute> cachedAttributes = new LinkedHashMap<String, CachedAttribute>();
+
+    // used to maintain insertion ordering
     private PropertyUtilsBean beanUtil = new PropertyUtilsBean();
+
     private NotificationBroadcasterSupport broadcasterSupport = new NotificationBroadcasterSupport();
-    protected ExecutorService executorService;
+
     private MBeanAttributeInfo[] attributeInfos;
+
     private MBeanInfo beanInfo;
+
     // this values are set after registering with the MBeanServer//
     private ObjectName objectName;
+
     private MBeanServer beanServer;
 
     /**
@@ -90,17 +107,18 @@
      * @param description
      * @param attrs
      * @param ops
-     * @param executorService2 
+     * @param executorService2
      * @throws ReflectionException
      * @throws NotCompliantMBeanException
      */
-    public BaseStandardMBean(Object object, Class interfaceMBean, String description, MBeanAttributeInfo[] attrs,
-            MBeanOperationInfo[] ops, ExecutorService executorService) throws ReflectionException, NotCompliantMBeanException {
+    public BaseStandardMBean(Object object, Class<?> interfaceMBean, String description, 
+                             MBeanAttributeInfo[] attrs, MBeanOperationInfo[] ops,
+                             ExecutorService executorService) throws ReflectionException, NotCompliantMBeanException {
         super(object, interfaceMBean);
         this.attributeInfos = attrs;
         buildAttributes(object, this.attributeInfos);
         this.beanInfo = new MBeanInfo(object.getClass().getName(), description, attrs, null, ops, getNotificationInfo());
-        this.executorService = executorService; 
+        this.executorService = executorService;
     }
 
     /**
@@ -141,7 +159,8 @@
         Object result = null;
         CachedAttribute ca = cachedAttributes.get(name);
         if (ca == null) {
-            // the use of proxies in MX4J has a bug - in which the caps can be changed on
+            // the use of proxies in MX4J has a bug - in which the caps can be
+            // changed on
             // an attribute
             for (Map.Entry<String, CachedAttribute> entry : cachedAttributes.entrySet()) {
                 String key = entry.getKey();
@@ -153,8 +172,7 @@
         }
         if (ca != null) {
             result = getCurrentValue(ca);
-        }
-        else {
+        } else {
             throw new AttributeNotFoundException("Could not locate " + name);
         }
         return result;
@@ -169,8 +187,8 @@
      * @throws MBeanException
      * @throws ReflectionException
      */
-    public void setAttribute(Attribute attr) throws AttributeNotFoundException, InvalidAttributeValueException,
-            MBeanException, ReflectionException {
+    public void setAttribute(Attribute attr) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException,
+                    ReflectionException {
         String name = attr.getName();
         CachedAttribute ca = cachedAttributes.get(name);
         if (ca != null) {
@@ -178,22 +196,18 @@
             try {
                 ca.updateAttribute(beanUtil, attr);
                 sendAttributeChangeNotification(old, attr);
-            }
-            catch (NoSuchMethodException e) {
+            } catch (NoSuchMethodException e) {
                 throw new ReflectionException(e);
-            }
-            catch (IllegalAccessException e) {
+            } catch (IllegalAccessException e) {
                 throw new ReflectionException(e);
-            }
-            catch (InvocationTargetException e) {
+            } catch (InvocationTargetException e) {
                 Throwable t = e.getTargetException();
                 if (t instanceof Exception) {
                     throw new MBeanException(e);
                 }
                 throw new MBeanException(e);
             }
-        }
-        else {
+        } else {
             throw new AttributeNotFoundException("Could not locate " + name);
         }
     }
@@ -211,12 +225,10 @@
             ca.updateAttributeValue(value);
             try {
                 sendAttributeChangeNotification(old, ca.getAttribute());
-            }
-            catch (RuntimeOperationsException e) {
-                log.error("Failed to update attribute: " + name + " to new value: " + value, e);
-            }
-            catch (MBeanException e) {
-                log.error("Failed to update attribute: " + name + " to new value: " + value, e);
+            } catch (RuntimeOperationsException e) {
+                LOG.error("Failed to update attribute: " + name + " to new value: " + value, e);
+            } catch (MBeanException e) {
+                LOG.error("Failed to update attribute: " + name + " to new value: " + value, e);
             }
         }
     }
@@ -231,7 +243,8 @@
     }
 
     /**
-     * @param attributes - array of Attribute names
+     * @param attributes -
+     *            array of Attribute names
      * @return AttributeList of matching Attributes
      */
     public AttributeList getAttributes(String[] attributes) {
@@ -239,24 +252,21 @@
         try {
             if (attributes != null) {
                 result = new AttributeList();
-                for (int i = 0;i < attributes.length;i++) {
+                for (int i = 0; i < attributes.length; i++) {
                     CachedAttribute ca = cachedAttributes.get(attributes[i]);
                     ca.updateValue(beanUtil);
                     result.add(ca.getAttribute());
                 }
-            }
-            else {
+            } else {
                 // Do this to maintain insertion ordering
-                for (Iterator i = cachedAttributes.entrySet().iterator();i.hasNext();) {
-                    Map.Entry entry = (Map.Entry) i.next();
-                    CachedAttribute ca = (CachedAttribute) entry.getValue();
+                for (Map.Entry<String, CachedAttribute> entry : cachedAttributes.entrySet()) {
+                    CachedAttribute ca = entry.getValue();
                     ca.updateValue(beanUtil);
                     result.add(ca.getAttribute());
                 }
             }
-        }
-        catch (MBeanException e) {
-            log.error("Caught excdeption building attributes", e);
+        } catch (MBeanException e) {
+            LOG.error("Caught excdeption building attributes", e);
         }
         return result;
     }
@@ -270,22 +280,18 @@
     public AttributeList setAttributes(AttributeList attributes) {
         AttributeList result = new AttributeList();
         if (attributes != null) {
-            for (int i = 0;i < attributes.size();i++) {
+            for (int i = 0; i < attributes.size(); i++) {
                 Attribute attribute = (Attribute) attributes.get(i);
                 try {
                     setAttribute(attribute);
-                }
-                catch (AttributeNotFoundException e) {
-                    log.warn("Failed to setAttribute(" + attribute + ")", e);
-                }
-                catch (InvalidAttributeValueException e) {
-                    log.warn("Failed to setAttribute(" + attribute + ")", e);
-                }
-                catch (MBeanException e) {
-                    log.warn("Failed to setAttribute(" + attribute + ")", e);
-                }
-                catch (ReflectionException e) {
-                    log.warn("Failed to setAttribute(" + attribute + ")", e);
+                } catch (AttributeNotFoundException e) {
+                    LOG.warn("Failed to setAttribute(" + attribute + ")", e);
+                } catch (InvalidAttributeValueException e) {
+                    LOG.warn("Failed to setAttribute(" + attribute + ")", e);
+                } catch (MBeanException e) {
+                    LOG.warn("Failed to setAttribute(" + attribute + ")", e);
+                } catch (ReflectionException e) {
+                    LOG.warn("Failed to setAttribute(" + attribute + ")", e);
                 }
                 result.add(attribute);
             }
@@ -306,29 +312,25 @@
     public Object invoke(String name, Object[] params, String[] signature) throws MBeanException, ReflectionException {
         ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
         try {
-            Class[] parameterTypes = new Class[signature.length];
+            Class<?>[] parameterTypes = new Class<?>[signature.length];
             for (int i = 0; i < parameterTypes.length; i++) {
-                parameterTypes[i] = primitiveClasses.get(signature[i]);
+                parameterTypes[i] = PRIMITIVE_CLASSES.get(signature[i]);
                 if (parameterTypes[i] == null) {
                     parameterTypes[i] = Class.forName(signature[i]);
                 }
             }
             Thread.currentThread().setContextClassLoader(getImplementation().getClass().getClassLoader());
             return MethodUtils.invokeMethod(getImplementation(), name, params, parameterTypes);
-        }
-        catch (ClassNotFoundException e) {
+        } catch (ClassNotFoundException e) {
             throw new ReflectionException(e);
-        }
-        catch (NoSuchMethodException e) {
+        } catch (NoSuchMethodException e) {
             throw new ReflectionException(e);
-        }
-        catch (IllegalAccessException e) {
+        } catch (IllegalAccessException e) {
             throw new ReflectionException(e);
-        }
-        catch (InvocationTargetException e) {
+        } catch (InvocationTargetException e) {
             Throwable t = e.getTargetException();
             if (t instanceof Exception) {
-                throw new MBeanException((Exception)t);
+                throw new MBeanException((Exception) t);
             } else {
                 throw new MBeanException(e);
             }
@@ -337,18 +339,6 @@
         }
     }
 
-    private final static Hashtable<String, Class> primitiveClasses = new Hashtable<String, Class>(8);
-    {
-        primitiveClasses.put(Boolean.TYPE.toString(), Boolean.TYPE);
-        primitiveClasses.put(Character.TYPE.toString(), Character.TYPE);
-        primitiveClasses.put(Byte.TYPE.toString(), Byte.TYPE);
-        primitiveClasses.put(Short.TYPE.toString(), Short.TYPE);
-        primitiveClasses.put(Integer.TYPE.toString(), Integer.TYPE);
-        primitiveClasses.put(Long.TYPE.toString(), Long.TYPE);
-        primitiveClasses.put(Float.TYPE.toString(), Float.TYPE);
-        primitiveClasses.put(Double.TYPE.toString(), Double.TYPE);
-     }    
-    
     /**
      * Called at registration
      * 
@@ -357,11 +347,11 @@
      * @return the ObjectName
      * @throws Exception
      */
-    public ObjectName preRegister(MBeanServer mbs,ObjectName on) throws Exception{
-        if(mbs != null){
+    public ObjectName preRegister(MBeanServer mbs, ObjectName on) throws Exception {
+        if (mbs != null) {
             this.beanServer = mbs;
         }
-        if(on != null){
+        if (on != null) {
             this.objectName = on;
         }
         return on;
@@ -426,8 +416,8 @@
      * @throws RuntimeOperationsException
      * @throws IllegalArgumentException
      */
-    public void addAttributeChangeNotificationListener(NotificationListener l, String attrName, Object handback)
-            throws MBeanException, RuntimeOperationsException, IllegalArgumentException {
+    public void addAttributeChangeNotificationListener(NotificationListener l, String attrName, Object handback) throws MBeanException,
+                    RuntimeOperationsException, IllegalArgumentException {
         AttributeChangeNotificationFilter currFilter = new AttributeChangeNotificationFilter();
         currFilter.enableAttribute(attrName);
         broadcasterSupport.addNotificationListener(l, currFilter, handback);
@@ -440,8 +430,8 @@
      * @throws RuntimeOperationsException
      * @throws ListenerNotFoundException
      */
-    public void removeAttributeChangeNotificationListener(NotificationListener l, String attrName)
-            throws MBeanException, RuntimeOperationsException, ListenerNotFoundException {
+    public void removeAttributeChangeNotificationListener(NotificationListener l, String attrName) throws MBeanException,
+                    RuntimeOperationsException, ListenerNotFoundException {
         broadcasterSupport.removeNotificationListener(l);
     }
 
@@ -450,8 +440,8 @@
      * @throws MBeanException
      * @throws RuntimeOperationsException
      */
-    public void sendAttributeChangeNotification(AttributeChangeNotification notification) throws MBeanException,
-            RuntimeOperationsException {
+    public void sendAttributeChangeNotification(AttributeChangeNotification notification) throws MBeanException, 
+                                                                                                 RuntimeOperationsException {
         sendNotification(notification);
     }
 
@@ -461,12 +451,11 @@
      * @throws MBeanException
      * @throws RuntimeOperationsException
      */
-    public void sendAttributeChangeNotification(Attribute oldAttr, Attribute newAttr) throws MBeanException,
-            RuntimeOperationsException {
+    public void sendAttributeChangeNotification(Attribute oldAttr, Attribute newAttr) throws MBeanException, RuntimeOperationsException {
         if (!oldAttr.equals(newAttr)) {
-            AttributeChangeNotification notification = new AttributeChangeNotification(objectName, 1, ((new Date())
-                    .getTime()), "AttributeChange", oldAttr.getName(), (((newAttr.getValue()).getClass()).toString()),
-                    oldAttr.getValue(), newAttr.getValue());
+            AttributeChangeNotification notification = new AttributeChangeNotification(objectName, 1, (new Date()).getTime(),
+                            "AttributeChange", oldAttr.getName(), newAttr.getValue().getClass().toString(), oldAttr.getValue(),
+                            newAttr.getValue());
             sendAttributeChangeNotification(notification);
         }
     }
@@ -476,14 +465,15 @@
      */
     public MBeanNotificationInfo[] getNotificationInfo() {
         MBeanNotificationInfo[] result = new MBeanNotificationInfo[2];
-        Descriptor genericDescriptor = new DescriptorSupport(new String[]{"name=GENERIC",
-                "descriptorType=notification", "log=T", "severity=5", "displayName=jmx.modelmbean.generic"});
-        result[0] = new ModelMBeanNotificationInfo(new String[]{"jmx.modelmbean.generic"}, "GENERIC",
-                "A text notification has been issued by the managed resource", genericDescriptor);
-        Descriptor attributeDescriptor = new DescriptorSupport(new String[]{"name=ATTRIBUTE_CHANGE",
-                "descriptorType=notification", "log=T", "severity=5", "displayName=jmx.attribute.change"});
-        result[1] = new ModelMBeanNotificationInfo(new String[]{"jmx.attribute.change"}, "ATTRIBUTE_CHANGE",
-                "Signifies that an observed MBean attribute value has changed", attributeDescriptor);
+        Descriptor genericDescriptor = new DescriptorSupport(new String[] {
+            "name=GENERIC", "descriptorType=notification", "log=T",
+            "severity=5", "displayName=jmx.modelmbean.generic" });
+        result[0] = new ModelMBeanNotificationInfo(new String[] {"jmx.modelmbean.generic" }, "GENERIC",
+            "A text notification has been issued by the managed resource", genericDescriptor);
+        Descriptor attributeDescriptor = new DescriptorSupport(new String[] {"name=ATTRIBUTE_CHANGE", "descriptorType=notification",
+            "log=T", "severity=5", "displayName=jmx.attribute.change" });
+        result[1] = new ModelMBeanNotificationInfo(new String[] {"jmx.attribute.change" }, "ATTRIBUTE_CHANGE",
+            "Signifies that an observed MBean attribute value has changed", attributeDescriptor);
         return result;
     }
 
@@ -493,8 +483,8 @@
      * @param handle
      * @throws IllegalArgumentException
      */
-    public void addNotificationListener(NotificationListener l, NotificationFilter filter, Object handle)
-            throws IllegalArgumentException {
+    public void addNotificationListener(NotificationListener l, NotificationFilter filter, 
+                                        Object handle) throws IllegalArgumentException {
         broadcasterSupport.addNotificationListener(l, filter, handle);
     }
 
@@ -511,14 +501,11 @@
         if (ca != null) {
             try {
                 result = beanUtil.getProperty(ca.getBean(), ca.getName());
-            }
-            catch (IllegalAccessException e) {
+            } catch (IllegalAccessException e) {
                 throw new MBeanException(e);
-            }
-            catch (InvocationTargetException e) {
+            } catch (InvocationTargetException e) {
                 throw new MBeanException(e);
-            }
-            catch (NoSuchMethodException e) {
+            } catch (NoSuchMethodException e) {
                 throw new MBeanException(e);
             }
         }
@@ -534,7 +521,7 @@
      */
     private void buildAttributes(Object obj, MBeanAttributeInfo[] attrs) throws ReflectionException {
         if (attrs != null) {
-            for (int i = 0;i < attrs.length;i++) {
+            for (int i = 0; i < attrs.length; i++) {
                 try {
                     String name = attrs[i].getName();
                     PropertyDescriptor pd = beanUtil.getPropertyDescriptor(obj, name);
@@ -544,14 +531,11 @@
                     ca.setBean(obj);
                     ca.setPropertyDescriptor(pd);
                     cachedAttributes.put(name, ca);
-                }
-                catch (NoSuchMethodException e) {
+                } catch (NoSuchMethodException e) {
                     throw new ReflectionException(e);
-                }
-                catch (IllegalAccessException e) {
+                } catch (IllegalAccessException e) {
                     throw new ReflectionException(e);
-                }
-                catch (InvocationTargetException e) {
+                } catch (InvocationTargetException e) {
                     throw new ReflectionException(e);
                 }
             }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseSystemService.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseSystemService.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseSystemService.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/BaseSystemService.java Fri Aug 10 07:37:46 2007
@@ -47,9 +47,9 @@
         return "SystemService";
     }
 
-    public void init(JBIContainer container) throws JBIException {
-        this.container = container;
-        container.getManagementContext().registerSystemService(this, getServiceMBean());
+    public void init(JBIContainer cont) throws JBIException {
+        this.container = cont;
+        cont.getManagementContext().registerSystemService(this, getServiceMBean());
         super.init();
     }
 

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/CachedAttribute.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/CachedAttribute.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/CachedAttribute.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/CachedAttribute.java Fri Aug 10 07:37:46 2007
@@ -16,14 +16,14 @@
  */
 package org.apache.servicemix.jbi.management;
 
-import org.apache.commons.beanutils.PropertyUtilsBean;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
 
 import javax.management.Attribute;
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanException;
 
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.InvocationTargetException;
+import org.apache.commons.beanutils.PropertyUtilsBean;
 
 /**
  * A simple holder for an Attribute and a PropertyDescriptor
@@ -89,14 +89,11 @@
             if (value != attribute.getValue()) {
                 this.attribute = new Attribute(getName(), value);
             }
-        }
-        catch (IllegalAccessException e) {
+        } catch (IllegalAccessException e) {
             throw new MBeanException(e);
-        }
-        catch (InvocationTargetException e) {
+        } catch (InvocationTargetException e) {
             throw new MBeanException(e);
-        }
-        catch (NoSuchMethodException e) {
+        } catch (NoSuchMethodException e) {
             throw new MBeanException(e);
         }
     }
@@ -105,18 +102,18 @@
      * Update the Attribute
      * 
      * @param beanUtils
-     * @param attribute The attribute to set.
+     * @param attr The attribute to set.
      * @throws IllegalAccessException
      * @throws InvocationTargetException
      * @throws NoSuchMethodException
      */
-    public void updateAttribute(PropertyUtilsBean beanUtils, Attribute attribute) throws IllegalAccessException,
+    public void updateAttribute(PropertyUtilsBean beanUtils, Attribute attr) throws IllegalAccessException,
             InvocationTargetException, NoSuchMethodException {
         if (this.attribute != null && propertyDescriptor != null) {
             // update object value
-            beanUtils.setProperty(bean, getName(), attribute.getValue());
+            beanUtils.setProperty(bean, getName(), attr.getValue());
         }
-        this.attribute = attribute;
+        this.attribute = attr;
     }
 
     /**

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/MBeanBuilder.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/MBeanBuilder.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/MBeanBuilder.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/MBeanBuilder.java Fri Aug 10 07:37:46 2007
@@ -16,19 +16,21 @@
  */
 package org.apache.servicemix.jbi.management;
 
+import java.util.concurrent.ExecutorService;
+
 import javax.management.DynamicMBean;
 import javax.management.JMException;
 import javax.management.StandardMBean;
 
-import java.util.concurrent.ExecutorService;
-
 /**
  * Builds a DynamicMBean wrappers for existing objects
  * 
  * @version $Revision$
  */
-class MBeanBuilder {
+public final class MBeanBuilder {
     
+    private MBeanBuilder() {
+    }
 
     /**
      * Build an MBean
@@ -40,7 +42,8 @@
      * @return the MBean wrapper
      * @throws JMException
      */
-    static DynamicMBean buildStandardMBean(Object theObject, Class interfaceMBean, String description, ExecutorService executorService) throws JMException {
+    static DynamicMBean buildStandardMBean(Object theObject, Class interfaceMBean, 
+                                           String description, ExecutorService executorService) throws JMException {
         DynamicMBean result = null;
         if (theObject != null) {
             if (theObject instanceof MBeanInfoProvider) {
@@ -53,8 +56,7 @@
                         info.getOperationInfos(),
                         executorService);
                 info.setPropertyChangeListener((BaseStandardMBean)result);
-            }
-            else {
+            } else {
                 return new StandardMBean(theObject, interfaceMBean);
             }
         }

Modified: incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/MBeanInfoProvider.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/MBeanInfoProvider.java?view=diff&rev=564607&r1=564606&r2=564607
==============================================================================
--- incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/MBeanInfoProvider.java (original)
+++ incubator/servicemix/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/MBeanInfoProvider.java Fri Aug 10 07:37:46 2007
@@ -16,12 +16,12 @@
  */
 package org.apache.servicemix.jbi.management;
 
+import java.beans.PropertyChangeListener;
+
 import javax.management.JMException;
 import javax.management.MBeanAttributeInfo;
 import javax.management.MBeanOperationInfo;
 
-import java.beans.PropertyChangeListener;
-
 /**
  * An object to be managed can implement this class
  * to provide more meta infomation for the MBeanInfo
@@ -35,51 +35,49 @@
      * @return array of AttributeInfos
      * @throws JMException
      */
-    public MBeanAttributeInfo[] getAttributeInfos() throws JMException;
+    MBeanAttributeInfo[] getAttributeInfos() throws JMException;
     
     /**
      * Get an array of MBeanOperationInfo
      * @return array of OperationInfos
      * @throws JMException
      */
-    public MBeanOperationInfo[] getOperationInfos() throws JMException;
+    MBeanOperationInfo[] getOperationInfos() throws JMException;
     
     /**
      * Get the Object to Manage
      * @return the Object to Manage
      */
-    public Object getObjectToManage();
+    Object getObjectToManage();
     
     /**
      * Get the name of the item
      * @return the name
      */
-    public String getName();
+    String getName();
     
     /**
      * Get the type of this mbean
      * @return the type
      */
-    public String getType();
+    String getType();
     
     /**
      * Get the type of this mbean
      * @return the type
      */
-    public String getSubType();
+    String getSubType();
     
     /**
      * Get the Description of the item
      * @return the description
      */
-    public String getDescription();
+    String getDescription();
     
     /**
      * Register for propertyChange events
      * @param l
      */
-    public void setPropertyChangeListener(PropertyChangeListener l);
-    
-    
-    
+    void setPropertyChangeListener(PropertyChangeListener l);
+
 }



Mime
View raw message