geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwo...@apache.org
Subject svn commit: r884006 - in /geronimo/sandbox/rex: org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/ org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/
Date Wed, 25 Nov 2009 08:48:29 GMT
Author: rwonly
Date: Wed Nov 25 08:47:58 2009
New Revision: 884006

URL: http://svn.apache.org/viewvc?rev=884006&view=rev
Log:
more codes updates

Modified:
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/Activator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintState.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintMetadataMBean.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintStateMBean.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/Item.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/JmxConstants.java

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/Activator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/Activator.java?rev=884006&r1=884005&r2=884006&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/Activator.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/Activator.java
Wed Nov 25 08:47:58 2009
@@ -12,6 +12,7 @@
 import javax.management.ObjectName;
 import javax.management.StandardMBean;
 
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
 import org.apache.geronimo.blueprint.jmx.BlueprintStateMBean;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
@@ -20,24 +21,29 @@
 import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
 public class Activator implements BundleActivator {
-    
+
     protected BundleContext bundleContext;
-    
+
     protected StandardMBean blueprintState;
     protected ObjectName blueprintStateName;
-    
+
+    protected StandardMBean blueprintMetadata;
+    protected ObjectName blueprintMetadataName;
+
     protected List<MBeanServer> mbeanServers = new CopyOnWriteArrayList<MBeanServer>();
     protected ServiceTracker mbeanServiceTracker;
-    
+
     protected AtomicBoolean servicesRegistered = new AtomicBoolean(false);
-    
+
     public void start(BundleContext context) throws Exception {
         this.bundleContext = context;
         this.blueprintStateName = new ObjectName(BlueprintStateMBean.OBJECTNAME);
-        
-        //get mbeanServiceTracker
-        mbeanServiceTracker = new ServiceTracker(bundleContext, MBeanServer.class.getCanonicalName(),
new MBeanServiceTracker());
-        //log.fine("Awaiting MBeanServer service registration");
+        this.blueprintMetadataName = new ObjectName(BlueprintMetadataMBean.OBJECTNAME);
+
+        // get mbeanServiceTracker
+        mbeanServiceTracker = new ServiceTracker(bundleContext, MBeanServer.class.getCanonicalName(),
+                new MBeanServiceTracker());
+        System.out.println("Awaiting MBeanServer service registration"); // Fine
         mbeanServiceTracker.open();
     }
 
@@ -46,14 +52,14 @@
         for (MBeanServer mbeanServer : mbeanServers) {
             deregisterServices(mbeanServer);
         }
-        mbeanServers.clear();        
+        mbeanServers.clear();
     }
 
     class MBeanServiceTracker implements ServiceTrackerCustomizer {
 
         public Object addingService(ServiceReference servicereference) {
             try {
-                //log.fine("Adding MBeanServer: " + servicereference);
+                System.out.println("Adding MBeanServer: " + servicereference); // Fine
                 final MBeanServer mbeanServer = (MBeanServer) bundleContext.getService(servicereference);
                 mbeanServers.add(mbeanServer);
                 Runnable registration = new Runnable() {
@@ -61,27 +67,25 @@
                         Activator.this.registerServices(mbeanServer);
                     }
                 };
-                Thread registrationThread = new Thread(registration, "JMX Core MBean Registration");
+                Thread registrationThread = new Thread(registration, "Blueprint MBean Registration");
                 registrationThread.setDaemon(true);
                 registrationThread.start();
 
                 return mbeanServer;
             } catch (RuntimeException e) {
-                //log.log(Level.SEVERE, "uncaught exception in addingService", e);
+                System.out.println("uncaught exception in addingService"); // Severe
                 throw e;
             }
         }
 
