JBoss-OSGI SVN: r89545 - in projects/jboss-osgi/trunk: bundles/common/src/main/java/org/jboss/osgi/common/service and 5 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-30 06:24:42 -0400 (Sat, 30 May 2009)
New Revision: 89545
Removed:
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceTracker.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/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceDelegate.java
projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
projects/jboss-osgi/trunk/runtime/equinox/src/main/resources/osgi-deployers-jboss-beans.xml
projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-deployers-jboss-beans.xml
projects/jboss-osgi/trunk/runtime/knopflerfish/src/main/resources/osgi-deployers-jboss-beans.xml
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HuskyCapability.java
Log:
DeployerServiceDelegate uses provider=microcontainer and falls back provider=system
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-30 00:02:39 UTC (rev 89544)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/CommonServicesActivator.java 2009-05-30 10:24:42 UTC (rev 89545)
@@ -23,6 +23,8 @@
//$Id$
+import java.util.Properties;
+
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.StandardMBean;
@@ -54,6 +56,12 @@
// Track LogReaderService and add/remove LogListener
trackLogReaderService(context);
+ // Register the system DeployerService
+ Properties props = new Properties();
+ props.setProperty("provider", "system");
+ SimpleDeployerService service = new SimpleDeployerService(context);
+ context.registerService(DeployerService.class.getName(), service, props);
+
// Register the DeployerServiceDelegate
DeployerServiceDelegate delegate = new DeployerServiceDelegate(context);
context.registerService(DeployerServiceDelegate.class.getName(), delegate, null);
Deleted: 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/internal/DeployerServiceTracker.java 2009-05-30 00:02:39 UTC (rev 89544)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceTracker.java 2009-05-30 10:24:42 UTC (rev 89545)
@@ -1,77 +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 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(a)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-30 00:02:39 UTC (rev 89544)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/SimpleDeployerService.java 2009-05-30 10:24:42 UTC (rev 89545)
@@ -95,7 +95,7 @@
}
}
- public void undeploy(BundleInfo[] bundleInfos) throws Exception
+ public void undeploy(BundleInfo[] bundleInfos) throws BundleException
{
for (BundleInfo info : bundleInfos)
undeploy(info.getLocation());
@@ -104,7 +104,7 @@
// Note, in contrary to deploy(BundleInfo[]) this
// method does not start the bundle. The client
// is expected to do that
- public void deploy(URL url) throws Exception
+ public void deploy(URL url) throws BundleException
{
Bundle bundle = context.installBundle(url.toExternalForm());
log.log(LogService.LOG_INFO, "Installed: " + bundle);
@@ -112,7 +112,7 @@
registerManagedBundle(bundle);
}
- public void undeploy(URL url) throws Exception
+ public boolean undeploy(URL url) throws BundleException
{
Bundle bundle = deployments.remove(url.toExternalForm());
if (bundle != null)
@@ -120,10 +120,12 @@
unregisterManagedBundle(bundle);
bundle.uninstall();
log.log(LogService.LOG_INFO, "Uninstalled: " + bundle);
+ return true;
}
else
{
log.log(LogService.LOG_WARNING, "Cannot find bundle for: " + url);
+ return false;
}
}
Modified: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java 2009-05-30 00:02:39 UTC (rev 89544)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java 2009-05-30 10:24:42 UTC (rev 89545)
@@ -26,41 +26,49 @@
import javax.management.ObjectName;
import org.jboss.osgi.spi.management.ObjectNameFactory;
+import org.osgi.framework.BundleException;
//$Id$
-
/**
- * A Service that can be used to deploy bundles or archives
- * to the runtime.
+ * A Service that can be used to deploy/undeploy bundles or archives to/from the runtime.
*
* @author thomas.diesler(a)jboss.com
* @since 23-Jan-2009
*/
public interface DeployerService
{
- /**
- * The object name under which this is registered: 'jboss.osgi:service=DeployerService'
+ /**
+ * The object name under which this is registered: 'jboss.osgi:service=DeployerService'
*/
ObjectName MBEAN_DEPLOYER_SERVICE = ObjectNameFactory.create("jboss.osgi:service=DeployerService");
-
+
/**
* Deploy an array of bundles
*/
- void deploy(BundleInfo[] bundles) throws Exception;
+ void deploy(BundleInfo[] bundles) throws BundleException;
/**
* Undeploy an array of bundles
*/
- void undeploy(BundleInfo[] bundles) throws Exception;
+ void undeploy(BundleInfo[] bundles) throws BundleException;
- /**
- * Deploy MC beans from URL
+ /**
+ * Deploy bundle from URL
*/
- void deploy(URL url) throws Exception;
+ void deploy(URL url) throws BundleException;
/**
- * Undeploy MC beans from URL
+ * Undeploy bundle from URL.
+ *
+ * Note, due to the dynamic nature of OSGi services it is
+ * possible that a {@link DeployerService} is asked to undeploy
+ * a bundle URL which it did not deploy itself.
+ *
+ * In this case this method should return false, so that the
+ * {@link DeployerServiceDelegate} can use another {@link DeployerService}
+ *
+ * @return true if thhis service could undeploy the bundle
*/
- void undeploy(URL url) throws Exception;
+ boolean undeploy(URL url) throws BundleException;
}
\ No newline at end of file
Modified: 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/DeployerServiceDelegate.java 2009-05-30 00:02:39 UTC (rev 89544)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceDelegate.java 2009-05-30 10:24:42 UTC (rev 89545)
@@ -24,17 +24,15 @@
//$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;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
/**
- * A {@link DeployerService} that delegates to the service that is tracked
- * by the given {@link DeployerServiceTracker}
+ * A {@link DeployerService} that delegates to the service that is tracked by the given {@link DeployerServiceTracker}
*
* This delegate is registered as an MBean
*
@@ -44,50 +42,86 @@
public class DeployerServiceDelegate implements DeployerService
{
private LogServiceTracker log;
+ private BundleContext context;
- 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();
+ this.log = new LogServiceTracker(context);
+ this.context = context;
}
- public void deploy(BundleInfo[] bundles) throws Exception
+ public void deploy(BundleInfo[] bundles) throws BundleException
{
- DeployerService service = tracker.getService();
- for (BundleInfo info : bundles)
- serviceMap.put(info.getLocation().toString(), service);
-
+ DeployerService service = getDefaultDeployerService();
service.deploy(bundles);
}
- public void deploy(URL url) throws Exception
+ public void deploy(URL url) throws BundleException
{
- DeployerService service = tracker.getService();
- serviceMap.put(url.toString(), service);
+ DeployerService service = getDefaultDeployerService();
service.deploy(url);
}
- public void undeploy(BundleInfo[] bundles) throws Exception
+ public void undeploy(BundleInfo[] bundles) throws BundleException
{
for (BundleInfo info : bundles)
undeploy(info.getLocation());
}
- public void undeploy(URL url) throws Exception
+ public boolean undeploy(URL url) throws BundleException
{
- DeployerService service = serviceMap.remove(url.toString());
+ boolean undeployed = false;
+
+ DeployerService service = getMicrocontainerDeployerService();
if (service != null)
+ undeployed = service.undeploy(url);
+
+ if (undeployed == false)
{
- service.undeploy(url);
+ service = getSystemDeployerService();
+ undeployed = service.undeploy(url);
}
- else
+
+ return undeployed;
+ }
+
+ private DeployerService getDefaultDeployerService()
+ {
+ // First try the MC provider
+ DeployerService service = getMicrocontainerDeployerService();
+
+ // Fall back to the system provider
+ if (service == null)
+ service = getSystemDeployerService();
+
+ return service;
+ }
+
+ private DeployerService getMicrocontainerDeployerService()
+ {
+ DeployerService service = null;
+
+ try
{
- log.log(LogService.LOG_WARNING, "Cannot find DeployerService for: " + url);
+ String filter = "(provider=microcontainer)";
+ String serviceName = DeployerService.class.getName();
+ ServiceReference[] srefs = context.getServiceReferences(serviceName, filter);
+ if (srefs != null)
+ service = (DeployerService)context.getService(srefs[0]);
}
+ catch (InvalidSyntaxException ex)
+ {
+ throw new IllegalArgumentException(ex);
+ }
+
+ return service;
}
+
+ private DeployerService getSystemDeployerService()
+ {
+ String serviceName = DeployerService.class.getName();
+ ServiceReference sref = context.getServiceReference(serviceName);
+ return (DeployerService)context.getService(sref);
+ }
+
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-05-30 00:02:39 UTC (rev 89544)
+++ projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-05-30 10:24:42 UTC (rev 89545)
@@ -23,13 +23,13 @@
//$Id$
-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.Properties;
import javax.management.MBeanServer;
import javax.management.StandardMBean;
@@ -43,7 +43,6 @@
import org.jboss.dependency.spi.ControllerState;
import org.jboss.deployers.client.spi.Deployment;
import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.kernel.Kernel;
@@ -58,6 +57,7 @@
import org.jboss.virtual.VFS;
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
import org.osgi.util.tracker.ServiceTracker;
@@ -112,7 +112,7 @@
return context != null ? context.getTarget() : null;
}
- public void deploy(BundleInfo[] bundles) throws Exception
+ public void deploy(BundleInfo[] bundles) throws BundleException
{
ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
try
@@ -137,44 +137,80 @@
Deployment[] depArr = deployments.toArray(new Deployment[deployments.size()]);
mainDeployer.checkComplete(depArr);
}
- catch (IOException ex)
+ catch (RuntimeException rte)
{
- DeploymentException.rethrowAsDeploymentException("Cannot deploy bundles: ", ex);
+ throw rte;
}
+ catch (Exception ex)
+ {
+ throw new BundleException("Cannot deploy bundles", ex);
+ }
finally
{
Thread.currentThread().setContextClassLoader(ctxLoader);
}
}
- public void undeploy(BundleInfo[] bundles) throws Exception
+ public void undeploy(BundleInfo[] bundles) throws BundleException
{
- MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
- for (BundleInfo bundle : bundles)
+ try
{
- String deploymentName = contextMap.remove(bundle.getLocation());
- if (deploymentName != null)
+ MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
+ for (BundleInfo bundle : bundles)
{
- mainDeployer.removeDeployment(deploymentName);
+ String deploymentName = contextMap.remove(bundle.getLocation());
+ if (deploymentName != null)
+ {
+ mainDeployer.removeDeployment(deploymentName);
+ }
+ else
+ {
+ log.log(LogService.LOG_WARNING, "Package not deployed: " + bundle.getLocation());
+ }
}
- else
- {
- log.log(LogService.LOG_WARNING, "Package not deployed: " + bundle.getLocation());
- }
+ mainDeployer.process();
}
- mainDeployer.process();
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ log.log(LogService.LOG_WARNING, "Cannot undeploy bundles", ex);
+ }
}
- public void deploy(URL url) throws Exception
+ public void deploy(URL url) throws BundleException
{
BundleInfo info = new LocationOnlyBundleInfo(url);
deploy(new BundleInfo[] { info });
}
- public void undeploy(URL url) throws Exception
+ public boolean undeploy(URL url) throws BundleException
{
- BundleInfo info = new LocationOnlyBundleInfo(url);
- undeploy(new BundleInfo[] { info });
+ String deploymentName = contextMap.remove(url);
+ if (deploymentName == null)
+ {
+ log.log(LogService.LOG_WARNING, "Package not deployed: " + url);
+ return false;
+ }
+
+ try
+ {
+ MainDeployer mainDeployer = (MainDeployer)getRegisteredBean("MainDeployer");
+ mainDeployer.removeDeployment(deploymentName);
+ mainDeployer.process();
+ return true;
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ log.log(LogService.LOG_WARNING, "Cannot undeploy bundle", ex);
+ return false;
+ }
}
void start()
@@ -208,8 +244,10 @@
context.registerService(MicrocontainerService.class.getName(), mcServiceImpl, null);
// Register the DeployerService
+ Properties props = new Properties();
+ props.setProperty("provider", "microcontainer");
log.log(LogService.LOG_DEBUG, "Register DeployerService");
- context.registerService(DeployerService.class.getName(), mcServiceImpl, null);
+ context.registerService(DeployerService.class.getName(), mcServiceImpl, props);
// Register the MicrocontainerServiceMBean
registerMicrocontainerServiceMBean(mbeanServer);
Modified: projects/jboss-osgi/trunk/runtime/equinox/src/main/resources/osgi-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/equinox/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-30 00:02:39 UTC (rev 89544)
+++ projects/jboss-osgi/trunk/runtime/equinox/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-30 10:24:42 UTC (rev 89545)
@@ -29,10 +29,11 @@
javax.management,
javax.xml.parsers,
org.jboss.logging,
- org.jboss.osgi.spi.service,
- org.jboss.osgi.spi.management,
- org.jboss.osgi.spi.testing,
- org.jboss.osgi.spi.testing.capability,
+ org.jboss.osgi.spi;version=1.0,
+ org.jboss.osgi.spi.logging;version=1.0,
+ org.jboss.osgi.spi.management;version=1.0,
+ org.jboss.osgi.spi.testing;version=1.0,
+ org.jboss.osgi.spi.testing.capability;version=1.0,
org.osgi.framework; version=1.4,
org.osgi.service.packageadmin; version=1.2,
org.osgi.service.startlevel; version=1.1,
Modified: projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-30 00:02:39 UTC (rev 89544)
+++ projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-30 10:24:42 UTC (rev 89545)
@@ -30,11 +30,11 @@
org.jboss.osgi.jndi,
org.jboss.osgi.jmx,
org.jboss.osgi.microcontainer,
- org.jboss.osgi.spi,
- org.jboss.osgi.spi.logging,
- org.jboss.osgi.spi.management,
- org.jboss.osgi.spi.testing,
- org.jboss.osgi.spi.testing.capability,
+ org.jboss.osgi.spi;version=1.0,
+ org.jboss.osgi.spi.logging;version=1.0,
+ org.jboss.osgi.spi.management;version=1.0,
+ org.jboss.osgi.spi.testing;version=1.0,
+ org.jboss.osgi.spi.testing.capability;version=1.0,
org.jboss.xb.binding;version=2.0,
org.jboss.xb.binding.sunday.unmarshalling;version=2.0,
Modified: projects/jboss-osgi/trunk/runtime/knopflerfish/src/main/resources/osgi-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/knopflerfish/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-30 00:02:39 UTC (rev 89544)
+++ projects/jboss-osgi/trunk/runtime/knopflerfish/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-30 10:24:42 UTC (rev 89545)
@@ -28,10 +28,11 @@
javax.management,
javax.xml.parsers,
org.jboss.logging,
- org.jboss.osgi.spi.service,
- org.jboss.osgi.spi.management,
- org.jboss.osgi.spi.testing,
- org.jboss.osgi.spi.testing.capability,
+ org.jboss.osgi.spi;version=1.0,
+ org.jboss.osgi.spi.logging;version=1.0,
+ org.jboss.osgi.spi.management;version=1.0,
+ org.jboss.osgi.spi.testing;version=1.0,
+ org.jboss.osgi.spi.testing.capability;version=1.0,
org.osgi.framework; version=1.4,
org.osgi.service.packageadmin; version=1.2,
org.osgi.service.startlevel; version=1.1,
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HuskyCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HuskyCapability.java 2009-05-30 00:02:39 UTC (rev 89544)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HuskyCapability.java 2009-05-30 10:24:42 UTC (rev 89545)
@@ -38,6 +38,7 @@
// [TODO] make this a reference
super("org.jboss.osgi.husky.runtime.Connector");
+ addBundles(new JMXCapability().getBundles());
addBundle("bundles/jboss-osgi-husky.jar");
}
}
\ No newline at end of file
16 years, 6 months
JBoss-OSGI SVN: r89542 - in projects/jboss-osgi/trunk: bundles/common/src/main/java/org/jboss/osgi/common/internal and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-29 18:35:40 -0400 (Fri, 29 May 2009)
New Revision: 89542
Modified:
projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/SimpleDeployerService.java
projects/jboss-osgi/trunk/distribution/runtime/bin/run.conf
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java
Log:
Simple URL deployment should not get started
Modified: projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java 2009-05-29 22:02:05 UTC (rev 89541)
+++ projects/jboss-osgi/trunk/blueprint/testsuite/src/test/java/org/jboss/test/osgi/blueprint/context/BlueprintContextTestCase.java 2009-05-29 22:35:40 UTC (rev 89542)
@@ -33,7 +33,6 @@
import org.jboss.osgi.spi.testing.OSGiTest;
import org.jboss.osgi.spi.testing.capability.BlueprintCapability;
import org.jboss.osgi.spi.testing.capability.HuskyCapability;
-import org.jboss.osgi.spi.testing.capability.JMXCapability;
import org.jboss.osgi.spi.testing.capability.MicrocontainerCapability;
import org.junit.After;
import org.junit.Before;
@@ -65,7 +64,6 @@
if (context == null)
{
runtime = getDefaultRuntime();
- runtime.addCapability(new JMXCapability());
runtime.addCapability(new HuskyCapability());
runtime.addCapability(new MicrocontainerCapability());
runtime.addCapability(new BlueprintCapability());
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 22:02:05 UTC (rev 89541)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/SimpleDeployerService.java 2009-05-29 22:35:40 UTC (rev 89542)
@@ -101,13 +101,15 @@
undeploy(info.getLocation());
}
+ // Note, in contrary to deploy(BundleInfo[]) this
+ // method does not start the bundle. The client
+ // is expected to do that
public void deploy(URL url) throws Exception
{
Bundle bundle = context.installBundle(url.toExternalForm());
log.log(LogService.LOG_INFO, "Installed: " + bundle);
deployments.put(url.toExternalForm(), bundle);
registerManagedBundle(bundle);
- bundle.start();
}
public void undeploy(URL url) throws Exception
Modified: projects/jboss-osgi/trunk/distribution/runtime/bin/run.conf
===================================================================
--- projects/jboss-osgi/trunk/distribution/runtime/bin/run.conf 2009-05-29 22:02:05 UTC (rev 89541)
+++ projects/jboss-osgi/trunk/distribution/runtime/bin/run.conf 2009-05-29 22:35:40 UTC (rev 89542)
@@ -29,7 +29,7 @@
fi
# Sample JPDA settings for remote socket debuging
-#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"
+#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
# Sample JPDA settings for shared memory debugging
#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_shmem,server=y,suspend=n,address=jboss"
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 22:02:05 UTC (rev 89541)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-05-29 22:35:40 UTC (rev 89542)
@@ -203,6 +203,13 @@
return new RemotePackageAdmin(this);
}
+ @Override
+ public void shutdown()
+ {
+ super.shutdown();
+ getPackageAdmin().refreshPackages(null);
+ }
+
RemoteFramework getRemoteFramework()
{
try
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java 2009-05-29 22:02:05 UTC (rev 89541)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java 2009-05-29 22:35:40 UTC (rev 89542)
@@ -44,7 +44,6 @@
import org.jboss.osgi.spi.testing.OSGiRuntime;
import org.jboss.osgi.spi.testing.OSGiTest;
import org.jboss.osgi.spi.testing.OSGiTestHelper;
-import org.jboss.osgi.spi.testing.capability.JMXCapability;
import org.jboss.osgi.spi.testing.capability.JNDICapability;
import org.jboss.osgi.spi.testing.capability.MicrocontainerCapability;
import org.junit.AfterClass;
16 years, 6 months
JBoss-OSGI SVN: r89540 - projects/jboss-osgi/trunk/distribution/runtime/bin.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-29 17:56:43 -0400 (Fri, 29 May 2009)
New Revision: 89540
Modified:
projects/jboss-osgi/trunk/distribution/runtime/bin/run.sh
Log:
Use OSGiBootstrap as main
Modified: projects/jboss-osgi/trunk/distribution/runtime/bin/run.sh
===================================================================
--- projects/jboss-osgi/trunk/distribution/runtime/bin/run.sh 2009-05-29 21:51:10 UTC (rev 89539)
+++ projects/jboss-osgi/trunk/distribution/runtime/bin/run.sh 2009-05-29 21:56:43 UTC (rev 89540)
@@ -142,7 +142,7 @@
# Execute the JVM in the foreground
"$JAVA" $JAVA_OPTS \
-classpath "$OSGI_CLASSPATH" \
- -Dmainclass=org.jboss.osgi.spi.framework.OSGiBootstrap org.kohsuke.args4j.Starter "$@" &
+ org.jboss.osgi.spi.framework.OSGiBootstrap "$@" &
OSGI_PID=$!
echo $OSGI_PID > $OSGI_HOME/bin/pid.txt
@@ -162,7 +162,7 @@
if [ "${WAIT_STATUS}" -gt 128 ]; then
SIGNAL=`expr ${WAIT_STATUS} - 128`
SIGNAL_NAME=`kill -l ${SIGNAL}`
- echo "*** OSGi Runtime process (${OSGI_PID}) received ${SIGNAL_NAME} signal ***" >&2
+ # echo "*** OSGi Runtime process (${OSGI_PID}) received ${SIGNAL_NAME} signal ***" >&2
fi
done
if [ "${WAIT_STATUS}" -lt 127 ]; then
16 years, 6 months
JBoss-OSGI SVN: r89539 - projects/jboss-osgi/trunk/hudson/hudson-home.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-29 17:51:10 -0400 (Fri, 29 May 2009)
New Revision: 89539
Modified:
projects/jboss-osgi/trunk/hudson/hudson-home/command.sh
Log:
fix typo
Modified: projects/jboss-osgi/trunk/hudson/hudson-home/command.sh
===================================================================
--- projects/jboss-osgi/trunk/hudson/hudson-home/command.sh 2009-05-29 21:44:49 UTC (rev 89538)
+++ projects/jboss-osgi/trunk/hudson/hudson-home/command.sh 2009-05-29 21:51:10 UTC (rev 89539)
@@ -96,7 +96,7 @@
# Just wait 10sec for it to come up.
#
if [ "$CONTAINER" = "runtime" ]; then
- SLEEP_TIME = 10
+ SLEEP_TIME=10
echo "Wait $SLEEP_TIME seconds"
sleep $SLEEP_TIME
fi
@@ -125,11 +125,3 @@
# stop jbossas
#
$HUDSONBIN/startup.sh $RUNTIME_HOME stop
-
-#
-# copy test.log to workspace
-#
-TESTLOG=$OSGIDIR/testsuite/functional/target/test.log
-if [ -e $TESTLOG ]; then
- cp $TESTLOG $WORKSPACE/functional_testlog_build_$BUILD_NUMBER.txt
-fi
\ No newline at end of file
16 years, 6 months
JBoss-OSGI SVN: r89538 - projects/jboss-osgi/trunk/hudson/hudson-home.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-29 17:44:49 -0400 (Fri, 29 May 2009)
New Revision: 89538
Modified:
projects/jboss-osgi/trunk/hudson/hudson-home/command.sh
Log:
default runtime profile has no HttpService
Modified: projects/jboss-osgi/trunk/hudson/hudson-home/command.sh
===================================================================
--- projects/jboss-osgi/trunk/hudson/hudson-home/command.sh 2009-05-29 21:22:55 UTC (rev 89537)
+++ projects/jboss-osgi/trunk/hudson/hudson-home/command.sh 2009-05-29 21:44:49 UTC (rev 89538)
@@ -51,7 +51,7 @@
;;
'runtime')
RUNTIME_HOME=$DISTRODIR/auto-install-dest/runtime
- RUNTIME_LOG=$RUNTIME_HOME/log/server.log
+ RUNTIME_LOG=$RUNTIME_HOME/server/$JBOSS_SERVER/log/server.log
;;
*)
echo "Unsupported container: $CONTAINER"
@@ -87,16 +87,30 @@
echo $MVN_CMD; $MVN_CMD | tee $WORKSPACE/dependency-tree.txt
#
-# start jbossas
+# start jbossas/runtime
#
$HUDSONBIN/startup.sh $RUNTIME_HOME start $JBOSS_BINDADDR
+#
+# The default runtime profile has no HttpService
+# Just wait 10sec for it to come up.
+#
+if [ "$CONTAINER" = "runtime" ]; then
+ SLEEP_TIME = 10
+ echo "Wait $SLEEP_TIME seconds"
+ sleep $SLEEP_TIME
+fi
+
+#
# Was it successfully started?
-$HUDSONBIN/http-spider.sh $JBOSS_BINDADDR:8090/jboss-osgi $WORKSPACE
-if [ -e $WORKSPACE/spider.failed ]; then
- tail -n 200 $RUNTIME_LOG
- $HUDSONBIN/startup.sh $RUNTIME_HOME stop
- exit 1
+#
+if [ "$CONTAINER" != "runtime" ]; then
+ $HUDSONBIN/http-spider.sh $JBOSS_BINDADDR:8090/jboss-osgi $WORKSPACE
+ if [ -e $WORKSPACE/spider.failed ]; then
+ tail -n 200 $RUNTIME_LOG
+ $HUDSONBIN/startup.sh $RUNTIME_HOME stop
+ exit 1
+ fi
fi
#
16 years, 6 months
JBoss-OSGI SVN: r89537 - in projects/jboss-osgi/trunk: bundles/common/src/main/java/org/jboss/osgi/common/service and 10 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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(a)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
{
16 years, 6 months
JBoss-OSGI SVN: r89536 - in projects/jboss-osgi/trunk: distribution/runtime/conf and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-29 13:37:17 -0400 (Fri, 29 May 2009)
New Revision: 89536
Modified:
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/SimpleDeployerService.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/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HuskyCapability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
Log:
SimpleDeployerService registers ManagedBundle
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 16:58:50 UTC (rev 89535)
+++ 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)
@@ -30,13 +30,19 @@
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.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
/**
@@ -49,7 +55,7 @@
{
private LogServiceTracker log;
private BundleContext context;
-
+
private Map<URI, Bundle> urlDeployments = new HashMap<URI, Bundle>();
public SimpleDeployerService(BundleContext context)
@@ -68,6 +74,7 @@
{
log.log(LogService.LOG_DEBUG, "Install: " + info.getSymbolicName());
Bundle bundle = context.installBundle(info.getLocation().toExternalForm());
+ registerManagedBundle(bundle);
bundles.add(bundle);
}
catch (BundleException ex)
@@ -116,6 +123,7 @@
log.log(LogService.LOG_DEBUG, "Install: " + url);
Bundle bundle = context.installBundle(url.toExternalForm());
urlDeployments.put(url.toURI(), bundle);
+ registerManagedBundle(bundle);
bundle.start();
}
@@ -128,4 +136,27 @@
bundle.uninstall();
}
}
+
+ private void registerManagedBundle(Bundle bundle)
+ {
+ ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
+ if (sref == null)
+ {
+ log.log(LogService.LOG_WARNING, "No MBeanServer. Cannot register managed bundle: " + bundle.getSymbolicName());
+ return;
+ }
+
+ MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
+ ManagedBundle mb = new ManagedBundle(bundle);
+ ObjectName oname = mb.getObjectName();
+ try
+ {
+ log.log(LogService.LOG_DEBUG, "Register managed bundle: " + oname);
+ mbeanServer.registerMBean(mb, oname);
+ }
+ catch (JMException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot register managed bundle", ex);
+ }
+ }
}
\ No newline at end of file
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 16:58:50 UTC (rev 89535)
+++ projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties 2009-05-29 17:37:17 UTC (rev 89536)
@@ -73,4 +73,5 @@
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 16:58:50 UTC (rev 89535)
+++ projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml 2009-05-29 17:37:17 UTC (rev 89536)
@@ -180,11 +180,11 @@
<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>
<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" />
<include name="jboss-osgi-webconsole.jar" />
<include name="org.apache.felix.configadmin.jar" />
@@ -196,7 +196,6 @@
<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" />
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HuskyCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HuskyCapability.java 2009-05-29 16:58:50 UTC (rev 89535)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HuskyCapability.java 2009-05-29 17:37:17 UTC (rev 89536)
@@ -37,6 +37,7 @@
{
// [TODO] make this a reference
super("org.jboss.osgi.husky.runtime.Connector");
+
addBundle("bundles/jboss-osgi-husky.jar");
}
}
\ No newline at end of file
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 16:58:50 UTC (rev 89535)
+++ 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)
@@ -240,13 +240,13 @@
{
public ManagedBundleMBean getBundle(String symbolicName)
{
- ObjectName bundleOName = managedFramework.getBundle(symbolicName);
- if (bundleOName == null)
- throw new IllegalArgumentException("Cannot remote bundle for: " + symbolicName);
+ ObjectName oname = managedFramework.getBundle(symbolicName);
+ if (oname == null)
+ throw new IllegalArgumentException("Cannot get remote bundle for: " + symbolicName);
try
{
- return MBeanProxy.get(ManagedBundleMBean.class, bundleOName, getMBeanServer());
+ return MBeanProxy.get(ManagedBundleMBean.class, oname, getMBeanServer());
}
catch (MBeanProxyException ex)
{
16 years, 6 months
JBoss-OSGI SVN: r89534 - in projects/jboss-osgi/trunk: bundles/common/src/main/java/org/jboss/osgi/common/internal and 6 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-29 12:40:23 -0400 (Fri, 29 May 2009)
New Revision: 89534
Added:
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/SimpleDeployerService.java
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceTracker.java
Removed:
projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java
Modified:
projects/jboss-osgi/trunk/bundles/common/pom.xml
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/service/DeployerService.java
projects/jboss-osgi/trunk/bundles/hotdeploy/pom.xml
projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java
projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-felix.properties
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java
Log:
Register DeployerService as part of common services
Modified: projects/jboss-osgi/trunk/bundles/common/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/pom.xml 2009-05-29 14:50:22 UTC (rev 89533)
+++ projects/jboss-osgi/trunk/bundles/common/pom.xml 2009-05-29 16:40:23 UTC (rev 89534)
@@ -18,6 +18,11 @@
<!-- Dependencies -->
<dependencies>
<dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-spi</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-spi</artifactId>
<scope>provided</scope>
@@ -54,7 +59,9 @@
org.jboss.osgi.common.internal
</Private-Package>
<Import-Package>
+ javax.management,
org.jboss.logging,
+ org.jboss.osgi.spi.management;version="1.0",
org.osgi.framework;version=1.4,
org.osgi.service.log;version=1.3,
org.osgi.util.tracker
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 14:50:22 UTC (rev 89533)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/CommonServicesActivator.java 2009-05-29 16:40:23 UTC (rev 89534)
@@ -23,10 +23,18 @@
//$Id$
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.StandardMBean;
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.jboss.osgi.common.service.DeployerService;
+import org.jboss.osgi.common.service.DeployerServiceTracker;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogReaderService;
+import org.osgi.service.log.LogService;
import org.osgi.util.tracker.ServiceTracker;
/**
@@ -37,8 +45,12 @@
*/
public class CommonServicesActivator implements BundleActivator
{
+ private LogService log;
+
public void start(BundleContext context)
{
+ log = new LogServiceTracker(context);
+
// Track LogReaderService and add/remove LogListener
ServiceTracker logTracker = new ServiceTracker(context, LogReaderService.class.getName(), null)
{
@@ -51,6 +63,49 @@
}
};
logTracker.open();
+
+ // Track the DeployerService
+ final DeployerServiceTracker serviceTracker = new DeployerServiceTracker(context);
+ serviceTracker.open();
+
+ // Track the MBeanServer and register the DeployerServiceTracker
+ ServiceTracker jmxTracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ 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);
+ }
+ catch (JMException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot register DeployerService MBean", ex);
+ }
+ return mbeanServer;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ MBeanServer mbeanServer = (MBeanServer)service;
+ try
+ {
+ if (mbeanServer.isRegistered(DeployerService.MBEAN_DEPLOYER_SERVICE))
+ mbeanServer.unregisterMBean(DeployerService.MBEAN_DEPLOYER_SERVICE);
+ }
+ catch (JMException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot unregister DeployerService MBean", ex);
+ }
+
+ super.removedService(reference, service);
+ }
+ };
+ jmxTracker.open();
}
public void stop(BundleContext context)
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java 2009-05-29 16:40:23 UTC (rev 89534)
@@ -0,0 +1,69 @@
+/*
+ * 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(a)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
Property changes on: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/SimpleDeployerService.java (from rev 89533, projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java)
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/SimpleDeployerService.java (rev 0)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/internal/SimpleDeployerService.java 2009-05-29 16:40:23 UTC (rev 89534)
@@ -0,0 +1,131 @@
+/*
+ * 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.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.service.log.LogService;
+
+/**
+ * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 27-May-2009
+ */
+public class SimpleDeployerService implements DeployerService
+{
+ private LogServiceTracker log;
+ private BundleContext context;
+
+ private Map<URI, Bundle> urlDeployments = new HashMap<URI, Bundle>();
+
+ public SimpleDeployerService(BundleContext context)
+ {
+ this.log = new LogServiceTracker(context);
+ this.context = context;
+ }
+
+ public void deploy(BundleInfo[] bundleInfos) throws BundleException
+ {
+ // Install the NEW bundles
+ List<Bundle> bundles = new ArrayList<Bundle>();
+ for (BundleInfo info : bundleInfos)
+ {
+ try
+ {
+ log.log(LogService.LOG_DEBUG, "Install: " + info.getSymbolicName());
+ Bundle bundle = context.installBundle(info.getLocation().toExternalForm());
+ bundles.add(bundle);
+ }
+ catch (BundleException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot install bundle: " + info.getSymbolicName(), ex);
+ }
+ }
+
+ // Start the installed bundles
+ for (Bundle bundle : bundles)
+ {
+ try
+ {
+ log.log(LogService.LOG_DEBUG, "Start: " + bundle.getSymbolicName());
+ bundle.start();
+ }
+ catch (BundleException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot start bundle: " + bundle.getSymbolicName(), ex);
+ }
+ }
+ }
+
+ public void undeploy(BundleInfo[] bundleInfos) throws BundleException
+ {
+ 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);
+ }
+ }
+ }
+ }
+
+ 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);
+ bundle.start();
+ }
+
+ public void undeploy(URL url) throws Exception
+ {
+ Bundle bundle = urlDeployments.remove(url.toURI());
+ if (bundle != null)
+ {
+ log.log(LogService.LOG_DEBUG, "Uninstall: " + bundle.getSymbolicName());
+ bundle.uninstall();
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java 2009-05-29 14:50:22 UTC (rev 89533)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java 2009-05-29 16:40:23 UTC (rev 89534)
@@ -23,18 +23,27 @@
import java.net.URL;
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.management.ObjectNameFactory;
+
//$Id$
/**
- * A Service that deploys bundles through the deployers that
- * are registered with the {@link MicrocontainerService}
+ * A Service that can be used to deploy bundles or archives
+ * to the runtime.
*
* @author thomas.diesler(a)jboss.com
* @since 23-Jan-2009
*/
public interface DeployerService
{
+ /**
+ * The object name under which this is registered: 'jboss.osgi:service=DeployerService'
+ */
+ ObjectName MBEAN_DEPLOYER_SERVICE = ObjectNameFactory.create("jboss.osgi:service=DeployerService");
+
/**
* Deploy an array of bundles
*/
Added: 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 (rev 0)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceTracker.java 2009-05-29 16:40:23 UTC (rev 89534)
@@ -0,0 +1,95 @@
+/*
+ * 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(a)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
Property changes on: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerServiceTracker.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/bundles/hotdeploy/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/pom.xml 2009-05-29 14:50:22 UTC (rev 89533)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/pom.xml 2009-05-29 16:40:23 UTC (rev 89534)
@@ -52,6 +52,7 @@
<Bundle-Activator>org.jboss.osgi.service.hotdeploy.internal.DeploymentScannerActivator</Bundle-Activator>
<Private-Package>org.jboss.osgi.service.hotdeploy.internal</Private-Package>
<Import-Package>
+ javax.management,
org.jboss.osgi.common.log;version="1.0",
org.jboss.osgi.common.service;version="1.0",
org.osgi.framework,
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 14:50:22 UTC (rev 89533)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/DeploymentScannerImpl.java 2009-05-29 16:40:23 UTC (rev 89534)
@@ -38,15 +38,13 @@
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.common.service.DeploymentScannerService;
import org.jboss.osgi.common.service.BundleInfo.State;
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;
-import org.osgi.util.tracker.ServiceTracker;
/**
* The DeploymentScanner service
@@ -63,8 +61,8 @@
private File scanLocation;
private long scanCount;
+ private DeployerServiceTracker serviceTracker;
private ScannerThread scannerThread;
- private DeployerService deployerService;
private List<BundleInfo> lastScan = new ArrayList<BundleInfo>();
private boolean traceBundles = false;
@@ -73,25 +71,9 @@
this.log = new LogServiceTracker(context);
this.context = context;
- // Init and track the DeployerService
- deployerService = new SimpleDeployerService(context);
- ServiceTracker tracker = new ServiceTracker(context, DeployerService.class.getName(), null)
- {
- @Override
- public Object addingService(ServiceReference reference)
- {
- deployerService = (DeployerService)super.addingService(reference);
- return deployerService;
- }
+ serviceTracker = new DeployerServiceTracker(context);
+ serviceTracker.open();
- @Override
- public void removedService(ServiceReference reference, Object service)
- {
- deployerService = new SimpleDeployerService(context);
- }
- };
- tracker.open();
-
initScanner(context);
}
@@ -154,7 +136,7 @@
try
{
BundleInfo[] infoArr = diff.toArray(new BundleInfo[diff.size()]);
- deployerService.undeploy(infoArr);
+ serviceTracker.getService().undeploy(infoArr);
}
catch (Exception ex)
{
@@ -180,7 +162,7 @@
try
{
BundleInfo[] infoArr = diff.toArray(new BundleInfo[diff.size()]);
- deployerService.deploy(infoArr);
+ serviceTracker.getService().deploy(infoArr);
}
catch (Exception ex)
{
@@ -194,7 +176,7 @@
for (File file : scanLocation.listFiles())
{
BundleInfo info = getBundleInfo(file);
- Bundle bundle = SimpleDeployerService.getInstalledBundle(context, info);
+ Bundle bundle = DeployerServiceTracker.getInstalledBundle(context, info);
bundles.add(new BundleInfoImpl(toURL(file), info.getSymbolicName(), bundle));
}
BundleInfo[] arr = new BundleInfoImpl[bundles.size()];
Deleted: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java 2009-05-29 14:50:22 UTC (rev 89533)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java 2009-05-29 16:40:23 UTC (rev 89534)
@@ -1,147 +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.service.hotdeploy.internal;
-
-//$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 org.jboss.osgi.common.log.LogServiceTracker;
-import org.jboss.osgi.common.service.BundleInfo;
-import org.jboss.osgi.common.service.DeployerService;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.service.log.LogService;
-
-/**
- * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 27-May-2009
- */
-public class SimpleDeployerService implements DeployerService
-{
- private LogServiceTracker log;
- private BundleContext context;
-
- private Map<URI, Bundle> urlDeployments = new HashMap<URI, Bundle>();
-
- public SimpleDeployerService(BundleContext context)
- {
- this.log = new LogServiceTracker(context);
- this.context = context;
- }
-
- public void deploy(BundleInfo[] bundleInfos) throws BundleException
- {
- // Install the NEW bundles
- List<Bundle> bundles = new ArrayList<Bundle>();
- for (BundleInfo info : bundleInfos)
- {
- try
- {
- log.log(LogService.LOG_DEBUG, "Install: " + info.getSymbolicName());
- Bundle bundle = context.installBundle(info.getLocation().toExternalForm());
- bundles.add(bundle);
- }
- catch (BundleException ex)
- {
- log.log(LogService.LOG_ERROR, "Cannot install bundle: " + info.getSymbolicName(), ex);
- }
- }
-
- // Start the installed bundles
- for (Bundle bundle : bundles)
- {
- try
- {
- log.log(LogService.LOG_DEBUG, "Start: " + bundle.getSymbolicName());
- bundle.start();
- }
- catch (BundleException ex)
- {
- log.log(LogService.LOG_ERROR, "Cannot start bundle: " + bundle.getSymbolicName(), ex);
- }
- }
- }
-
- public void undeploy(BundleInfo[] bundleInfos) throws BundleException
- {
- for (BundleInfo info : bundleInfos)
- {
- Bundle bundle = 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);
- }
- }
- }
- }
-
- 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);
- bundle.start();
- }
-
- public void undeploy(URL url) throws Exception
- {
- Bundle bundle = urlDeployments.remove(url.toURI());
- if (bundle != null)
- {
- log.log(LogService.LOG_DEBUG, "Uninstall: " + bundle.getSymbolicName());
- bundle.uninstall();
- }
- }
-
- 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
Modified: projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-felix.properties
===================================================================
--- projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-felix.properties 2009-05-29 14:50:22 UTC (rev 89533)
+++ projects/jboss-osgi/trunk/husky/testsuite/src/test/resources/jboss-osgi-felix.properties 2009-05-29 16:40:23 UTC (rev 89534)
@@ -22,6 +22,7 @@
org.osgi.framework.system.packages.extra=\
org.jboss.logging, \
org.jboss.osgi.spi;version=1.0, \
+ org.jboss.osgi.spi.management;version=1.0, \
org.jboss.osgi.spi.testing;version=1.0, \
org.jboss.osgi.spi.testing.capability;version=1.0, \
org.osgi.framework;version=1.4
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 14:50:22 UTC (rev 89533)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-05-29 16:40:23 UTC (rev 89534)
@@ -161,18 +161,18 @@
public void deploy(String location) throws Exception
{
URL archiveURL = getTestHelper().getTestArchiveURL(location);
- invokeMainDeployer("deploy", archiveURL);
+ invokeDeployerService("deploy", archiveURL);
}
public void undeploy(String location) throws Exception
{
URL archiveURL = getTestHelper().getTestArchiveURL(location);
- invokeMainDeployer("undeploy", archiveURL);
+ invokeDeployerService("undeploy", archiveURL);
}
- private void invokeMainDeployer(String method, URL archiveURL) throws Exception
+ private void invokeDeployerService(String method, URL archiveURL) throws Exception
{
- ObjectName oname = new ObjectName("jboss.osgi:service=MicrocontainerService");
+ ObjectName oname = new ObjectName("jboss.osgi:service=DeployerService");
getMBeanServer().invoke(oname, method, new Object[] { archiveURL }, new String[] { "java.net.URL" });
}
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java 2009-05-29 14:50:22 UTC (rev 89533)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/microcontainer/MicrocontainerTestCase.java 2009-05-29 16:40:23 UTC (rev 89534)
@@ -23,6 +23,7 @@
//$Id$
+import static org.jboss.osgi.common.service.DeployerService.MBEAN_DEPLOYER_SERVICE;
import static org.jboss.osgi.common.service.MicrocontainerService.BEAN_KERNEL;
import static org.jboss.osgi.common.service.MicrocontainerService.BEAN_MBEAN_SERVER;
import static org.jboss.osgi.common.service.MicrocontainerService.BEAN_SYSTEM_BUNDLE_CONTEXT;
@@ -36,6 +37,7 @@
import javax.management.ObjectName;
+import org.jboss.osgi.common.service.DeployerService;
import org.jboss.osgi.microcontainer.MicrocontainerServiceMBean;
import org.jboss.osgi.spi.management.MBeanProxy;
import org.jboss.osgi.spi.management.ManagedFrameworkMBean;
@@ -64,7 +66,6 @@
{
runtime = new OSGiTestHelper().getDefaultRuntime();
runtime.addCapability(new JNDICapability());
- runtime.addCapability(new JMXCapability());
runtime.addCapability(new MicrocontainerCapability());
}
@@ -90,21 +91,23 @@
@Test
public void testBundleDeployment() throws Exception
{
- MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, runtime.getMBeanServer());
- mcService.deploy(getTestArchiveURL("example-mcservice-bundleA.jar"));
+ DeployerService deployer = MBeanProxy.get(DeployerService.class, MBEAN_DEPLOYER_SERVICE, runtime.getMBeanServer());
+ deployer.deploy(getTestArchiveURL("example-mcservice-bundleA.jar"));
ManagedFrameworkMBean frameworkMBean = MBeanProxy.get(ManagedFrameworkMBean.class, MBEAN_MANAGED_FRAMEWORK, runtime.getMBeanServer());
Set<ObjectName> bundles = frameworkMBean.getBundles();
assertTrue("Managed bundle registered", bundles.toString().indexOf("jboss.osgi:bundle=example-mcservice-bundleA") > 0);
- mcService.undeploy(getTestArchiveURL("example-mcservice-bundleA.jar"));
+ deployer.undeploy(getTestArchiveURL("example-mcservice-bundleA.jar"));
}
@Test
public void testBeansDeployment() throws Exception
{
MicrocontainerServiceMBean mcService = MBeanProxy.get(MicrocontainerServiceMBean.class, MBEAN_MICROCONTAINER_SERVICE, runtime.getMBeanServer());
- mcService.deploy(getTestArchiveURL("example-mcservice-bundleB.jar"));
+ DeployerService deployer = MBeanProxy.get(DeployerService.class, MBEAN_DEPLOYER_SERVICE, runtime.getMBeanServer());
+
+ deployer.deploy(getTestArchiveURL("example-mcservice-bundleB.jar"));
ManagedFrameworkMBean frameworkMBean = MBeanProxy.get(ManagedFrameworkMBean.class, MBEAN_MANAGED_FRAMEWORK, runtime.getMBeanServer());
Set<ObjectName> bundles = frameworkMBean.getBundles();
@@ -114,7 +117,7 @@
List<String> registeredBeans = mcService.getRegisteredBeans();
assertTrue("SomeBean registered", registeredBeans.contains("SomeBean"));
- mcService.undeploy(getTestArchiveURL("example-mcservice-bundleB.jar"));
+ deployer.undeploy(getTestArchiveURL("example-mcservice-bundleB.jar"));
// Check whether the bean is unregistered
registeredBeans = mcService.getRegisteredBeans();
16 years, 6 months
JBoss-OSGI SVN: r89530 - in projects/jboss-osgi/trunk: bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal and 14 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-29 10:09:21 -0400 (Fri, 29 May 2009)
New Revision: 89530
Added:
projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java
projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceBean.java
projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceBean.java
projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceBean.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
Removed:
projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerServiceActivator.java
projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceImpl.java
projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java
projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
Modified:
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java
projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java
projects/jboss-osgi/trunk/bundles/jmx/pom.xml
projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerService.java
projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerServiceMBean.java
projects/jboss-osgi/trunk/bundles/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml
projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties
projects/jboss-osgi/trunk/distribution/runtime/conf/log4j.xml
projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml
projects/jboss-osgi/trunk/runtime/equinox/src/main/resources/osgi-deployers-jboss-beans.xml
projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-deployers-jboss-beans.xml
projects/jboss-osgi/trunk/runtime/knopflerfish/src/main/resources/osgi-deployers-jboss-beans.xml
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java
Log:
WIP
Modified: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/DeployerService.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -21,6 +21,8 @@
*/
package org.jboss.osgi.common.service;
+import java.net.URL;
+
//$Id$
@@ -42,4 +44,14 @@
* Undeploy an array of bundles
*/
void undeploy(BundleInfo[] bundles) throws Exception;
+
+ /**
+ * Deploy MC beans from URL
+ */
+ void deploy(URL url) throws Exception;
+
+ /**
+ * Undeploy MC beans from URL
+ */
+ void undeploy(URL url) throws Exception;
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/hotdeploy/src/main/java/org/jboss/osgi/service/hotdeploy/internal/SimpleDeployerService.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -23,8 +23,12 @@
//$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 org.jboss.osgi.common.log.LogServiceTracker;
import org.jboss.osgi.common.service.BundleInfo;
@@ -44,6 +48,8 @@
{
private LogServiceTracker log;
private BundleContext context;
+
+ private Map<URI, Bundle> urlDeployments = new HashMap<URI, Bundle>();
public SimpleDeployerService(BundleContext context)
{
@@ -104,6 +110,24 @@
}
}
+ 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);
+ bundle.start();
+ }
+
+ public void undeploy(URL url) throws Exception
+ {
+ Bundle bundle = urlDeployments.remove(url.toURI());
+ if (bundle != null)
+ {
+ log.log(LogService.LOG_DEBUG, "Uninstall: " + bundle.getSymbolicName());
+ bundle.uninstall();
+ }
+ }
+
public static Bundle getInstalledBundle(BundleContext context, BundleInfo bundleInfo)
{
Bundle bundle = null;
Modified: projects/jboss-osgi/trunk/bundles/jmx/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundles/jmx/pom.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/jmx/pom.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -57,7 +57,7 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
- <Bundle-Activator>org.jboss.osgi.jmx.internal.MBeanServerServiceActivator</Bundle-Activator>
+ <Bundle-Activator>org.jboss.osgi.jmx.internal.JMXServiceActivator</Bundle-Activator>
<Import-Package>
<!-- system -->
@@ -67,6 +67,7 @@
<!-- jboss-osgi -->
org.jboss.osgi.common.log;version="1.0",
+ org.jboss.osgi.spi.management;version="1.0",
<!-- osgi -->
org.osgi.framework;version=1.4,
Copied: projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java (from rev 89521, projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/JMXServiceActivator.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -0,0 +1,170 @@
+/*
+ * 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.MBeanServer;
+import javax.management.MBeanServerConnection;
+import javax.management.remote.JMXServiceURL;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+
+import org.jboss.osgi.common.log.LogServiceTracker;
+import org.jboss.osgi.spi.management.ManagedFramework;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A BundleActivator for the MBeanServer related services
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Apr-2009
+ */
+public class JMXServiceActivator implements BundleActivator
+{
+ public static final String REMOTE_JMX_HOST = "org.jboss.osgi.jmx.host";
+ public static final String REMOTE_JMX_RMI_PORT = "org.jboss.osgi.jmx.rmi.port";
+ public static final String REMOTE_JMX_RMI_ADAPTOR = "org.jboss.osgi.jmx.rmi.adaptor";
+
+ private JMXConnectorService jmxConnector;
+ private String jmxHost;
+ private String jmxRmiPort;
+ private String rmiAdaptorPath;
+ private MBeanServer mbeanServer;
+
+ private LogService log;
+
+ public void start(BundleContext context)
+ {
+ log = new LogServiceTracker(context);
+
+ MBeanServerService mbeanService = new MBeanServerService(context);
+ mbeanServer = mbeanService.getMBeanServer();
+
+ // Register the MBeanServer
+ context.registerService(MBeanServer.class.getName(), mbeanServer, null);
+ log.log(LogService.LOG_DEBUG, "MBeanServer registered");
+
+ // Register the ManagedFramework
+ new ManagedFramework(context, mbeanServer).start();
+
+ jmxHost = context.getProperty(REMOTE_JMX_HOST);
+ if (jmxHost == null)
+ jmxHost = "localhost";
+
+ jmxRmiPort = context.getProperty(REMOTE_JMX_RMI_PORT);
+ if (jmxRmiPort == null)
+ jmxRmiPort = "1098";
+
+ rmiAdaptorPath = context.getProperty(REMOTE_JMX_RMI_ADAPTOR);
+ if (rmiAdaptorPath == null)
+ rmiAdaptorPath = "jmx/invoker/RMIAdaptor";
+
+ // Start tracking the NamingService
+ InitialContextTracker tracker = new InitialContextTracker(context, rmiAdaptorPath);
+ tracker.open();
+ }
+
+ public void stop(BundleContext context)
+ {
+ stopJMXConnectorService();
+ }
+
+ private void stopJMXConnectorService()
+ {
+ if (jmxConnector != null)
+ {
+ jmxConnector.stop();
+ jmxConnector = null;
+ }
+ }
+
+ class InitialContextTracker extends ServiceTracker
+ {
+ private String rmiAdaptorPath;
+
+ public InitialContextTracker(BundleContext context, String rmiAdaptorPath)
+ {
+ super(context, InitialContext.class.getName(), null);
+ this.rmiAdaptorPath = rmiAdaptorPath;
+ }
+
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ InitialContext iniCtx = (InitialContext)super.addingService(reference);
+
+ // Start JMXConnectorService
+ if (jmxConnector == null)
+ {
+ jmxConnector = new JMXConnectorService(context, mbeanServer, jmxHost, Integer.parseInt(jmxRmiPort));
+ jmxConnector.start();
+ }
+
+ // Bind the RMIAdaptor
+ try
+ {
+ iniCtx.createSubcontext("jmx").createSubcontext("invoker");
+ StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), jmxConnector.getServiceURL().toString());
+ Reference ref = new Reference(MBeanServerConnection.class.getName(), addr, RMIAdaptorFactory.class.getName(), null);
+ iniCtx.bind(rmiAdaptorPath, ref);
+
+ log.log(LogService.LOG_INFO, "MBeanServerConnection bound to: " + rmiAdaptorPath);
+ }
+ catch (NamingException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot bind RMIAdaptor", ex);
+ }
+
+ return iniCtx;
+ }
+
+ @Override
+ public void removedService(ServiceReference reference, Object service)
+ {
+ InitialContext iniCtx = (InitialContext)service;
+
+ // Stop JMXConnectorService
+ stopJMXConnectorService();
+
+ // Unbind the RMIAdaptor
+ try
+ {
+ iniCtx.unbind(rmiAdaptorPath);
+
+ log.log(LogService.LOG_INFO, "MBeanServerConnection unbound from: " + rmiAdaptorPath);
+ }
+ catch (NamingException ex)
+ {
+ log.log(LogService.LOG_ERROR, "Cannot unbind RMIAdaptor", ex);
+ }
+
+ super.removedService(reference, service);
+ }
+ }
+}
\ No newline at end of file
Modified: 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 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerService.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -68,9 +68,6 @@
log.log(LogService.LOG_DEBUG, "No MBeanServer, create one ...");
mbeanServer = MBeanServerFactory.createMBeanServer();
}
-
- log.log(LogService.LOG_DEBUG, "Register MBeanServer");
- context.registerService(MBeanServer.class.getName(), mbeanServer, null);
}
}
Deleted: projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerServiceActivator.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/jmx/src/main/java/org/jboss/osgi/jmx/internal/MBeanServerServiceActivator.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -1,162 +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.MBeanServer;
-import javax.management.MBeanServerConnection;
-import javax.management.remote.JMXServiceURL;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
-
-import org.jboss.osgi.common.log.LogServiceTracker;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * A BundleActivator for the MBeanServer related services
- *
- * @author thomas.diesler(a)jboss.com
- * @since 24-Apr-2009
- */
-public class MBeanServerServiceActivator implements BundleActivator
-{
- public static final String REMOTE_JMX_HOST = "org.jboss.osgi.jmx.host";
- public static final String REMOTE_JMX_RMI_PORT = "org.jboss.osgi.jmx.rmi.port";
- public static final String REMOTE_JMX_RMI_ADAPTOR = "org.jboss.osgi.jmx.rmi.adaptor";
-
- private JMXConnectorService jmxConnector;
- private String jmxHost;
- private String jmxRmiPort;
- private String rmiAdaptorPath;
- private MBeanServer mbanServer;
-
- private LogService log;
-
- public void start(BundleContext context)
- {
- log = new LogServiceTracker(context);
-
- MBeanServerService mbeanService = new MBeanServerService(context);
- mbanServer = mbeanService.getMBeanServer();
-
- jmxHost = context.getProperty(REMOTE_JMX_HOST);
- if (jmxHost == null)
- jmxHost = "localhost";
-
- jmxRmiPort = context.getProperty(REMOTE_JMX_RMI_PORT);
- if (jmxRmiPort == null)
- jmxRmiPort = "1098";
-
- rmiAdaptorPath = context.getProperty(REMOTE_JMX_RMI_ADAPTOR);
- if (rmiAdaptorPath == null)
- rmiAdaptorPath = "jmx/invoker/RMIAdaptor";
-
- // Start tracking the NamingService
- InitialContextTracker tracker = new InitialContextTracker(context, rmiAdaptorPath);
- tracker.open();
- }
-
- public void stop(BundleContext context)
- {
- stopJMXConnectorService();
- }
-
- private void stopJMXConnectorService()
- {
- if (jmxConnector != null)
- {
- jmxConnector.stop();
- jmxConnector = null;
- }
- }
-
- class InitialContextTracker extends ServiceTracker
- {
- private String rmiAdaptorPath;
-
- public InitialContextTracker(BundleContext context, String rmiAdaptorPath)
- {
- super(context, InitialContext.class.getName(), null);
- this.rmiAdaptorPath = rmiAdaptorPath;
- }
-
- @Override
- public Object addingService(ServiceReference reference)
- {
- InitialContext iniCtx = (InitialContext)super.addingService(reference);
-
- // Start JMXConnectorService
- if (jmxConnector == null)
- {
- jmxConnector = new JMXConnectorService(context, mbanServer, jmxHost, Integer.parseInt(jmxRmiPort));
- jmxConnector.start();
- }
-
- // Bind the RMIAdaptor
- try
- {
- iniCtx.createSubcontext("jmx").createSubcontext("invoker");
- StringRefAddr addr = new StringRefAddr(JMXServiceURL.class.getName(), jmxConnector.getServiceURL().toString());
- Reference ref = new Reference(MBeanServerConnection.class.getName(), addr, RMIAdaptorFactory.class.getName(), null);
- iniCtx.bind(rmiAdaptorPath, ref);
-
- log.log(LogService.LOG_INFO, "MBeanServerConnection bound to: " + rmiAdaptorPath);
- }
- catch (NamingException ex)
- {
- log.log(LogService.LOG_ERROR, "Cannot bind RMIAdaptor", ex);
- }
-
- return iniCtx;
- }
-
- @Override
- public void removedService(ServiceReference reference, Object service)
- {
- InitialContext iniCtx = (InitialContext)service;
-
- // Stop JMXConnectorService
- stopJMXConnectorService();
-
- // Unbind the RMIAdaptor
- try
- {
- iniCtx.unbind(rmiAdaptorPath);
-
- log.log(LogService.LOG_INFO, "MBeanServerConnection unbound from: " + rmiAdaptorPath);
- }
- catch (NamingException ex)
- {
- log.log(LogService.LOG_ERROR, "Cannot unbind RMIAdaptor", ex);
- }
-
- super.removedService(reference, service);
- }
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerServiceMBean.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerServiceMBean.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/microcontainer/src/main/java/org/jboss/osgi/microcontainer/MicrocontainerServiceMBean.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -23,7 +23,6 @@
//$Id$
-import java.net.URL;
import java.util.List;
import javax.management.ObjectName;
@@ -47,14 +46,4 @@
* Get the list of registered beans.
*/
List<String> getRegisteredBeans();
-
- /**
- * Deploy MC beans from URL
- */
- void deploy(URL url) throws Exception;
-
- /**
- * Undeploy MC beans from URL
- */
- void undeploy(URL url) throws Exception;
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/bundles/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/bundles/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/bundles/microcontainer/src/main/resources/META-INF/base-deployers-beans.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -77,12 +77,6 @@
<!-- OSGi Deployment -->
- <!-- The Framework Management -->
- <bean name="jboss.osgi:service=ManagedFramework" class="org.jboss.osgi.spi.management.ManagedFramework">
- <property name="systemContext"><inject bean="jboss.osgi:service=BundleContext" /></property>
- <property name="mbeanServer"><inject bean="jboss.osgi:service=MBeanServer"/></property>
- </bean>
-
<bean name="BundleMetaDataDeployer" class="org.jboss.osgi.deployer.BundleMetaDataDeployer" />
<bean name="BundleStructureDeployer" class="org.jboss.osgi.deployer.BundleStructureDeployer" />
<bean name="BundleRealDeployer" class="org.jboss.osgi.deployer.BundleRealDeployer">
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 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/distribution/runtime/conf/jboss-osgi-felix.properties 2009-05-29 14:09:21 UTC (rev 89530)
@@ -8,17 +8,17 @@
org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
# Properties to configure the Framework
-org.osgi.framework.storage=${osgi.home}/server/${jboss.server.name}/data/osgi-store
+org.osgi.framework.storage=${osgi.server.home}/data/osgi-store
org.osgi.framework.storage.clean=onFirstInit
# Hot Deployement
-org.jboss.osgi.hotdeploy.scandir=${osgi.home}/server/${jboss.server.name}/bundles
+org.jboss.osgi.hotdeploy.scandir=${osgi.server.home}/bundles
# HTTP Service Port
org.osgi.service.http.port=8090
# Config Admin Service
-felix.cm.dir=${osgi.home}/server/${jboss.server.name}/data/osgi-configadmin
+felix.cm.dir=${osgi.server.home}/data/osgi-configadmin
# JMX bundle properties
org.jboss.osgi.jmx.host=${jboss.bind.address}
Modified: projects/jboss-osgi/trunk/distribution/runtime/conf/log4j.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/runtime/conf/log4j.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/distribution/runtime/conf/log4j.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -8,7 +8,7 @@
<!-- ================================= -->
<appender name="FILE" class="org.apache.log4j.FileAppender">
- <param name="File" value="${osgi.home}/server/${jboss.server.name}/log/server.log"/>
+ <param name="File" value="${osgi.server.home}/log/server.log"/>
<param name="Append" value="false"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
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 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/distribution/src/main/resources/installer/install-definition.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -183,6 +183,9 @@
</fileset>
<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" />
<include name="jboss-osgi-webconsole.jar" />
<include name="org.apache.felix.configadmin.jar" />
<include name="org.apache.felix.http.jetty.jar" />
@@ -191,10 +194,10 @@
<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-common-core.jar" />
+ <include name="jboss-osgi-jmx.jar" />
<include name="jboss-osgi-jndi.jar" />
- <include name="jboss-osgi-jmx.jar" />
<include name="jboss-osgi-microcontainer.jar" />
<include name="jboss-osgi-webconsole.jar" />
<include name="jboss-osgi-xml-binding.jar" />
Copied: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceBean.java (from rev 89516, projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceBean.java (rev 0)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceBean.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -0,0 +1,55 @@
+/*
+ * 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.MBeanServer;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * A service that gives access to the MBeanServer
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 24-Apr-2009
+ */
+public class ManagementServiceBean
+{
+ private MBeanServer mbeanServer;
+ private BundleContext context;
+
+ public void setSystemContext(BundleContext context)
+ {
+ this.context = context;
+ }
+
+ public void setMbeanServer(MBeanServer mbeanServer)
+ {
+ this.mbeanServer = mbeanServer;
+ }
+
+ public void start()
+ {
+ context.registerService(MBeanServer.class.getName(), mbeanServer, null);
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceImpl.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jmx/internal/ManagementServiceImpl.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -1,55 +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.MBeanServer;
-
-import org.osgi.framework.BundleContext;
-
-/**
- * A service that gives access to the MBeanServer
- *
- * @author thomas.diesler(a)jboss.com
- * @since 24-Apr-2009
- */
-public class ManagementServiceImpl
-{
- private MBeanServer mbeanServer;
- private BundleContext context;
-
- public void setSystemContext(BundleContext context)
- {
- this.context = context;
- }
-
- public void setMbeanServer(MBeanServer mbeanServer)
- {
- this.mbeanServer = mbeanServer;
- }
-
- public void start()
- {
- context.registerService(MBeanServer.class.getName(), mbeanServer, null);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceBean.java (from rev 89516, projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceBean.java (rev 0)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceBean.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -0,0 +1,58 @@
+/*
+ * 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.jndi.internal;
+
+//$Id$
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.osgi.framework.BundleContext;
+
+/**
+ * A service that gives access to JNDI
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 05-May-2009
+ */
+public class NamingServiceBean
+{
+ private BundleContext context;
+
+ public void setSystemContext(BundleContext context)
+ {
+ this.context = context;
+ }
+
+ public void start()
+ {
+ try
+ {
+ InitialContext initialContext = new InitialContext();
+ context.registerService(InitialContext.class.getName(), initialContext, null);
+ }
+ catch (NamingException ex)
+ {
+ throw new IllegalStateException("Cannot register InitialContext", ex);
+ }
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/jndi/internal/NamingServiceImpl.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -1,58 +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.jndi.internal;
-
-//$Id$
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.osgi.framework.BundleContext;
-
-/**
- * A service that gives access to JNDI
- *
- * @author thomas.diesler(a)jboss.com
- * @since 05-May-2009
- */
-public class NamingServiceImpl
-{
- private BundleContext context;
-
- public void setSystemContext(BundleContext context)
- {
- this.context = context;
- }
-
- public void start()
- {
- try
- {
- InitialContext initialContext = new InitialContext();
- context.registerService(InitialContext.class.getName(), initialContext, null);
- }
- catch (NamingException ex)
- {
- throw new IllegalStateException("Cannot register InitialContext", ex);
- }
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceBean.java (from rev 89516, projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceBean.java (rev 0)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceBean.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -0,0 +1,145 @@
+/*
+ * 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.microcontainer.internal;
+
+//$Id$
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.dependency.plugins.AbstractControllerContext;
+import org.jboss.dependency.plugins.AbstractControllerContextActions;
+import org.jboss.dependency.plugins.action.ControllerContextAction;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerContextActions;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.osgi.microcontainer.MicrocontainerService;
+import org.jboss.osgi.microcontainer.MicrocontainerServiceMBean;
+import org.osgi.framework.BundleContext;
+
+/**
+ * A service the gives access to the Microcontainer.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 05-May-2009
+ */
+public class MicrocontainerServiceBean implements MicrocontainerService, MicrocontainerServiceMBean
+{
+ private BundleContext context;
+ private MBeanServer mbeanServer;
+ private Kernel kernel;
+
+ public void setSystemContext(BundleContext context)
+ {
+ this.context = context;
+ }
+
+ public void setMbeanServer(MBeanServer mbeanServer)
+ {
+ this.mbeanServer = mbeanServer;
+ }
+
+ public void setKernel(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
+ public void deploy(URL url) throws Exception
+ {
+ invokeMainDeployer("deploy", url);
+ }
+
+ public void undeploy(URL url) throws Exception
+ {
+ invokeMainDeployer("undeploy", url);
+ }
+
+ private void invokeMainDeployer(String method, URL archiveURL) throws Exception
+ {
+ ObjectName oname = new ObjectName("jboss.system:service=MainDeployer");
+ mbeanServer.invoke(oname, method, new Object[] { archiveURL }, new String[] { "java.net.URL" });
+ }
+
+ public Kernel getKernel()
+ {
+ return kernel;
+ }
+
+ public List<String> getRegisteredBeans()
+ {
+ List<String> names = new ArrayList<String>();
+
+ AbstractController controller = (AbstractController)getKernel().getController();
+ for (ControllerContext ctx : controller.getAllContexts())
+ {
+ if (ctx instanceof KernelControllerContext || ctx instanceof PreInstalledControllerContext)
+ names.add(ctx.getName().toString());
+ }
+
+ return names;
+ }
+
+ public Object getRegisteredBean(String beanName)
+ {
+ ControllerContext context = getKernel().getController().getInstalledContext(beanName);
+ return context != null ? context.getTarget() : null;
+ }
+
+ public void start()
+ {
+ context.registerService(MicrocontainerService.class.getName(), this, null);
+
+ try
+ {
+ KernelController controller = kernel.getController();
+ ControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
+ controller.install(new PreInstalledControllerContext(BEAN_SYSTEM_BUNDLE_CONTEXT, actions, context));
+ controller.install(new PreInstalledControllerContext(BEAN_MBEAN_SERVER, actions, mbeanServer));
+ controller.install(new PreInstalledControllerContext(BEAN_KERNEL, actions, kernel));
+
+ StandardMBean mbean = new StandardMBean(this, MicrocontainerServiceMBean.class);
+ mbeanServer.registerMBean(mbean, MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE);
+ }
+ catch (Throwable ex)
+ {
+ throw new IllegalStateException("Cannot register MicrocontainerServiceMBean", ex);
+ }
+ }
+
+ static class PreInstalledControllerContext extends AbstractControllerContext
+ {
+ public PreInstalledControllerContext(Object name, ControllerContextActions actions, Object target)
+ {
+ super(name, actions, null, target);
+ }
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/integration/jbossas/src/main/java/org/jboss/osgi/microcontainer/internal/MicrocontainerServiceImpl.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -1,145 +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.microcontainer.internal;
-
-//$Id$
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.StandardMBean;
-
-import org.jboss.dependency.plugins.AbstractController;
-import org.jboss.dependency.plugins.AbstractControllerContext;
-import org.jboss.dependency.plugins.AbstractControllerContextActions;
-import org.jboss.dependency.plugins.action.ControllerContextAction;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerContextActions;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.osgi.microcontainer.MicrocontainerService;
-import org.jboss.osgi.microcontainer.MicrocontainerServiceMBean;
-import org.osgi.framework.BundleContext;
-
-/**
- * A service the gives access to the Microcontainer.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 05-May-2009
- */
-public class MicrocontainerServiceImpl implements MicrocontainerService, MicrocontainerServiceMBean
-{
- private BundleContext context;
- private MBeanServer mbeanServer;
- private Kernel kernel;
-
- public void setSystemContext(BundleContext context)
- {
- this.context = context;
- }
-
- public void setMbeanServer(MBeanServer mbeanServer)
- {
- this.mbeanServer = mbeanServer;
- }
-
- public void setKernel(Kernel kernel)
- {
- this.kernel = kernel;
- }
-
- public void deploy(URL url) throws Exception
- {
- invokeMainDeployer("deploy", url);
- }
-
- public void undeploy(URL url) throws Exception
- {
- invokeMainDeployer("undeploy", url);
- }
-
- private void invokeMainDeployer(String method, URL archiveURL) throws Exception
- {
- ObjectName oname = new ObjectName("jboss.system:service=MainDeployer");
- mbeanServer.invoke(oname, method, new Object[] { archiveURL }, new String[] { "java.net.URL" });
- }
-
- public Kernel getKernel()
- {
- return kernel;
- }
-
- public List<String> getRegisteredBeans()
- {
- List<String> names = new ArrayList<String>();
-
- AbstractController controller = (AbstractController)getKernel().getController();
- for (ControllerContext ctx : controller.getAllContexts())
- {
- if (ctx instanceof KernelControllerContext || ctx instanceof PreInstalledControllerContext)
- names.add(ctx.getName().toString());
- }
-
- return names;
- }
-
- public Object getRegisteredBean(String beanName)
- {
- ControllerContext context = getKernel().getController().getInstalledContext(beanName);
- return context != null ? context.getTarget() : null;
- }
-
- public void start()
- {
- context.registerService(MicrocontainerService.class.getName(), this, null);
-
- try
- {
- KernelController controller = kernel.getController();
- ControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
- controller.install(new PreInstalledControllerContext(BEAN_SYSTEM_BUNDLE_CONTEXT, actions, context));
- controller.install(new PreInstalledControllerContext(BEAN_MBEAN_SERVER, actions, mbeanServer));
- controller.install(new PreInstalledControllerContext(BEAN_KERNEL, actions, kernel));
-
- StandardMBean mbean = new StandardMBean(this, MicrocontainerServiceMBean.class);
- mbeanServer.registerMBean(mbean, MicrocontainerServiceMBean.MBEAN_MICROCONTAINER_SERVICE);
- }
- catch (Throwable ex)
- {
- throw new IllegalStateException("Cannot register MicrocontainerServiceMBean", ex);
- }
- }
-
- static class PreInstalledControllerContext extends AbstractControllerContext
- {
- public PreInstalledControllerContext(Object name, ControllerContextActions actions, Object target)
- {
- super(name, actions, null, target);
- }
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/runtime/equinox/src/main/resources/osgi-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/equinox/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/runtime/equinox/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -74,19 +74,19 @@
-->
<!-- A Service that gives access to the Microcontainer -->
- <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.microcontainer.internal.MicrocontainerServiceImpl">
+ <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.microcontainer.internal.MicrocontainerServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
<property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
</bean>
<!-- A Service that gives access to JNDI -->
- <bean name="jboss.osgi:service=Naming" class="org.jboss.osgi.jndi.internal.NamingServiceImpl">
+ <bean name="jboss.osgi:service=Naming" class="org.jboss.osgi.jndi.internal.NamingServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
</bean>
<!-- A Service that gives access to the MBeanServer -->
- <bean name="jboss.osgi:service=Management" class="org.jboss.osgi.jmx.internal.ManagementServiceImpl">
+ <bean name="jboss.osgi:service=Management" class="org.jboss.osgi.jmx.internal.ManagementServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
</bean>
Modified: projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/runtime/felix/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -87,19 +87,19 @@
-->
<!-- A Service that gives access to the Microcontainer -->
- <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.microcontainer.internal.MicrocontainerServiceImpl">
+ <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.microcontainer.internal.MicrocontainerServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
<property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
</bean>
<!-- A Service that gives access to JNDI -->
- <bean name="jboss.osgi:service=Naming" class="org.jboss.osgi.jndi.internal.NamingServiceImpl">
+ <bean name="jboss.osgi:service=Naming" class="org.jboss.osgi.jndi.internal.NamingServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
</bean>
<!-- A Service that gives access to the MBeanServer -->
- <bean name="jboss.osgi:service=Management" class="org.jboss.osgi.jmx.internal.ManagementServiceImpl">
+ <bean name="jboss.osgi:service=Management" class="org.jboss.osgi.jmx.internal.ManagementServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
</bean>
Modified: projects/jboss-osgi/trunk/runtime/knopflerfish/src/main/resources/osgi-deployers-jboss-beans.xml
===================================================================
--- projects/jboss-osgi/trunk/runtime/knopflerfish/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/runtime/knopflerfish/src/main/resources/osgi-deployers-jboss-beans.xml 2009-05-29 14:09:21 UTC (rev 89530)
@@ -73,19 +73,19 @@
-->
<!-- A Service that gives access to the Microcontainer -->
- <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.microcontainer.internal.MicrocontainerServiceImpl">
+ <bean name="jboss.osgi:service=Microcontainer" class="org.jboss.osgi.microcontainer.internal.MicrocontainerServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
<property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
</bean>
<!-- A Service that gives access to JNDI -->
- <bean name="jboss.osgi:service=Naming" class="org.jboss.osgi.jndi.internal.NamingServiceImpl">
+ <bean name="jboss.osgi:service=Naming" class="org.jboss.osgi.jndi.internal.NamingServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
</bean>
<!-- A Service that gives access to the MBeanServer -->
- <bean name="jboss.osgi:service=Management" class="org.jboss.osgi.jmx.internal.ManagementServiceImpl">
+ <bean name="jboss.osgi:service=Management" class="org.jboss.osgi.jmx.internal.ManagementServiceBean">
<property name="systemContext"><inject bean="jboss.osgi:service=Framework" property="bundleContext"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
</bean>
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -57,7 +57,9 @@
private static final String JAVA_PROTOCOL_HANDLERS = "java.protocol.handler.pkgs";
private static final String JBOSS_BIND_ADDRESS = "jboss.bind.address";
- private static final String JBOSS_SERVER_NAME = "jboss.server.name";
+ private static final String OSGI_SERVER_NAME = "osgi.server.name";
+ private static final String OSGI_SERVER_HOME = "osgi.server.home";
+ private static final String OSGI_HOME = "osgi.home";
@Option(name = "-c", aliases = { "--server-name" }, usage = "Sets the server config (-c minimal)")
public String serverName = "default";
@@ -65,6 +67,9 @@
@Option(name = "-b", aliases = { "--bind-address" }, usage = "Sets the bind address (-b 127.0.0.1)")
public String bindAdress = "localhost";
+ private String osgiHome;
+ private String osgiServerHome;
+
/*
* The main entry point
*/
@@ -100,12 +105,20 @@
private void initSystemProperties()
{
+ osgiHome = System.getProperty(OSGI_HOME);
+ if (osgiHome == null)
+ throw new IllegalStateException("Cannot obtain system property: '" + OSGI_HOME + "'");
+
+ osgiServerHome = osgiHome + "/server/" + serverName;
+
Properties defaults = new Properties();
- defaults.setProperty(JBOSS_SERVER_NAME, serverName);
+ defaults.setProperty(OSGI_SERVER_NAME, serverName);
+ defaults.setProperty(OSGI_SERVER_HOME, osgiServerHome);
defaults.setProperty(JBOSS_BIND_ADDRESS, bindAdress);
defaults.setProperty(JAVA_PROTOCOL_HANDLERS, "org.jboss.net.protocol|org.jboss.virtual.protocol");
getLogger().debug("JBoss OSGi System Properties");
+ getLogger().debug(" " + OSGI_SERVER_HOME + "=" + osgiServerHome);
Enumeration<?> defaultNames = defaults.propertyNames();
while (defaultNames.hasMoreElements())
@@ -125,7 +138,7 @@
{
if (log == null)
{
- System.setProperty(JBOSS_SERVER_NAME, serverName);
+ System.setProperty(OSGI_SERVER_HOME, osgiServerHome);
log = Logger.getLogger(OSGiBootstrap.class);
}
return log;
Deleted: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -1,102 +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.spi.management;
-
-//$Id$
-
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import javax.management.ObjectName;
-
-import org.jboss.osgi.spi.Constants;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-
-/**
- * The managed view of an OSGi Bundle
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Jan-2009
- */
-public class ManagedBundle implements ManagedBundleMBean
-{
- private Bundle bundle;
- private ObjectName oname;
-
- public ManagedBundle(Bundle bundle)
- {
- this.bundle = bundle;
- this.oname = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=" + bundle.getSymbolicName() + ",id=" + bundle.getBundleId());
- }
-
- public ObjectName getObjectName()
- {
- return oname;
- }
-
- public String getProperty(String key)
- {
- return bundle.getBundleContext().getProperty(key);
- }
-
- public int getState()
- {
- return bundle.getState();
- }
-
- public long getBundleId()
- {
- return bundle.getBundleId();
- }
-
- public String getSymbolicName()
- {
- return bundle.getSymbolicName();
- }
-
- @SuppressWarnings("unchecked")
- public Dictionary<String, String> getHeaders()
- {
- Hashtable<String, String> retHeaders = new Hashtable<String, String>();
- Dictionary bundleHeaders = bundle.getHeaders();
- Enumeration keys = bundleHeaders.keys();
- while(keys.hasMoreElements())
- {
- String key = (String)keys.nextElement();
- String value = (String)bundleHeaders.get(key);
- retHeaders.put(key, value);
- }
- return retHeaders;
- }
-
- public void start() throws BundleException
- {
- bundle.start();
- }
-
- public void stop() throws BundleException
- {
- bundle.stop();
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java (from rev 89516, projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java)
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java (rev 0)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -0,0 +1,102 @@
+/*
+ * 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.spi.management;
+
+//$Id$
+
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import javax.management.ObjectName;
+
+import org.jboss.osgi.spi.Constants;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * The managed view of an OSGi Bundle
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Jan-2009
+ */
+public class ManagedBundle implements ManagedBundleMBean
+{
+ private Bundle bundle;
+ private ObjectName oname;
+
+ public ManagedBundle(Bundle bundle)
+ {
+ this.bundle = bundle;
+ this.oname = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=" + bundle.getSymbolicName() + ",id=" + bundle.getBundleId());
+ }
+
+ public ObjectName getObjectName()
+ {
+ return oname;
+ }
+
+ public String getProperty(String key)
+ {
+ return bundle.getBundleContext().getProperty(key);
+ }
+
+ public int getState()
+ {
+ return bundle.getState();
+ }
+
+ public long getBundleId()
+ {
+ return bundle.getBundleId();
+ }
+
+ public String getSymbolicName()
+ {
+ return bundle.getSymbolicName();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Dictionary<String, String> getHeaders()
+ {
+ Hashtable<String, String> retHeaders = new Hashtable<String, String>();
+ Dictionary bundleHeaders = bundle.getHeaders();
+ Enumeration keys = bundleHeaders.keys();
+ while(keys.hasMoreElements())
+ {
+ String key = (String)keys.nextElement();
+ String value = (String)bundleHeaders.get(key);
+ retHeaders.put(key, value);
+ }
+ return retHeaders;
+ }
+
+ public void start() throws BundleException
+ {
+ bundle.start();
+ }
+
+ public void stop() throws BundleException
+ {
+ bundle.stop();
+ }
+}
\ No newline at end of file
Deleted: 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 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -1,183 +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.spi.management;
-
-//$Id$
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.QueryExp;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.spi.Constants;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * The managed view of an OSGi Framework
- *
- * @author thomas.diesler(a)jboss.com
- * @since 04-Mar-2009
- */
-public class ManagedFramework implements ManagedFrameworkMBean
-{
- // Provide logging
- final Logger log = Logger.getLogger(ManagedFramework.class);
-
- private MBeanServer mbeanServer;
- private BundleContext systemContext;
-
- public void setMbeanServer(MBeanServer server)
- {
- this.mbeanServer = server;
- }
-
- public void setSystemContext(BundleContext systemContext)
- {
- this.systemContext = systemContext;
- }
-
- @SuppressWarnings("unchecked")
- public ObjectName getBundle(String symbolicName)
- {
- ObjectName pattern = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=" + symbolicName + ",*");
- Set<ObjectName> names = mbeanServer.queryNames(pattern, null);
-
- if (names.size() < 1)
- return null;
-
- if (names.size() > 1)
- throw new IllegalArgumentException("Multiple bundles found: " + names);
-
- return names.iterator().next();
- }
-
- @SuppressWarnings("unchecked")
- public Set<ObjectName> getBundles()
- {
- // [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;
- }
-
- public ManagedServiceReference getServiceReference(String clazz)
- {
- ManagedServiceReference manref = null;
- ServiceReference sref = systemContext.getServiceReference(clazz);
- if (sref != null)
- {
- 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;
- }
-
- public ManagedServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
- {
- List<ManagedServiceReference> foundRefs = new ArrayList<ManagedServiceReference>();
- ServiceReference[] srefs = systemContext.getServiceReferences(clazz, filter);
- if (srefs != null)
- {
- for (ServiceReference sref : srefs)
- {
- 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;
- }
-
- public void refreshPackages(String[] symbolicNames)
- {
- ServiceReference sref = systemContext.getServiceReference(PackageAdmin.class.getName());
- PackageAdmin service = (PackageAdmin)systemContext.getService(sref);
-
- Bundle[] bundles = null;
- if (symbolicNames != null)
- {
- List<String> nameList = Arrays.asList(symbolicNames);
- Set<Bundle> bundleSet = new HashSet<Bundle>();
- for (Bundle bundle : systemContext.getBundles())
- {
- if (nameList.contains(bundle.getSymbolicName()))
- bundleSet.add(bundle);
- }
- bundles = new Bundle[bundleSet.size()];
- bundleSet.toArray(bundles);
- }
- service.refreshPackages(bundles);
- }
-
- public void start()
- {
- try
- {
- if (mbeanServer != null)
- mbeanServer.registerMBean(this, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
- }
- catch (Exception ex)
- {
- log.warn("Cannot register: " + ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
- }
- }
-
- // Accept names like "jboss.osgi:bundle=*"
- static class IsBundleQueryExp implements QueryExp
- {
- private static final long serialVersionUID = 1L;
-
- public boolean apply(ObjectName name)
- {
- return name.getKeyProperty("bundle") != null;
- }
-
- public void setMBeanServer(MBeanServer server)
- {
- }
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java (from rev 89516, 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 (rev 0)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -0,0 +1,193 @@
+/*
+ * 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.spi.management;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.QueryExp;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.Constants;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * The managed view of an OSGi Framework
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 04-Mar-2009
+ */
+public class ManagedFramework implements ManagedFrameworkMBean
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(ManagedFramework.class);
+
+ private MBeanServer mbeanServer;
+ private BundleContext systemContext;
+
+ public ManagedFramework(BundleContext systemContext, MBeanServer mbeanServer)
+ {
+ this.systemContext = systemContext;
+ this.mbeanServer = mbeanServer;
+ }
+
+ public ManagedFramework()
+ {
+ }
+
+ public void setMbeanServer(MBeanServer server)
+ {
+ this.mbeanServer = server;
+ }
+
+ public void setSystemContext(BundleContext systemContext)
+ {
+ this.systemContext = systemContext;
+ }
+
+ @SuppressWarnings("unchecked")
+ public ObjectName getBundle(String symbolicName)
+ {
+ ObjectName pattern = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=" + symbolicName + ",*");
+ Set<ObjectName> names = mbeanServer.queryNames(pattern, null);
+
+ if (names.size() < 1)
+ return null;
+
+ if (names.size() > 1)
+ throw new IllegalArgumentException("Multiple bundles found: " + names);
+
+ return names.iterator().next();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Set<ObjectName> getBundles()
+ {
+ // [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;
+ }
+
+ public ManagedServiceReference getServiceReference(String clazz)
+ {
+ ManagedServiceReference manref = null;
+ ServiceReference sref = systemContext.getServiceReference(clazz);
+ if (sref != null)
+ {
+ 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;
+ }
+
+ public ManagedServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
+ {
+ List<ManagedServiceReference> foundRefs = new ArrayList<ManagedServiceReference>();
+ ServiceReference[] srefs = systemContext.getServiceReferences(clazz, filter);
+ if (srefs != null)
+ {
+ for (ServiceReference sref : srefs)
+ {
+ 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;
+ }
+
+ public void refreshPackages(String[] symbolicNames)
+ {
+ ServiceReference sref = systemContext.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin service = (PackageAdmin)systemContext.getService(sref);
+
+ Bundle[] bundles = null;
+ if (symbolicNames != null)
+ {
+ List<String> nameList = Arrays.asList(symbolicNames);
+ Set<Bundle> bundleSet = new HashSet<Bundle>();
+ for (Bundle bundle : systemContext.getBundles())
+ {
+ if (nameList.contains(bundle.getSymbolicName()))
+ bundleSet.add(bundle);
+ }
+ bundles = new Bundle[bundleSet.size()];
+ bundleSet.toArray(bundles);
+ }
+ service.refreshPackages(bundles);
+ }
+
+ public void start()
+ {
+ try
+ {
+ if (mbeanServer != null)
+ mbeanServer.registerMBean(this, ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
+ }
+ catch (Exception ex)
+ {
+ log.warn("Cannot register: " + ManagedFrameworkMBean.MBEAN_MANAGED_FRAMEWORK);
+ }
+ }
+
+ // Accept names like "jboss.osgi:bundle=*"
+ static class IsBundleQueryExp implements QueryExp
+ {
+ private static final long serialVersionUID = 1L;
+
+ public boolean apply(ObjectName name)
+ {
+ return name.getKeyProperty("bundle") != null;
+ }
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java 2009-05-29 13:51:03 UTC (rev 89529)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/management/ManagedServiceReference.java 2009-05-29 14:09:21 UTC (rev 89530)
@@ -21,6 +21,7 @@
*/
package org.jboss.osgi.spi.management;
+import java.io.Serializable;
import java.util.Map;
import java.util.Set;
@@ -30,16 +31,23 @@
* @author Thomas.Diesler(a)jboss.org
* @since 25-Sep-2008
*/
-public class ManagedServiceReference
+public class ManagedServiceReference implements Serializable
{
- private String className;
+ private static final long serialVersionUID = 1L;
+
+ private String serviceInterface;
private Map<String, Object> props;
public ManagedServiceReference(String className, Map<String, Object> props)
{
- this.className = className;
+ this.serviceInterface = className;
}
+ public String getServiceInterface()
+ {
+ return serviceInterface;
+ }
+
public Object getProperty(String key)
{
return props.get(key);
16 years, 6 months
JBoss-OSGI SVN: r89528 - in projects/jboss-osgi/trunk: blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender and 9 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-05-29 08:37:36 -0400 (Fri, 29 May 2009)
New Revision: 89528
Added:
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/BlueprintService.java
projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/RemoteLogService.java
projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/RemoteLogServiceActivator.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyActivator.java
Removed:
projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/ServiceActivator.java
projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/Activator.java
Modified:
projects/jboss-osgi/trunk/blueprint/impl/pom.xml
projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintActivator.java
projects/jboss-osgi/trunk/bundles/remotelog/pom.xml
projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/RemoteLogListener.java
projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/RemoteLogReaderServiceImpl.java
projects/jboss-osgi/trunk/husky/harness/pom.xml
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/BlueprintCapability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/Capability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/ConfigAdminCapability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HttpCapability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HuskyCapability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/JAXBCapability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/JMXCapability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/JNDICapability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/MicrocontainerCapability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/RemoteLogCapability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/XMLBindingCapability.java
projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/XMLParserCapability.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/RemoteRuntime.java
Log:
Add capability dependent on whether it is already registered
Modified: projects/jboss-osgi/trunk/blueprint/impl/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/pom.xml 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/blueprint/impl/pom.xml 2009-05-29 12:37:36 UTC (rev 89528)
@@ -64,8 +64,9 @@
</Export-Package>
<Import-Package>
org.apache.xerces.dom,
- org.jboss.osgi.spi,
+ org.jboss.osgi.spi;version=1.0,
org.jboss.osgi.common.log;version=1.0,
+ org.jboss.osgi.common.service;version=1.0,
org.jboss.xb.*,
org.osgi.framework,
org.osgi.service.log,
Modified: projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintActivator.java
===================================================================
--- projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintActivator.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/blueprint/impl/src/main/java/org/jboss/osgi/blueprint/extender/BlueprintActivator.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -23,6 +23,7 @@
//$Id$
+import org.jboss.osgi.common.service.BlueprintService;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleListener;
@@ -40,6 +41,10 @@
public void start(BundleContext context) throws Exception
{
+ // Register the marker service
+ BlueprintService service = new BlueprintService(){};
+ context.registerService(BlueprintService.class.getName(), service, null);
+
extender = new BlueprintExtender(context);
context.addBundleListener(extender);
}
Added: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/BlueprintService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/BlueprintService.java (rev 0)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/BlueprintService.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -0,0 +1,34 @@
+/*
+ * 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$
+
+/**
+ * A marker service that is registered by jboss-osgi-blueprint
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 29-May-2009
+ */
+public interface BlueprintService
+{
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/BlueprintService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/RemoteLogService.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/RemoteLogService.java (rev 0)
+++ projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/RemoteLogService.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -0,0 +1,34 @@
+/*
+ * 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$
+
+/**
+ * A marker service that is registered by jboss-osgi-remotelog
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 29-May-2009
+ */
+public interface RemoteLogService
+{
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/bundles/common/src/main/java/org/jboss/osgi/common/service/RemoteLogService.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/bundles/remotelog/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/bundles/remotelog/pom.xml 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/bundles/remotelog/pom.xml 2009-05-29 12:37:36 UTC (rev 89528)
@@ -43,6 +43,13 @@
<scope>provided</scope>
</dependency>
+ <!-- Bundle Dependencies -->
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-common</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
<!-- Remoting Dependencies -->
<dependency>
<groupId>org.jboss.remoting</groupId>
@@ -81,7 +88,7 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
- <Bundle-Activator>org.jboss.osgi.service.remotelog.internal.ServiceActivator</Bundle-Activator>
+ <Bundle-Activator>org.jboss.osgi.service.remotelog.internal.RemoteLogServiceActivator</Bundle-Activator>
<Export-Package>org.jboss.osgi.service.remotelog;version=${version}</Export-Package>
<Import-Package>
org.osgi.framework,
@@ -99,8 +106,9 @@
org.apache.log4j,
org.jboss.logging,
org.jboss.mx.util;resolution:=optional,
- org.jboss.osgi.spi,
- org.jboss.osgi.spi.logging,
+ org.jboss.osgi.common.service;version=1.0,
+ org.jboss.osgi.spi;version=1.0,
+ org.jboss.osgi.spi.logging;version=1.0,
org.jboss.remoting;resolution:=optional,
org.jboss.remoting.*;resolution:=optional,
org.jboss.util.*,
Modified: projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/RemoteLogListener.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/RemoteLogListener.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/RemoteLogListener.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -25,7 +25,7 @@
import java.util.Properties;
-import org.jboss.osgi.service.remotelog.internal.ServiceActivator;
+import org.jboss.osgi.service.remotelog.internal.RemoteLogServiceActivator;
import org.jboss.osgi.service.remotelog.internal.RemoteLogEntry;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
@@ -54,8 +54,8 @@
public RemoteLogListener(BundleContext context, Properties props)
{
this.context = context;
- this.host = props.getProperty(ServiceActivator.REMOTE_LOG_HOST);
- this.port = new Integer(props.getProperty(ServiceActivator.REMOTE_LOG_PORT));
+ this.host = props.getProperty(RemoteLogServiceActivator.REMOTE_LOG_HOST);
+ this.port = new Integer(props.getProperty(RemoteLogServiceActivator.REMOTE_LOG_PORT));
// Get the remoting client
try
Modified: projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/RemoteLogReaderServiceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/RemoteLogReaderServiceImpl.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/RemoteLogReaderServiceImpl.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -58,8 +58,8 @@
public RemoteLogReaderServiceImpl(BundleContext context, Properties props)
{
- this.host = props.getProperty(ServiceActivator.REMOTE_LOG_HOST);
- this.port = new Integer(props.getProperty(ServiceActivator.REMOTE_LOG_PORT));
+ this.host = props.getProperty(RemoteLogServiceActivator.REMOTE_LOG_HOST);
+ this.port = new Integer(props.getProperty(RemoteLogServiceActivator.REMOTE_LOG_PORT));
}
public void addLogListener(LogListener listener)
Copied: projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/RemoteLogServiceActivator.java (from rev 89516, projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/ServiceActivator.java)
===================================================================
--- projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/RemoteLogServiceActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/RemoteLogServiceActivator.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -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.service.remotelog.internal;
+
+//$Id$
+
+import java.util.Properties;
+
+import org.jboss.osgi.common.service.RemoteLogService;
+import org.jboss.osgi.service.remotelog.RemoteLogListener;
+import org.jboss.osgi.spi.logging.RemoteLogReaderService;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * [TODO]
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 23-Jan-2009
+ */
+public class RemoteLogServiceActivator implements BundleActivator
+{
+ public static final String REMOTE_LOG_SENDER = "org.jboss.osgi.service.remote.log.sender";
+ public static final String REMOTE_LOG_READER = "org.jboss.osgi.service.remote.log.reader";
+ public static final String REMOTE_LOG_HOST = "org.jboss.osgi.service.remote.log.host";
+ public static final String REMOTE_LOG_PORT = "org.jboss.osgi.service.remote.log.port";
+
+ private Boolean isReader = Boolean.FALSE;
+ private Boolean isSender = Boolean.FALSE;
+ private RemoteLogReaderServiceImpl readerService;
+ private RemoteLogListener remoteSender;
+
+ public void start(BundleContext context)
+ {
+ String readerProp = context.getProperty(REMOTE_LOG_READER);
+ String senderProp = context.getProperty(REMOTE_LOG_SENDER);
+ String hostProp = context.getProperty(REMOTE_LOG_HOST);
+ String portProp = context.getProperty(REMOTE_LOG_PORT);
+
+ if (readerProp != null)
+ isReader = Boolean.valueOf(readerProp);
+
+ if (senderProp != null)
+ isSender = Boolean.valueOf(senderProp);
+
+ String host = hostProp != null ? hostProp : "localhost";
+ String port = portProp != null ? portProp : "5400";
+
+ Properties props = new Properties();
+ props.put(REMOTE_LOG_HOST, host);
+ props.put(REMOTE_LOG_PORT, port);
+
+ RemoteLogService service = new RemoteLogService(){};
+ context.registerService(RemoteLogService.class.getName(), service, props);
+
+ ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+
+ if (isReader == true)
+ {
+ readerService = new RemoteLogReaderServiceImpl(context, props);
+ context.registerService(RemoteLogReaderService.class.getName(), readerService, props);
+ readerService.start();
+ }
+
+ if (isSender == true)
+ {
+ remoteSender = new RemoteLogListener(context, props);
+ remoteSender.start();
+ }
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(ctxLoader);
+ }
+ }
+
+ public void stop(BundleContext context) throws Exception
+ {
+ if (isReader == true)
+ {
+ readerService.stop();
+ readerService = null;
+ }
+
+ if (isSender == true)
+ {
+ remoteSender.stop();
+ remoteSender = null;
+ }
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/ServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/ServiceActivator.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/bundles/remotelog/src/main/java/org/jboss/osgi/service/remotelog/internal/ServiceActivator.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -1,109 +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.service.remotelog.internal;
-
-//$Id$
-
-import java.util.Properties;
-
-import org.jboss.osgi.service.remotelog.RemoteLogListener;
-import org.jboss.osgi.spi.logging.RemoteLogReaderService;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- * [TODO]
- *
- * @author thomas.diesler(a)jboss.com
- * @since 23-Jan-2009
- */
-public class ServiceActivator implements BundleActivator
-{
- public static final String REMOTE_LOG_SENDER = "org.jboss.osgi.service.remote.log.sender";
- public static final String REMOTE_LOG_READER = "org.jboss.osgi.service.remote.log.reader";
- public static final String REMOTE_LOG_HOST = "org.jboss.osgi.service.remote.log.host";
- public static final String REMOTE_LOG_PORT = "org.jboss.osgi.service.remote.log.port";
-
- private Boolean isReader = Boolean.FALSE;
- private Boolean isSender = Boolean.FALSE;
- private RemoteLogReaderServiceImpl readerService;
- private RemoteLogListener remoteSender;
-
- public void start(BundleContext context)
- {
- String readerProp = context.getProperty(REMOTE_LOG_READER);
- String senderProp = context.getProperty(REMOTE_LOG_SENDER);
- String hostProp = context.getProperty(REMOTE_LOG_HOST);
- String portProp = context.getProperty(REMOTE_LOG_PORT);
-
- if (readerProp != null)
- isReader = Boolean.valueOf(readerProp);
-
- if (senderProp != null)
- isSender = Boolean.valueOf(senderProp);
-
- String host = hostProp != null ? hostProp : "localhost";
- String port = portProp != null ? portProp : "5400";
-
- Properties props = new Properties();
- props.put(REMOTE_LOG_HOST, host);
- props.put(REMOTE_LOG_PORT, port);
-
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
-
- if (isReader == true)
- {
- readerService = new RemoteLogReaderServiceImpl(context, props);
- context.registerService(RemoteLogReaderService.class.getName(), readerService, props);
- readerService.start();
- }
-
- if (isSender == true)
- {
- remoteSender = new RemoteLogListener(context, props);
- remoteSender.start();
- }
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(ctxLoader);
- }
- }
-
- public void stop(BundleContext context) throws Exception
- {
- if (isReader == true)
- {
- readerService.stop();
- readerService = null;
- }
-
- if (isSender == true)
- {
- remoteSender.stop();
- remoteSender = null;
- }
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/husky/harness/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/pom.xml 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/husky/harness/pom.xml 2009-05-29 12:37:36 UTC (rev 89528)
@@ -56,7 +56,7 @@
<configuration>
<instructions>
<Bundle-SymbolicName>${artifactId}</Bundle-SymbolicName>
- <Bundle-Activator>org.jboss.osgi.husky.runtime.osgi.Activator</Bundle-Activator>
+ <Bundle-Activator>org.jboss.osgi.husky.runtime.osgi.HuskyActivator</Bundle-Activator>
<Private-Package>
org.jboss.osgi.husky.internal,
org.jboss.osgi.husky.runtime*,
Deleted: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/Activator.java
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/Activator.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/Activator.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -1,68 +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.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-/**
- * [TODO]
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 17-May-2009
- */
-public class Activator implements BundleActivator
-{
- private SocketConnector socketConnector;
- private JMXConnector jmxConnector;
-
- public void start(BundleContext context) throws Exception
- {
- jmxConnector = new JMXConnector(context);
- jmxConnector.start();
-
- if (SocketConnector.isRemoteConnection(context))
- {
- socketConnector = new SocketConnector(context);
- socketConnector.start();
- }
-
- context.addBundleListener(new Extender(context));
- }
-
- public void stop(BundleContext context) throws Exception
- {
- if (socketConnector != null)
- {
- socketConnector.stop();
- socketConnector = null;
- }
-
- if (jmxConnector != null)
- {
- jmxConnector.stop();
- jmxConnector = null;
- }
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyActivator.java (from rev 89516, projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/Activator.java)
===================================================================
--- projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/husky/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyActivator.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -0,0 +1,68 @@
+/*
+ * 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.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+/**
+ * [TODO]
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 17-May-2009
+ */
+public class HuskyActivator implements BundleActivator
+{
+ private SocketConnector socketConnector;
+ private JMXConnector jmxConnector;
+
+ public void start(BundleContext context) throws Exception
+ {
+ jmxConnector = new JMXConnector(context);
+ jmxConnector.start();
+
+ if (SocketConnector.isRemoteConnection(context))
+ {
+ socketConnector = new SocketConnector(context);
+ socketConnector.start();
+ }
+
+ context.addBundleListener(new Extender(context));
+ }
+
+ public void stop(BundleContext context) throws Exception
+ {
+ if (socketConnector != null)
+ {
+ socketConnector.stop();
+ socketConnector = null;
+ }
+
+ if (jmxConnector != null)
+ {
+ jmxConnector.stop();
+ jmxConnector = null;
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -59,10 +59,10 @@
private static final String JBOSS_BIND_ADDRESS = "jboss.bind.address";
private static final String JBOSS_SERVER_NAME = "jboss.server.name";
- @Option(name = "-c", usage = "Sets the server config (must )")
+ @Option(name = "-c", aliases = { "--server-name" }, usage = "Sets the server config (-c minimal)")
public String serverName = "default";
- @Option(name = "-b", usage = "Sets the bind address")
+ @Option(name = "-b", aliases = { "--bind-address" }, usage = "Sets the bind address (-b 127.0.0.1)")
public String bindAdress = "localhost";
/*
@@ -105,7 +105,7 @@
defaults.setProperty(JBOSS_BIND_ADDRESS, bindAdress);
defaults.setProperty(JAVA_PROTOCOL_HANDLERS, "org.jboss.net.protocol|org.jboss.virtual.protocol");
- getLogger().info("JBoss OSGi System Properties");
+ getLogger().debug("JBoss OSGi System Properties");
Enumeration<?> defaultNames = defaults.propertyNames();
while (defaultNames.hasMoreElements())
@@ -116,7 +116,7 @@
{
String propValue = defaults.getProperty(propName);
System.setProperty(propName, propValue);
- getLogger().info(" " + propName + "=" + propValue);
+ getLogger().debug(" " + propName + "=" + propValue);
}
}
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/BlueprintCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/BlueprintCapability.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/BlueprintCapability.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -36,6 +36,9 @@
{
public BlueprintCapability()
{
+ // [TODO] make this a reference
+ super ("org.jboss.osgi.common.service.BlueprintService");
+
addBundle("bundles/jboss-osgi-blueprint.jar");
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/Capability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/Capability.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/Capability.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -37,13 +37,20 @@
*/
public abstract class Capability
{
+ private String serviceName;
private Properties props = new Properties();
private Set<String> bundles = new LinkedHashSet<String>();
-
- public Capability()
+
+ public Capability(String serviceName)
{
+ this.serviceName = serviceName;
}
+ public String getServiceName()
+ {
+ return serviceName;
+ }
+
public Properties getProperties()
{
return props;
@@ -53,7 +60,7 @@
{
bundles.add(bundle);
}
-
+
protected void addBundles(List<String> bundles)
{
for (String bundle : bundles)
@@ -61,7 +68,7 @@
addBundle(bundle);
}
}
-
+
public List<String> getBundles()
{
return new ArrayList<String>(bundles);
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/ConfigAdminCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/ConfigAdminCapability.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/ConfigAdminCapability.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -21,7 +21,9 @@
*/
package org.jboss.osgi.spi.testing.capability;
+import org.osgi.service.cm.ConfigurationAdmin;
+
//$Id$
/**
@@ -34,6 +36,7 @@
{
public ConfigAdminCapability()
{
+ super(ConfigurationAdmin.class.getName());
addBundle("bundles/org.apache.felix.metatype.jar");
addBundle("bundles/org.apache.felix.configadmin.jar");
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HttpCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HttpCapability.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HttpCapability.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -23,7 +23,9 @@
import java.util.Properties;
+import org.osgi.service.http.HttpService;
+
//$Id$
/**
@@ -36,6 +38,8 @@
{
public HttpCapability()
{
+ super(HttpService.class.getName());
+
Properties props = getProperties();
props.setProperty("org.osgi.service.http.port", "8090");
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HuskyCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HuskyCapability.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/HuskyCapability.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -22,6 +22,7 @@
package org.jboss.osgi.spi.testing.capability;
+
//$Id$
/**
@@ -34,6 +35,8 @@
{
public HuskyCapability()
{
+ // [TODO] make this a reference
+ super("org.jboss.osgi.husky.runtime.Connector");
addBundle("bundles/jboss-osgi-husky.jar");
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/JAXBCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/JAXBCapability.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/JAXBCapability.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -21,7 +21,6 @@
*/
package org.jboss.osgi.spi.testing.capability;
-
//$Id$
@@ -35,6 +34,9 @@
{
public JAXBCapability()
{
+ // [TODO] make this a reference
+ super("org.jboss.osgi.common.service.JAXBService");
+
addBundles(new XMLParserCapability().getBundles());
addBundle("bundles/jboss-osgi-jaxb.jar");
}
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/JMXCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/JMXCapability.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/JMXCapability.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -25,8 +25,10 @@
import java.util.Properties;
+import javax.management.MBeanServer;
+
/**
* [TODO]
*
@@ -37,6 +39,8 @@
{
public JMXCapability()
{
+ super(MBeanServer.class.getName());
+
Properties props = getProperties();
props.setProperty("org.jboss.osgi.jmx.host", System.getProperty("jboss.bind.address", "localhost"));
props.setProperty("org.jboss.osgi.jmx.rmi.port", "1198");
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/JNDICapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/JNDICapability.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/JNDICapability.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -25,8 +25,10 @@
import java.util.Properties;
+import javax.naming.InitialContext;
+
/**
* [TODO]
*
@@ -37,6 +39,8 @@
{
public JNDICapability()
{
+ super(InitialContext.class.getName());
+
Properties props = getProperties();
props.setProperty("org.jboss.osgi.jndi.host", System.getProperty("jboss.bind.address", "localhost"));
props.setProperty("org.jboss.osgi.jndi.rmi.port", "1198");
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/MicrocontainerCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/MicrocontainerCapability.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/MicrocontainerCapability.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -35,6 +35,9 @@
{
public MicrocontainerCapability()
{
+ // [TODO] make this a reference
+ super("org.jboss.osgi.common.service.MicrocontainerService");
+
addBundles(new JMXCapability().getBundles());
addBundles(new XMLBindingCapability().getBundles());
addBundle("bundles/jboss-osgi-microcontainer.jar");
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/RemoteLogCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/RemoteLogCapability.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/RemoteLogCapability.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -37,6 +37,9 @@
{
public RemoteLogCapability()
{
+ // [TODO] make this a reference
+ super("org.jboss.osgi.common.service.RemoteLogService");
+
Properties props = getProperties();
props.setProperty("org.jboss.osgi.service.remote.log.reader", "true");
props.setProperty("org.jboss.osgi.remote.log.host", System.getProperty("jboss.bind.address", "localhost"));
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/XMLBindingCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/XMLBindingCapability.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/XMLBindingCapability.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -35,6 +35,9 @@
{
public XMLBindingCapability()
{
+ // [TODO] make this a reference
+ super ("org.jboss.osgi.common.service.XMLBindingService");
+
addBundles(new JAXBCapability().getBundles());
addBundle("bundles/jboss-osgi-common-core.jar");
addBundle("bundles/jboss-osgi-xml-binding.jar");
Modified: projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/XMLParserCapability.java
===================================================================
--- projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/XMLParserCapability.java 2009-05-29 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/capability/XMLParserCapability.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -21,7 +21,9 @@
*/
package org.jboss.osgi.spi.testing.capability;
+import javax.xml.parsers.SAXParserFactory;
+
//$Id$
@@ -35,6 +37,8 @@
{
public XMLParserCapability()
{
+ super(SAXParserFactory.class.getName());
+
addBundle("bundles/jboss-osgi-apache-xerces.jar");
}
}
\ No newline at end of file
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 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -36,6 +36,7 @@
import org.jboss.osgi.spi.logging.LogEntryCache;
import org.jboss.osgi.spi.testing.OSGiBundle;
import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiServiceReference;
import org.jboss.osgi.spi.testing.OSGiTestHelper;
import org.jboss.osgi.spi.testing.capability.Capability;
import org.osgi.framework.BundleException;
@@ -81,43 +82,48 @@
public void addCapability(Capability capability) throws BundleException
{
- log.debug("Add capability : " + capability);
+ OSGiServiceReference sref = getServiceReference(capability.getServiceName());
+ if (sref == null)
+ {
+ log.debug("Add capability : " + capability);
- for (String location : capability.getBundles())
- {
- if (bundles.get(location) == null)
+ for (String location : capability.getBundles())
{
- OSGiBundle bundle = installBundle(location);
- bundle.start();
+ if (bundles.get(location) == null)
+ {
+ OSGiBundle bundle = installBundle(location);
+ bundle.start();
- bundles.put(location, bundle);
+ bundles.put(location, bundle);
+ }
}
+ capabilities.add(capability);
}
- capabilities.add(capability);
}
public void removeCapability(Capability capability)
{
- log.debug("Remove capability : " + capability);
+ if (capabilities.remove(capability))
+ {
+ log.debug("Remove capability : " + capability);
+
+ List<String> bundleLocations = capability.getBundles();
+ Collections.reverse(bundleLocations);
- capabilities.remove(capability);
-
- List<String> bundleLocations = capability.getBundles();
- Collections.reverse(bundleLocations);
-
- for (String location : bundleLocations)
- {
- OSGiBundle bundle = bundles.remove(location);
- if (bundle != null)
+ for (String location : bundleLocations)
{
- try
+ OSGiBundle bundle = bundles.remove(location);
+ if (bundle != null)
{
- bundle.uninstall();
+ try
+ {
+ bundle.uninstall();
+ }
+ catch (BundleException ex)
+ {
+ log.error("Cannot uninstall bundle: " + bundle);
+ }
}
- catch (BundleException ex)
- {
- log.error("Cannot uninstall bundle: " + bundle);
- }
}
}
}
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 11:53:48 UTC (rev 89527)
+++ projects/jboss-osgi/trunk/spi/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-05-29 12:37:36 UTC (rev 89528)
@@ -47,12 +47,6 @@
import org.jboss.osgi.spi.testing.OSGiPackageAdmin;
import org.jboss.osgi.spi.testing.OSGiServiceReference;
import org.jboss.osgi.spi.testing.OSGiTestHelper;
-import org.jboss.osgi.spi.testing.capability.Capability;
-import org.jboss.osgi.spi.testing.capability.ConfigAdminCapability;
-import org.jboss.osgi.spi.testing.capability.HttpCapability;
-import org.jboss.osgi.spi.testing.capability.JMXCapability;
-import org.jboss.osgi.spi.testing.capability.JNDICapability;
-import org.jboss.osgi.spi.testing.capability.MicrocontainerCapability;
import org.jboss.osgi.spi.testing.capability.RemoteLogCapability;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -72,8 +66,7 @@
{
private MBeanServerConnection mbeanServer;
private ManagedFrameworkMBean managedFramework;
- private Set<Class<?>> ignoredCaps = new HashSet<Class<?>>();
-
+
// Needed for remote logging
private EmbeddedRuntime embeddedRuntime;
private RemoteLogCapability remoteLogCapability;
@@ -81,13 +74,6 @@
public RemoteRuntime(OSGiTestHelper helper)
{
super(helper);
-
- // Initialize the ignored capabilities
- ignoredCaps.add(ConfigAdminCapability.class);
- ignoredCaps.add(HttpCapability.class);
- ignoredCaps.add(JNDICapability.class);
- ignoredCaps.add(JMXCapability.class);
- ignoredCaps.add(MicrocontainerCapability.class);
}
public OSGiBundle installBundle(String location) throws BundleException
@@ -124,15 +110,6 @@
}
}
- @Override
- public void addCapability(Capability capability) throws BundleException
- {
- if (ignoredCaps.contains(capability.getClass()))
- return;
-
- super.addCapability(capability);
- }
-
public OSGiBundle[] getBundles()
{
try
@@ -144,7 +121,7 @@
OSGiBundle[] bundleArr = new OSGiBundle[bundles.size()];
bundles.toArray(bundleArr);
-
+
return bundleArr;
}
catch (Exception ex)
@@ -162,30 +139,30 @@
public OSGiServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
{
OSGiServiceReference[] srefs = null;
-
+
ManagedServiceReference[] manrefs = getRemoteFramework().getServiceReferences(clazz, filter);
if (manrefs != null)
{
srefs = new OSGiServiceReference[manrefs.length];
- for(int i=0; i < manrefs.length; i++)
+ for (int i = 0; i < manrefs.length; i++)
srefs[i] = new RemoteServiceReference(manrefs[i]);
}
-
+
return srefs;
}
public void startLogEntryTracking(final LogEntryCache logEntryCache)
{
super.startLogEntryTracking(logEntryCache);
-
+
try
{
remoteLogCapability = new RemoteLogCapability();
addCapability(remoteLogCapability);
-
+
embeddedRuntime = (EmbeddedRuntime)getTestHelper().getEmbeddedRuntime();
embeddedRuntime.addCapability(remoteLogCapability);
-
+
// Track the RemoteLogReaderService to add the LogEntryCache as LogListener
BundleContext context = embeddedRuntime.getBundleContext();
ServiceTracker tracker = new ServiceTracker(context, RemoteLogReaderService.class.getName(), null)
@@ -215,13 +192,13 @@
removeCapability(remoteLogCapability);
remoteLogCapability = null;
}
-
+
if (embeddedRuntime != null)
{
embeddedRuntime.shutdown();
embeddedRuntime = null;
}
-
+
super.stopLogEntryTracking();
}
@@ -247,7 +224,7 @@
return new RemotePackageAdmin(this);
}
- private RemoteFramework getRemoteFramework()
+ private RemoteFramework getRemoteFramework()
{
try
{
16 years, 6 months