[jboss-osgi-commits] JBoss-OSGI SVN: r95744 - in projects/jboss-osgi/trunk: reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal and 1 other directory.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Thu Oct 29 06:54:08 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-10-29 06:54:08 -0400 (Thu, 29 Oct 2009)
New Revision: 95744

Added:
   projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleTracker.java
Removed:
   projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleServiceImpl.java
Modified:
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
   projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-all.properties
   projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
   projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedFrameworkImpl.java
Log:
Fix jbossmc runtime regression

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml	2009-10-29 10:36:54 UTC (rev 95743)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml	2009-10-29 10:54:08 UTC (rev 95744)
@@ -60,6 +60,8 @@
         <entry><key>org.jboss.osgi.jndi.host</key><value>${jboss.bind.address}</value></entry>
         <entry><key>org.jboss.osgi.jndi.rmi.port</key><value>1098</value></entry>
         <entry><key>org.jboss.osgi.jndi.port</key><value>1099</value></entry>
+        <!-- JTA Object Store -->
+        <entry><key>com.arjuna.ats.arjuna.objectstore.objectStoreDir</key><value>${osgi.server.home}/data/ObjectStore</value></entry>
       </map>
     </property>
     <incallback method="addPlugin" />

Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-all.properties
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-all.properties	2009-10-29 10:36:54 UTC (rev 95743)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-felix-all.properties	2009-10-29 10:54:08 UTC (rev 95744)
@@ -25,6 +25,9 @@
 org.jboss.osgi.husky.runtime.connector.host=${jboss.bind.address}
 org.jboss.osgi.husky.runtime.connector.port=5401
 
+# JTA ObjectStore
+com.arjuna.ats.arjuna.objectstore.objectStoreDir=${osgi.server.home}/data/ObjectStore
+
 # Extra System Packages
 org.osgi.framework.system.packages.extra=\
    org.apache.log4j;version=1.2, \

Modified: projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java	2009-10-29 10:36:54 UTC (rev 95743)
+++ projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java	2009-10-29 10:54:08 UTC (rev 95744)
@@ -37,7 +37,6 @@
 import javax.naming.Reference;
 import javax.naming.StringRefAddr;
 
-import org.jboss.osgi.spi.management.ManagedBundleService;
 import org.jboss.osgi.spi.management.ManagedFramework;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
@@ -78,10 +77,6 @@
       context.registerService(ManagedFramework.class.getName(), managedFramework, null);
       managedFramework.start();
 
-      // Register the ManagedBundleService 
-      ManagedBundleService managedBundleService = new ManagedBundleServiceImpl(sysContext, mbeanServer);
-      context.registerService(ManagedBundleService.class.getName(), managedBundleService, null);
-
       jmxHost = context.getProperty(REMOTE_JMX_HOST);
       if (jmxHost == null)
          jmxHost = "localhost";

Deleted: projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleServiceImpl.java	2009-10-29 10:36:54 UTC (rev 95743)
+++ projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleServiceImpl.java	2009-10-29 10:54:08 UTC (rev 95744)
@@ -1,123 +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.
- */
-package org.jboss.osgi.jmx.internal;
-
-//$Id$
-
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import org.jboss.osgi.spi.management.ManagedBundle;
-import org.jboss.osgi.spi.management.ManagedBundleService;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.util.tracker.BundleTracker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A service that registers an MBeanServer
- * 
- * @author thomas.diesler at jboss.com
- * @since 24-Apr-2009
- */
-public class ManagedBundleServiceImpl implements ManagedBundleService
-{
-   // Provide logging
-   private Logger log = LoggerFactory.getLogger(ManagedBundleServiceImpl.class);
-   
-   private MBeanServer mbeanServer;
-
-   public ManagedBundleServiceImpl(BundleContext context, MBeanServer mbeanServer)
-   {
-      this.mbeanServer = mbeanServer;
-
-      // Start tracking bundles
-      ManagedBundleTracker bundleTracker = new ManagedBundleTracker(context);
-      bundleTracker.open();
-   }
-
-   public ManagedBundle register(Bundle bundle)
-   {
-      try
-      {
-         ManagedBundle mb = new ManagedBundle(bundle);
-         ObjectName oname = mb.getObjectName();
-
-         if (mbeanServer.isRegistered(oname) == false)
-         {
-            log.debug("Register managed bundle: " + oname);
-            mbeanServer.registerMBean(mb, oname);
-         }
-
-         return mb;
-      }
-      catch (JMException ex)
-      {
-         log.error("Cannot register managed bundle", ex);
-         return null;
-      }
-   }
-
-   public void unregister(Bundle bundle)
-   {
-      try
-      {
-         ManagedBundle mb = new ManagedBundle(bundle);
-         ObjectName oname = mb.getObjectName();
-
-         log.debug("Unregister managed bundle: " + oname);
-         if (mbeanServer.isRegistered(oname))
-            mbeanServer.unregisterMBean(oname);
-
-      }
-      catch (JMException ex)
-      {
-         log.error("Cannot register managed bundle", ex);
-      }
-   }
-
-   class ManagedBundleTracker extends BundleTracker
-   {
-      ManagedBundleTracker(BundleContext context)
-      {
-         super(context, Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE | Bundle.UNINSTALLED, null);
-      }
-
-      @Override
-      public Object addingBundle(Bundle bundle, BundleEvent event)
-      {
-         Object retObject = super.addingBundle(bundle, event);
-         register(bundle);
-         return retObject;
-      }
-
-      @Override
-      public void removedBundle(Bundle bundle, BundleEvent event, Object object)
-      {
-         unregister(bundle);
-         super.removedBundle(bundle, event, object);
-      }
-   }
-}
\ No newline at end of file