-        public void modifiedService(ServiceReference servicereference,
-                Object obj) {
+        public void modifiedService(ServiceReference servicereference, Object obj) {
             // no op
         }
 
         public void removedService(ServiceReference servicereference, Object obj) {
             try {
-                //log.fine("Removing MBeanServer: " + servicereference);
-                final MBeanServer mbeanServer = (MBeanServer) bundleContext
-                        .getService(servicereference);
+                System.out.println("Removing MBeanServer: " + servicereference); // Fine
+                final MBeanServer mbeanServer = (MBeanServer) bundleContext.getService(servicereference);
                 mbeanServers.remove(mbeanServer);
                 Runnable deregister = new Runnable() {
                     public void run() {
@@ -89,56 +93,85 @@
                     }
                 };
 
-                Thread deregisterThread = new Thread(deregister,
-                        "JMX Core MBean Deregistration");
+                Thread deregisterThread = new Thread(deregister, "Blueprint MBean Deregistration");
                 deregisterThread.setDaemon(true);
                 deregisterThread.start();
 
             } catch (Throwable e) {
-                //log.log(Level.FINE, "uncaught exception in removedService", e);
+                System.out.println("uncaught exception in removedService"); // Fine
             }
         }
     }
-    
+
     protected synchronized void registerServices(MBeanServer mbeanServer) {
-        // create MBean
+        // create BlueprintMetadataMBean
         try {
             blueprintState = new StandardMBean(new BlueprintState(bundleContext), BlueprintStateMBean.class);
         } catch (NotCompliantMBeanException e) {
-            //log.log(Level.SEVERE, "Unable to create StandardMBean for BundleState", e);
+            System.out.println("Unable to create StandardMBean for BlueprintState"); // Severe
             return;
         }
-        // register MBean to MBean server
-        //log.fine("Registering bundle state monitor with MBeanServer: " + mbeanServer +
" with name: " + bundlesStateName);
+        // register BlueprintStateMBean to MBean server
+        System.out.println("Registering bundle state monitor with MBeanServer: " + mbeanServer
+ " with name: "
+                + blueprintStateName); // Fine
         try {
             mbeanServer.registerMBean(blueprintState, blueprintStateName);
         } catch (InstanceAlreadyExistsException e) {
-            //log.log(Level.FINE, "Cannot register OSGi BundleStateMBean", e);
+            System.out.println("Cannot register BlueprintStateMBean"); // Fine
+        } catch (MBeanRegistrationException e) {
+            System.out.println("Cannot register BlueprintStateMBean"); // Severe
+        } catch (NotCompliantMBeanException e) {
+            System.out.println("Cannot register BlueprintStateMBean"); // Severe
+        }
+
+        // create BlueprintMetadataMBean
+        try {
+            blueprintMetadata = new StandardMBean(new BlueprintMetadata(bundleContext), BlueprintMetadataMBean.class);
+        } catch (NotCompliantMBeanException e) {
+            System.out.println("Unable to create StandardMBean for BlueprintMetadata"); //
Severe
+            return;
+        }
+        // register BlueprintMetadataMBean to MBean server
+        System.out.println("Registering bundle state monitor with MBeanServer: " + mbeanServer
+ " with name: "
+                + blueprintMetadataName); // Fine
+        try {
+            mbeanServer.registerMBean(blueprintMetadata, blueprintMetadataName);
+        } catch (InstanceAlreadyExistsException e) {
+            System.out.println("Cannot register BlueprintMetadataMBean"); // Fine
         } catch (MBeanRegistrationException e) {
-            //log.log(Level.SEVERE, "Cannot register OSGi BundleStateMBean", e);
+            System.out.println("Cannot register BlueprintMetadataMBean"); // Severe
         } catch (NotCompliantMBeanException e) {
-            //log.log(Level.SEVERE, "Cannot register OSGi BundleStateMBean", e);
+            System.out.println("Cannot register BlueprintMetadataMBean"); // Severe
         }
-        
+
         servicesRegistered.set(true);
     }
-    
+
     protected synchronized void deregisterServices(MBeanServer mbeanServer) {
         if (!servicesRegistered.get()) {
             return;
         }
-        // unregister MBean to MBean server
+        // unregister BlueprintStateMBean from MBean server
         try {
             mbeanServer.unregisterMBean(blueprintStateName);
         } catch (InstanceNotFoundException e) {
-            //log.log(Level.FINEST, "OSGi BundleStateMBean not found on deregistration",
e);
+            System.out.println("BlueprintStateMBean not found on deregistration"); // Finest
         } catch (MBeanRegistrationException e) {
-            //log.log(Level.FINE, "OSGi BundleStateMBean deregistration problem", e);
+            System.out.println("BlueprintStateMBean deregistration problem"); // Fine
         }
-        // 
         blueprintState = null;
