geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r884983 - in /geronimo/sandbox/rex: org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/ org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/ org.apache.g...
Date Fri, 27 Nov 2009 20:20:33 GMT
Author: gawor
Date: Fri Nov 27 20:20:33 2009
New Revision: 884983

URL: http://svn.apache.org/viewvc?rev=884983&view=rev
Log:
a bunch of fixes. finally getting some metadata infomration in jconsole from blueprintmetadata
mbean

Modified:
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintMetadata.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPBeanProperty.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPComponentMetadata.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPMapEntry.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPServiceMetadata.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/Util.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx/src/main/java/org/apache/geronimo/blueprint/jmx/BlueprintMetadataMBean.java

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintMetadata.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/BlueprintMetadata.java?rev=884983&r1=884982&r2=884983&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintMetadata.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/BlueprintMetadata.java
Fri Nov 27 20:20:33 2009
@@ -1,6 +1,7 @@
 package org.apache.geronimo.blueprint.jmx.impl;
 
 import java.io.IOException;
+import java.util.Collection;
 import java.util.Set;
 
 import javax.management.openmbean.CompositeData;
@@ -73,20 +74,22 @@
      */
     public String[] getComponentIdsByType(long containerServiceId, String type) {
         BlueprintContainer container = getBlueprintContainer(containerServiceId);
-        ComponentMetadata[] components;
-        if (type.equals(BlueprintMetadataMBean.SERVICE_MATADATA))
-            components = (ComponentMetadata[]) container.getMetadata(ServiceMetadata.class).toArray();
-        else if (type.equals(BlueprintMetadataMBean.BEAN_METADATA))
-            components = (ComponentMetadata[]) container.getMetadata(BeanMetadata.class).toArray();
-        else if (type.equals(BlueprintMetadataMBean.SERVICE_REFERENCE_METADATA))
-            components = (ComponentMetadata[]) container.getMetadata(ServiceReferenceMetadata.class).toArray();
-        else
-            throw new IllegalArgumentException();
-        String ids[] = new String[components.length];
-        for (int i = 0; i < components.length; i++) {
-            ids[i] = components[i].getId();
+        Collection<ComponentMetadata> components;
+        if (type.equals(BlueprintMetadataMBean.SERVICE_METADATA)) {
+            components = container.getMetadata(ServiceMetadata.class);
+        } else if (type.equals(BlueprintMetadataMBean.BEAN_METADATA)) {
+            components = container.getMetadata(BeanMetadata.class);
+        } else if (type.equals(BlueprintMetadataMBean.SERVICE_REFERENCE_METADATA)) {
+            components = container.getMetadata(ServiceReferenceMetadata.class);
+        } else {
+            throw new IllegalArgumentException("Unrecognized component type: " + type);
         }
-        return ids;// (String [])container.getMetadata(type).toArray();
+        String ids[] = new String[components.size()];
+        int i = 0;
+        for (ComponentMetadata component : components) {
+            ids[i++] = component.getId();
+        }
+        return ids;
     }
 
     public CompositeData getComponentMetadata(long containerServiceId, String componentId)
{
@@ -105,7 +108,10 @@
             throw new RuntimeException(e);
         }
 
-        return serviceReferences == null ? null : (BlueprintContainer) bundleContext.getService(serviceReferences[0]);
+        if (serviceReferences == null) {
+            throw new IllegalArgumentException("Invalid BlueprintContainer service id: "
+ containerServiceId);
+        }
+        return (BlueprintContainer) bundleContext.getService(serviceReferences[0]);
     }
 
 }

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPBeanProperty.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/codec/BPBeanProperty.java?rev=884983&r1=884982&r2=884983&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPBeanProperty.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPBeanProperty.java
Fri Nov 27 20:20:33 2009
@@ -32,7 +32,7 @@
         items.put(BlueprintMetadataMBean.VALUE, Util.bpMetadata2Binary(value));
 
         try {
-            return new CompositeDataSupport(BlueprintMetadataMBean.BEAN_ARGUMENT_TYPE, items);
+            return new CompositeDataSupport(BlueprintMetadataMBean.BEAN_PROPERTY_TYPE, items);
         } catch (OpenDataException e) {
             throw new RuntimeException(e);
         }

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPComponentMetadata.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/codec/BPComponentMetadata.java?rev=884983&r1=884982&r2=884983&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPComponentMetadata.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPComponentMetadata.java
Fri Nov 27 20:20:33 2009
@@ -24,7 +24,7 @@
 
     protected BPComponentMetadata(ComponentMetadata component) {
         activation = component.getActivation();
-        dependsOn = (String[]) component.getDependsOn().toArray();
+        dependsOn = (String[]) component.getDependsOn().toArray(new String [] {});
         id = (String) component.getId();
     }
 

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPMapEntry.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/codec/BPMapEntry.java?rev=884983&r1=884982&r2=884983&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPMapEntry.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPMapEntry.java
Fri Nov 27 20:20:33 2009
@@ -29,7 +29,7 @@
 
     public CompositeData asCompositeData() {
         HashMap<String, Object> items = new HashMap<String, Object>();
-        items.put(BlueprintMetadataMBean.KEY, key);
+        items.put(BlueprintMetadataMBean.KEY, Util.bpMetadata2Binary(key));
         items.put(BlueprintMetadataMBean.VALUE, Util.bpMetadata2Binary(value));
 
         try {

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPServiceMetadata.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/codec/BPServiceMetadata.java?rev=884983&r1=884982&r2=884983&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPServiceMetadata.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPServiceMetadata.java
Fri Nov 27 20:20:33 2009
@@ -50,7 +50,7 @@
     public BPServiceMetadata(ServiceMetadata service) {
         super(service);
         autoExport = service.getAutoExport();
-        interfaces = (String[]) service.getInterfaces().toArray();
+        interfaces = (String[]) service.getInterfaces().toArray(new String [] {});
         ranking = service.getRanking();
 
         listeners = new BPRegistrationListener[service.getRegistrationListeners().size()];
@@ -93,7 +93,7 @@
 
     public CompositeData asCompositeData() {
         try {
-            return new CompositeDataSupport(BlueprintMetadataMBean.SERVICE_MATADATA_TYPE,
getItemsMap());
+            return new CompositeDataSupport(BlueprintMetadataMBean.SERVICE_METADATA_TYPE,
getItemsMap());
         } catch (OpenDataException e) {
             throw new RuntimeException(e);
         }

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/Util.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/codec/Util.java?rev=884983&r1=884982&r2=884983&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/Util.java
(original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/Util.java
Fri Nov 27 20:20:33 2009
@@ -25,6 +25,9 @@
 public class Util {
 
     public static BPMetadata metadata2BPMetadata(Metadata metadata) {
+        if (metadata == null) {
+            return null;
+        }
         // target first
         if (metadata instanceof BeanMetadata)
             return new BPBeanMetadata((BeanMetadata) metadata);
@@ -95,7 +98,7 @@
         if (typename.equals(BlueprintMetadataMBean.COLLECTION_METADATA))
             return new BPCollectionMetadata(metadata);
 
-        if (typename.equals(BlueprintMetadataMBean.SERVICE_MATADATA))
+        if (typename.equals(BlueprintMetadataMBean.SERVICE_METADATA))
             return new BPServiceMetadata(metadata);
 
         if (typename.equals(BlueprintMetadataMBean.REFERENCE_LIST_METADATA))
@@ -121,6 +124,9 @@
     }
 
     public static byte[] bpMetadata2Binary(BPMetadata metadata) {
+        if (metadata == null) {
+            return null;
+        }
         ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
         ObjectOutputStream outObject;
         try {

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=884983&r1=884982&r2=884983&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
Fri Nov 27 20:20:33 2009
@@ -557,12 +557,12 @@
     
     /**
      * The item containing the id of the factory component on which to invoke the factory
method for the bean.
-     * The key is {@link #FACTORY_COMPONENT}, and the type is {@link SimpleType#STRING}.
+     * The key is {@link #FACTORY_COMPONENT}, and the type is {@link JmxConstants#PRIMITIVE_BYTE_ARRAY_TYPE}.
      */
     Item            FACTORY_COMPONENT_ITEM  = new Item(
                                                     FACTORY_COMPONENT, 
-                                                    "The id of the factory component on which
to invoke the factory method for the bean", 
-                                                    SimpleType.STRING);
+                                                    "The factory component on which to invoke
the factory method for the bean", 
+                                                    JmxConstants.PRIMITIVE_BYTE_ARRAY_TYPE);
     
     /**
      * The key SCOPE, used in {@link #SCOPE_ITEM}.
@@ -757,12 +757,12 @@
     
     /**
      * The item containing the id of the component to be exported as a service.
-     * The key is {@link #SERVICE_COMPONENT}, and the type is {@link SimpleType#STRING}.
+     * The key is {@link #SERVICE_COMPONENT}, and the type is {@link JmxConstants#PRIMITIVE_BYTE_ARRAY_TYPE}.
      */
     Item            SERVICE_COMPONENT_ITEM  = new Item(
                                                     SERVICE_COMPONENT, 
-                                                    "The id of the component to be exported
as a service", 
-                                                    SimpleType.STRING);
+                                                    "The component to be exported as a service",

+                                                    JmxConstants.PRIMITIVE_BYTE_ARRAY_TYPE);
     
     /**
      * The key SERVICE_PROPERTIES, used in {@link #SERVICE_PROPERTIES_ITEM}.
@@ -793,9 +793,9 @@
                                                     Item.arrayType(1, REGISTRATION_LISTENER_TYPE));
     
     /**
-     * The name of CompositeType for ServiceMetadata objects, used in {@link #SERVICE_MATADATA_TYPE}.
+     * The name of CompositeType for ServiceMetadata objects, used in {@link #SERVICE_METADATA_TYPE}.
      */
-    String          SERVICE_MATADATA               = "ServiceMetadata";    
+    String          SERVICE_METADATA               = "ServiceMetadata";    
     
     /**
      * The CompositeType for a ServiceMetadata object, it extends {@link #COMPONENT_METADATA_TYPE}
@@ -809,9 +809,9 @@
      * <li>{@link #REGISTRATION_LISTENERS}</li>
      * </ul>
      */
-    CompositeType   SERVICE_MATADATA_TYPE   = Item.extend(
+    CompositeType   SERVICE_METADATA_TYPE   = Item.extend(
                                                     COMPONENT_METADATA_TYPE, 
-                                                    SERVICE_MATADATA, 
+                                                    SERVICE_METADATA, 
                                                     "This type encapsulates ServiceMetadata
objects",
                                                     INTERFACES_ITEM,
                                                     AUTO_EXPORT_ITEM,



Mime
View raw message