[jboss-osgi-commits] JBoss-OSGI SVN: r87832 - in projects/jboss-osgi/trunk: bundle/blueprint and 13 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Fri Apr 24 18:18:20 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-04-24 18:18:20 -0400 (Fri, 24 Apr 2009)
New Revision: 87832

Added:
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/BlueprintTest.java
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/Foo.java
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/FooMBean.java
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/JMXTestService.java
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/ServiceActivator.java
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jmx/
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jmx/jmx-test.bnd
   projects/jboss-osgi/trunk/bundle/jmx/
   projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/
   projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-examples-zip.xml
Removed:
   projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/SystemBundleTestCase.java
   projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/blueprint/
   projects/jboss-osgi/trunk/bundle/jmx/src/test/
   projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-examples.xml
Modified:
   projects/jboss-osgi/trunk/bundle/blueprint/pom.xml
   projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/PropertiesBootstrapProvider.java
   projects/jboss-osgi/trunk/bundle/jmx/.classpath
   projects/jboss-osgi/trunk/bundle/jmx/pom.xml
   projects/jboss-osgi/trunk/bundle/pom.xml
   projects/jboss-osgi/trunk/testsuite/example/pom.xml
Log:
Add bundle jboss-osgi-jmx.jar

Modified: projects/jboss-osgi/trunk/bundle/blueprint/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/pom.xml	2009-04-24 21:37:33 UTC (rev 87831)
+++ projects/jboss-osgi/trunk/bundle/blueprint/pom.xml	2009-04-24 22:18:20 UTC (rev 87832)
@@ -23,6 +23,35 @@
       <version>${version}</version>
     </dependency>
     <dependency>
+      <groupId>biz.aQute</groupId>
+      <artifactId>bnd</artifactId>
+    </dependency>
+
+    <!-- Provided Dependencies -->
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.log</artifactId>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.osgi</groupId>
+      <artifactId>jboss-osgi-common</artifactId>
+      <version>${version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.osgi</groupId>
+      <artifactId>jboss-osgi-logging</artifactId>
+      <version>${version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.osgi</groupId>
+      <artifactId>jboss-osgi-jmx</artifactId>
+      <version>${version}</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
       <groupId>org.osgi</groupId>
       <artifactId>org.osgi.core</artifactId>
       <scope>provided</scope>
@@ -44,6 +73,45 @@
 
   <build>
     <plugins>
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>bundles</id>
+            <phase>test-compile</phase>
+            <goals>
+              <goal>directory-single</goal>
+            </goals>
+            <configuration>
+              <finalName>test-libs</finalName>
+              <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+              <appendAssemblyId>false</appendAssemblyId>
+              <descriptors>
+                <descriptor>scripts/assembly-bundles.xml</descriptor>
+              </descriptors>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>build-test-jars</id>
+            <phase>test-compile</phase>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <configuration>
+              <tasks>
+                <property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
+                <property name="tests.output.dir" value="${project.build.directory}" />
+                <ant antfile="scripts/antrun-test-jars.xml" />
+              </tasks>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
   

Modified: projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/PropertiesBootstrapProvider.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/PropertiesBootstrapProvider.java	2009-04-24 21:37:33 UTC (rev 87831)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/main/java/org/jboss/osgi/blueprint/PropertiesBootstrapProvider.java	2009-04-24 22:18:20 UTC (rev 87832)
@@ -26,6 +26,9 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
 
 import org.jboss.osgi.spi.NotImplementedException;
@@ -91,6 +94,22 @@
          throw new IllegalStateException("Cannot load framework: " + frameworkImpl, ex);
       }
       
+      // Process Framework props
+      String prefix = "framework.prop.";
+      Map<String,Object> frameworkProps = new HashMap<String,Object>();
+      Enumeration<?> keys = props.propertyNames();
+      while(keys.hasMoreElements())
+      {
+         String key = (String)keys.nextElement();
+         if (key.startsWith(prefix))
+         {
+            String value = props.getProperty(key);
+            key = key.substring(prefix.length());
+            frameworkProps.put(key, value);
+         }
+      }
+      framework.setProperties(frameworkProps);
+
       // Start the Framework
       framework.start();
    }

Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/BlueprintTest.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/BlueprintTest.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/BlueprintTest.java	2009-04-24 22:18:20 UTC (rev 87832)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.blueprint;
+
+//$Id$
+
+import java.util.ArrayList;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
+import org.jboss.osgi.spi.junit.OSGiTest;
+
+/**
+ * The base class for Blueprint Service tests
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public abstract class BlueprintTest extends OSGiTest
+{
+   @SuppressWarnings("unchecked")
+   protected MBeanServer getMBeanServer()
+   {
+      ArrayList<MBeanServer> serverArr = MBeanServerFactory.findMBeanServer(null);
+      if (serverArr.size() > 1)
+         throw new IllegalStateException("Multiple MBeanServer instances not supported");
+
+      MBeanServer server = null;
+      if (serverArr.size() == 1)
+         server = serverArr.get(0);
+
+      if (server == null)
+         server = MBeanServerFactory.createMBeanServer();
+
+      return server;
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/BlueprintTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Deleted: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/SystemBundleTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/SystemBundleTestCase.java	2009-04-24 21:37:33 UTC (rev 87831)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/SystemBundleTestCase.java	2009-04-24 22:18:20 UTC (rev 87832)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-
-//$Id$
-package org.jboss.test.osgi.blueprint;
-
-import org.jboss.osgi.spi.framework.OSGiBootstrap;
-import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
-import org.jboss.osgi.spi.framework.OSGiFramework;
-import org.jboss.osgi.spi.junit.OSGiTest;
-import org.osgi.framework.Bundle;
-
-/**
- * Test OSGi System bundle access
- * 
- * @author thomas.diesler at jboss.com
- * @since 23-Jan-2009
- */
-public class SystemBundleTestCase extends OSGiTest
-{
-   public void testSystemBundle()
-   {
-      OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
-      OSGiFramework framework = configProvider.getFramework();
-      Bundle bundle = framework.getSystemBundle();
-
-      assertEquals("BundleId == 0", 0, bundle.getBundleId());
-      assertEquals("SymbolicName", "org.apache.felix.framework", bundle.getSymbolicName());
-   }
-}
\ No newline at end of file

