You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by rw...@apache.org on 2009/12/03 08:33:28 UTC

svn commit: r886689 - in /geronimo/sandbox/rex: ./ org.apache.geronimo.blueprint.jmx.agent/ org.apache.geronimo.blueprint.jmx.agent/src/ org.apache.geronimo.blueprint.jmx.agent/src/main/ org.apache.geronimo.blueprint.jmx.agent/src/main/java/ org.apache...

Author: rwonly
Date: Thu Dec  3 07:33:09 2009
New Revision: 886689

URL: http://svn.apache.org/viewvc?rev=886689&view=rev
Log:
make the jmx agent in a separate bundle, and add a sample. Thanks Siqi for the help!

Added:
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/pom.xml
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/agent/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/agent/Activator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/pom.xml
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/test/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/test/RemoteMonitor.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/Bar.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/BindingListener.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/CurrencyTypeConverter.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/DateTypeConverter.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/Foo.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/FooRegistrationListener.java
Modified:
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/pom.xml
    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/codec/BPBeanArgument.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPBeanMetadata.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/BPCollectionMetadata.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/BPReferenceListener.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPRegistrationListener.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/pom.xml

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/pom.xml?rev=886689&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/pom.xml (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/pom.xml Thu Dec  3 07:33:09 2009
@@ -0,0 +1,46 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.geronimo.blueprint</groupId>
+        <artifactId>jmx-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>org.apache.geronimo.blueprint.jmx.agent</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Geronimo Blueprint Jmx Agent</name>
+  
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+					    <Bundle-SymbolicName>org.apache.geronimo.blueprint.jmx.agent</Bundle-SymbolicName>
+						<Bundle-Name>Apache Geronimo Blueprint Jmx Agent.</Bundle-Name>
+						<Bundle-Description>Apache Geronimo Blueprint Jmx Agent..</Bundle-Description>
+						<Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+						<Bundle-Activator>org.apache.geronimo.blueprint.jmx.agent.Activator</Bundle-Activator>
+                     </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/agent/Activator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/agent/Activator.java?rev=886689&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/agent/Activator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.agent/src/main/java/org/apache/geronimo/blueprint/jmx/agent/Activator.java Thu Dec  3 07:33:09 2009
@@ -0,0 +1,35 @@
+package org.apache.geronimo.blueprint.jmx.agent;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.remote.JMXConnectorServer;
+import javax.management.remote.JMXConnectorServerFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+public class Activator implements BundleActivator {
+    
+    protected ServiceRegistration mbsReg;
+    
+    public void start(BundleContext context) throws Exception {
+        
+        MBeanServer mbs = MBeanServerFactory.createMBeanServer();
+        
+        // Create an RMI connector and start it, need "rmiregistry 9999" in cmd of Windows
+        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/server");
+        JMXConnectorServer connServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, mbs);
+        connServer.start();
+        System.out.println("rmi..start.....");
+        
+        // Register as a service
+        mbsReg = context.registerService(MBeanServer.class.getCanonicalName(), mbs, null);
+    }
+
+    public void stop(BundleContext context) throws Exception {
+        if (mbsReg != null) mbsReg.unregister();
+    }
+
+}

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/pom.xml?rev=886689&r1=886688&r2=886689&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/pom.xml (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/pom.xml Thu Dec  3 07:33:09 2009
@@ -28,6 +28,12 @@
             <version>1.0-SNAPSHOT</version>
         </dependency>
         <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.7</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.easymock</groupId>
             <artifactId>easymock</artifactId>
             <version>2.5.2</version>

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=886689&r1=886688&r2=886689&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 Thu Dec  3 07:33:09 2009
@@ -29,8 +29,8 @@
 
     protected BundleContext bundleContext;
 
-    protected ServiceRegistration mbsReg;
-    
+
+
     protected StandardMBean blueprintState;
     protected ObjectName blueprintStateName;
 
@@ -52,11 +52,6 @@
                 new MBeanServiceTracker());
         System.out.println("Awaiting MBeanServer service registration"); // Fine
         mbeanServiceTracker.open();