-       
+
+        // unregister BlueprintMetadataMBean from MBean server
+        try {
+            mbeanServer.unregisterMBean(blueprintMetadataName);
+        } catch (InstanceNotFoundException e) {
+            System.out.println("BlueprintMetadataMBean not found on deregistration"); //
Finest
+        } catch (MBeanRegistrationException e) {
+            System.out.println("BlueprintMetadataMBean deregistration problem"); // Fine
+        }
+        blueprintMetadata = null;
+
         servicesRegistered.set(false);
     }
-    
+
 }

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintState.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintState.java?rev=884006&r1=884005&r2=884006&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintState.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintState.java
Wed Nov 25 08:47:58 2009
@@ -21,26 +21,26 @@
 public class BlueprintState implements BlueprintStateMBean, MBeanRegistration {
 
     private BundleContext context;
-    
+
     private ServiceRegistration listenerReg;
-        
-    private Map<String, CompositeData> dataMap = new HashMap<String, CompositeData>();
-    
-    public BlueprintState(BundleContext context){
+
+    private Map<Long, CompositeData> dataMap = new HashMap<Long, CompositeData>();
+
+    public BlueprintState(BundleContext context) {
         this.context = context;
     }
-    
+
     public synchronized long[] getBlueprintBundleIds() throws IOException {
-        String[] bundleIdKeys= dataMap.keySet().toArray(new String[0]);
+        Long[] bundleIdKeys = (Long[]) dataMap.keySet().toArray();
         long[] bundleIds = new long[bundleIdKeys.length];
-        for (int i=0;i<bundleIdKeys.length;i++){
-            bundleIds[i] = Long.parseLong(bundleIdKeys[i]);
+        for (int i = 0; i < bundleIdKeys.length; i++) {
+            bundleIds[i] = bundleIdKeys[i].longValue();
         }
         return bundleIds;
     }
-    
+
     public synchronized CompositeData getLastEvent(long bundleId) throws IOException {
-        return dataMap.get(String.valueOf(bundleId));
+        return dataMap.get(Long.valueOf(bundleId));
     }
 
     public synchronized TabularData getLastEvents() throws IOException {
@@ -48,14 +48,14 @@
         table.putAll(dataMap);
         return table;
     }
-    
+
     public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
         // no op
         return name;
     }
-    
+
     public void postRegister(Boolean registrationDone) {
-        BlueprintListener listener =  new BlueprintStateListener();
+        BlueprintListener listener = new BlueprintStateListener();
         // reg listener
         listenerReg = context.registerService(BlueprintListener.class.getName(), listener,
null);
     }
@@ -68,13 +68,13 @@
     public void postDeregister() {
         // no op
     }
-    
-    private class BlueprintStateListener implements BlueprintListener{
+
+    private class BlueprintStateListener implements BlueprintListener {
         public synchronized void blueprintEvent(BlueprintEvent event) {
-            CompositeData data = new OSGiBlueprintEvent(event).asCompositeData();    
-            dataMap.put(String.valueOf(event.getBundle().getBundleId()), data);
+            CompositeData data = new OSGiBlueprintEvent(event).asCompositeData();
+            dataMap.put(Long.valueOf(event.getBundle().getBundleId()), data);
         }
-        
+
     }
 
 }

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintMetadataMBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintMetadataMBean.java?rev=884006&r1=884005&r2=884006&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintMetadataMBean.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintMetadataMBean.java
Wed Nov 25 08:47:58 2009
@@ -12,7 +12,7 @@
     /**
      * The object name for this MBean.
      */
-    String OBJECTNAME = JmxConstants.OSGI_COMPENDIUM+":service=blueprintMetadata,version=1.0";
+    String OBJECTNAME = JmxConstants.GERONIMO_BLUEPRINT+":service=blueprintMetadata,version=1.0";
     
     
     ///////////////////////////////////////////////////////////////
@@ -167,7 +167,7 @@
     Item            KEY_ITEM                = new Item(
                                                     KEY,
                                                     "The key of an entry",
-                                                    JmxConstants.P_BYTE_ARRAY_TYPE);
+                                                    JmxConstants.PRIMITIVE_BYTE_ARRAY_TYPE);
     
     /**
     * The key VALUE, used in {@link #VALUE_ITEM}.
@@ -177,12 +177,12 @@
     /**
     * The item containing a value and this will be used by 
     * BeanArgument, BeanProperty, MapEntry and CollectionMetadata.
-    * The key is {@link #VALUE}, and the type is {@link JmxConstants#P_BYTE_ARRAY_TYPE}.
+    * The key is {@link #VALUE}, and the type is {@link JmxConstants#PRIMITIVE_BYTE_ARRAY_TYPE}.
     */
     Item            VALUE_ITEM              = new Item(
                                                    VALUE, 
                                                    "A value", 
-                                                   JmxConstants.P_BYTE_ARRAY_TYPE);  
+                                                   JmxConstants.PRIMITIVE_BYTE_ARRAY_TYPE);
 
 
     /**
      * The name of CompositeType for MapEntry objects, used in {@link #MAP_ENTRY_TYPE}.
@@ -320,7 +320,7 @@
     Item            VALUES_ITEM             = new Item(
                                                     VALUES,
                                                     "All the values",
-                                                    Item.arrayType(1, JmxConstants.P_BYTE_ARRAY_TYPE));
+                                                    Item.arrayType(1, JmxConstants.PRIMITIVE_BYTE_ARRAY_TYPE));
     
 
     /**
@@ -648,12 +648,12 @@
     
     /**
      * The item containing the listener component.
-     * The key is {@link #LISTENER_COMPONENT}, and the type is {@link JmxConstants#P_BYTE_ARRAY_TYPE}.
+     * The key is {@link #LISTENER_COMPONENT}, and the type is {@link JmxConstants#PRIMITIVE_BYTE_ARRAY_TYPE}.
      */
     Item            LISTENER_COMPONENT_ITEM = new Item(
                                                     LISTENER_COMPONENT, 
                                                     "The listener component", 
-                                                    JmxConstants.P_BYTE_ARRAY_TYPE);
+                                                    JmxConstants.PRIMITIVE_BYTE_ARRAY_TYPE);
     
     /**
      * The key REGISTRATION_METHOD, used in {@link #REGISTRATION_METHOD_ITEM}.
@@ -1066,11 +1066,11 @@
     /**
      * Returns the ComponentMetadata according to the its component id.
      * The returned Composite Data is serialized and stored in a byte array, 
-     * typed by {@link JmxConstants#P_BYTE_ARRAY_TYPE}.
+     * typed by {@link JmxConstants#PRIMITIVE_BYTE_ARRAY_TYPE}.
      * 
      * @param containerServiceId The blueprint container service id
      * @param componentId The component id
-     * @return the serialized ComponentMetadata, see {@link JmxConstants#P_BYTE_ARRAY_TYPE}
+     * @return the serialized ComponentMetadata, see {@link JmxConstants#PRIMITIVE_BYTE_ARRAY_TYPE}
      */
     public byte [] getComponentMetadata(long containerServiceId, String componentId);
     

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintStateMBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintStateMBean.java?rev=884006&r1=884005&r2=884006&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintStateMBean.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintStateMBean.java
Wed Nov 25 08:47:58 2009
@@ -17,7 +17,7 @@
     /**
      * The object name for this MBean.
      */