Copied: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java (from rev 87823, projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/SystemBundleTestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/bootstrap/SystemBundleTestCase.java	2009-04-24 22:18:20 UTC (rev 87832)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+
+//$Id$
+package org.jboss.test.osgi.blueprint.bootstrap;
+
+import org.jboss.osgi.spi.framework.OSGiBootstrap;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.framework.OSGiFramework;
+import org.jboss.osgi.spi.junit.OSGiTest;
+import org.osgi.framework.Bundle;
+
+/**
+ * Test OSGi System bundle access
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 23-Jan-2009
+ */
+public class SystemBundleTestCase extends OSGiTest
+{
+   public void testSystemBundle()
+   {
+      OSGiBootstrapProvider configProvider = OSGiBootstrap.getBootstrapProvider();
+      OSGiFramework framework = configProvider.getFramework();
+      Bundle bundle = framework.getSystemBundle();
+
+      assertEquals("BundleId == 0", 0, bundle.getBundleId());
+      assertEquals("SymbolicName", "org.apache.felix.framework", bundle.getSymbolicName());
+   }
+}
\ No newline at end of file

Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java	2009-04-24 22:18:20 UTC (rev 87832)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.blueprint.jmx;
+
+//$Id$
+
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.framework.OSGiFramework;
+import org.jboss.osgi.spi.management.MBeanProxy;
+import org.jboss.test.osgi.blueprint.BlueprintTest;
+import org.jboss.test.osgi.blueprint.jmx.bundle.FooMBean;
+import org.jboss.test.osgi.blueprint.jmx.bundle.JMXTestService;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A test that deployes a bundle that registeres an MBean
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 12-Feb-2009
+ */
+public class JMXTestCase extends BlueprintTest
+{
+   public void testMBeanAccess() throws Exception
+   {
+      OSGiFramework framework = getBootstrapProvider().getFramework();
+      try
+      {
+         BundleContext sysContext = framework.getSystemBundleContext();
+         
+         installBundle(sysContext, "bundles/jboss-osgi-jmx.jar", true);
+         installBundle(sysContext, "jmx-test.jar", true);
+         
+         ObjectName oname = new ObjectName("jboss.osgi:service=mbean-test-service");
+         FooMBean foo = (FooMBean)MBeanProxy.get(FooMBean.class, oname, getMBeanServer());
+         assertEquals("hello", foo.echo("hello"));
+      }
+      finally
+      {
+         framework.stop();
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/JMXTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/Foo.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/Foo.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/Foo.java	2009-04-24 22:18:20 UTC (rev 87832)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.blueprint.jmx.bundle;
+
+
+
+
+//$Id$
+
+public class Foo implements FooMBean
+{
+	public String echo(String msg)
+	{
+		return msg;
+	}
+}


Property changes on: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/Foo.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/FooMBean.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/FooMBean.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/FooMBean.java	2009-04-24 22:18:20 UTC (rev 87832)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.blueprint.jmx.bundle;
+
+//$Id$
+
+public interface FooMBean 
+{
+	String echo(String msg);
+}


Property changes on: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/FooMBean.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/JMXTestService.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/JMXTestService.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/JMXTestService.java	2009-04-24 22:18:20 UTC (rev 87832)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.blueprint.jmx.bundle;
+
+//$Id$
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A service that registers an MBean
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class JMXTestService
+{
+   public JMXTestService(BundleContext context)
+   {
+      ServiceTracker tracker = new ServiceTracker(context, MBeanServer.class.getName(), null);
+      tracker.open();
+      
+      MBeanServer mbeanServer = (MBeanServer)tracker.getService();
+      if (mbeanServer == null)
+         throw new IllegalStateException("No MBeanServer");
+
+      try
+      {
+         ObjectName oname = new ObjectName("jboss.osgi:service=mbean-test-service");
+         mbeanServer.registerMBean(new Foo(), oname);
+      }
+      catch (Exception ex)
+      {
+         throw new IllegalStateException(ex);
+      }
+   }
+}


Property changes on: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/JMXTestService.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/ServiceActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/ServiceActivator.java	2009-04-24 22:18:20 UTC (rev 87832)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.blueprint.jmx.bundle;
+
+//$Id$
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A Service Activator
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class ServiceActivator implements BundleActivator
+{
+   public void start(BundleContext context)
+   {
+      JMXTestService service = new JMXTestService(context);
+      context.registerService(JMXTestService.class.getName(), service, null);
+   }
+
+   public void stop(BundleContext context)
+   {
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/bundle/blueprint/src/test/java/org/jboss/test/osgi/blueprint/jmx/bundle/ServiceActivator.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jmx/jmx-test.bnd
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jmx/jmx-test.bnd	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/blueprint/src/test/resources/jmx/jmx-test.bnd	2009-04-24 22:18:20 UTC (rev 87832)
@@ -0,0 +1,5 @@
+# bnd build -classpath target/test-classes -output target/test-libs/jmx-test.jar src/test/resources/jmx/jmx-test.bnd
+
+Bundle-SymbolicName: jmx-test
+Bundle-Activator: org.jboss.test.osgi.blueprint.jmx.bundle.ServiceActivator
+Export-Package: org.jboss.test.osgi.blueprint.jmx.bundle 

Copied: projects/jboss-osgi/trunk/bundle/jmx (from rev 87823, projects/jboss-osgi/trunk/bundle/blueprint)

Modified: projects/jboss-osgi/trunk/bundle/jmx/.classpath
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/.classpath	2009-04-24 17:35:14 UTC (rev 87823)
+++ projects/jboss-osgi/trunk/bundle/jmx/.classpath	2009-04-24 22:18:20 UTC (rev 87832)
@@ -2,6 +2,7 @@
 <classpath>
 	<classpathentry kind="src" output="target/classes" path="src/main/java"/>
 	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
 	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
 	<classpathentry kind="output" path="target/classes"/>

Modified: projects/jboss-osgi/trunk/bundle/jmx/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/blueprint/pom.xml	2009-04-24 17:35:14 UTC (rev 87823)
+++ projects/jboss-osgi/trunk/bundle/jmx/pom.xml	2009-04-24 22:18:20 UTC (rev 87832)
@@ -1,9 +1,9 @@
 <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>
   
-  <name>JBossOSGi - Bundle Blueprint Service</name>
-  <artifactId>jboss-osgi-blueprint</artifactId>
-  <packaging>jar</packaging>
+  <name>JBossOSGi - Bundle JMX</name>
+  <artifactId>jboss-osgi-jmx</artifactId>
+  <packaging>bundle</packaging>
   
   <parent>
     <groupId>org.jboss.osgi</groupId>
@@ -44,6 +44,21 @@
 
   <build>
     <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-SymbolicName>jboss-osgi-jmx</Bundle-SymbolicName>
+            <Bundle-Activator>org.jboss.osgi.jmx.ServiceActivator</Bundle-Activator>
+            <Import-Package>
+               org.osgi.framework;version=1.4,
+               javax.management,
+            </Import-Package>
+          </instructions>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
   

Added: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java	2009-04-24 22:18:20 UTC (rev 87832)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.jmx;
+
+//$Id$
+
+import java.util.ArrayList;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * A Service Activator that registers an MBeanServer
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class ServiceActivator implements BundleActivator
+{
+   private ServiceRegistration registration;
+   
+   @SuppressWarnings("unchecked")
+   public void start(BundleContext context)
+   {
+      ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+      if (sref == null)
+      {
+         ArrayList<MBeanServer> serverArr = MBeanServerFactory.findMBeanServer(null);
+         if (serverArr.size() > 1)
+            throw new IllegalStateException("Multiple MBeanServer instances not supported");
+
+         MBeanServer mbeanServer = null;
+         if (serverArr.size() == 1)
+            mbeanServer = serverArr.get(0);
+
+         if (mbeanServer == null)
+            mbeanServer = MBeanServerFactory.createMBeanServer();
+         
+         System.out.println("Register MBeanServer");
+         registration = context.registerService(MBeanServer.class.getName(), mbeanServer, null);
+      }
+   }
+
+   public void stop(BundleContext context)
+   {
+      if (registration != null)
+      {
+         System.out.println("Unregister MBeanServer");
+         registration.unregister();
+         registration = null;
+      }
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/bundle/jmx/src/main/java/org/jboss/osgi/jmx/ServiceActivator.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Modified: projects/jboss-osgi/trunk/bundle/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundle/pom.xml	2009-04-24 21:37:33 UTC (rev 87831)
+++ projects/jboss-osgi/trunk/bundle/pom.xml	2009-04-24 22:18:20 UTC (rev 87832)
@@ -13,8 +13,9 @@
   
   <!-- Modules -->
   <modules>
+    <module>blueprint</module>
     <module>common</module>
-    <module>blueprint</module>
+    <module>jmx</module>
     <module>logging</module>
     <module>remotelog</module>
     <module>webconsole</module>

Modified: projects/jboss-osgi/trunk/testsuite/example/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/pom.xml	2009-04-24 21:37:33 UTC (rev 87831)
+++ projects/jboss-osgi/trunk/testsuite/example/pom.xml	2009-04-24 22:18:20 UTC (rev 87832)
@@ -111,7 +111,7 @@
             <configuration>
               <appendAssemblyId>false</appendAssemblyId>
               <descriptors>
-                <descriptor>scripts/assembly-examples.xml</descriptor>
+                <descriptor>scripts/assembly-examples-zip.xml</descriptor>
               </descriptors>
             </configuration>
           </execution>

Copied: projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-examples-zip.xml (from rev 87817, projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-examples.xml)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-examples-zip.xml	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-examples-zip.xml	2009-04-24 22:18:20 UTC (rev 87832)
@@ -0,0 +1,19 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+  <id>examples</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <directory></directory>
+      <outputDirectory>example</outputDirectory>
+      <includes>
+        <include>scripts/**</include>
+        <include>src/**</include>
+        <include>pom.xml</include>
+      </includes>
+    </fileSet>
+  </fileSets>
+</assembly>
\ No newline at end of file

Deleted: projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-examples.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-examples.xml	2009-04-24 21:37:33 UTC (rev 87831)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/assembly-examples.xml	2009-04-24 22:18:20 UTC (rev 87832)
@@ -1,19 +0,0 @@
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
-  <id>examples</id>
-  <formats>
-    <format>zip</format>
-  </formats>
-  <includeBaseDirectory>false</includeBaseDirectory>
-  <fileSets>
-    <fileSet>
-      <directory></directory>
-      <outputDirectory>example</outputDirectory>
-      <includes>
-        <include>scripts/**</include>
-        <include>src/**</include>
-        <include>pom.xml</include>
-      </includes>
-    </fileSet>
-  </fileSets>
-</assembly>
\ No newline at end of file




More information about the jboss-osgi-commits mailing list