-        
-        // create JMX agent. This could be in a separate bundle.
-        MBeanServer mbs = createJMXAgent();
-        // reg mbeanServer
-        mbsReg = context.registerService(MBeanServer.class.getCanonicalName(), mbs, null);
     }
 
     public void stop(BundleContext context) throws Exception {
@@ -65,9 +60,6 @@
             deregisterServices(mbeanServer);
         }
         mbeanServers.clear();
-        
-        // move mbs
-        mbsReg.unregister();
     }
 
     class MBeanServiceTracker implements ServiceTrackerCustomizer {
@@ -120,15 +112,15 @@
 
     protected synchronized void registerServices(MBeanServer mbeanServer) {
         // create BlueprintStateMBean
-        
-        /* the StardardMBean does not implement the MBeanRegistration in jdk1.5*/        
+
+        /* the StardardMBean does not implement the MBeanRegistration in jdk1.5 */
         try {
             blueprintState = new RegistrationStandardMBean(new BlueprintState(bundleContext), BlueprintStateMBean.class);
         } catch (NotCompliantMBeanException e) {
             System.out.println("Unable to create StandardMBean for BlueprintState" + e); // Severe
             return;
         }
-        
+
         // register BlueprintStateMBean to MBean server
         System.out.println("Registering bundle state monitor with MBeanServer: " + mbeanServer + " with name: "
                 + blueprintStateName); // Fine
@@ -191,24 +183,6 @@
 
         servicesRegistered.set(false);
     }
-    
-    
-    private MBeanServer createJMXAgent() throws Exception {    
-        MBeanServer server = MBeanServerFactory.createMBeanServer();    
-        // Create an RMI connector and start it    
-        try{
-        JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/server");   
-        JMXConnectorServer connServer = JMXConnectorServerFactory.newJMXConnectorServer(url, null, server);    
-        connServer.start();    
-        System.out.println("rmi..start....."); 
-        }
-        catch(Exception e){
-            e.printStackTrace();
-        }
-        
-        
-        
-        return server;
-    }    
+
 
 }

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPBeanArgument.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/BPBeanArgument.java?rev=886689&r1=886688&r2=886689&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPBeanArgument.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPBeanArgument.java Thu Dec  3 07:33:09 2009
@@ -18,8 +18,8 @@
 
     public BPBeanArgument(CompositeData argument) {
         index = (Integer) argument.get(BlueprintMetadataMBean.INDEX);
-        byte[] buf = (byte[]) argument.get(BlueprintMetadataMBean.VALUE);
-        value = Util.binary2BPMetadata(buf);
+        Byte[] buf = (Byte[]) argument.get(BlueprintMetadataMBean.VALUE);
+        value = Util.boxedBinary2BPMetadata(buf);
         valueType = (String) argument.get(BlueprintMetadataMBean.VALUE_TYPE);
     }
 