Added: projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleTracker.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleTracker.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleTracker.java	2009-10-29 10:54:08 UTC (rev 95744)
@@ -0,0 +1,113 @@
+/*
+ * 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.internal;
+
+//$Id$
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.management.ManagedBundle;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.util.tracker.BundleTracker;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Track and register/unregister bundles with the MBeanServer.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 29-Oct-2009
+ */
+public class ManagedBundleTracker extends BundleTracker
+{
+   // Provide logging
+   private Logger log = LoggerFactory.getLogger(ManagedBundleTracker.class);
+
+   private MBeanServer mbeanServer;
+
+   public ManagedBundleTracker(BundleContext context, MBeanServer mbeanServer)
+   {
+      super(context, Bundle.INSTALLED | Bundle.RESOLVED | Bundle.ACTIVE | Bundle.UNINSTALLED, null);
+      this.mbeanServer = mbeanServer;
+   }
+
+   @Override
+   public Object addingBundle(Bundle bundle, BundleEvent event)
+   {
+      Object retObject = super.addingBundle(bundle, event);
+      register(bundle);
+      return retObject;
+   }
+
+   @Override
+   public void modifiedBundle(Bundle bundle, BundleEvent event, Object object)
+   {
+      if (event != null && event.getType() == BundleEvent.UNINSTALLED)
+         unregister(bundle);
+   }
+
+   private ManagedBundle register(Bundle bundle)
+   {
+      try
+      {
+         ManagedBundle mb = new ManagedBundle(bundle);
+         ObjectName oname = mb.getObjectName();
+
+         if (mbeanServer.isRegistered(oname) == false)
+         {
+            log.debug("Register managed bundle: " + oname);
+            mbeanServer.registerMBean(mb, oname);
+         }
+
+         return mb;
+      }
+      catch (JMException ex)
+      {
+         log.error("Cannot register managed bundle", ex);
+         return null;
+      }
+   }
+
+   private void unregister(Bundle bundle)
+   {
+      try
+      {
+         ManagedBundle mb = new ManagedBundle(bundle);
+         ObjectName oname = mb.getObjectName();
+
+         if (mbeanServer.isRegistered(oname))
+         {
+            log.debug("Unregister managed bundle: " + oname);
+            mbeanServer.unregisterMBean(oname);
+         }
+
+      }
+      catch (JMException ex)
+      {
+         log.error("Cannot register managed bundle", ex);
+      }
+   }
+}
\ No newline at end of file


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

Modified: projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedFrameworkImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedFrameworkImpl.java	2009-10-29 10:36:54 UTC (rev 95743)
+++ projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedFrameworkImpl.java	2009-10-29 10:54:08 UTC (rev 95744)
@@ -40,6 +40,7 @@
 import javax.management.QueryExp;
 import javax.management.StandardMBean;
 
+import org.jboss.osgi.spi.management.ManagedBundle;
 import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
 import org.jboss.osgi.spi.management.ManagedServiceReference;
 import org.jboss.osgi.spi.management.ObjectNameFactory;
@@ -63,25 +64,28 @@
    final Logger log = LoggerFactory.getLogger(ManagedFrameworkImpl.class);
 
    private MBeanServer mbeanServer;
-   private BundleContext bundleContext;
+   private BundleContext context;
+   private ManagedBundleTracker bundleTracker;
 
-   public ManagedFrameworkImpl(BundleContext bundleContext, MBeanServer mbeanServer)
+   public ManagedFrameworkImpl(BundleContext context, MBeanServer mbeanServer)
    {
-      if (bundleContext == null)
+      if (context == null)
          throw new IllegalArgumentException("Null BundleContext");
-      this.bundleContext = bundleContext;
-
       if (mbeanServer == null)
          throw new IllegalArgumentException("Null MBeanServer");
+      
+      if (context.getBundle().getBundleId() != 0)
+         throw new IllegalArgumentException("Not the system bundle context: " + context);
+      
+      this.context = context;
       this.mbeanServer = mbeanServer;
-
-      if (bundleContext.getBundle().getBundleId() != 0)
-         throw new IllegalArgumentException("Not the system bundle context: " + bundleContext);
+      
+      this.bundleTracker = new ManagedBundleTracker(context, mbeanServer);
    }
 
    public BundleContext getBundleContext()
    {
-      return bundleContext;
+      return context;
    }
 
    @SuppressWarnings("unchecked")
@@ -207,6 +211,9 @@
 
    public void start()
    {
+      // Start tracking the bundles
+      bundleTracker.open();
+      
       try
       {
          if (mbeanServer != null)
@@ -241,7 +248,7 @@
 
       public boolean apply(ObjectName name)
       {
-         return name.getKeyProperty("bundle") != null;
+         return name.getKeyProperty(ManagedBundle.PROPERTY_SYMBOLIC_NAME) != null;
       }
 
       public void setMBeanServer(MBeanServer server)



More information about the jboss-osgi-commits mailing list