]> gcc.gnu.org Git - gcc.git/commitdiff
MBeanServer.java: Updated.
authorGary Benson <gbenson@redhat.com>
Tue, 20 Feb 2007 15:02:38 +0000 (15:02 +0000)
committerGary Benson <gary@gcc.gnu.org>
Tue, 20 Feb 2007 15:02:38 +0000 (15:02 +0000)
2007-02-20  Gary Benson  <gbenson@redhat.com>

* javax/management/MBeanServer.java: Updated.
* javax/management/MBeanServerConnection.java: Likewise.
* javax/management/ObjectName.java: Likewise.
* javax/management/StandardMBean.java: Likewise.

From-SVN: r122165

libjava/classpath/ChangeLog.gcj
libjava/classpath/javax/management/MBeanServer.java
libjava/classpath/javax/management/MBeanServerConnection.java
libjava/classpath/javax/management/ObjectName.java
libjava/classpath/javax/management/StandardMBean.java
libjava/classpath/lib/javax/management/MBeanServer.class
libjava/classpath/lib/javax/management/MBeanServerConnection.class
libjava/classpath/lib/javax/management/ObjectName.class
libjava/classpath/lib/javax/management/StandardMBean.class
libjava/javax/management/ObjectName.h

index c147ab6a7a828ec9b5fbc993b8b6e49b7805b433..9273fe261c31aa6cc64427dd4c07185581e496db 100644 (file)
@@ -1,3 +1,10 @@
+2007-02-20  Gary Benson  <gbenson@redhat.com>
+
+       * javax/management/MBeanServer.java: Updated.
+       * javax/management/MBeanServerConnection.java: Likewise.
+       * javax/management/ObjectName.java: Likewise.
+       * javax/management/StandardMBean.java: Likewise.
+
 2007-02-15  David Daney  <ddaney@avtrex.com>
 
        * tools/Makefile.am (TOOLS_ZIP): Add classes from vm-tools-packages.
index 73a28e3b85aa6bd5ad248cc93ae8b31e78b91edd..0be5d71ad5df553a0f48d22f6ec9ef6307048027 100644 (file)
@@ -890,7 +890,7 @@ public interface MBeanServer
    *                           arise from the execution of the query, in which
    *                           case that particular bean will again be excluded.
    */
-  Set queryMBeans(ObjectName name, QueryExp query);
+  Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query);
   
   /**
    * <p>
@@ -929,7 +929,7 @@ public interface MBeanServer
    *                           Note that these permissions are implied if the
    *                           <code>queryMBeans</code> permissions are available.
    */
-  Set queryNames(ObjectName name, QueryExp query);
+  Set<ObjectName> queryNames(ObjectName name, QueryExp query);
 
   /**
    * Registers the supplied instance with the server, using the specified
index dff03e8c0d476e7ca4683d2698994e05087365d1..cba6dacc63c774d6881459d4130078aa5e78e5f4 100644 (file)
@@ -533,7 +533,7 @@ public interface MBeanServerConnection
    * @throws IOException if an I/O error occurred in communicating with
    *                     the bean server.
    */
-  Set queryMBeans(ObjectName name, QueryExp query)
+  Set<ObjectInstance> queryMBeans(ObjectName name, QueryExp query)
     throws IOException;
   
   /**
@@ -560,7 +560,7 @@ public interface MBeanServerConnection
    * @throws IOException if an I/O error occurred in communicating with
    *                     the bean server.
    */
-  Set queryNames(ObjectName name, QueryExp query)
+  Set<ObjectName> queryNames(ObjectName name, QueryExp query)
     throws IOException;
 
   /**
index 757b80fb266a85f380f706664de90fd00c615137..8259eab02bedd3795917f31e1adb5ddd49e4911a 100644 (file)
@@ -105,7 +105,7 @@ public class ObjectName
   /**
    * The properties, as key-value pairs.
    */
-  private TreeMap properties;
+  private TreeMap<String,String> properties = new TreeMap<String,String>();
 
   /**
    * The properties as a string (stored for ordering).
@@ -164,7 +164,6 @@ public class ObjectName
          throw new MalformedObjectNameException("A name that is not a " +
                                                 "pattern must contain at " +
                                                 "least one key-value pair.");
-       properties = new TreeMap();
        for (int a = 0; a < pairs.length; ++a)
          {
            int sep = pairs[a].indexOf('=');
@@ -197,7 +196,6 @@ public class ObjectName
     throws MalformedObjectNameException
   {
     this.domain = domain;
-    properties = new TreeMap();
     properties.put(key, value);
     checkComponents();
   }
@@ -216,7 +214,7 @@ public class ObjectName
    * @throws NullPointerException if one of the parameters is
    *                              <code>null</code>.
    */