@@ -34,7 +34,7 @@
     public CompositeData asCompositeData() {
         HashMap<String, Object> items = new HashMap<String, Object>();
         items.put(BlueprintMetadataMBean.INDEX, index);
-        items.put(BlueprintMetadataMBean.VALUE, Util.bpMetadata2Binary(value));
+        items.put(BlueprintMetadataMBean.VALUE, Util.bpMetadata2BoxedBinary(value));
         items.put(BlueprintMetadataMBean.VALUE_TYPE, valueType);
 
         try {

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPBeanMetadata.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/BPBeanMetadata.java?rev=886689&r1=886688&r2=886689&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPBeanMetadata.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPBeanMetadata.java Thu Dec  3 07:33:09 2009
@@ -37,8 +37,8 @@
         initMethod = (String) bean.get(BlueprintMetadataMBean.INIT_METHOD);
         scope = (String) bean.get(BlueprintMetadataMBean.SCOPE);
 
-        byte[] buf = (byte[]) bean.get(BlueprintMetadataMBean.FACTORY_COMPONENT);
-        factoryComponent = (BPTarget) Util.binary2BPMetadata(buf);
+        Byte[] buf = (Byte[]) bean.get(BlueprintMetadataMBean.FACTORY_COMPONENT);
+        factoryComponent = (BPTarget) Util.boxedBinary2BPMetadata(buf);
 
         CompositeData[] cd_args = (CompositeData[]) bean.get(BlueprintMetadataMBean.ARGUMENTS);
         arguments = new BPBeanArgument[cd_args.length];
@@ -87,7 +87,7 @@
         items.put(BlueprintMetadataMBean.INIT_METHOD, initMethod);
         items.put(BlueprintMetadataMBean.SCOPE, scope);
 
-        items.put(BlueprintMetadataMBean.FACTORY_COMPONENT, Util.bpMetadata2Binary(factoryComponent));
+        items.put(BlueprintMetadataMBean.FACTORY_COMPONENT, Util.bpMetadata2BoxedBinary(factoryComponent));
 
         CompositeData[] cd_args = new CompositeData[arguments.length];
         for (int i = 0; i < arguments.length; i++) {

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=886689&r1=886688&r2=886689&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 Thu Dec  3 07:33:09 2009
@@ -16,8 +16,8 @@
     public BPBeanProperty(CompositeData property) {
         name = (String) property.get(BlueprintMetadataMBean.NAME);
 
-        byte[] buf = (byte[]) property.get(BlueprintMetadataMBean.VALUE);
-        value = Util.binary2BPMetadata(buf);
+        Byte[] buf = (Byte[]) property.get(BlueprintMetadataMBean.VALUE);
+        value = Util.boxedBinary2BPMetadata(buf);
     }
 
     public BPBeanProperty(BeanProperty property) {
@@ -29,7 +29,7 @@
     public CompositeData asCompositeData() {
         HashMap<String, Object> items = new HashMap<String, Object>();
         items.put(BlueprintMetadataMBean.NAME, name);
-        items.put(BlueprintMetadataMBean.VALUE, Util.bpMetadata2Binary(value));
+        items.put(BlueprintMetadataMBean.VALUE, Util.bpMetadata2BoxedBinary(value));
 
         try {
             return new CompositeDataSupport(BlueprintMetadataMBean.BEAN_PROPERTY_TYPE, items);

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPCollectionMetadata.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/BPCollectionMetadata.java?rev=886689&r1=886688&r2=886689&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPCollectionMetadata.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPCollectionMetadata.java Thu Dec  3 07:33:09 2009
@@ -21,10 +21,10 @@
         collectionClass = (String) collection.get(BlueprintMetadataMBean.COLLECTION_CLASS);
         valueType = (String) collection.get(BlueprintMetadataMBean.VALUE_TYPE);
 
-        byte[][] arrays = (byte[][]) collection.get(BlueprintMetadataMBean.VALUES);
+        Byte[][] arrays = (Byte[][]) collection.get(BlueprintMetadataMBean.VALUES);
         values = new BPMetadata[arrays.length];
         for (int i = 0; i < values.length; i++) {
-            values[i] = Util.binary2BPMetadata((byte[]) arrays[i]);
+            values[i] = Util.boxedBinary2BPMetadata((Byte[]) arrays[i]);
         }
     }
 
@@ -44,9 +44,9 @@
         items.put(BlueprintMetadataMBean.COLLECTION_CLASS, collectionClass);
         items.put(BlueprintMetadataMBean.VALUE_TYPE, valueType);
 
-        byte[][] arrays = new byte[values.length][];
+        Byte[][] arrays = new Byte[values.length][];
         for (int i = 0; i < arrays.length; i++) {
-            arrays[i] = Util.bpMetadata2Binary(values[i]);
+            arrays[i] = Util.bpMetadata2BoxedBinary(values[i]);
         }
         items.put(BlueprintMetadataMBean.VALUES, arrays);
 

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=886689&r1=886688&r2=886689&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 Thu Dec  3 07:33:09 2009
@@ -15,11 +15,11 @@
     private BPMetadata value;
 
     public BPMapEntry(CompositeData entry) {
-        byte[] buf = (byte[]) entry.get(BlueprintMetadataMBean.KEY);
-        key = (BPNonNullMetadata) Util.binary2BPMetadata(buf);
+        Byte[] buf = (Byte[]) entry.get(BlueprintMetadataMBean.KEY);
+        key = (BPNonNullMetadata) Util.boxedBinary2BPMetadata(buf);
 
-        buf = (byte[]) entry.get(BlueprintMetadataMBean.VALUE);
-        value = Util.binary2BPMetadata(buf);
+        buf = (Byte[]) entry.get(BlueprintMetadataMBean.VALUE);
+        value = Util.boxedBinary2BPMetadata(buf);
     }
 
     public BPMapEntry(MapEntry entry) {
@@ -29,8 +29,8 @@
 
     public CompositeData asCompositeData() {
         HashMap<String, Object> items = new HashMap<String, Object>();
-        items.put(BlueprintMetadataMBean.KEY, Util.bpMetadata2Binary(key));
-        items.put(BlueprintMetadataMBean.VALUE, Util.bpMetadata2Binary(value));
+        items.put(BlueprintMetadataMBean.KEY, Util.bpMetadata2BoxedBinary(key));
+        items.put(BlueprintMetadataMBean.VALUE, Util.bpMetadata2BoxedBinary(value));
 
         try {
             return new CompositeDataSupport(BlueprintMetadataMBean.MAP_ENTRY_TYPE, items);

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPReferenceListener.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/BPReferenceListener.java?rev=886689&r1=886688&r2=886689&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPReferenceListener.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPReferenceListener.java Thu Dec  3 07:33:09 2009
@@ -20,8 +20,8 @@
         bindMethod = (String) listener.get(BlueprintMetadataMBean.BIND_METHOD);
         unbindMethod = (String) listener.get(BlueprintMetadataMBean.UNBIND_METHOD);
 
-        byte[] buf = (byte[]) listener.get(BlueprintMetadataMBean.LISTENER_COMPONENT);
-        listenerComponent = (BPTarget) Util.binary2BPMetadata(buf);
+        Byte[] buf = (Byte[]) listener.get(BlueprintMetadataMBean.LISTENER_COMPONENT);
+        listenerComponent = (BPTarget) Util.boxedBinary2BPMetadata(buf);
     }
 
     public BPReferenceListener(ReferenceListener listener) {
@@ -36,7 +36,7 @@
         items.put(BlueprintMetadataMBean.BIND_METHOD, bindMethod);
         items.put(BlueprintMetadataMBean.UNBIND_METHOD, unbindMethod);
 
-        items.put(BlueprintMetadataMBean.LISTENER_COMPONENT, Util.bpMetadata2Binary(listenerComponent));
+        items.put(BlueprintMetadataMBean.LISTENER_COMPONENT, Util.bpMetadata2BoxedBinary(listenerComponent));
 
         try {
             return new CompositeDataSupport(BlueprintMetadataMBean.REFERENCE_LISTENER_TYPE, items);

Modified: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPRegistrationListener.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/BPRegistrationListener.java?rev=886689&r1=886688&r2=886689&view=diff
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPRegistrationListener.java (original)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.impl/src/main/java/org/apache/geronimo/blueprint/jmx/impl/codec/BPRegistrationListener.java Thu Dec  3 07:33:09 2009
@@ -20,8 +20,8 @@
         registrationMethod = (String) listener.get(BlueprintMetadataMBean.REGISTRATION_METHOD);
         unregistrationMethod = (String) listener.get(BlueprintMetadataMBean.UNREGISTRATION_METHOD);
 
-        byte[] buf = (byte[]) listener.get(BlueprintMetadataMBean.LISTENER_COMPONENT);
-        listenerComponent = (BPTarget) Util.binary2BPMetadata(buf);
+        Byte[] buf = (Byte[]) listener.get(BlueprintMetadataMBean.LISTENER_COMPONENT);
+        listenerComponent = (BPTarget) Util.boxedBinary2BPMetadata(buf);
     }
 
     public BPRegistrationListener(RegistrationListener listener) {
@@ -36,7 +36,7 @@
         items.put(BlueprintMetadataMBean.REGISTRATION_METHOD, registrationMethod);
         items.put(BlueprintMetadataMBean.UNREGISTRATION_METHOD, unregistrationMethod);
 
-        items.put(BlueprintMetadataMBean.LISTENER_COMPONENT, Util.bpMetadata2Binary(listenerComponent));
+        items.put(BlueprintMetadataMBean.LISTENER_COMPONENT, Util.bpMetadata2BoxedBinary(listenerComponent));
 
         try {
             return new CompositeDataSupport(BlueprintMetadataMBean.REGISTRATION_LISTENER_TYPE, items);

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=886689&r1=886688&r2=886689&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 Thu Dec  3 07:33:09 2009
@@ -43,8 +43,8 @@
             properties[i] = new BPMapEntry(cd_props[i]);
         }
 
-        byte[] buf = (byte[]) service.get(BlueprintMetadataMBean.SERVICE_COMPONENT);
-        serviceComponent = (BPTarget) Util.binary2BPMetadata(buf);
+        Byte[] buf = (Byte[]) service.get(BlueprintMetadataMBean.SERVICE_COMPONENT);
+        serviceComponent = (BPTarget) Util.boxedBinary2BPMetadata(buf);
     }
 
     public BPServiceMetadata(ServiceMetadata service) {
@@ -86,7 +86,7 @@
         }
         items.put(BlueprintMetadataMBean.SERVICE_PROPERTIES, cd_props);
 
-        items.put(BlueprintMetadataMBean.SERVICE_COMPONENT, Util.bpMetadata2Binary(serviceComponent));
+        items.put(BlueprintMetadataMBean.SERVICE_COMPONENT, Util.bpMetadata2BoxedBinary(serviceComponent));
 
         return items;
     }

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=886689&r1=886688&r2=886689&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 Thu Dec  3 07:33:09 2009
@@ -141,4 +141,28 @@
 
         return outBytes.toByteArray();
     }
+    public static Byte[] bpMetadata2BoxedBinary(BPMetadata metadata)
+    {
+        if(null == metadata)
+            return null;
+        
+        byte [] src = bpMetadata2Binary(metadata);
+        Byte [] res = new Byte[src.length];
+        for(int i=0;i<src.length;i++)
+        {
+            res[i] = src[i];
+        }
+        return res;
+    }
+    public static BPMetadata boxedBinary2BPMetadata(Byte[] buf) {
+        if(null == buf)
+            return null;
+        
+        byte [] unbox = new byte[buf.length];
+        for(int i=0;i<buf.length;i++)
+        {
+            unbox[i] = buf[i];
+        }
+        return binary2BPMetadata(unbox);
+    }
 }

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/pom.xml?rev=886689&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/pom.xml (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/pom.xml Thu Dec  3 07:33:09 2009
@@ -0,0 +1,64 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.geronimo.blueprint</groupId>
+        <artifactId>jmx-parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>org.apache.geronimo.blueprint.jmx.test</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Geronimo Blueprint Jmx Test</name>
+
+	<dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <version>4.2.0</version>
+        </dependency>
+		<dependency>
+            <groupId>org.apache.geronimo.blueprint</groupId>
+            <artifactId>org.apache.geronimo.blueprint.jmx</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+		<dependency>
+            <groupId>org.apache.geronimo.blueprint</groupId>
+            <artifactId>org.apache.geronimo.blueprint.jmx.impl</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+	</dependencies>
+	
+	<build>
+        <plugins>
+			<plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+						<Bundle-SymbolicName>org.apache.geronimo.blueprint.jmx.test</Bundle-SymbolicName>
+						<Bundle-Name>Apache Geronimo Blueprint Jmx Test</Bundle-Name>
+						<Bundle-Description>Apache Geronimo Blueprint Jmx test.</Bundle-Description>
+						<Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+						<Bundle-Activator>org.apache.geronimo.blueprint.jmx.test.Activator</Bundle-Activator>
+						<Export-Package></Export-Package>
+                     </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/test/RemoteMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/test/RemoteMonitor.java?rev=886689&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/test/RemoteMonitor.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/jmx/test/RemoteMonitor.java Thu Dec  3 07:33:09 2009
@@ -0,0 +1,141 @@
+package org.apache.geronimo.blueprint.jmx.test;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import javax.management.JMX;
+import javax.management.MBeanServerConnection;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.management.openmbean.CompositeData;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.geronimo.blueprint.jmx.BlueprintMetadataMBean;
+import org.apache.geronimo.blueprint.jmx.impl.codec.BPMapEntry;
+import org.apache.geronimo.blueprint.jmx.impl.codec.BPServiceMetadata;
+import org.apache.geronimo.blueprint.jmx.impl.codec.BPValueMetadata;
+
+public class RemoteMonitor implements Runnable {
+    public static final ObjectName objectName = initObjectName();
+    public static final JMXServiceURL url = initJMXServiceURL();
+
+    private static ObjectName initObjectName() {
+        ObjectName tmp = null;
+        try {
+            tmp = new ObjectName(BlueprintMetadataMBean.OBJECTNAME);
+        } catch (MalformedObjectNameException e) {
+            e.printStackTrace();
+        }
+        return tmp;
+    }
+
+    private static JMXServiceURL initJMXServiceURL() {
+        JMXServiceURL tmp = null;
+        try {
+            tmp = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/server");
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        }
+        return tmp;
+    }
+
+    // private BlueprintContainer container;
+
+    private BlueprintMetadataMBean mbean;
+
+    private long bundleId;
+
+    public RemoteMonitor(long bundleId) {
+        this.bundleId = bundleId;
+    }
+
+    public void run() {
+        // get mbean reference
+        JMXConnector jmxc;
+        try {
+            jmxc = JMXConnectorFactory.connect(url);
+            MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
+            while (!mbsc.isRegistered(objectName))
+                Thread.sleep(1000);
+            mbean = JMX.newMBeanProxy(mbsc, objectName, BlueprintMetadataMBean.class);
+
+            checkMetadata();
+            checkState();
+            jmxc.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void checkMetadata() {
+        long serviceId = -1;
+        try {
+            while (serviceId < 0) {
+                serviceId = mbean.getBlueprintContainerServiceId(bundleId);
+
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+            }
+            printLong("getBlueprintContainerServiceId", serviceId);
+
+            long[] ids = mbean.getBlueprintContainerServiceIds();
+            printLong("getBlueprintContainerServiceIds", ids);
+
+            String[] cids = mbean.getComponentIds(serviceId);
+            printString("getComponentIds", cids);
+
+            String[] bids = mbean.getComponentIdsByType(serviceId, BlueprintMetadataMBean.BEAN_METADATA);
+            printString("getComponentIdsByType - " + BlueprintMetadataMBean.BEAN_METADATA, bids);
+
+            String[] sids = mbean.getComponentIdsByType(serviceId, BlueprintMetadataMBean.SERVICE_METADATA);
+            printString("getComponentIdsByType - " + BlueprintMetadataMBean.SERVICE_METADATA, sids);
+
+            String[] rids = mbean.getComponentIdsByType(serviceId, BlueprintMetadataMBean.SERVICE_REFERENCE_METADATA);
+            printString("getComponentIdsByType - " + BlueprintMetadataMBean.SERVICE_REFERENCE_METADATA, rids);
+
+            for (String id : sids) {
+                CompositeData cd = mbean.getComponentMetadata(serviceId, id);
+                BPServiceMetadata smd = new BPServiceMetadata(cd);
+                
+                System.out.println(tag+ "ServiceMetadata - " + id);
+                System.out.println(smd.getId());
+                System.out.println(smd.getRanking());
+                for (String $interface : smd.getInterfaces()) {
+                    System.out.println($interface);
+                }
+                for (BPMapEntry entry : smd.getServiceProperties()) {
+                    BPValueMetadata key = (BPValueMetadata) entry.getKey();
+                    BPValueMetadata value = (BPValueMetadata) entry.getValue();
+                    System.out.println(key.getStringValue());
+                    System.out.println(value.getStringValue());
+                }
+            }
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void checkState() {
+
+    }
+
+    public static final String tag = "********************************************";
+    private static void printString(String info, String... array) {
+        System.out.println(tag + info);
+        for (String obj : array)
+            System.out.println(obj);
+    }
+
+    private static void printLong(String info, long... array) {
+        System.out.println(tag + info);
+        for (long obj : array)
+            System.out.println(obj);
+    }
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/Bar.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/Bar.java?rev=886689&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/Bar.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/Bar.java Thu Dec  3 07:33:09 2009
@@ -0,0 +1,57 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.blueprint.sample;
+
+import java.util.List;
+
+import org.osgi.framework.BundleContext;
+
+public class Bar {
+    
+    private BundleContext context;
+    private String value;
+    private List list;
+
+    public BundleContext getContext() {
+        return context;
+    }
+
+    public void setContext(BundleContext ctx) {
+        context = ctx;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String s) {
+        value = s;
+    }
+
+    public List getList() {
+        return list;
+    }
+
+    public void setList(List l) {
+        list = l;
+    }
+
+    public String toString() {
+        return hashCode() + ": " + value + " " + context + " " + list;
+    }
+
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/BindingListener.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/BindingListener.java?rev=886689&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/BindingListener.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/BindingListener.java Thu Dec  3 07:33:09 2009
@@ -0,0 +1,72 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.blueprint.sample;
+
+import java.util.Map;
+import java.util.List;
+import java.io.Serializable;
+
+import org.osgi.framework.ServiceReference;
+
+public class BindingListener {
+
+    private InterfaceA a;
+    private Map props;
+    private ServiceReference reference;
+    private List list;
+
+    public InterfaceA getA() {
+        return a;
+    }
+
+    public Map getProps() {
+        return props;
+    }
+
+    public ServiceReference getReference() {
+        return reference;
+    }
+
+    public List getList() {
+        return list;
+    }
+
+    public void setList(List list) {
+        this.list = list;
+    }
+
+    public void init() {
+    }
+
+    public void bind(InterfaceA a, Map props) {
+        this.a = a;
+        this.props = props;
+    }
+
+    public void bind(ServiceReference ref) {
+        this.reference = ref;
+    }
+
+    public void unbind(InterfaceA a, Map props) {
+        this.a = null;
+        this.props = null;
+    }
+
+    public void unbind(ServiceReference ref) {
+        this.reference = null;
+    }
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/CurrencyTypeConverter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/CurrencyTypeConverter.java?rev=886689&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/CurrencyTypeConverter.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/CurrencyTypeConverter.java Thu Dec  3 07:33:09 2009
@@ -0,0 +1,34 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.blueprint.sample;
+
+import java.util.Currency;
+
+import org.osgi.service.blueprint.container.Converter;
+import org.osgi.service.blueprint.container.ReifiedType;
+
+public class CurrencyTypeConverter implements Converter {
+
+    public boolean canConvert(Object fromValue, ReifiedType toType) {
+        return Currency.class.isAssignableFrom(toType.getRawClass());
+    }
+
+    public Object convert(Object source, ReifiedType toType) throws Exception {
+        return Currency.getInstance(source.toString());
+    }
+
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/DateTypeConverter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/DateTypeConverter.java?rev=886689&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/DateTypeConverter.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/DateTypeConverter.java Thu Dec  3 07:33:09 2009
@@ -0,0 +1,42 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.blueprint.sample;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.osgi.service.blueprint.container.Converter;
+import org.osgi.service.blueprint.container.ReifiedType;
+
+public class DateTypeConverter implements Converter {
+
+    DateFormat dateFormat;
+    
+    public void setFormat(String format) {
+        dateFormat = new SimpleDateFormat(format);
+    }
+    
+    public Object convert(Object source, ReifiedType toType) throws Exception {
+        return dateFormat.parse(source.toString());
+    }
+
+    public boolean canConvert(Object fromValue, ReifiedType toType) {
+        return Date.class.isAssignableFrom(toType.getRawClass());
+    }
+
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/Foo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/Foo.java?rev=886689&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/Foo.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/Foo.java Thu Dec  3 07:33:09 2009
@@ -0,0 +1,106 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.blueprint.sample;
+
+import java.io.Serializable;
+import java.util.Currency;
+import java.util.Date;
+import java.util.Map;
+
+public class Foo implements Serializable {
+    
+    private int a;
+    private int b;
+    private Bar bar;
+    private Currency currency;
+    private Date date;
+
+    public boolean initialized;
+    public boolean destroyed;
+    private Map<String, Object> props;
+
+    public int getA() {
+        return a;
+    }
+
+    public void setA(int i) {
+        a = i;
+    }
+
+    public int getB() {
+        return b;
+    }
+
+    public void setB(int i) {
+        b = i;
+    }
+
+    public Bar getBar() {
+        return bar;
+    }
+
+    public void setBar(Bar b) {
+        bar = b;
+    }
+
+    public Currency getCurrency() {
+        return currency;
+    }
+
+    public void setCurrency(Currency c) {
+        currency = c;
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date d) {
+        date = d;
+    }
+
+    public String toString() {
+        return a + " " + b + " " + bar + " " + currency + " " + date;
+    }
+
+    public void init() {
+        System.out.println("======== Initializing Foo =========");
+        initialized = true;
+    }
+
+    public void destroy() {
+        System.out.println("======== Destroying Foo =========");
+        destroyed = true;
+    }
+
+    public boolean isInitialized() {
+        return initialized;
+    }
+
+    public boolean isDestroyed() {
+        return destroyed;
+    }
+
+    public void update(Map<String,Object> props) {
+        this.props = props;
+    }
+
+    public Map<String, Object> getProps() {
+        return props;
+    }
+}
+

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/FooRegistrationListener.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/FooRegistrationListener.java?rev=886689&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/FooRegistrationListener.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.test/src/main/java/org/apache/geronimo/blueprint/sample/FooRegistrationListener.java Thu Dec  3 07:33:09 2009
@@ -0,0 +1,32 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.blueprint.sample;
+
+import java.io.Serializable;
+import java.util.Map;
+
+public class FooRegistrationListener {
+        
+    public void serviceRegistered(Serializable foo, Map props) {
+        System.out.println("Service registration notification: " + foo + " " + props);
+    }
+    
+    public void serviceUnregistered(Foo foo, Map props) {
+        System.out.println("Service unregistration notification: " + foo + " " + props);
+    }
+
+}

Modified: geronimo/sandbox/rex/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/pom.xml?rev=886689&r1=886688&r2=886689&view=diff
==============================================================================
--- geronimo/sandbox/rex/pom.xml (original)
+++ geronimo/sandbox/rex/pom.xml Thu Dec  3 07:33:09 2009
@@ -26,12 +26,20 @@
             </plugin>
         </plugins>
     </pluginManagement>
-    <plugins></plugins>
+    <plugins>
+		<plugin>
+			<groupId>org.ops4j</groupId>
+			<artifactId>maven-pax-plugin</artifactId>
+			<version>1.4</version>
+		  </plugin>
+	</plugins>
     </build>
 
     <modules>
         <module>org.apache.geronimo.blueprint.jmx</module>
         <module>org.apache.geronimo.blueprint.jmx.impl</module>
+		<module>org.apache.geronimo.blueprint.jmx.test</module>
+		<module>org.apache.geronimo.blueprint.jmx.agent</module>
     </modules>
 
 </project>