-    String OBJECTNAME = JmxConstants.OSGI_COMPENDIUM+":service=blueprintState,version=1.0";
+    String OBJECTNAME = JmxConstants.GERONIMO_BLUEPRINT+":service=blueprintState,version=1.0";
     
     ///////////////////////////////////////////////////////////////
     // Define Event's CompositeType

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/Item.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/Item.java?rev=884006&r1=884005&r2=884006&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/Item.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/Item.java
Wed Nov 25 08:47:58 2009
@@ -12,21 +12,16 @@
 import javax.management.openmbean.TabularType;
 
 /**
- * The item class enables the definition of open types in the appropriate
- * interfaces.
+ * The item class enables the definition of open types in the appropriate interfaces.
  * 
- * This class contains a number of methods that make it possible to create open
- * types for {@link CompositeType}, {@link TabularType}, and {@link ArrayType}.
- * The normal creation throws a checked exception, making it impossible to use
- * them in a static initializer. They constructors are also not very suitable
- * for static construction.
+ * This class contains a number of methods that make it possible to create open types for
{@link CompositeType},
+ * {@link TabularType}, and {@link ArrayType}. The normal creation throws a checked exception,
making it impossible to
+ * use them in a static initializer. They constructors are also not very suitable for static
construction.
  * 
  * 
- * An Item instance describes an item in a Composite Type. It groups the triplet
- * of name, description, and Open Type. These Item instances allows the
- * definitions of an item to stay together.
+ * An Item instance describes an item in a Composite Type. It groups the triplet of name,
description, and Open Type.
+ * These Item instances allows the definitions of an item to stay together.
  * 
- * @version $Revision: 8214 $
  * @Immutable
  */
 public class Item {
@@ -34,55 +29,55 @@
     /**
      * The name of this item.
      */
-    private final String    name;
+    private final String name;
 
     /**
      * The description of this item.
      */
-    private final String    description;
+    private final String description;
 
     /**
      * The type of this item.
      */
-    private final OpenType  type;
+    private final OpenType<?> type;
 
     /**
-     * Create a triple of name, description, and type. This triplet is used in
-     * the creation of a Composite Type.
+     * Create a triple of name, description, and type. This triplet is used in the creation
of a Composite Type.
      * 
-     * @param name The name of the item.
-     * @param description The description of the item.
-     * @param type The Open Type of this item.
-     * @param restrictions Ignored, contains list of restrictions
+     * @param name
+     *            The name of the item.
+     * @param description
+     *            The description of the item.
+     * @param type
+     *            The Open Type of this item.
+     * @param restrictions
+     *            Ignored, contains list of restrictions
      */
-    public Item(String name, String description, OpenType type,
-            String... restrictions) {
+    public Item(String name, String description, OpenType<?> type, String... restrictions)
{
         this.name = name;
         this.description = description;
         this.type = type;
     }
 
     /**
-     * 
-     */
-
-    /**
      * Create a Tabular Type.
      * 
-     * @param name The name of the Tabular Type.
-     * @param description The description of the Tabular Type.
-     * @param rowType The Open Type for a row
-     * @param index The names of the items that form the index .
+     * @param name
+     *            The name of the Tabular Type.
+     * @param description
+     *            The description of the Tabular Type.
+     * @param rowType
+     *            The Open Type for a row
+     * @param index
+     *            The names of the items that form the index .
      * @return A new Tabular Type composed from the parameters.
-     * @throws RuntimeException when the Tabular Type throws an
-     *         OpenDataException
+     * @throws RuntimeException
+     *             when the Tabular Type throws an OpenDataException
      */
-    static public TabularType tabularType(String name, String description,
-            CompositeType rowType, String... index) {
+    static public TabularType tabularType(String name, String description, CompositeType
rowType, String... index) {
         try {
             return new TabularType(name, description, rowType, index);
-        }
-        catch (OpenDataException e) {
+        } catch (OpenDataException e) {
             throw new RuntimeException(e);
         }
     }
@@ -90,54 +85,42 @@
     /**
      * Create a Composite Type
      * 
-     * @param name The name of the Tabular Type.
-     * @param description The description of the Tabular Type.
-     * @param items The items that describe the composite type.
+     * @param name
+     *            The name of the Tabular Type.
+     * @param description
+     *            The description of the Tabular Type.
+     * @param items
+     *            The items that describe the composite type.
      * @return a new Composite Type
-     * @throws RuntimeException when the Tabular Type throws an
-     *         OpenDataException
+     * @throws RuntimeException
+     *             when the Tabular Type throws an OpenDataException
      */
-    static public CompositeType compositeType(String name, String description,
-            Item... items) {
+    static public CompositeType compositeType(String name, String description, Item... items)
{
         return extend(null, name, description, items);
     }
 
     /**
-     * Return a new Array Type.
-     * 
-     * @param dim The dimension
-     * @param elementType The element type
-     * @return A new Array Type
-     */
-    public static ArrayType arrayType(int dim, OpenType elementType) {
-        try {
-            return new ArrayType(dim, elementType);
-        }
-        catch (OpenDataException e) {
-            throw new RuntimeException(e);
-        }
-    }
-
-    /**
-     * Extend a Composite Type by adding new items. Items can override items in
-     * the parent type.
+     * Extend a Composite Type by adding new items. Items can override items in the parent
type.
      * 
-     * @param parent The parent type, can be <code>null</code>
-     * @param name The name of the type
-     * @param description The description of the type
-     * @param items The items that should be added/override to the parent type
+     * @param parent
+     *            The parent type, can be <code>null</code>
+     * @param name
+     *            The name of the type
+     * @param description
+     *            The description of the type
+     * @param items
+     *            The items that should be added/override to the parent type
      * @return A new Composite Type that extends the parent type
-     * @throws RuntimeException when an OpenDataException is thrown
+     * @throws RuntimeException
+     *             when an OpenDataException is thrown
      */
-    public static CompositeType extend(CompositeType parent, String name,
-            String description, Item... items) {
+    public static CompositeType extend(CompositeType parent, String name, String description,
Item... items) {
         Set<Item> all = new LinkedHashSet<Item>();
 
         if (parent != null) {
             for (Object nm : parent.keySet()) {
                 String key = (String) nm;
-                all.add(new Item((String) nm, parent.getDescription(key),
-                        parent.getType(key)));
+                all.add(new Item((String) nm, parent.getDescription(key), parent.getType(key)));
             }
         }
 
@@ -145,7 +128,7 @@
 
         String names[] = new String[all.size()];
         String descriptions[] = new String[all.size()];
-        OpenType types[] = new OpenType[all.size()];
+        OpenType<?> types[] = new OpenType<?>[all.size()];
 
         for (int n = 0; n < types.length; n++) {
             names[n] = items[n].name;
@@ -154,24 +137,40 @@
         }
 
         try {
-            return new CompositeType(name, description, names, descriptions,
-                    types);
+            return new CompositeType(name, description, names, descriptions, types);
+        } catch (OpenDataException e) {
+            throw new RuntimeException(e);
         }
-        catch (OpenDataException e) {
+    }
+
+    /**
+     * Return a new Array Type.
+     * 
+     * @param dim
+     *            The dimension
+     * @param elementType
+     *            The element type
+     * @return A new Array Type
+     */
+    public static ArrayType<?> arrayType(int dim, OpenType<?> elementType) {
+        try {
+            return new ArrayType(dim, elementType);
+        } catch (OpenDataException e) {
             throw new RuntimeException(e);
         }
     }
+    
     /**
      * Return a new primaArray Type.
      * 
-     * @param elementType The element type
+     * @param elementType
+     *            The element type
      * @return A new Array Type
      */
-    public static ArrayType primitiveArrayType(SimpleType elementType) {
+    public static ArrayType<?> primitiveArrayType(SimpleType<?> elementType)
{
         try {
             return new ArrayType(elementType, true);
-        }
-        catch (OpenDataException e) {
+        } catch (OpenDataException e) {
             throw new RuntimeException(e);
         }
     }

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/JmxConstants.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/JmxConstants.java?rev=884006&r1=884005&r2=884006&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/JmxConstants.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/JmxConstants.java
Wed Nov 25 08:47:58 2009
@@ -16,23 +16,16 @@
 
 package org.apache.geronimo.blueprint.jmx;
 
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
 import javax.management.openmbean.ArrayType;
-import javax.management.openmbean.CompositeType;
 import javax.management.openmbean.SimpleType;
-import javax.management.openmbean.TabularType;
 
 /**
- * Constants for OSGi JMX Specification.
+ * Constants.
  * 
  * Additionally, this class contains a number of utility types that are used in
  * different places in the specification. These are {@link #LONG_ARRAY_TYPE},
- * {@link #STRING_ARRAY_TYPE}, and {@link #PROPERTIES_TYPE}.
+ * {@link #STRING_ARRAY_TYPE}, and {@link #PRIMITIVE_BYTE_ARRAY_TYPE}.
  * 
- * @version $Revision: 8214 $
  * @Immutable
  */
 public class JmxConstants {
@@ -47,278 +40,27 @@
     /**
      * The MBean Open type for an array of longs
      */
-    public static final ArrayType       P_BYTE_ARRAY_TYPE   = Item
+    public static final ArrayType<?>    PRIMITIVE_BYTE_ARRAY_TYPE   = Item
                                                                     .primitiveArrayType(
                                                                             SimpleType.BYTE);
     
     /**
      * The MBean Open type for an array of strings
      */
-    public static final ArrayType       STRING_ARRAY_TYPE   = Item
+    public static final ArrayType<?>    STRING_ARRAY_TYPE   = Item
                                                                     .arrayType(
                                                                             1,
                                                                             SimpleType.STRING);
     /**
      * The MBean Open type for an array of longs
      */
-    public static final ArrayType       LONG_ARRAY_TYPE     = Item
+    public static final ArrayType<?>    LONG_ARRAY_TYPE     = Item
                                                                     .arrayType(
                                                                             1,
                                                                             SimpleType.LONG);
 
     /**
-     * For an encoded array we need to start with ARRAY_OF. This must be
-     * followed by one of the names in {@link #SCALAR}.
-     * 
-     */
-    public final static String          ARRAY_OF            = "Array of ";
-
-    /**
-     * For an encoded vector we need to start with ARRAY_OF. This must be
-     * followed by one of the names in {@link #SCALAR}.
-     */
-    public final static String          VECTOR_OF           = "Vector of ";
-
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * {@link java.lang.String}
-     */
-    public static final String          STRING              = "String";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * {@link java.lang.Integer}
-     */
-    public static final String          INTEGER             = "Integer";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * {@link java.lang.Long}
-     */
-    public static final String          LONG                = "Long";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * {@link java.lang.Float}
-     */
-    public static final String          FLOAT               = "Float";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * {@link java.lang.Double}
-     */
-    public static final String          DOUBLE              = "Double";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * {@link java.lang.Byte}
-     */
-    public static final String          BYTE                = "Byte";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * {@link java.lang.Short}
-     */
-    public static final String          SHORT               = "Short";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * {@link java.lang.Character}
-     */
-    public static final String          CHARACTER           = "Character";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * {@link java.lang.Boolean}
-     */
-    public static final String          BOOLEAN             = "Boolean";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * {@link java.math.BigDecimal}
-     */
-    public static final String          BIGDECIMAL          = "BigDecimal";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * {@link java.math.BigInteger}
-     */
-    public static final String          BIGINTEGER          = "BigInteger";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * the <code>double</code> primitive type.
-     */
-    public static final String          P_DOUBLE            = "double";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * the <code>float</code> primitive type.
-     */
-    public static final String          P_FLOAT             = "float";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * the <code>long</code> primitive type.
-     */
-    public static final String          P_LONG              = "long";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * the <code>int</code> primitive type.
-     */
-    public static final String          P_INT               = "int";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * the <code>short</code> primitive type.
-     */
-    public static final String          P_SHORT             = "short";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * the <code>byte</code> primitive type.
-     */
-    public static final String          P_BYTE              = "byte";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * the <code>char</code> primitive type.
-     */
-    public static final String          P_CHAR              = "char";
-    /**
-     * Value for {@link #PROPERTY_TYPE} <code>Type</code> value in the case of
-     * the <code>boolean</code> primitive type.
-     */
-    public static final String          P_BOOLEAN           = "boolean";
-
-    /**
-     * A set of all scalars that can be used in the {@link #TYPE} property of a
-     * {@link #PROPERTIES_TYPE}. This contains the following names:
-     * <ul>
-     * <li>{@link #BIGDECIMAL}</li>
-     * <li>{@link #BIGINTEGER}</li>
-     * <li>{@link #BOOLEAN}</li>
-     * <li>{@link #BYTE}</li>
-     * <li>{@link #CHARACTER}</li>
-     * <li>{@link #DOUBLE}</li>
-     * <li>{@link #FLOAT}</li>
-     * <li>{@link #INTEGER}</li>
-     * <li>{@link #LONG}</li>
-     * <li>{@link #SHORT}</li>
-     * <li>{@link #STRING}</li>
-     * <li>{@link #P_BYTE}</li>
-     * <li>{@link #P_CHAR}</li>
-     * <li>{@link #P_DOUBLE}</li>
-     * <li>{@link #P_FLOAT}</li>
-     * <li>{@link #P_INT}</li>
-     * <li>{@link #P_LONG}</li>
-     * <li>{@link #P_SHORT}</li>
-     */
-    public final static Set<String>     SCALAR              = new HashSet<String>(
-                                                                    Arrays
-                                                                            .asList(
-                                                                                    STRING,
-                                                                                    INTEGER,
-                                                                                    LONG,
-                                                                                    FLOAT,
-                                                                                    DOUBLE,
-                                                                                    BYTE,
-                                                                                    SHORT,
-                                                                                    CHARACTER,
-                                                                                    BOOLEAN,
-                                                                                    BIGDECIMAL,
-                                                                                    BIGINTEGER,
-                                                                                    P_BYTE,
-                                                                                    P_CHAR,
-                                                                                    P_SHORT,
-                                                                                    P_INT,
-                                                                                    P_LONG,
-                                                                                    P_DOUBLE,
-                                                                                    P_FLOAT));
-    /**
-     * The key KEY.
-     */
-    public static final String          KEY                 = "Key";
-    /**
-     * The key of a property. The key is {@link #KEY} and the type is
-     * {@link SimpleType#STRING}.
-     */
-    public static final Item            KEY_ITEM            = new Item(
-                                                                    KEY,
-                                                                    "The key of the property",
-                                                                    SimpleType.STRING);
-
-    /**
-     * The key VALUE.
-     */
-    public static final String          VALUE               = "Value";
-
-    /**
-     * The value of a property. The key is {@link #VALUE} and the type is
-     * {@link SimpleType#STRING}. A value will be encoded by the string given in
-     * {@link #TYPE}. The syntax for this type is given in {@link #TYPE_ITEM}.
-     */
-    public static final Item            VALUE_ITEM          = new Item(
-                                                                    VALUE,
-                                                                    "The value of the property",
-                                                                    SimpleType.STRING);
-
-    /**
-     * The key PROPERTY_TYPE.
-     * 
-     * ### can we call this value PropertyType and service type ServiceType?
-     */
-    public static final String          TYPE                = "Type";
-
-    /**
-     * The type of the property. The key is {@link #TYPE} and the type is
-     * {@link SimpleType#STRING}. This string must follow the following syntax:
-     * 
-     * TYPE ::= ( 'Array of ' | 'Vector of ' )? {@link #SCALAR}
-     * 
-     * ### why can't we just use the class name?
-     * 
-     * ### why do we have to distinguish between primitives and wrappers?
-     */
-    public static final Item            TYPE_ITEM           = new Item(
-                                                                    TYPE,
-                                                                    "The type of the property",
-                                                                    SimpleType.STRING, //
-                                                                    STRING,
-                                                                    INTEGER,
-                                                                    LONG,
-                                                                    FLOAT,
-                                                                    DOUBLE,
-                                                                    BYTE,
-                                                                    SHORT,
-                                                                    CHARACTER,
-                                                                    BOOLEAN,
-                                                                    BIGDECIMAL,
-                                                                    BIGINTEGER,
-                                                                    P_DOUBLE,
-                                                                    P_FLOAT,
-                                                                    P_LONG,
-                                                                    P_INT,
-                                                                    P_SHORT,
-                                                                    P_CHAR,
-                                                                    P_BYTE,
-                                                                    P_BOOLEAN);
-
-    /**
-     * A Composite Type describing a a single property. A property consists of
-     * the following items {@link #KEY_ITEM}, {@link #VALUE_ITEM}, and
-     * {@link #TYPE_ITEM}.
-     */
-    public static final CompositeType   PROPERTY_TYPE       = Item
-                                                                    .compositeType(
-                                                                            "PROPERTY",
-                                                                            "This type encapsulates
a key/value pair",
-                                                                            KEY_ITEM,
-                                                                            VALUE_ITEM,
-                                                                            TYPE_ITEM);
-
-    /**
-     * Describes a map with properties. The row type is {@link #PROPERTY_TYPE}.
-     * The index is defined to the {@link #KEY} of the property.
-     */
-    public static final TabularType     PROPERTIES_TYPE     = Item
-                                                                    .tabularType(
-                                                                            "PROPERTIES",
-                                                                            "A table of PROPERTY",
-                                                                            PROPERTY_TYPE,
-                                                                            KEY);
-
-    /**
-     * The domain name of the core OSGi MBeans
-     */
-    public static final String          OSGI_CORE           = "osgi.core";
-
-    /**
-     * The domain name of the selected OSGi compendium MBeans
+     * The domain name of the Blueprint MBeans
      */
-    public static final String          OSGI_COMPENDIUM     = "osgi.compendium";
+    public static final String          GERONIMO_BLUEPRINT  = "org.apache.geronimo.blueprint";
 }



Mime
View raw message