[jboss-osgi-commits] JBoss-OSGI SVN: r89537 - in projects/jboss-osgi/trunk: bundles/common/src/main/java/org/jboss/osgi/common/service and 10 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Fri May 29 17:22:55 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-05-29 17:22:55 -0400 (Fri, 29 May 2009)
New Revision: 89537
Added:
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceTracker.java
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceDelegate.java
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/ManagedBundleService.java
projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/DeploymentScannerService.java
projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerLocator.java
projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleServiceImpl.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java
Removed:
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceTracker.java
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeploymentScannerService.java
projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerService.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/Extender.java
Modified:
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/CommonServicesActivator.java
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/SimpleDeployerService.java
projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/BundleInfoImpl.java
projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerActivator.java
projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/ScannerThread.java
projects/jboss-osgi/trunk/bundles/jmx/pom.xml
projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties
projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyActivator.java
projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteBundle.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemotePackageAdmin.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
Log:
DeployerServiceDelegate maintains DeployerService
Modified: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/CommonServicesActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/CommonServicesActivator.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/CommonServicesActivator.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -29,7 +29,7 @@
import org.jboss.osgi.common.log.LogServiceTracker;
import org.jboss.osgi.common.service.DeployerService;
-import org.jboss.osgi.common.service.DeployerServiceTracker;
+import org.jboss.osgi.common.service.DeployerServiceDelegate;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -52,23 +52,18 @@
log = new LogServiceTracker(context);
// Track LogReaderService and add/remove LogListener
- ServiceTracker logTracker = new ServiceTracker(context, LogReaderService.class.getName(), null)
- {
- @Override
- public Object addingService(ServiceReference reference)
- {
- LogReaderService logReader = (LogReaderService)super.addingService(reference);
- logReader.addLogListener(new LoggingLogListener());
- return logReader;
- }
- };
- logTracker.open();
+ trackLogReaderService(context);
- // Track the DeployerService
- final DeployerServiceTracker serviceTracker = new DeployerServiceTracker(context);
- serviceTracker.open();
+ // Register the DeployerServiceDelegate
+ DeployerServiceDelegate delegate = new DeployerServiceDelegate(context);
+ context.registerService(DeployerServiceDelegate.class.getName(), delegate, null);
- // Track the MBeanServer and register the DeployerServiceTracker
+ // Track the MBeanServer and register the DeployerServiceDelegate
+ trackMBeanServer(context, delegate);
+ }
+
+ private void trackMBeanServer(BundleContext context, final DeployerServiceDelegate delegate)
+ {
ServiceTracker jmxTracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
{
@Override
@@ -77,7 +72,6 @@
MBeanServer mbeanServer = (MBeanServer)super.addingService(reference);
try
{
- DeployerServiceDelegate delegate = new DeployerServiceDelegate(serviceTracker);
StandardMBean mbean = new StandardMBean(delegate, DeployerService.class);
mbeanServer.registerMBean(mbean, DeployerService.MBEAN_DEPLOYER_SERVICE);
}
@@ -108,6 +102,21 @@
jmxTracker.open();
}
+ private void trackLogReaderService(BundleContext context)
+ {
+ ServiceTracker logTracker = new ServiceTracker(context, LogReaderService.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ LogReaderService logReader = (LogReaderService)super.addingService(reference);
+ logReader.addLogListener(new LoggingLogListener());
+ return logReader;
+ }
+ };
+ logTracker.open();
+ }
+
public void stop(BundleContext context)
{
// NOTE: The service is automatically unregistered.
Deleted: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -1,69 +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.common.internal;
-
-//$Id$
-
-import java.net.URL;
-
-import org.jboss.osgi.common.service.BundleInfo;
-import org.jboss.osgi.common.service.DeployerService;
-import org.jboss.osgi.common.service.DeployerServiceTracker;
-
-/**
- * A {@link DeployerService} that delegates to the service that is tracked
- * by the given {@link DeployerServiceTracker}
- *
- * This delegate is registered as an MBean
- *
- * @author thomas.diesler at jboss.com
- * @since 27-May-2009
- */
-public class DeployerServiceDelegate implements DeployerService
-{
- private DeployerServiceTracker tracker;
-
- public DeployerServiceDelegate(DeployerServiceTracker tracker)
- {
- this.tracker = tracker;
- }
-
- public void deploy(BundleInfo[] bundles) throws Exception
- {
- tracker.getService().deploy(bundles);
- }
-
- public void deploy(URL url) throws Exception
- {
- tracker.getService().deploy(url);
- }
-
- public void undeploy(BundleInfo[] bundles) throws Exception
- {
- tracker.getService().undeploy(bundles);
- }
-
- public void undeploy(URL url) throws Exception
- {
- tracker.getService().undeploy(url);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceTracker.java (from rev 89534, projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceTracker.java)
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceTracker.java (rev 0)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceTracker.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -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.common.internal;
+
+//$Id$
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.jboss.osgi.common.service.DeployerService;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A {@link ServiceTracker} that tracks the {@link DeployerService}.
+ * In case there is not such service registered, it returns an instance
+ * of {@link SimpleDeployerService}
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 27-May-2009
+ */
+public class DeployerServiceTracker extends ServiceTracker
+{
+ private LogServiceTracker log;
+ private BundleContext context;
+
+ public DeployerServiceTracker(BundleContext context)
+ {
+ super(context, DeployerService.class.getName(), null);
+ this.log = new LogServiceTracker(context);
+ this.context = context;
+ }
+
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ DeployerService service = (DeployerService)super.addingService(reference);
+ log.log(LogService.LOG_INFO, "Adding DeployerService: " + service.getClass().getName());
+ return service;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ log.log(LogService.LOG_INFO, "Removing DeployerService: " + service.getClass().getName());
+ super.removedService(reference, service);
+ }
+
+ @Override
+ public DeployerService getService()
+ {
+ DeployerService service = (DeployerService)super.getService();
+ if (service == null)
+ service = new SimpleDeployerService(context);
+
+ return service;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/SimpleDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/SimpleDeployerService.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/SimpleDeployerService.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -23,22 +23,16 @@
//$Id$
-import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
import org.jboss.osgi.common.log.LogServiceTracker;
import org.jboss.osgi.common.service.BundleInfo;
import org.jboss.osgi.common.service.DeployerService;
-import org.jboss.osgi.common.service.DeployerServiceTracker;
-import org.jboss.osgi.spi.management.ManagedBundle;
+import org.jboss.osgi.common.service.ManagedBundleService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -56,7 +50,7 @@
private LogServiceTracker log;
private BundleContext context;
- private Map<URI, Bundle> urlDeployments = new HashMap<URI, Bundle>();
+ private Map<String, Bundle> deployments = new HashMap<String, Bundle>();
public SimpleDeployerService(BundleContext context)
{
@@ -72,14 +66,17 @@
{
try
{
- log.log(LogService.LOG_DEBUG, "Install: " + info.getSymbolicName());
- Bundle bundle = context.installBundle(info.getLocation().toExternalForm());
+ String location = info.getLocation().toExternalForm();
+ Bundle bundle = context.installBundle(location);
+ log.log(LogService.LOG_INFO, "Installed: " + bundle);
+
+ deployments.put(location, bundle);
registerManagedBundle(bundle);
bundles.add(bundle);
}
catch (BundleException ex)
{
- log.log(LogService.LOG_ERROR, "Cannot install bundle: " + info.getSymbolicName(), ex);
+ log.log(LogService.LOG_ERROR, "Cannot install bundle: " + info, ex);
}
}
@@ -88,75 +85,71 @@
{
try
{
- log.log(LogService.LOG_DEBUG, "Start: " + bundle.getSymbolicName());
+ log.log(LogService.LOG_DEBUG, "Start: " + bundle);
bundle.start();
}
catch (BundleException ex)
{
- log.log(LogService.LOG_ERROR, "Cannot start bundle: " + bundle.getSymbolicName(), ex);
+ log.log(LogService.LOG_ERROR, "Cannot start bundle: " + bundle, ex);
}
}
}
- public void undeploy(BundleInfo[] bundleInfos) throws BundleException
+ public void undeploy(BundleInfo[] bundleInfos) throws Exception
{
for (BundleInfo info : bundleInfos)
- {
- Bundle bundle = DeployerServiceTracker.getInstalledBundle(context, info);
- if (bundle != null)
- {
- try
- {
- log.log(LogService.LOG_DEBUG, "Uninstall: " + info.getSymbolicName());
- bundle.uninstall();
- }
- catch (BundleException ex)
- {
- log.log(LogService.LOG_ERROR, "Cannot uninstall bundle", ex);
- }
- }
- }
+ undeploy(info.getLocation());
}
public void deploy(URL url) throws Exception
{
- log.log(LogService.LOG_DEBUG, "Install: " + url);
Bundle bundle = context.installBundle(url.toExternalForm());
- urlDeployments.put(url.toURI(), bundle);
+ log.log(LogService.LOG_INFO, "Installed: " + bundle);
+ deployments.put(url.toExternalForm(), bundle);
registerManagedBundle(bundle);
bundle.start();
}
public void undeploy(URL url) throws Exception
{
- Bundle bundle = urlDeployments.remove(url.toURI());
+ Bundle bundle = deployments.remove(url.toExternalForm());
if (bundle != null)
{
- log.log(LogService.LOG_DEBUG, "Uninstall: " + bundle.getSymbolicName());
+ unregisterManagedBundle(bundle);
bundle.uninstall();
+ log.log(LogService.LOG_INFO, "Uninstalled: " + bundle);
}
+ else
+ {
+ log.log(LogService.LOG_WARNING, "Cannot find bundle for: " + url);
+ }
}
private void registerManagedBundle(Bundle bundle)
{
- ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
- if (sref == null)
+ ServiceReference sref = context.getServiceReference(ManagedBundleService.class.getName());
+ if (sref != null)
{
- log.log(LogService.LOG_WARNING, "No MBeanServer. Cannot register managed bundle: " + bundle.getSymbolicName());
- return;
+ ManagedBundleService service = (ManagedBundleService)context.getService(sref);
+ service.register(bundle);
}
+ else
+ {
+ log.log(LogService.LOG_DEBUG, "No ManagedBundleService. Cannot register managed bundle: " + bundle);
+ }
+ }
- MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
- ManagedBundle mb = new ManagedBundle(bundle);
- ObjectName oname = mb.getObjectName();
- try
+ private void unregisterManagedBundle(Bundle bundle)
+ {
+ ServiceReference sref = context.getServiceReference(ManagedBundleService.class.getName());
+ if (sref != null)
{
- log.log(LogService.LOG_DEBUG, "Register managed bundle: " + oname);
- mbeanServer.registerMBean(mb, oname);
+ ManagedBundleService service = (ManagedBundleService)context.getService(sref);
+ service.unregister(bundle);
}
- catch (JMException ex)
+ else
{
- log.log(LogService.LOG_ERROR, "Cannot register managed bundle", ex);
+ log.log(LogService.LOG_DEBUG, "No ManagedBundleService. Cannot unregister managed bundle: " + bundle);
}
}
}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceDelegate.java (from rev 89534, projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java)
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceDelegate.java (rev 0)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceDelegate.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -0,0 +1,93 @@
+/*
+ * 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.common.service;
+
+//$Id$
+
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.osgi.common.internal.DeployerServiceTracker;
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * A {@link DeployerService} that delegates to the service that is tracked
+ * by the given {@link DeployerServiceTracker}
+ *
+ * This delegate is registered as an MBean
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 27-May-2009
+ */
+public class DeployerServiceDelegate implements DeployerService
+{
+ private LogServiceTracker log;
+
+ private DeployerServiceTracker tracker;
+ private Map<String, DeployerService> serviceMap = new HashMap<String, DeployerService>();
+
+ public DeployerServiceDelegate(BundleContext context)
+ {
+ log = new LogServiceTracker(context);
+
+ tracker = new DeployerServiceTracker(context);
+ tracker.open();
+ }
+
+ public void deploy(BundleInfo[] bundles) throws Exception
+ {
+ DeployerService service = tracker.getService();
+ for (BundleInfo info : bundles)
+ serviceMap.put(info.getLocation().toString(), service);
+
+ service.deploy(bundles);
+ }
+
+ public void deploy(URL url) throws Exception
+ {
+ DeployerService service = tracker.getService();
+ serviceMap.put(url.toString(), service);
+ service.deploy(url);
+ }
+
+ public void undeploy(BundleInfo[] bundles) throws Exception
+ {
+ for (BundleInfo info : bundles)
+ undeploy(info.getLocation());
+ }
+
+ public void undeploy(URL url) throws Exception
+ {
+ DeployerService service = serviceMap.remove(url.toString());
+ if (service != null)
+ {
+ service.undeploy(url);
+ }
+ else
+ {
+ log.log(LogService.LOG_WARNING, "Cannot find DeployerService for: " + url);
+ }
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceTracker.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceTracker.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceTracker.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -1,95 +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.common.service;
-
-//$Id$
-
-import org.jboss.osgi.common.internal.SimpleDeployerService;
-import org.jboss.osgi.common.log.LogServiceTracker;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * A {@link ServiceTracker} that tracks the {@link DeployerService}.
- * In case there is not such service registered, it returns an instance
- * of {@link SimpleDeployerService}
- *
- * @author thomas.diesler at jboss.com
- * @since 27-May-2009
- */
-public class DeployerServiceTracker extends ServiceTracker
-{
- private LogServiceTracker log;
- private BundleContext context;
-
- public DeployerServiceTracker(BundleContext context)
- {
- super(context, DeployerService.class.getName(), null);
- this.log = new LogServiceTracker(context);
- this.context = context;
- }
-
- @Override
- public Object addingService(ServiceReference reference)
- {
- DeployerService service = (DeployerService)super.addingService(reference);
- log.log(LogService.LOG_INFO, "Adding DeployerService: " + service.getClass().getName());
- return service;
- }
-
- @Override
- public void removedService(ServiceReference reference, Object service)
- {
- log.log(LogService.LOG_INFO, "Removing DeployerService: " + service.getClass().getName());
- super.removedService(reference, service);
- }
-
- @Override
- public DeployerService getService()
- {
- DeployerService service = (DeployerService)super.getService();
- if (service == null)
- service = new SimpleDeployerService(context);
-
- return service;
- }
-
- public static Bundle getInstalledBundle(BundleContext context, BundleInfo bundleInfo)
- {
- Bundle bundle = null;
-
- for (Bundle aux : context.getBundles())
- {
- String symbolicName = aux.getSymbolicName();
- if (symbolicName.equals(bundleInfo.getSymbolicName()))
- {
- bundle = aux;
- break;
- }
- }
-
- return bundle;
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeploymentScannerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeploymentScannerService.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeploymentScannerService.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -1,74 +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.common.service;
-
-//$Id$
-
-import java.net.URL;
-
-
-/**
- * A service that scans a directory location for new/removed bundles.
- *
- * @author thomas.diesler at jboss.com
- * @since 27-May-2009
- */
-public interface DeploymentScannerService
-{
- /**
- * The property that names the scan location: org.jboss.osgi.hotdeploy.scandir
- */
- String PROPERTY_SCAN_LOCATION = "org.jboss.osgi.hotdeploy.scandir";
-
- /**
- * The property to defines the scan interval: org.jboss.osgi.hotdeploy.interval
- */
- String PROPERTY_SCAN_INTERVAL = "org.jboss.osgi.hotdeploy.interval";
-
- /**
- * Get the scan location URL.
- *
- * This is can be specified by setting the {@link PROPERTY_SCAN_LOCATION} property.
- */
- URL getScanLocation();
-
- /**
- * The number of scans since the service started
- */
- long getScanCount();
-
- /**
- * The number of milliseconds between scans
- * Defaults to 2000ms
- */
- long getScanInterval();
-
- /**
- * Run a directory scan
- */
- void scan();
-
- /**
- * Returns the array of bundles currently known to the deployemtn scanner.
- */
- BundleInfo[] getBundles();
-}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/ManagedBundleService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/ManagedBundleService.java (rev 0)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/ManagedBundleService.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -0,0 +1,48 @@
+/*
+ * 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.common.service;
+
+//$Id$
+
+import org.jboss.osgi.spi.management.ManagedBundle;
+import org.osgi.framework.Bundle;
+
+
+/**
+ * A Service that registers/unregisters the management view
+ * of a bundle.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 29-May-2009
+ */
+public interface ManagedBundleService
+{
+ /**
+ * Register a managed bundle
+ */
+ ManagedBundle register(Bundle bundle);
+
+ /**
+ * Unregister a managed bundle
+ */
+ void unregister(Bundle bundle);
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/ManagedBundleService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/DeploymentScannerService.java (from rev 89533, projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeploymentScannerService.java)
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/DeploymentScannerService.java (rev 0)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/DeploymentScannerService.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -0,0 +1,76 @@
+/*
+ * 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.service.hotdeploy;
+
+//$Id$
+
+import java.net.URL;
+
+import org.jboss.osgi.common.service.BundleInfo;
+
+
+/**
+ * A service that scans a directory location for new/removed bundles.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 27-May-2009
+ */
+public interface DeploymentScannerService
+{
+ /**
+ * The property that names the scan location: org.jboss.osgi.hotdeploy.scandir
+ */
+ String PROPERTY_SCAN_LOCATION = "org.jboss.osgi.hotdeploy.scandir";
+
+ /**
+ * The property to defines the scan interval: org.jboss.osgi.hotdeploy.interval
+ */
+ String PROPERTY_SCAN_INTERVAL = "org.jboss.osgi.hotdeploy.interval";
+
+ /**
+ * Get the scan location URL.
+ *
+ * This is can be specified by setting the {@link PROPERTY_SCAN_LOCATION} property.
+ */
+ URL getScanLocation();
+
+ /**
+ * The number of scans since the service started
+ */
+ long getScanCount();
+
+ /**
+ * The number of milliseconds between scans
+ * Defaults to 2000ms
+ */
+ long getScanInterval();
+
+ /**
+ * Run a directory scan
+ */
+ void scan();
+
+ /**
+ * Returns the array of bundles currently known to the deployemtn scanner.
+ */
+ BundleInfo[] getBundles();
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/BundleInfoImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/BundleInfoImpl.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/BundleInfoImpl.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -43,39 +43,40 @@
private String version;
private State state;
- @SuppressWarnings("unchecked")
- public BundleInfoImpl(URL bundleURL, String symbolicName, Bundle bundle)
+ public BundleInfoImpl(URL bundleURL, String symbolicName, String version)
{
this.symbolicName = symbolicName;
this.location = bundleURL;
- this.version = "0.0.0";
this.state = State.NEW;
- if (bundle != null)
+ this.version = (version != null ? version : "0.0.0");
+ }
+
+ @SuppressWarnings("unchecked")
+ public void initFromBundle(Bundle bundle)
+ {
+ Dictionary headers = bundle.getHeaders();
+ String bundleVersion = (String)headers.get(Constants.BUNDLE_VERSION);
+ if (bundleVersion != null)
+ this.version = bundleVersion;
+
+ int bundleState = bundle.getState();
+ switch (bundleState)
{
- Dictionary headers = bundle.getHeaders();
- String bundleVersion = (String)headers.get(Constants.BUNDLE_VERSION);
- if (bundleVersion != null)
- this.version = bundleVersion;
-
- int bundleState = bundle.getState();
- switch (bundleState)
- {
- case Bundle.INSTALLED:
- case Bundle.RESOLVED:
- case Bundle.STARTING:
- case Bundle.STOPPING:
- state = State.INSTALLED;
- break;
-
- case Bundle.ACTIVE:
- state = State.ACTIVE;
- break;
-
- case Bundle.UNINSTALLED:
- state = State.UNINSTALLED;
- break;
- }
+ case Bundle.INSTALLED:
+ case Bundle.RESOLVED:
+ case Bundle.STARTING:
+ case Bundle.STOPPING:
+ state = State.INSTALLED;
+ break;
+
+ case Bundle.ACTIVE:
+ state = State.ACTIVE;
+ break;
+
+ case Bundle.UNINSTALLED:
+ state = State.UNINSTALLED;
+ break;
}
}
Modified: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerActivator.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerActivator.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -23,7 +23,7 @@
//$Id$
-import org.jboss.osgi.common.service.DeploymentScannerService;
+import org.jboss.osgi.service.hotdeploy.DeploymentScannerService;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
Modified: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -23,8 +23,6 @@
//$Id$
-import static org.osgi.framework.Constants.BUNDLE_SYMBOLICNAME;
-
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
@@ -38,12 +36,13 @@
import org.jboss.osgi.common.log.LogServiceTracker;
import org.jboss.osgi.common.service.BundleInfo;
-import org.jboss.osgi.common.service.DeployerServiceTracker;
-import org.jboss.osgi.common.service.DeploymentScannerService;
+import org.jboss.osgi.common.service.DeployerServiceDelegate;
import org.jboss.osgi.common.service.BundleInfo.State;
+import org.jboss.osgi.service.hotdeploy.DeploymentScannerService;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
/**
@@ -61,7 +60,7 @@
private File scanLocation;
private long scanCount;
- private DeployerServiceTracker serviceTracker;
+ private DeployerServiceDelegate delegate;
private ScannerThread scannerThread;
private List<BundleInfo> lastScan = new ArrayList<BundleInfo>();
private boolean traceBundles = false;
@@ -71,8 +70,9 @@
this.log = new LogServiceTracker(context);
this.context = context;
- serviceTracker = new DeployerServiceTracker(context);
- serviceTracker.open();
+ // Get the DeployerServiceDelegate
+ ServiceReference sref = context.getServiceReference(DeployerServiceDelegate.class.getName());
+ delegate = (DeployerServiceDelegate)context.getService(sref);
initScanner(context);
}
@@ -136,7 +136,7 @@
try
{
BundleInfo[] infoArr = diff.toArray(new BundleInfo[diff.size()]);
- serviceTracker.getService().undeploy(infoArr);
+ delegate.undeploy(infoArr);
}
catch (Exception ex)
{
@@ -162,7 +162,7 @@
try
{
BundleInfo[] infoArr = diff.toArray(new BundleInfo[diff.size()]);
- serviceTracker.getService().deploy(infoArr);
+ delegate.deploy(infoArr);
}
catch (Exception ex)
{
@@ -175,9 +175,13 @@
List<BundleInfo> bundles = new ArrayList<BundleInfo>();
for (File file : scanLocation.listFiles())
{
- BundleInfo info = getBundleInfo(file);
- Bundle bundle = DeployerServiceTracker.getInstalledBundle(context, info);
- bundles.add(new BundleInfoImpl(toURL(file), info.getSymbolicName(), bundle));
+ BundleInfoImpl info = getBundleInfo(file);
+
+ Bundle bundle = getInstalledBundle(info);
+ if (bundle != null)
+ info.initFromBundle(bundle);
+
+ bundles.add(info);
}
BundleInfo[] arr = new BundleInfoImpl[bundles.size()];
return bundles.toArray(arr);
@@ -233,26 +237,50 @@
scanLocation = scanFile;
}
- private BundleInfo getBundleInfo(File file)
+ private BundleInfoImpl getBundleInfo(File file)
{
+ Manifest manifest;
try
{
JarFile jarFile = new JarFile(file);
- Manifest manifest = jarFile.getManifest();
- Attributes attribs = manifest.getMainAttributes();
-
- String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
- if (symbolicName == null)
- throw new IllegalStateException("Cannot obtain '" + Constants.BUNDLE_SYMBOLICNAME + "' from: " + file);
-
- return new BundleInfoImpl(toURL(file), symbolicName, null);
+ manifest = jarFile.getManifest();
}
catch (IOException ex)
{
- throw new IllegalStateException("Cannot obtain '" + BUNDLE_SYMBOLICNAME + "' from: " + file, ex);
+ throw new IllegalStateException("Cannot obtain manifest from: " + file, ex);
}
+
+ Attributes attribs = manifest.getMainAttributes();
+
+ String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
+ if (symbolicName == null)
+ throw new IllegalStateException("Cannot obtain '" + Constants.BUNDLE_SYMBOLICNAME + "' from: " + file);
+
+ String version = attribs.getValue(Constants.BUNDLE_VERSION);
+
+ return new BundleInfoImpl(toURL(file), symbolicName, version);
}
+ private Bundle getInstalledBundle(BundleInfo info)
+ {
+ Bundle bundle = null;
+ for (Bundle aux : context.getBundles())
+ {
+ String name = aux.getSymbolicName();
+
+ String version = (String)aux.getHeaders().get(Constants.BUNDLE_VERSION);
+ if (version == null)
+ version = "0.0.0";
+
+ if (name.equals(info.getSymbolicName()) && version.equals(info.getVersion()))
+ {
+ bundle = aux;
+ break;
+ }
+ }
+ return bundle;
+ }
+
private URL toURL(File file)
{
try
Modified: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/ScannerThread.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/ScannerThread.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/ScannerThread.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -24,7 +24,7 @@
//$Id$
import org.jboss.osgi.common.log.LogServiceTracker;
-import org.jboss.osgi.common.service.DeploymentScannerService;
+import org.jboss.osgi.service.hotdeploy.DeploymentScannerService;
import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
Modified: projects/jboss-osgi/trunk/bundles/jmx/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundles/jmx/pom.xml 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/bundles/jmx/pom.xml 2009-05-29 21:22:55 UTC (rev 89537)
@@ -67,6 +67,7 @@
<!-- jboss-osgi -->
org.jboss.osgi.common.log;version="1.0",
+ org.jboss.osgi.common.service;version="1.0",
org.jboss.osgi.spi.management;version="1.0",
<!-- osgi -->
Modified: projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -32,7 +32,9 @@
import javax.naming.StringRefAddr;
import org.jboss.osgi.common.log.LogServiceTracker;
+import org.jboss.osgi.common.service.ManagedBundleService;
import org.jboss.osgi.spi.management.ManagedFramework;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -56,6 +58,8 @@
private String jmxRmiPort;
private String rmiAdaptorPath;
private MBeanServer mbeanServer;
+ private ManagedFramework managedFramework;
+ private ManagedBundleService managedBundleService;
private LogService log;
@@ -63,15 +67,25 @@
{
log = new LogServiceTracker(context);
- MBeanServerService mbeanService = new MBeanServerService(context);
- mbeanServer = mbeanService.getMBeanServer();
+ MBeanServerLocator locator = new MBeanServerLocator(context);
+ mbeanServer = locator.getMBeanServer();
// Register the MBeanServer
context.registerService(MBeanServer.class.getName(), mbeanServer, null);
log.log(LogService.LOG_DEBUG, "MBeanServer registered");
+ // Register the ManagedBundleService
+ managedBundleService = new ManagedBundleServiceImpl(context, mbeanServer);
+ context.registerService(ManagedBundleService.class.getName(), managedBundleService, null);
+ log.log(LogService.LOG_DEBUG, "ManagedBundleService registered");
+
// Register the ManagedFramework
- new ManagedFramework(context, mbeanServer).start();
+ managedFramework = new ManagedFramework(context, mbeanServer);
+ managedFramework.start();
+
+ // Register all ManagedBundles
+ for (Bundle bundle : context.getBundles())
+ managedBundleService.register(bundle);
jmxHost = context.getProperty(REMOTE_JMX_HOST);
if (jmxHost == null)
@@ -92,6 +106,13 @@
public void stop(BundleContext context)
{
+ // Unregister all ManagedBundles
+ for (Bundle bundle : context.getBundles())
+ managedBundleService.unregister(bundle);
+
+ // Unregister the managed framework
+ managedFramework.stop();
+
stopJMXConnectorService();
}
Copied: projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerLocator.java (from rev 89533, projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerService.java)
===================================================================
--- projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerLocator.java (rev 0)
+++ projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerLocator.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -0,0 +1,78 @@
+/*
+ * 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 java.util.ArrayList;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+
+/**
+ * A service that registers an MBeanServer
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class MBeanServerLocator
+{
+ private LogService log;
+ private MBeanServer mbeanServer;
+
+ @SuppressWarnings("unchecked")
+ public MBeanServerLocator(BundleContext context)
+ {
+ log = new LogServiceTracker(context);
+
+ // Check if there is an MBeanServer service already
+ 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");
+
+ if (serverArr.size() == 1)
+ {
+ mbeanServer = serverArr.get(0);
+ log.log(LogService.LOG_DEBUG, "Found MBeanServer: " + mbeanServer.getDefaultDomain());
+ }
+
+ if (mbeanServer == null)
+ {
+ log.log(LogService.LOG_DEBUG, "No MBeanServer, create one ...");
+ mbeanServer = MBeanServerFactory.createMBeanServer();
+ }
+ }
+ }
+
+ public MBeanServer getMBeanServer()
+ {
+ return mbeanServer;
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerService.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerService.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -1,78 +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 java.util.ArrayList;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-
-import org.jboss.osgi.common.log.LogServiceTracker;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-
-/**
- * A service that registers an MBeanServer
- *
- * @author thomas.diesler at jboss.com
- * @since 24-Apr-2009
- */
-public class MBeanServerService
-{
- private LogService log;
- private MBeanServer mbeanServer;
-
- @SuppressWarnings("unchecked")
- public MBeanServerService(BundleContext context)
- {
- log = new LogServiceTracker(context);
-
- // Check if there is an MBeanServer service already
- 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");
-
- if (serverArr.size() == 1)
- {
- mbeanServer = serverArr.get(0);
- log.log(LogService.LOG_DEBUG, "Found MBeanServer: " + mbeanServer.getDefaultDomain());
- }
-
- if (mbeanServer == null)
- {
- log.log(LogService.LOG_DEBUG, "No MBeanServer, create one ...");
- mbeanServer = MBeanServerFactory.createMBeanServer();
- }
- }
- }
-
- public MBeanServer getMBeanServer()
- {
- return mbeanServer;
- }
-}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleServiceImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleServiceImpl.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -0,0 +1,90 @@
+/*
+ * 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.common.log.LogServiceTracker;
+import org.jboss.osgi.common.service.ManagedBundleService;
+import org.jboss.osgi.spi.management.ManagedBundle;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.log.LogService;
+
+/**
+ * A service that registers an MBeanServer
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class ManagedBundleServiceImpl implements ManagedBundleService
+{
+ private LogService log;
+ private MBeanServer mbeanServer;
+
+ public ManagedBundleServiceImpl(BundleContext context, MBeanServer mbeanServer)
+ {
+ this.log = new LogServiceTracker(context);
+ this.mbeanServer = mbeanServer;
+ }
+
+ public ManagedBundle register(Bundle bundle)
+ {
+ try
+ {
+ ManagedBundle mb = new ManagedBundle(bundle);
+ ObjectName oname = mb.getObjectName();
+
+ log.log(LogService.LOG_DEBUG, "Register managed bundle: " + oname);
+ mbeanServer.registerMBean(mb, oname);
+
+ return mb;
+ }
+ catch (JMException ex)
+ {
+ log.log(LogService.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.log(LogService.LOG_DEBUG, "Unregister managed bundle: " + oname);
+ if (mbeanServer.isRegistered(oname))
+ mbeanServer.unregisterMBean(oname);
+
+ }
+ catch (JMException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot register managed bundle", ex);
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedBundleServiceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties 2009-05-29 21:22:55 UTC (rev 89537)
@@ -73,5 +73,4 @@
org.jboss.osgi.spi.framework.autoStart=\
file://${osgi.home}/server/minimal/bundles/org.apache.felix.log.jar \
file://${osgi.home}/server/minimal/bundles/jboss-osgi-common.jar \
- file://${osgi.home}/server/minimal/bundles/jboss-osgi-jmx.jar \
file://${osgi.home}/server/minimal/bundles/jboss-osgi-hotdeploy.jar
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml 2009-05-29 21:22:55 UTC (rev 89537)
@@ -175,27 +175,37 @@
<include name="log4j.jar" />
</fileset>
- <!-- JBossOSGi Minimal -->
+ <!-- Server Minimal -->
<fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/minimal/bundles" override="true">
<include name="org.apache.felix.log.jar" />
<include name="jboss-osgi-common.jar" />
<include name="jboss-osgi-hotdeploy.jar" />
- <include name="jboss-osgi-jmx.jar" />
</fileset>
+ <!-- Server Default -->
<fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/default/bundles" override="true">
<include name="jboss-osgi-common-core.jar" />
+ <include name="jboss-osgi-jmx.jar" />
<include name="jboss-osgi-jndi.jar" />
+ </fileset>
+
+ <!-- Server Web -->
+ <fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/web/bundles" override="true">
+ <include name="jboss-osgi-common-core.jar" />
+ <include name="jboss-osgi-jmx.jar" />
+ <include name="jboss-osgi-jndi.jar" />
<include name="jboss-osgi-webconsole.jar" />
<include name="org.apache.felix.configadmin.jar" />
<include name="org.apache.felix.http.jetty.jar" />
<include name="org.apache.felix.metatype.jar" />
</fileset>
+ <!-- Server All -->
<fileset dir="@{deploy.artifacts.dir}/lib" targetdir="$INSTALL_PATH/runtime/server/all/bundles" override="true">
<include name="jboss-osgi-apache-xerces.jar" />
<include name="jboss-osgi-common-core.jar" />
<include name="jboss-osgi-jaxb.jar" />
+ <include name="jboss-osgi-jmx.jar" />
<include name="jboss-osgi-jndi.jar" />
<include name="jboss-osgi-microcontainer.jar" />
<include name="jboss-osgi-webconsole.jar" />
Deleted: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/Extender.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/Extender.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/Extender.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -1,87 +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.husky.runtime.osgi;
-
-// $Id$
-
-import org.jboss.osgi.husky.internal.LogServiceTracker;
-import org.jboss.osgi.husky.runtime.Connector;
-import org.jboss.osgi.husky.runtime.junit.JUnitPackageListener;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-
-/**
- * [TODO]
- *
- * @author Thomas.Diesler at jboss.com
- * @since 17-May-2009
- */
-public class Extender implements BundleListener
-{
- private BundleContext context;
- private LogService log;
-
- public Extender(BundleContext context)
- {
- this.log = new LogServiceTracker(context);
- this.context = context;
- }
-
- public void bundleChanged(BundleEvent event)
- {
- if (event.getType() == BundleEvent.STARTED)
- {
- Bundle bundle = event.getBundle();
- String testPackage = (String)bundle.getHeaders().get("Test-Package");
- if (testPackage != null)
- {
- log.log(LogService.LOG_INFO, "Test-Package: " + testPackage + " in bundle: " + bundle);
- registerPackageListener(bundle, testPackage.split("[, ]"));
- }
- }
- }
-
- private void registerPackageListener(Bundle bundle, String[] testPackages)
- {
- ServiceReference[] srefs = null;
- try
- {
- srefs = context.getServiceReferences(Connector.class.getName(), null);
- }
- catch (InvalidSyntaxException ex)
- {
- // cannot get here
- }
-
- for (ServiceReference sref : srefs)
- {
- Connector connector = (Connector)context.getService(sref);
- JUnitPackageListener listener = new OSGiJUnitPackageListener(bundle, testPackages);
- connector.addPackageListener(listener);
- }
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyActivator.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyActivator.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyActivator.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -48,7 +48,7 @@
socketConnector.start();
}
- context.addBundleListener(new Extender(context));
+ context.addBundleListener(new HuskyExtender(context));
}
public void stop(BundleContext context) throws Exception
Copied: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java (from rev 89533, projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/Extender.java)
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java (rev 0)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -0,0 +1,87 @@
+/*
+ * 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.husky.runtime.osgi;
+
+// $Id$
+
+import org.jboss.osgi.husky.internal.LogServiceTracker;
+import org.jboss.osgi.husky.runtime.Connector;
+import org.jboss.osgi.husky.runtime.junit.JUnitPackageListener;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+
+/**
+ * [TODO]
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 17-May-2009
+ */
+public class HuskyExtender implements BundleListener
+{
+ private BundleContext context;
+ private LogService log;
+
+ public HuskyExtender(BundleContext context)
+ {
+ this.log = new LogServiceTracker(context);
+ this.context = context;
+ }
+
+ public void bundleChanged(BundleEvent event)
+ {
+ if (event.getType() == BundleEvent.STARTED)
+ {
+ Bundle bundle = event.getBundle();
+ String testPackage = (String)bundle.getHeaders().get("Test-Package");
+ if (testPackage != null)
+ {
+ log.log(LogService.LOG_INFO, "Test-Package [" + testPackage + "] in bundle: " + bundle);
+ registerPackageListener(bundle, testPackage.split("[, ]"));
+ }
+ }
+ }
+
+ private void registerPackageListener(Bundle bundle, String[] testPackages)
+ {
+ ServiceReference[] srefs = null;
+ try
+ {
+ srefs = context.getServiceReferences(Connector.class.getName(), null);
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ // cannot get here
+ }
+
+ for (ServiceReference sref : srefs)
+ {
+ Connector connector = (Connector)context.getService(sref);
+ JUnitPackageListener listener = new OSGiJUnitPackageListener(bundle, testPackages);
+ connector.addPackageListener(listener);
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/java/org/jboss/test/osgi/husky/context/ContextTestCase.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -72,7 +72,9 @@
{
if (context == null)
{
- bundle.uninstall();
+ if (bundle != null)
+ bundle.uninstall();
+
runtime.shutdown();
}
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -31,6 +31,7 @@
import java.util.Map;
import java.util.Set;
+import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.management.QueryExp;
@@ -82,7 +83,7 @@
{
ObjectName pattern = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=" + symbolicName + ",*");
Set<ObjectName> names = mbeanServer.queryNames(pattern, null);
-
+
if (names.size() < 1)
return null;
@@ -98,7 +99,7 @@
// [JBAS-6571] JMX filtering does not work with wildcards
// ObjectName pattern = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=*,*");
// Set<ObjectName> names = mbeanServer.queryNames(pattern, null);
-
+
ObjectName pattern = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":*");
Set<ObjectName> names = mbeanServer.queryNames(pattern, new IsBundleQueryExp());
return names;
@@ -113,7 +114,7 @@
Map<String, Object> props = new HashMap<String, Object>();
for (String key : sref.getPropertyKeys())
props.put(key, sref.getProperty(key));
-
+
manref = new ManagedServiceReference(clazz, props);
}
return manref;
@@ -130,15 +131,15 @@
Map<String, Object> props = new HashMap<String, Object>();
for (String key : sref.getPropertyKeys())
props.put(key, sref.getProperty(key));
-
+
foundRefs.add(new ManagedServiceReference(clazz, props));
}
}
-
+
ManagedServiceReference[] manrefs = null;
if (foundRefs.size() > 0)
manrefs = foundRefs.toArray(new ManagedServiceReference[foundRefs.size()]);
-
+
return manrefs;
}
@@ -146,7 +147,7 @@
{
ServiceReference sref = systemContext.getServiceReference(PackageAdmin.class.getName());
PackageAdmin service = (PackageAdmin)systemContext.getService(sref);
-
+
Bundle[] bundles = null;
if (symbolicNames != null)
{
@@ -170,12 +171,25 @@
if (mbeanServer != null)
mbeanServer.registerMBean(this, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
}
- catch (Exception ex)
+ catch (JMException ex)
{
log.warn("Cannot register: " + ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
}
}
+ public void stop()
+ {
+ try
+ {
+ if (mbeanServer != null && mbeanServer.isRegistered(MBEAN_MANAGED_FRAMEWORK))
+ mbeanServer.unregisterMBean(ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
+ }
+ catch (JMException ex)
+ {
+ log.warn("Cannot register: " + ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
+ }
+ }
+
// Accept names like "jboss.osgi:bundle=*"
static class IsBundleQueryExp implements QueryExp
{
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -21,12 +21,17 @@
*/
package org.jboss.osgi.spi.testing.internal;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.JarInputStream;
import javax.management.ObjectName;
import javax.naming.InitialContext;
@@ -40,6 +45,7 @@
import org.jboss.osgi.spi.testing.OSGiTestHelper;
import org.jboss.osgi.spi.testing.capability.Capability;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
import org.osgi.service.log.LogReaderService;
/**
@@ -54,7 +60,7 @@
final Logger log = Logger.getLogger(OSGiRuntimeImpl.class);
private OSGiTestHelper helper;
- private Map<String, OSGiBundle> bundles = new HashMap<String, OSGiBundle>();
+ private Map<String, OSGiBundle> capBundles = new HashMap<String, OSGiBundle>();
private List<Capability> capabilities = new ArrayList<Capability>();
private LogReaderService logReaderService;
@@ -85,20 +91,28 @@
OSGiServiceReference sref = getServiceReference(capability.getServiceName());
if (sref == null)
{
- log.debug("Add capability : " + capability);
+ log.debug("Add capability: " + capability);
for (String location : capability.getBundles())
{
- if (bundles.get(location) == null)
+ String symName = getSymbolicName(location);
+ if (capBundles.get(location) == null && getBundle(symName, null) == null)
{
OSGiBundle bundle = installBundle(location);
bundle.start();
-
- bundles.put(location, bundle);
+ capBundles.put(location, bundle);
}
+ else
+ {
+ log.debug("Skip bundle: " + location);
+ }
}
capabilities.add(capability);
}
+ else
+ {
+ log.debug("Skip capability : " + capability);
+ }
}
public void removeCapability(Capability capability)
@@ -106,13 +120,13 @@
if (capabilities.remove(capability))
{
log.debug("Remove capability : " + capability);
-
+
List<String> bundleLocations = capability.getBundles();
Collections.reverse(bundleLocations);
for (String location : bundleLocations)
{
- OSGiBundle bundle = bundles.remove(location);
+ OSGiBundle bundle = capBundles.remove(location);
if (bundle != null)
{
try
@@ -202,4 +216,26 @@
}
return bundle;
}
+
+ protected String getSymbolicName(String location)
+ {
+ String symbolicName = null;
+ try
+ {
+ File archiveFile = getTestHelper().getTestArchiveFile(location);
+ JarInputStream jarInputStream = new JarInputStream(new FileInputStream(archiveFile));
+ Attributes attribs = jarInputStream.getManifest().getMainAttributes();
+ symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
+ jarInputStream.close();
+ }
+ catch (IOException ex)
+ {
+
+ }
+ if (symbolicName == null)
+ throw new IllegalArgumentException("Cannot obtain Bundle-SymbolicName for: " + location);
+
+ return symbolicName;
+ }
+
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteBundle.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteBundle.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -40,11 +40,11 @@
// Provide logging
private static final Logger log = Logger.getLogger(RemoteBundle.class);
- private RemoteRuntime runtime;
+ private OSGiRuntimeImpl runtime;
private ManagedBundleMBean bundle;
private String location;
- public RemoteBundle(RemoteRuntime runtime, ManagedBundleMBean bundle, String location)
+ public RemoteBundle(OSGiRuntimeImpl runtime, ManagedBundleMBean bundle, String location)
{
this.runtime = runtime;
this.bundle = bundle;
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemotePackageAdmin.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemotePackageAdmin.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemotePackageAdmin.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -35,9 +35,9 @@
*/
public class RemotePackageAdmin implements OSGiPackageAdmin
{
- private RemoteRuntime runtime;
+ private OSGiRuntimeImpl runtime;
- public RemotePackageAdmin(RemoteRuntime runtime)
+ public RemotePackageAdmin(OSGiRuntimeImpl runtime)
{
this.runtime = runtime;
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-05-29 17:37:17 UTC (rev 89536)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-05-29 21:22:55 UTC (rev 89537)
@@ -23,13 +23,8 @@
// $Id$
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
-import java.util.jar.Attributes;
-import java.util.jar.JarInputStream;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
@@ -50,7 +45,6 @@
import org.jboss.osgi.spi.testing.capability.RemoteLogCapability;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogReaderService;
@@ -78,24 +72,9 @@
public OSGiBundle installBundle(String location) throws BundleException
{
- String symbolicName = null;
+ String symbolicName = getSymbolicName(location);
try
{
- File archiveFile = getTestHelper().getTestArchiveFile(location);
- JarInputStream jarInputStream = new JarInputStream(new FileInputStream(archiveFile));
- Attributes attribs = jarInputStream.getManifest().getMainAttributes();
- symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
- jarInputStream.close();
- }
- catch (IOException ex)
- {
-
- }
- if (symbolicName == null)
- throw new IllegalArgumentException("Cannot obtain Bundle-SymbolicName for: " + location);
-
- try
- {
deploy(location);
ManagedBundleMBean bundle = getRemoteFramework().getBundle(symbolicName);
return new RemoteBundle(this, bundle, location);
@@ -109,7 +88,7 @@
throw new BundleException("Cannot install: " + location, ex);
}
}
-
+
public OSGiBundle[] getBundles()
{
try
@@ -224,7 +203,7 @@
return new RemotePackageAdmin(this);
}
- private RemoteFramework getRemoteFramework()
+ RemoteFramework getRemoteFramework()
{
try
{
More information about the jboss-osgi-commits
mailing list