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/04 06:49:22 UTC

svn commit: r887071 - in /geronimo/sandbox/rex: ./ org.apache.geronimo.blueprint.jmx.demo/ org.apache.geronimo.blueprint.jmx.demo/src/ org.apache.geronimo.blueprint.jmx.demo/src/main/ org.apache.geronimo.blueprint.jmx.demo/src/main/java/ org.apache.ger...

Author: rwonly
Date: Fri Dec  4 05:49:21 2009
New Revision: 887071

URL: http://svn.apache.org/viewvc?rev=887071&view=rev
Log:
add demo

Added:
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/pom.xml
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/jmx/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/jmx/demo/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/jmx/demo/Activator.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/jmx/demo/RemoteMonitor.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/Bar.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/BindingListener.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/CurrencyTypeConverter.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/DateTypeConverter.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/Foo.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/FooRegistrationListener.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/InterfaceA.java
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/resources/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/resources/OSGI-INF/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/resources/OSGI-INF/blueprint/
    geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/resources/OSGI-INF/blueprint/config.xml
Modified:
    geronimo/sandbox/rex/pom.xml

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/pom.xml?rev=887071&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/pom.xml (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/pom.xml Fri Dec  4 05:49:21 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.demo</artifactId>
+    <packaging>bundle</packaging>
+    <name>Apache Geronimo Blueprint Jmx Demo</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.demo</Bundle-SymbolicName>
+						<Bundle-Name>Apache Geronimo Blueprint Jmx Demo</Bundle-Name>
+						<Bundle-Description>Apache Geronimo Blueprint Jmx demo.</Bundle-Description>
+						<Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
+						<Bundle-Activator>org.apache.geronimo.blueprint.jmx.demo.Activator</Bundle-Activator>
+						<Export-Package></Export-Package>
+                     </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/jmx/demo/Activator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/jmx/demo/Activator.java?rev=887071&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/jmx/demo/Activator.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/jmx/demo/Activator.java Fri Dec  4 05:49:21 2009
@@ -0,0 +1,48 @@
+package org.apache.geronimo.blueprint.jmx.demo;
+
+import java.lang.management.ManagementFactory;
+
+import javax.management.MBeanServer;
+import javax.management.remote.JMXConnectorServer;
+import javax.management.remote.JMXConnectorServerFactory;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.util.tracker.ServiceTracker;
+// import org.slf4j.Logger;
+// import org.slf4j.LoggerFactory;
+
+public class Activator implements BundleActivator {
+    //private static final Logger logger = LoggerFactory.getLogger(Activator.class);
+
+    BundleContext context;
+    ServiceRegistration reg;
+
+    protected ServiceTracker containerServiceTracker;
+
+    //@Override
+    public void start(BundleContext context) throws Exception {
+        this.context = context;
+
+        // register a MBeanServer service
+        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+        reg = context.registerService(MBeanServer.class.getName(), mbs, null);
+        //logger.debug("A MBeanServer " + mbs + " has been registered into service registry");
+
+        // Create an RMI connector and start it
+        JMXConnectorServer cs = JMXConnectorServerFactory.newJMXConnectorServer(RemoteMonitor.url, null, mbs);
+        cs.start();
+
+        //logger.debug("A JMXConnectorServer has started.");
+        
+        RemoteMonitor test = new RemoteMonitor(context.getBundle().getBundleId());
+        new Thread(test).start();
+    }
+
+    //@Override
+    public void stop(BundleContext context) throws Exception {
+        containerServiceTracker.close();
+        reg.unregister();
+    }
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/jmx/demo/RemoteMonitor.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/jmx/demo/RemoteMonitor.java?rev=887071&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/jmx/demo/RemoteMonitor.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/jmx/demo/RemoteMonitor.java Fri Dec  4 05:49:21 2009
@@ -0,0 +1,141 @@
+package org.apache.geronimo.blueprint.jmx.demo;
+
+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.demo/src/main/java/org/apache/geronimo/blueprint/sample/Bar.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/Bar.java?rev=887071&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/Bar.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/Bar.java Fri Dec  4 05:49:21 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.demo/src/main/java/org/apache/geronimo/blueprint/sample/BindingListener.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/BindingListener.java?rev=887071&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/BindingListener.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/BindingListener.java Fri Dec  4 05:49:21 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.demo/src/main/java/org/apache/geronimo/blueprint/sample/CurrencyTypeConverter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/CurrencyTypeConverter.java?rev=887071&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/CurrencyTypeConverter.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/CurrencyTypeConverter.java Fri Dec  4 05:49:21 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.demo/src/main/java/org/apache/geronimo/blueprint/sample/DateTypeConverter.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/DateTypeConverter.java?rev=887071&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/DateTypeConverter.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/DateTypeConverter.java Fri Dec  4 05:49:21 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.demo/src/main/java/org/apache/geronimo/blueprint/sample/Foo.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/Foo.java?rev=887071&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/Foo.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/Foo.java Fri Dec  4 05:49:21 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.demo/src/main/java/org/apache/geronimo/blueprint/sample/FooRegistrationListener.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/FooRegistrationListener.java?rev=887071&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/FooRegistrationListener.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/FooRegistrationListener.java Fri Dec  4 05:49:21 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);
+    }
+
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/InterfaceA.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/InterfaceA.java?rev=887071&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/InterfaceA.java (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/java/org/apache/geronimo/blueprint/sample/InterfaceA.java Fri Dec  4 05:49:21 2009
@@ -0,0 +1,22 @@
+/**
+ *  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;
+
+public interface InterfaceA {
+
+    String hello(String msg);
+}

Added: geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/resources/OSGI-INF/blueprint/config.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/resources/OSGI-INF/blueprint/config.xml?rev=887071&view=auto
==============================================================================
--- geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/resources/OSGI-INF/blueprint/config.xml (added)
+++ geronimo/sandbox/rex/org.apache.geronimo.blueprint.jmx.demo/src/main/resources/OSGI-INF/blueprint/config.xml Fri Dec  4 05:49:21 2009
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://geronimo.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
+           xmlns:ext="http://geronimo.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
+           default-availability="optional">
+
+    <type-converters>
+        <bean id="converter1" class="org.apache.geronimo.blueprint.sample.DateTypeConverter">
+            <property name="format" value="yyyy.MM.dd"/>
+        </bean>
+        <bean id="converter2" class="org.apache.geronimo.blueprint.sample.CurrencyTypeConverter"/>
+
+    </type-converters>
+
+    <ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]" ignore-missing-locations="true" system-properties="override">
+        <ext:default-properties>
+            <ext:property name="name" value="value"/>
+        </ext:default-properties>
+        <ext:location>file://url</ext:location>
+    </ext:property-placeholder>
+
+    <cm:managed-service-factory id="managed-service-factory" factory-pid="blueprint-sample-managed-service-factory"
+            interface="org.apache.geronimo.blueprint.sample.Foo"
+            ext:system-properties="fallback">
+        <service-properties>
+            <entry key="key1" value="value1"/>
+        </service-properties>
+        <cm:managed-component class="org.apache.geronimo.blueprint.sample.Foo"/>
+    </cm:managed-service-factory>
+
+    <cm:property-placeholder id="property-placeholder" persistent-id="blueprint-sample-placeholder">
+        <cm:default-properties>
+            <cm:property name="key.b" value="-1"/>
+        </cm:default-properties>
+    </cm:property-placeholder>
+
+    <bean id="none-managed" class="org.apache.geronimo.blueprint.sample.Foo">
+        <cm:managed-properties persistent-id="blueprint-sample-managed.none" update-strategy="none"/>
+    </bean>
+
+    <bean id="component-managed" class="org.apache.geronimo.blueprint.sample.Foo">
+        <cm:managed-properties persistent-id="blueprint-sample-managed.component" update-strategy="component-managed" update-method="update"/>
+    </bean>
+
+    <bean id="container-managed" class="org.apache.geronimo.blueprint.sample.Foo">
+        <cm:managed-properties persistent-id="blueprint-sample-managed.container" update-strategy="container-managed"/>
+    </bean>
+
+    <bean id="foo" class="org.apache.geronimo.blueprint.sample.Foo" init-method="init" destroy-method="destroy">
+        <property name="a" value="5" />
+        <property name="b" value="${key.b}" />
+        <property name="bar" ref="bar" />
+        <property name="currency">
+            <value>PLN</value>
+        </property>
+        <property name="date">
+              <value>2009.04.17</value>
+        </property>
+    </bean>
+
+    <bean id="bar" class="org.apache.geronimo.blueprint.sample.Bar">
+        <property name="value"><value>Hello FooBar</value></property>
+        <property name="context" ref="blueprintBundleContext"/>
+        <property name="list">
+            <list>
+                <value>a list element</value>
+                <value type = "java.lang.Integer">5</value>
+            </list>        
+        </property>
+    </bean>
+
+    <service ref="foo" auto-export="all-classes">
+        <service-properties>
+            <entry key="key" value="value"/>
+        </service-properties>
+        <registration-listener ref="fooRegistrationListener"
+                               registration-method="serviceRegistered"
+                               unregistration-method="serviceUnregistered"/>
+    </service>
+    
+    <bean id="fooRegistrationListener" class="org.apache.geronimo.blueprint.sample.FooRegistrationListener"/>
+
+    <reference id="ref2" interface="org.apache.geronimo.blueprint.sample.InterfaceA" timeout="100">
+        <reference-listener bind-method="bind" unbind-method="unbind" ref="bindingListener" />
+    </reference>
+
+    <bean id="bindingListener" class="org.apache.geronimo.blueprint.sample.BindingListener"/>
+
+    <reference-list id="ref-list" interface="org.apache.geronimo.blueprint.sample.InterfaceA">
+        <reference-listener bind-method="bind" unbind-method="unbind" ref="listBindingListener" />
+    </reference-list>
+
+    <bean id="listBindingListener" class="org.apache.geronimo.blueprint.sample.BindingListener"/>
+
+    <bean id="circularReference" class="org.apache.geronimo.blueprint.sample.BindingListener" init-method="init">
+        <property name="list">
+            <reference-list interface="org.apache.geronimo.blueprint.sample.InterfaceA" availability="optional">
+                <reference-listener bind-method="bind" unbind-method="unbind" ref="circularReference"/>
+            </reference-list>
+        </property>
+    </bean>
+
+</blueprint>
+

Modified: geronimo/sandbox/rex/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/rex/pom.xml?rev=887071&r1=887070&r2=887071&view=diff
==============================================================================
--- geronimo/sandbox/rex/pom.xml (original)
+++ geronimo/sandbox/rex/pom.xml Fri Dec  4 05:49:21 2009
@@ -40,6 +40,7 @@
         <module>org.apache.geronimo.blueprint.jmx.impl</module>
 		<module>org.apache.geronimo.blueprint.jmx.test</module>
 		<module>org.apache.geronimo.blueprint.jmx.agent</module>
+		<module>org.apache.geronimo.blueprint.jmx.demo</module>
     </modules>
 
 </project>