-  public ObjectName(String domain, Hashtable properties)
+  public ObjectName(String domain, Hashtable<String,String> properties)
     throws MalformedObjectNameException
   {
     this.domain = domain;
@@ -305,70 +303,80 @@ public class ObjectName
   {
     if (name.isPattern())
       return false;
-    if (isPattern())
+
+    if (!isPattern())
+      return equals(name);
+
+    if (isDomainPattern())
       {
-       boolean domainMatch, propMatch;
-       if (isDomainPattern())
+       if (!domainMatches(domain, 0, name.getDomain(), 0))
+         return false;
+      }
+    else
+      {
+       if (!domain.equals(name.getDomain()))
+         return false;
+      }
+
+    if (isPropertyPattern())
+      {
+       Hashtable oProps = name.getKeyPropertyList();
+       Iterator i = properties.entrySet().iterator();
+       while (i.hasNext())
          {
-           String oDomain = name.getDomain();
-           int oLength = oDomain.length();
-           for (int a = 0; a < domain.length(); ++a)
-             {
-               char n = domain.charAt(a);
-               if (oLength == a && n != '*')
-                 return false;
-               if (n == '?')
-                 continue;
-               if (n == '*')
-                 if ((a + 1) < domain.length())
-                   {
-                     if (oLength == a)
-                       return false;
-                     char next;
-                     do
-                       {
-                         next = domain.charAt(a + 1);
-                       } while (next == '*');
-                     if (next == '?')
-                       continue;
-                     int pos = a;
-                     while (oDomain.charAt(pos) != next)
-                       {
-                         ++pos;
-                         if (pos == oLength)
-                           return false;
-                       }
-                   }
-               if (n != oDomain.charAt(a))
-                 return false;
-             }
-           domainMatch = true;
+           Map.Entry entry = (Map.Entry) i.next();
+           String key = (String) entry.getKey();
+           if (!(oProps.containsKey(key)))
+             return false;
+           String val = (String) entry.getValue();
+           if (!(val.equals(oProps.get(key))))
+             return false;
          }
-       else
-         domainMatch = domain.equals(name.getDomain());
-       if (isPropertyPattern())
+      }
+    else
+      {
+       if (!getCanonicalKeyPropertyListString().equals
+           (name.getCanonicalKeyPropertyListString()))
+         return false;
+      }
+    return true;
+  }
+
+  /**
+   * Returns true if the domain matches the pattern.
+   *
+   * @param pattern the pattern to match against.
+   * @param patternindex the index into the pattern to start matching.
+   * @param domain the domain to match.
+   * @param domainindex the index into the domain to start matching.
+   * @return true if the domain matches the pattern.
+   */
+  private static boolean domainMatches(String pattern, int patternindex,
+                                      String domain, int domainindex)
+  {
+    while (patternindex < pattern.length())
+      {
+       char c = pattern.charAt(patternindex++);
+       
+       if (c == '*')
          {
-           Hashtable oProps = name.getKeyPropertyList();
-           Iterator i = properties.entrySet().iterator();
-           while (i.hasNext())
+           for (int i = domain.length(); i >= domainindex; i--)
              {
-               Map.Entry entry = (Map.Entry) i.next();
-               String key = (String) entry.getKey();
-               if (!(oProps.containsKey(key)))
-                 return false;
-               String val = (String) entry.getValue();
-               if (!(val.equals(oProps.get(key))))
-                 return false;
+               if (domainMatches(pattern, patternindex, domain, i))
+                 return true;
              }
-           propMatch = true;
+           return false;
          }
-       else
-         propMatch =
-           getCanonicalKeyPropertyListString().equals
-           (name.getCanonicalKeyPropertyListString());
-       return domainMatch && propMatch;
+
+       if (domainindex >= domain.length())
+         return false;
+       
+       if (c != '?' && c != domain.charAt(domainindex))
+         return false;
+
+       domainindex++;
       }
-    return equals(name);
+    return true;
   }
 
   /**
@@ -542,7 +550,8 @@ public class ObjectName
    *                                      specifications.
    * @throws NullPointerException if <code>name</code> is <code>null</code>.
    */
-  public static ObjectName getInstance(String domain, Hashtable properties)
+  public static ObjectName getInstance(String domain,
+                                      Hashtable<String,String> properties)
     throws MalformedObjectNameException
   {
     return new ObjectName(domain, properties);
@@ -571,9 +580,9 @@ public class ObjectName
    * @return a {@link java.util.Hashtable}, containing each of the object
    *         name's properties.
    */
-  public Hashtable getKeyPropertyList()
+  public Hashtable<String,String> getKeyPropertyList()
   {
-    return new Hashtable(properties);
+    return new Hashtable<String,String>(properties);
   }
 
   /**
index 0434a40b8cc3169a0ffe73c5230da62e3348ff62..b31436c6ec1772091af2850b52766d72a5daf104 100644 (file)
@@ -69,7 +69,7 @@ public class StandardMBean
   /**
    * The interface for this bean.
    */
-  private Class iface;
+  private Class<?> iface;
 
   /**
    * The implementation of the interface.
@@ -94,7 +94,7 @@ public class StandardMBean
    *                                    in the interface that doesn't comply
    *                                    with the naming conventions.
    */
-  protected StandardMBean(Class iface)
+  protected StandardMBean(Class<?> iface)
     throws NotCompliantMBeanException
   {
     if (iface == null)
@@ -133,7 +133,7 @@ public class StandardMBean
    *                                    in the interface that doesn't comply
    *                                    with the naming conventions.
    */
-  public StandardMBean(Object impl, Class iface)
+  public <T> StandardMBean(T impl, Class<T> iface)
     throws NotCompliantMBeanException
   {
     if (impl == null)
@@ -143,8 +143,8 @@ public class StandardMBean
        String className = impl.getClass().getName();
        try
          {
-           iface = Class.forName(className + "MBean", true,
-                                 impl.getClass().getClassLoader());
+           this.iface = Class.forName(className + "MBean", true,
+                                      impl.getClass().getClassLoader());
          }
        catch (ClassNotFoundException e)
          {
@@ -154,11 +154,12 @@ public class StandardMBean
                                              " was not found.").initCause(e));
          }
       }
-    if (!(iface.isInstance(impl)))
+    else
+      this.iface = iface;
+    if (!(this.iface.isInstance(impl)))
       throw new NotCompliantMBeanException("The instance, " + impl + 
                                           ", is not an instance of " + iface);
     this.impl = impl;
-    this.iface = iface;
   }
 
   /**
@@ -493,7 +494,7 @@ public class StandardMBean
    *
    * @return the implementation class.
    */
