[jboss-cvs] JBossAS SVN: r95024 - in projects/jboss-osgi/projects: bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 16 06:37:54 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-16 06:37:53 -0400 (Fri, 16 Oct 2009)
New Revision: 95024
Removed:
projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/AbstractCommonServicesActivator.java
projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java
projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java
projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java
Modified:
projects/jboss-osgi/projects/bundles/common/trunk/pom.xml
projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/CommonServicesActivator.java
projects/jboss-osgi/projects/spi/trunk/pom.xml
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleContextWrapper.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleWrapper.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegration.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkWrapper.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/logging/ExportedPackageHelper.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteBundle.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ServiceLoader.java
Log:
[JBOSGI-183] Initial implementation of OSGi Deployers
Move deployment stuff from common to deployement project
Modified: projects/jboss-osgi/projects/bundles/common/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/pom.xml 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/bundles/common/trunk/pom.xml 2009-10-16 10:37:53 UTC (rev 95024)
@@ -97,15 +97,11 @@
</Export-Package>
<Import-Package>
javax.management,
- org.apache.log4j;version="1.2";resolution:=optional,
- org.jboss.osgi.spi.management;version="1.0",
- org.jboss.osgi.spi.logging;version="1.0",
- org.jboss.osgi.spi.service;version="1.0",
- org.jboss.osgi.spi.util;version="1.0",
+ org.apache.log4j;version=1.2;resolution:=optional,
+ org.jboss.osgi.spi.logging;version=1.0,
+ org.jboss.osgi.spi.util;version=1.0,
org.osgi.framework;version=1.4,
org.osgi.service.log;version=1.3,
- org.osgi.service.packageadmin;version=1.2,
- org.osgi.service.startlevel;version=1.1,
org.osgi.util.tracker
</Import-Package>
<Embed-Dependency>
Deleted: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/AbstractCommonServicesActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/AbstractCommonServicesActivator.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/AbstractCommonServicesActivator.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -1,111 +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.util.Properties;
-
-import javax.management.JMException;
-import javax.management.MBeanServer;
-import javax.management.StandardMBean;
-
-import org.jboss.osgi.spi.service.DeployerService;
-import org.jboss.osgi.spi.service.DeploymentRegistryService;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogReaderService;
-import org.osgi.util.tracker.ServiceTracker;
-
-
-/**
- * The common services activator
- *
- * @author thomas.diesler at jboss.com
- * @since 23-Jan-2009
- */
-public abstract class AbstractCommonServicesActivator
-{
- protected ServiceTracker 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 LogListenerBridge());
- return logReader;
- }
- };
- return logTracker;
- }
-
- protected DeployerService registerDeployerServices(BundleContext context)
- {
- // Register the DeploymentRegistryService
- DeploymentRegistryService registry = new DeploymentRegistryServiceImpl(context);
- context.registerService(DeploymentRegistryService.class.getName(), registry, null);
-
- // Register the SystemDeployerService
- Properties props = new Properties();
- props.put("provider", "system");
- SystemDeployerService systemDeployer = new SystemDeployerService(context);
- context.registerService(DeployerService.class.getName(), systemDeployer, props);
-
- // Register the DeployerServiceDelegate
- props = new Properties();
- props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
- DeployerService deployerDelegate = new DeployerServiceDelegate(context);
- context.registerService(DeployerService.class.getName(), deployerDelegate, props);
- return deployerDelegate;
- }
-
- protected void registerDeployerServiceMBean(MBeanServer mbeanServer, DeployerService delegate)
- {
- try
- {
- StandardMBean mbean = new StandardMBean(delegate, DeployerService.class);
- mbeanServer.registerMBean(mbean, DeployerService.MBEAN_DEPLOYER_SERVICE);
- }
- catch (JMException ex)
- {
- throw new IllegalStateException("Cannot register DeployerService MBean", ex);
- }
- }
-
- protected void unregisterDeployerServiceMBean(MBeanServer mbeanServer)
- {
- try
- {
- if (mbeanServer.isRegistered(DeployerService.MBEAN_DEPLOYER_SERVICE))
- mbeanServer.unregisterMBean(DeployerService.MBEAN_DEPLOYER_SERVICE);
- }
- catch (JMException ex)
- {
- logError("Cannot unregister DeployerService MBean", ex);
- }
- }
-
- protected abstract void logError(String message, Exception ex);
-}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/CommonServicesActivator.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/CommonServicesActivator.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/CommonServicesActivator.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -24,14 +24,11 @@
//$Id$
-import javax.management.MBeanServer;
-
import org.jboss.osgi.common.log.LogServiceTracker;
-import org.jboss.osgi.spi.service.DeployerService;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
+import org.osgi.service.log.LogReaderService;
import org.osgi.util.tracker.ServiceTracker;
/**
@@ -40,17 +37,11 @@
* @author thomas.diesler at jboss.com
* @since 23-Jan-2009
*/
-public class CommonServicesActivator extends AbstractCommonServicesActivator implements BundleActivator
+public class CommonServicesActivator implements BundleActivator
{
private LogServiceTracker logServiceTracker;
private ServiceTracker logReaderTracker;
- @Override
- protected void logError(String message, Exception ex)
- {
- logServiceTracker.log(LogService.LOG_ERROR, message, ex);
- }
-
public void start(BundleContext context)
{
logServiceTracker = new LogServiceTracker(context);
@@ -58,12 +49,6 @@
// Track LogReaderService and add/remove LogListener
logReaderTracker = trackLogReaderService(context);
logReaderTracker.open();
-
- // Register the system SystemDeployerService and DeployerServiceDelegate
- DeployerService deployer = registerDeployerServices(context);
-
- // Track the MBeanServer and register the DeployerServiceDelegate
- trackMBeanServer(context, deployer);
}
public void stop(BundleContext context)
@@ -73,35 +58,20 @@
if (logReaderTracker != null)
logReaderTracker.close();
-
- ServiceReference sref = context.getServiceReference(MBeanServer.class.getName());
- if (sref != null)
- {
- MBeanServer mbeanServer = (MBeanServer)context.getService(sref);
- unregisterDeployerServiceMBean(mbeanServer);
- }
}
-
- private void trackMBeanServer(BundleContext context, final DeployerService deployer)
+
+ private ServiceTracker trackLogReaderService(BundleContext context)
{
- ServiceTracker jmxTracker = new ServiceTracker(context, MBeanServer.class.getName(), null)
+ ServiceTracker logTracker = new ServiceTracker(context, LogReaderService.class.getName(), null)
{
@Override
public Object addingService(ServiceReference reference)
{
- MBeanServer mbeanServer = (MBeanServer)super.addingService(reference);
- registerDeployerServiceMBean(mbeanServer, deployer);
- return mbeanServer;
+ LogReaderService logReader = (LogReaderService)super.addingService(reference);
+ logReader.addLogListener(new LogListenerBridge());
+ return logReader;
}
-
- @Override
- public void removedService(ServiceReference reference, Object service)
- {
- MBeanServer mbeanServer = (MBeanServer)service;
- unregisterDeployerServiceMBean(mbeanServer);
- super.removedService(reference, service);
- }
};
- jmxTracker.open();
+ return logTracker;
}
}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeployerServiceDelegate.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -1,137 +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.spi.service.DeployerService;
-import org.jboss.osgi.spi.util.BundleDeployment;
-import org.osgi.framework.BundleContext;
-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}
- *
- * This delegate is registered as an MBean
- *
- * @author thomas.diesler at jboss.com
- * @since 27-May-2009
- */
-public class DeployerServiceDelegate implements DeployerService
-{
- private BundleContext context;
-
- public DeployerServiceDelegate(BundleContext context)
- {
- this.context = context;
- }
-
- public void deploy(BundleDeployment[] bundles) throws BundleException
- {
- DeployerService service = getDefaultDeployerService();
- service.deploy(bundles);
- }
-
- public void deploy(URL url) throws BundleException
- {
- DeployerService service = getDefaultDeployerService();
- service.deploy(url);
- }
-
- public void undeploy(BundleDeployment[] bundles) throws BundleException
- {
- for (BundleDeployment info : bundles)
- undeploy(info.getLocation());
- }
-
- public boolean undeploy(URL url) throws BundleException
- {
- boolean undeployed = false;
-
- DeployerService service = getMicrocontainerDeployerService();
- if (service != null)
- undeployed = service.undeploy(url);
-
- if (undeployed == false)
- {
- service = getSystemDeployerService();
- undeployed = service.undeploy(url);
- }
-
- 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
- {
- 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()
- {
- DeployerService service = null;
- try
- {
- String filter = "(provider=system)";
- 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);
- }
-
- if (service == null)
- throw new IllegalStateException("Cannot obtain system DeployerService");
- return service;
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/DeploymentRegistryServiceImpl.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -1,97 +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: SystemDeployerService.java 90894 2009-07-07 11:58:40Z thomas.diesler at jboss.com $
-
-import java.net.URL;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.osgi.spi.service.DeployerService;
-import org.jboss.osgi.spi.service.DeploymentRegistryService;
-import org.jboss.osgi.spi.util.BundleDeployment;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Version;
-
-/**
- * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
- *
- * @author thomas.diesler at jboss.com
- * @since 27-May-2009
- */
-public class DeploymentRegistryServiceImpl implements DeploymentRegistryService
-{
- private Set<BundleDeployment> deployments = new HashSet<BundleDeployment>();
-
- public DeploymentRegistryServiceImpl(BundleContext context)
- {
- }
-
- public void registerBundleDeployment(BundleDeployment dep)
- {
- deployments.add(dep);
- }
-
- public void unregisterBundleDeployment(BundleDeployment dep)
- {
- deployments.remove(dep);
- }
-
- public BundleDeployment getBundleDeployment(String symbolicName, Version version)
- {
- if (symbolicName == null)
- throw new IllegalArgumentException("Cannot obtain bundle deployment for null symbolic name");
-
- BundleDeployment dep = null;
- for (BundleDeployment auxDep : deployments)
- {
- String auxName = auxDep.getSymbolicName();
- String auxVersion = auxDep.getVersion();
- if (symbolicName.equals(auxName) && version.equals(auxVersion))
- {
- dep = auxDep;
- break;
- }
- }
-
- return dep;
- }
-
- public BundleDeployment getBundleDeployment(URL url)
- {
- if (url == null)
- throw new IllegalArgumentException("Cannot obtain bundle deployment for: null");
-
- BundleDeployment dep = null;
- for (BundleDeployment auxDep : deployments)
- {
- if (url.equals(auxDep.getLocation()))
- {
- dep = auxDep;
- break;
- }
- }
-
- return dep;
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/bundles/common/trunk/src/main/java/org/jboss/osgi/common/internal/SystemDeployerService.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -1,260 +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 java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import org.jboss.osgi.common.log.LogServiceTracker;
-import org.jboss.osgi.spi.logging.ExportedPackageHelper;
-import org.jboss.osgi.spi.management.ManagedBundleService;
-import org.jboss.osgi.spi.service.DeployerService;
-import org.jboss.osgi.spi.service.DeploymentRegistryService;
-import org.jboss.osgi.spi.util.BundleDeployment;
-import org.jboss.osgi.spi.util.BundleDeploymentFactory;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Version;
-import org.osgi.service.log.LogService;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.service.startlevel.StartLevel;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * A {@link DeployerService} that installs/uninstalls the bundles directly on the OSGi framework without going through the MC registered deployers.
- *
- * @author thomas.diesler at jboss.com
- * @since 27-May-2009
- */
-public class SystemDeployerService implements DeployerService
-{
- private LogServiceTracker log;
- private BundleContext context;
- private ServiceTracker registryTracker;
- private ServiceTracker startLevelTracker;
-
- public SystemDeployerService(BundleContext context)
- {
- this.log = new LogServiceTracker(context);
- this.context = context;
- }
-
- public void deploy(BundleDeployment[] depArr) throws BundleException
- {
- DeploymentRegistryService registry = getDeploymentRegistry();
-
- List<Bundle> resolvableBundles = new ArrayList<Bundle>();
- Map<BundleDeployment, Bundle> bundleMap = new HashMap<BundleDeployment, Bundle>();
-
- for (BundleDeployment dep : depArr)
- {
- try
- {
- String location = dep.getLocation().toExternalForm();
- Bundle bundle = context.installBundle(location);
- log.log(LogService.LOG_INFO, "Installed: " + bundle);
-
- registerManagedBundle(bundle);
-
- bundleMap.put(dep, bundle);
- if (dep.isAutoStart())
- resolvableBundles.add(bundle);
-
- registry.registerBundleDeployment(dep);
- }
- catch (BundleException ex)
- {
- log.log(LogService.LOG_ERROR, "Cannot install bundle: " + dep, ex);
- }
- }
-
- // Resolve the installed bundles through the PackageAdmin
- ServiceReference packageAdminRef = context.getServiceReference(PackageAdmin.class.getName());
- if (packageAdminRef != null && resolvableBundles.isEmpty() == false)
- {
- PackageAdmin packageAdmin = (PackageAdmin)context.getService(packageAdminRef);
- Bundle[] resolvableBundleArr = new Bundle[resolvableBundles.size()];
- resolvableBundles.toArray(resolvableBundleArr);
- packageAdmin.resolveBundles(resolvableBundleArr);
- }
-
- // Start the installed bundles
- for (Entry<BundleDeployment, Bundle> entry : bundleMap.entrySet())
- {
- BundleDeployment dep = entry.getKey();
- Bundle bundle = entry.getValue();
-
- StartLevel startLevel = getStartLevel();
- if (dep.getStartLevel() > 0)
- {
- startLevel.setBundleStartLevel(bundle, dep.getStartLevel());
- }
-
- if (dep.isAutoStart())
- {
- int state = bundle.getState();
- if (state == Bundle.RESOLVED || packageAdminRef == null)
- {
- try
- {
- log.log(LogService.LOG_DEBUG, "Start: " + bundle);
-
- // Added support for Bundle.START_ACTIVATION_POLICY on start
- // http://issues.apache.org/jira/browse/FELIX-1317
- // bundle.start(Bundle.START_ACTIVATION_POLICY);
-
- bundle.start();
-
- log.log(LogService.LOG_INFO, "Started: " + bundle);
- ExportedPackageHelper packageHelper = new ExportedPackageHelper(context);
- packageHelper.logExportedPackages(bundle);
- }
- catch (BundleException ex)
- {
- log.log(LogService.LOG_ERROR, "Cannot start bundle: " + bundle, ex);
- }
- }
- }
- }
- }
-
- public void undeploy(BundleDeployment[] depArr) throws BundleException
- {
- DeploymentRegistryService registry = getDeploymentRegistry();
-
- for (BundleDeployment dep : depArr)
- {
- Bundle bundle = getBundle(dep);
- if (bundle != null)
- {
- registry.unregisterBundleDeployment(dep);
-
- unregisterManagedBundle(bundle);
- bundle.uninstall();
- log.log(LogService.LOG_INFO, "Uninstalled: " + bundle);
- }
- else
- {
- log.log(LogService.LOG_WARNING, "Cannot obtain bundle for: " + dep);
- }
- }
- }
-
- public void deploy(URL url) throws BundleException
- {
- BundleDeployment dep = BundleDeploymentFactory.createBundleDeployment(url);
- deploy(new BundleDeployment[] { dep });
- }
-
- public boolean undeploy(URL url) throws BundleException
- {
- DeploymentRegistryService registry = getDeploymentRegistry();
- BundleDeployment dep = registry.getBundleDeployment(url);
- if (dep != null)
- {
- undeploy(new BundleDeployment[] { dep });
- return true;
- }
- else
- {
- log.log(LogService.LOG_WARNING, "Cannot find deployment for: " + url);
- return false;
- }
- }
-
- private Bundle getBundle(BundleDeployment dep)
- {
- String symbolicName = dep.getSymbolicName();
- Version version = Version.parseVersion(dep.getVersion());
-
- Bundle bundle = null;
- for (Bundle aux : context.getBundles())
- {
- if (aux.getSymbolicName().equals(symbolicName))
- {
- Version auxVersion = aux.getVersion();
- if (version.equals(auxVersion))
- {
- bundle = aux;
- break;
- }
- }
- }
- return bundle;
- }
-
- private void registerManagedBundle(Bundle bundle)
- {
- ServiceReference sref = context.getServiceReference(ManagedBundleService.class.getName());
- if (sref != null)
- {
- ManagedBundleService service = (ManagedBundleService)context.getService(sref);
- service.register(bundle);
- }
- else
- {
- log.log(LogService.LOG_DEBUG, "No ManagedBundleService. Cannot register managed bundle: " + bundle);
- }
- }
-
- private void unregisterManagedBundle(Bundle bundle)
- {
- ServiceReference sref = context.getServiceReference(ManagedBundleService.class.getName());
- if (sref != null)
- {
- ManagedBundleService service = (ManagedBundleService)context.getService(sref);
- service.unregister(bundle);
- }
- else
- {
- log.log(LogService.LOG_DEBUG, "No ManagedBundleService. Cannot unregister managed bundle: " + bundle);
- }
- }
-
- private DeploymentRegistryService getDeploymentRegistry()
- {
- if (registryTracker == null)
- {
- registryTracker = new ServiceTracker(context, DeploymentRegistryService.class.getName(), null);
- registryTracker.open();
- }
- return (DeploymentRegistryService)registryTracker.getService();
- }
-
- private StartLevel getStartLevel()
- {
- if (startLevelTracker == null)
- {
- startLevelTracker = new ServiceTracker(context, StartLevel.class.getName(), null);
- startLevelTracker.open();
- }
- return (StartLevel)startLevelTracker.getService();
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/spi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/pom.xml 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/pom.xml 2009-10-16 10:37:53 UTC (rev 95024)
@@ -39,8 +39,8 @@
<!-- Properties -->
<properties>
<version.args4j>2.0.12</version.args4j>
- <version.jboss.logging>2.0.5.GA</version.jboss.logging>
<version.jboss.vfs>2.1.3.SP1</version.jboss.vfs>
+ <version.slf4j>1.5.8</version.slf4j>
<version.osgi>r4v42</version.osgi>
</properties>
@@ -54,16 +54,16 @@
<version>${version.args4j}</version>
</dependency>
<dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${version.slf4j}</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-vfs</artifactId>
<version>${version.jboss.vfs}</version>
</dependency>
<dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- <version>${version.jboss.logging}</version>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleContextWrapper.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleContextWrapper.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleContextWrapper.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -27,7 +27,6 @@
import java.io.InputStream;
import java.util.Dictionary;
-import org.jboss.logging.Logger;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -38,6 +37,8 @@
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A generic BundleContext wrapper that delegates all method calls to the underlying
@@ -49,7 +50,7 @@
public class BundleContextWrapper implements BundleContext
{
// Provide logging
- final Logger log = Logger.getLogger(BundleContextWrapper.class);
+ final Logger log = LoggerFactory.getLogger(BundleContextWrapper.class);
protected BundleContext context;
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleWrapper.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleWrapper.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/BundleWrapper.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -30,12 +30,13 @@
import java.util.Enumeration;
import java.util.Map;
-import org.jboss.logging.Logger;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A generic Bundle wrapper that delegates all method calls to the underlying
@@ -47,7 +48,7 @@
public class BundleWrapper implements Bundle
{
// Provide logging
- final Logger log = Logger.getLogger(BundleWrapper.class);
+ final Logger log = LoggerFactory.getLogger(BundleWrapper.class);
protected Bundle bundle;
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegration.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegration.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkIntegration.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -29,13 +29,14 @@
import java.util.List;
import java.util.Map;
-import org.jboss.logging.Logger;
import org.jboss.osgi.spi.FrameworkException;
import org.jboss.osgi.spi.logging.ExportedPackageHelper;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.launch.Framework;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* An abstraction of an OSGi Framework.
@@ -49,7 +50,7 @@
public abstract class FrameworkIntegration
{
// Provide logging
- final Logger log = Logger.getLogger(FrameworkIntegration.class);
+ final Logger log = LoggerFactory.getLogger(FrameworkIntegration.class);
private Map<String, Object> properties = new HashMap<String, Object>();
private List<URL> autoInstall = new ArrayList<URL>();
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkWrapper.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkWrapper.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/FrameworkWrapper.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -30,13 +30,14 @@
import java.util.Enumeration;
import java.util.Map;
-import org.jboss.logging.Logger;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
import org.osgi.framework.launch.Framework;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A generic Framework wrapper that delegates all method calls to the underlying
@@ -48,7 +49,7 @@
public class FrameworkWrapper implements Framework
{
// Provide logging
- final Logger log = Logger.getLogger(FrameworkWrapper.class);
+ final Logger log = LoggerFactory.getLogger(FrameworkWrapper.class);
protected Framework framework;
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -37,13 +37,14 @@
import java.util.List;
import java.util.Properties;
-import org.jboss.logging.Logger;
import org.jboss.osgi.spi.util.ServiceLoader;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
import org.osgi.framework.BundleException;
import org.osgi.framework.launch.Framework;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The OSGiBootstrap provides an {@link OSGiFramework} through a {@link OSGiBootstrapProvider}.
@@ -129,7 +130,7 @@
// This property must be set before the logger is obtained
System.setProperty(OSGI_SERVER_HOME, osgiServerHome);
- log = Logger.getLogger(OSGiBootstrap.class);
+ log = LoggerFactory.getLogger(OSGiBootstrap.class);
Properties defaults = new Properties();
defaults.setProperty(OSGI_SERVER_NAME, serverName);
@@ -172,7 +173,7 @@
}
catch (Exception ex)
{
- Logger tmplog = Logger.getLogger(OSGiBootstrap.class);
+ Logger tmplog = LoggerFactory.getLogger(OSGiBootstrap.class);
tmplog.debug("Cannot configure [" + aux.getClass().getName() + "]", ex);
}
}
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -38,7 +38,6 @@
import java.util.Properties;
import java.util.Set;
-import org.jboss.logging.Logger;
import org.jboss.osgi.spi.FrameworkException;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.internal.StringPropertyReplacer;
@@ -52,6 +51,8 @@
import org.osgi.framework.Version;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A simple properties based bootstrap provider
@@ -69,7 +70,6 @@
* # Properties to configure the Framework
* org.osgi.framework.storage.clean=onFirstInit
* org.osgi.framework.system.packages=\
- * org.jboss.logging, \
* org.osgi.framework; version=1.4, \
* javax.management
*
@@ -92,7 +92,7 @@
public class PropertiesBootstrapProvider implements OSGiBootstrapProvider
{
// Provide logging
- final Logger log = Logger.getLogger(PropertiesBootstrapProvider.class);
+ final Logger log = LoggerFactory.getLogger(PropertiesBootstrapProvider.class);
/** The default framework property: jboss.osgi.framework.properties */
public static final String OSGI_FRAMEWORK_CONFIG = "jboss.osgi.framework.properties";
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/logging/ExportedPackageHelper.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/logging/ExportedPackageHelper.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/logging/ExportedPackageHelper.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -27,12 +27,13 @@
import java.util.Collections;
import java.util.List;
-import org.jboss.logging.Logger;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.packageadmin.ExportedPackage;
import org.osgi.service.packageadmin.PackageAdmin;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* A helper the logs the exported packages for a bundle.
@@ -43,7 +44,7 @@
public final class ExportedPackageHelper
{
// Provide logging
- final Logger log = Logger.getLogger(ExportedPackageHelper.class);
+ final Logger log = LoggerFactory.getLogger(ExportedPackageHelper.class);
private PackageAdmin packageAdmin;
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -36,13 +36,14 @@
import javax.management.ObjectName;
import javax.management.QueryExp;
-import org.jboss.logging.Logger;
import org.jboss.osgi.spi.OSGiConstants;
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;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The managed view of an OSGi Framework
@@ -53,7 +54,7 @@
public class ManagedFramework implements ManagedFrameworkMBean
{
// Provide logging
- final Logger log = Logger.getLogger(ManagedFramework.class);
+ final Logger log = LoggerFactory.getLogger(ManagedFramework.class);
private MBeanServer mbeanServer;
private BundleContext bundleContext;
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/OSGiTest.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -27,10 +27,11 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.jboss.logging.Logger;
import org.jboss.virtual.VFS;
import org.junit.After;
import org.junit.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* An abstract OSGi Test.
@@ -44,7 +45,7 @@
public abstract class OSGiTest
{
// Provide logging
- final Logger log = Logger.getLogger(OSGiTest.class);
+ final Logger log = LoggerFactory.getLogger(OSGiTest.class);
private OSGiTestHelper helper;
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -40,7 +40,6 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
-import org.jboss.logging.Logger;
import org.jboss.osgi.spi.capability.Capability;
import org.jboss.osgi.spi.testing.OSGiBundle;
import org.jboss.osgi.spi.testing.OSGiRuntime;
@@ -50,6 +49,8 @@
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* An abstract implementation of the {@link OSGiRuntime}
@@ -60,7 +61,7 @@
public abstract class OSGiRuntimeImpl implements OSGiRuntime
{
// Provide logging
- final Logger log = Logger.getLogger(OSGiRuntimeImpl.class);
+ final Logger log = LoggerFactory.getLogger(OSGiRuntimeImpl.class);
private OSGiTestHelper helper;
private Map<String, OSGiBundle> bundles = new LinkedHashMap<String, OSGiBundle>();
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteBundle.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteBundle.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteBundle.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -21,15 +21,18 @@
*/
package org.jboss.osgi.spi.testing.internal;
+// $Id$
+
import java.util.Dictionary;
-import org.jboss.logging.Logger;
import org.jboss.osgi.spi.management.ManagedBundleMBean;
import org.jboss.osgi.spi.testing.OSGiBundle;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* An implementation of a remote {@link OSGiBundle}
@@ -40,7 +43,7 @@
public class RemoteBundle extends OSGiBundle
{
// Provide logging
- private static final Logger log = Logger.getLogger(RemoteBundle.class);
+ private final Logger log = LoggerFactory.getLogger(RemoteBundle.class);
private OSGiRuntimeImpl runtime;
private ManagedBundleMBean bundle;
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ServiceLoader.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ServiceLoader.java 2009-10-16 10:01:33 UTC (rev 95023)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ServiceLoader.java 2009-10-16 10:37:53 UTC (rev 95024)
@@ -28,7 +28,8 @@
import java.util.ArrayList;
import java.util.List;
-import org.jboss.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Loads service implementations from the requesters classpath.
@@ -39,7 +40,7 @@
public abstract class ServiceLoader
{
// Provide logging
- final static Logger log = Logger.getLogger(ServiceLoader.class);
+ static final Logger log = LoggerFactory.getLogger(ServiceLoader.class);
/**
* Loads a list of service implementations defined in META-INF/services/${serviceClass}
More information about the jboss-cvs-commits
mailing list