-  public Class getImplementationClass()
+  public Class<?> getImplementationClass()
   {
     return impl.getClass();
   }
@@ -681,7 +682,7 @@ public class StandardMBean
    *
    * @return the management interface.
    */
-  public final Class getMBeanInterface()
+  public final Class<?> getMBeanInterface()
   {
     return iface;
   }
index 119458287393905727ba200c032054d23f4b864c..68c2041fa131a636b5be6b7bdbf4c6d1f99de0a3 100644 (file)
Binary files a/libjava/classpath/lib/javax/management/MBeanServer.class and b/libjava/classpath/lib/javax/management/MBeanServer.class differ
index 2ca079e125e3fef1ddde45dfb0d3ba5195bb24b3..7f60a3e8f9bc562d836d4b807eb2584f5dd1992d 100644 (file)
Binary files a/libjava/classpath/lib/javax/management/MBeanServerConnection.class and b/libjava/classpath/lib/javax/management/MBeanServerConnection.class differ
index 720f6689d434a74188173807d7bb9dde4a622799..28a3f54fbbff38c2a4ee95d15268b13aeca1d411 100644 (file)
Binary files a/libjava/classpath/lib/javax/management/ObjectName.class and b/libjava/classpath/lib/javax/management/ObjectName.class differ
index 29ed9dbc1f39211481727639ebef749ab42ad990..be542358394f1698d0efb2787d6a5eb8c703dc9c 100644 (file)
Binary files a/libjava/classpath/lib/javax/management/StandardMBean.class and b/libjava/classpath/lib/javax/management/StandardMBean.class differ
index aaaf89b5ebf5f305ad2ac863e0b35d255bd06363..21473cace9ea38c9ba6536aba8928631842a7b12 100644 (file)
@@ -30,6 +30,9 @@ private:
   void checkComponents();
 public:
   virtual jboolean apply(::javax::management::ObjectName *);
+private:
+  static jboolean domainMatches(::java::lang::String *, jint, ::java::lang::String *, jint);
+public:
   virtual jboolean equals(::java::lang::Object *);
   virtual ::java::lang::String * getCanonicalKeyPropertyListString();
   virtual ::java::lang::String * getCanonicalName();
This page took 0.080638 seconds and 5 git commands to generate.