JBoss-OSGI SVN: r92608 - projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-20 08:28:36 -0400 (Thu, 20 Aug 2009)
New Revision: 92608
Modified:
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer/install-definition.xml
Log:
Install OSGiBootstrapProvider in META-INF/services
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer/install-definition.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer/install-definition.xml 2009-08-20 12:03:26 UTC (rev 92607)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/installer/install-definition.xml 2009-08-20 12:28:36 UTC (rev 92608)
@@ -159,7 +159,7 @@
<executable targetfile="$INSTALL_PATH/runtime/bin/run.sh" stage="never" keep="true"/>
<!-- JBossOSGi conf -->
- <fileset dir="@{runtime.dir}/conf" targetdir="$INSTALL_PATH/runtime/conf" override="true">
+ <fileset dir="@{runtime.dir}/conf" targetdir="$INSTALL_PATH/runtime/conf/META-INF/services" override="true">
<include name="org.jboss.osgi.spi.framework.OSGiBootstrapProvider" />
</fileset>
16 years, 11 months
JBoss-OSGI SVN: r92607 - in projects/jboss-osgi: projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal and 10 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-20 08:03:26 -0400 (Thu, 20 Aug 2009)
New Revision: 92607
Added:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapProvider.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/jboss-osgi-framework.xml
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/services/
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-framework.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/services/
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
Removed:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/bootstrap.xml
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
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/PropertiesBootstrapProvider.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ServiceLoader.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryPluginImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java
Log:
Add FrameworkBootstrapProvider
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-08-20 11:43:14 UTC (rev 92606)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/OSGiBootstrap.java 2009-08-20 12:03:26 UTC (rev 92607)
@@ -26,7 +26,6 @@
import static org.jboss.osgi.spi.Constants.OSGI_HOME;
import static org.jboss.osgi.spi.Constants.OSGI_SERVER_HOME;
-import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -35,11 +34,13 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Enumeration;
+import java.util.List;
import java.util.Properties;
import org.jboss.logging.Logger;
import org.jboss.osgi.spi.service.DeploymentScannerService;
import org.jboss.osgi.spi.service.DeploymentScannerService.ScanListener;
+import org.jboss.osgi.spi.util.ServiceLoader;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.Option;
@@ -158,49 +159,31 @@
}
/*
- * * Get an instance of an OSGiBootstrapProvider.
+ * Get an instance of an OSGiBootstrapProvider.
*/
public static OSGiBootstrapProvider getBootstrapProvider()
{
- OSGiBootstrapProvider provider;
+ OSGiBootstrapProvider provider = null;
- // Get the provider name from the System property
- String providerName = System.getProperty(OSGiBootstrapProvider.class.getName());
-
- // Get the provider name from the resource file
- if (providerName == null)
+ List<OSGiBootstrapProvider> providers = ServiceLoader.loadServices(OSGiBootstrapProvider.class);
+ for (OSGiBootstrapProvider aux : providers)
{
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- URL providerURL = ctxLoader.getResource(OSGiBootstrapProvider.class.getName());
- if (providerURL == null)
- throw new IllegalStateException("Cannot find resource: " + OSGiBootstrapProvider.class.getName());
-
try
{
- providerName = new BufferedReader(new InputStreamReader(providerURL.openStream())).readLine();
+ aux.configure();
+ provider = aux;
+ break;
}
- catch (Exception e)
+ catch (Exception ex)
{
- throw new IllegalStateException("Cannot read bootstrap provider name from: " + providerURL);
+ Logger tmplog = Logger.getLogger(OSGiBootstrap.class);
+ tmplog.debug("Cannot configure [" + aux.getClass().getName() + "], cause: " + ex);
}
}
- // Verify that we have a provider name
- if (providerName == null)
+ if (provider == null)
throw new IllegalStateException("Cannot obtain bootstrap provider");
- // Load the bootstrap provider
- try
- {
- ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
- Class<?> providerClass = ctxLoader.loadClass(providerName);
- provider = (OSGiBootstrapProvider)providerClass.newInstance();
- }
- catch (Exception e)
- {
- throw new IllegalStateException("Cannot load bootstrap provider: " + providerName);
- }
-
return provider;
}
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-08-20 11:43:14 UTC (rev 92606)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/framework/PropertiesBootstrapProvider.java 2009-08-20 12:03:26 UTC (rev 92607)
@@ -59,7 +59,6 @@
* The PropertiesBootstrapProvider supports the following properties
*
* <ul>
- * <li><b>org.jboss.osgi.spi.framework.impl</b> - The OSGiFramework implementation</li>
* <li><b>org.jboss.osgi.spi.framework.autoInstall</b> - Bundles that need to be installed with the Framework automatically</li>
* <li><b>org.jboss.osgi.spi.framework.autoStart</b> - Bundles that need to be started automatically</li>
* </ul>
@@ -67,9 +66,6 @@
* All other properties are passed on to configure the framework.
*
* <pre>
- * # The OSGiFramework implementation
- * org.jboss.osgi.spi.framework.impl=org.jboss.osgi.felix.framework.FelixIntegration
- *
* # Properties to configure the Framework
* org.osgi.framework.storage.clean=onFirstInit
* org.osgi.framework.system.packages=\
@@ -123,7 +119,7 @@
public void configure()
{
- configure(DEFAULT_OSGI_FRAMEWORK_PROPERTIES);
+ configure(System.getProperty(OSGI_FRAMEWORK_CONFIG, DEFAULT_OSGI_FRAMEWORK_PROPERTIES));
}
public void configure(URL urlConfig)
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-08-20 11:43:14 UTC (rev 92606)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-08-20 12:03:26 UTC (rev 92607)
@@ -68,12 +68,22 @@
String symbolicName = getManifestEntry(location, Constants.BUNDLE_SYMBOLICNAME);
String version = getManifestEntry(location, Constants.BUNDLE_VERSION);
+ OSGiBundle bundle;
+
+ BundleContext context = getBundleContext();
URL bundleURL = getTestHelper().getTestArchiveURL(location);
- ServiceReference sref = getBundleContext().getServiceReference(DeployerService.class.getName());
- DeployerService service = (DeployerService)getBundleContext().getService(sref);
- service.deploy(bundleURL);
-
- OSGiBundle bundle = getBundle(symbolicName, version);
+ ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
+ if (sref != null)
+ {
+ DeployerService service = (DeployerService)context.getService(sref);
+ service.deploy(bundleURL);
+ bundle = getBundle(symbolicName, version);
+ }
+ else
+ {
+ Bundle auxBundle = context.installBundle(bundleURL.toExternalForm());
+ bundle = new EmbeddedBundle(this, auxBundle);
+ }
return registerBundle(location, 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-08-20 11:43:14 UTC (rev 92606)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ServiceLoader.java 2009-08-20 12:03:26 UTC (rev 92607)
@@ -22,50 +22,89 @@
package org.jboss.osgi.spi.util;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+import org.jboss.logging.Logger;
+
/**
- * Loads a service from the requesters classpath.
+ * Loads service implementations from the requesters classpath.
*
* @author Thomas.Diesler(a)jboss.com
* @since 14-Dec-2006
*/
public abstract class ServiceLoader
{
+ // Provide logging
+ final static Logger log = Logger.getLogger(ServiceLoader.class);
+
/**
- * Loads the requested service from META-INF/services/${serviceClass}
+ * Loads a list of service implementations defined in META-INF/services/${serviceClass}
*/
@SuppressWarnings("unchecked")
- public static <T> T loadService(Class<T> serviceClass)
+ public static <T> List<T> loadServices(Class<T> serviceClass)
{
- T factory = null;
- String factoryName = null;
+ List<T> services = new ArrayList<T>();
ClassLoader loader = serviceClass.getClassLoader();
-
+
// Use the Services API (as detailed in the JAR specification), if available, to determine the classname.
String filename = "META-INF/services/" + serviceClass.getName();
InputStream inStream = loader.getResourceAsStream(filename);
+ if (inStream == null)
+ log.debug ("Cannot find resource: " + filename);
+
if (inStream != null)
{
try
{
BufferedReader br = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
- factoryName = br.readLine();
- br.close();
- if (factoryName != null)
+ String implClassName = br.readLine();
+ while(implClassName != null)
{
- factoryName = factoryName.trim();
- Class<T> factoryClass = (Class<T>)loader.loadClass(factoryName);
- factory = factoryClass.newInstance();
+ int hashIndex = implClassName.indexOf("#");
+ if (hashIndex > 0)
+ implClassName = implClassName.substring(0, hashIndex);
+
+ implClassName = implClassName.trim();
+
+ if (implClassName.length() > 0)
+ {
+ try
+ {
+ Class<T> implClass = (Class<T>)loader.loadClass(implClassName);
+ services.add(implClass.newInstance());
+ }
+ catch (Exception ex)
+ {
+ log.debug ("Cannot load service: " + implClassName);
+ }
+ }
+
+ implClassName = br.readLine();
}
+ br.close();
}
- catch (Throwable t)
+ catch (IOException ex)
{
- throw new IllegalStateException("Failed to load " + serviceClass.getName() + ": " + factoryName, t);
+ throw new IllegalStateException("Failed to load services for: " + serviceClass.getName());
}
}
- return factory;
+ if (services.size() == 0)
+ throw new IllegalStateException("Failed to load services for: " + serviceClass.getName());
+
+ return services;
}
+
+ /**
+ * Loads the first of a list of service implementations defined in META-INF/services/${serviceClass}
+ */
+ public static <T> T loadService(Class<T> serviceClass)
+ {
+ List<T> services = loadServices(serviceClass);
+ return services.get(0);
+ }
}
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapProvider.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapProvider.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapProvider.java 2009-08-20 12:03:26 UTC (rev 92607)
@@ -0,0 +1,73 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id: FrameworkFactoryBean.java 92605 2009-08-20 10:29:21Z thomas.diesler(a)jboss.com $
+
+import java.io.InputStream;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.spi.framework.OSGiBootstrapProvider;
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * An implementation of a OSGiBootstrapProvider.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 29-Jul-2009
+ */
+public class FrameworkBootstrapProvider implements OSGiBootstrapProvider
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(FrameworkBootstrapProvider.class);
+
+ private Framework framework;
+
+ public void configure()
+ {
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ framework = factory.newFramework(null);
+ }
+
+ public void configure(URL urlConfig)
+ {
+ configure();
+ }
+
+ public void configure(String resourceConfig)
+ {
+ configure();
+ }
+
+ public void configure(InputStream streamConfig)
+ {
+ configure();
+ }
+
+ public Framework getFramework()
+ {
+ return framework;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java 2009-08-20 11:43:14 UTC (rev 92606)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java 2009-08-20 12:03:26 UTC (rev 92607)
@@ -46,12 +46,15 @@
// Provide logging
final Logger log = Logger.getLogger(FrameworkFactoryImpl.class);
+ private static final String BOOTSTRAP_NAME = "jboss-osgi-bootstrap.xml";
+
@SuppressWarnings("unchecked")
public Framework newFramework(Map configuration)
{
// Create a configuration
MCServerConfig config = new BasicMCServerConfig();
config.bootstrapHome(getBootstrapHome());
+ config.bootstrapName(BOOTSTRAP_NAME);
// Create the server
final MCServer server = new MCServerImpl(config);
@@ -91,6 +94,6 @@
private URL getBootstrapUrl()
{
ClassLoader cl = getClass().getClassLoader();
- return cl.getResource("META-INF/bootstrap.xml");
+ return cl.getResource("META-INF/" + BOOTSTRAP_NAME);
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-20 11:43:14 UTC (rev 92606)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-20 12:03:26 UTC (rev 92607)
@@ -113,7 +113,7 @@
{
if (AbstractPlugin.class.isAssignableFrom(interf))
{
- log.debug("Plugin: [" + interf.getName() + "=" + clazz.getName() + "]");
+ log.debug("Add plugin: " + clazz.getName());
plugins.put(interf, plugin);
}
}
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryPluginImpl.java 2009-08-20 11:43:14 UTC (rev 92606)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryPluginImpl.java 2009-08-20 12:03:26 UTC (rev 92607)
@@ -190,6 +190,9 @@
public Object getService(Bundle bundle, ServiceReference sref)
{
+ if (sref == null)
+ throw new IllegalArgumentException("Cannot get service for null reference");
+
ServiceReferenceImpl srefImpl = (ServiceReferenceImpl)sref;
// If the service has been unregistered, null is returned.
@@ -221,6 +224,9 @@
public boolean ungetService(Bundle bundle, ServiceReference sref)
{
+ if (sref == null)
+ throw new IllegalArgumentException("Cannot unget service for null reference");
+
ServiceReferenceImpl srefImpl = (ServiceReferenceImpl)sref;
// 1. If the context bundle's use count for the service is zero or the service has been unregistered, false is returned.
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/bootstrap.xml 2009-08-20 11:43:14 UTC (rev 92606)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/bootstrap.xml 2009-08-20 12:03:26 UTC (rev 92607)
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<bootstrap xmlns="urn:jboss:bootstrap:1.0">
-
- <url>jboss-osgi-framework.xml</url>
-
-</bootstrap>
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml 2009-08-20 11:43:14 UTC (rev 92606)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml 2009-08-20 12:03:26 UTC (rev 92607)
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- $Id$
--->
-
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
- <!--
- ********************************
- * *
- * Framework *
- * *
- ********************************
- -->
-
- <!-- The OSGi Framework Factory -->
- <bean name="jboss.osgi:service=FrameworkFactory" class="org.jboss.osgi.jbossmc.framework.FrameworkFactoryBean">
- <property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
- <property name="properties">
- <map keyClass="java.lang.String" valueClass="java.lang.String">
- <entry><key>org.osgi.framework.storage</key><value>${log4j.output.dir}/osgi-store</value></entry>
- <entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
- </map>
- </property>
- <property name="plugins">
- <list elementClass="org.jboss.osgi.jbossmc.api.AbstractPlugin">
- <inject bean="jboss.osgi:plugin=ClassLoaderFactory"/>
- </list>
- </property>
- <property name="autoInstall">
- <list elementClass="java.net.URL">
- </list>
- </property>
- <property name="autoStart">
- <list elementClass="java.net.URL">
- </list>
- </property>
- </bean>
-
- <!--
- ********************************
- * *
- * Framework Plugins *
- * *
- ********************************
- -->
-
- <bean name="jboss.osgi:plugin=ClassLoaderFactory" class="org.jboss.osgi.jbossmc.framework.ClassLoaderFactoryPluginImpl"/>
-
-</deployment>
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java 2009-08-20 11:43:14 UTC (rev 92606)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java 2009-08-20 12:03:26 UTC (rev 92607)
@@ -45,13 +45,13 @@
{
private static OSGiRuntime runtime;
- //@BeforeClass
+ @BeforeClass
public static void beforeClass() throws BundleException
{
runtime = new OSGiTestHelper().getDefaultRuntime();
}
- //@AfterClass
+ @AfterClass
public static void afterClass() throws BundleException
{
if (runtime != null)
@@ -59,7 +59,6 @@
}
@Test
- @Ignore
public void testBundleInstall() throws Exception
{
OSGiBundle bundle = runtime.installBundle("simple-bundle.jar");
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/jboss-osgi-bootstrap.xml (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/bootstrap.xml)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/jboss-osgi-bootstrap.xml (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-08-20 12:03:26 UTC (rev 92607)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bootstrap xmlns="urn:jboss:bootstrap:1.0">
+
+ <url>jboss-osgi-framework.xml</url>
+
+</bootstrap>
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/jboss-osgi-framework.xml (from rev 92605, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/jboss-osgi-framework.xml (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/jboss-osgi-framework.xml 2009-08-20 12:03:26 UTC (rev 92607)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ $Id$
+-->
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!--
+ ********************************
+ * *
+ * Framework *
+ * *
+ ********************************
+ -->
+
+ <!-- The OSGi Framework Factory -->
+ <bean name="jboss.osgi:service=FrameworkFactory" class="org.jboss.osgi.jbossmc.framework.FrameworkFactoryBean">
+ <property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
+ <property name="properties">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry><key>org.osgi.framework.storage</key><value>${log4j.output.dir}/osgi-store</value></entry>
+ <entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
+ </map>
+ </property>
+ <property name="plugins">
+ <list elementClass="org.jboss.osgi.jbossmc.api.AbstractPlugin">
+ <inject bean="jboss.osgi:plugin=ClassLoaderFactory"/>
+ </list>
+ </property>
+ <property name="autoInstall">
+ <list elementClass="java.net.URL">
+ </list>
+ </property>
+ <property name="autoStart">
+ <list elementClass="java.net.URL">
+ </list>
+ </property>
+ </bean>
+
+ <!--
+ ********************************
+ * *
+ * Framework Plugins *
+ * *
+ ********************************
+ -->
+
+ <bean name="jboss.osgi:plugin=ClassLoaderFactory" class="org.jboss.osgi.jbossmc.framework.ClassLoaderFactoryPluginImpl"/>
+
+</deployment>
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider 2009-08-20 12:03:26 UTC (rev 92607)
@@ -0,0 +1 @@
+org.jboss.osgi.jbossmc.framework.FrameworkBootstrapProvider
\ No newline at end of file
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-08-20 12:03:26 UTC (rev 92607)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bootstrap xmlns="urn:jboss:bootstrap:1.0">
+
+ <url>jboss-osgi-framework.xml</url>
+
+</bootstrap>
Added: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-framework.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-framework.xml (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-framework.xml 2009-08-20 12:03:26 UTC (rev 92607)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ $Id: jboss-osgi-framework.xml 92605 2009-08-20 10:29:21Z thomas.diesler(a)jboss.com $
+-->
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!--
+ ********************************
+ * *
+ * Framework *
+ * *
+ ********************************
+ -->
+
+ <!-- The OSGi Framework Factory -->
+ <bean name="jboss.osgi:service=FrameworkFactory" class="org.jboss.osgi.jbossmc.framework.FrameworkFactoryBean">
+ <property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
+ <property name="properties">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry><key>org.osgi.framework.storage</key><value>${log4j.output.dir}/osgi-store</value></entry>
+ <entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
+ </map>
+ </property>
+ <property name="plugins">
+ <list elementClass="org.jboss.osgi.jbossmc.api.AbstractPlugin">
+ <inject bean="jboss.osgi:plugin=ClassLoaderFactory"/>
+ </list>
+ </property>
+ <property name="autoInstall">
+ <list elementClass="java.net.URL">
+ </list>
+ </property>
+ <property name="autoStart">
+ <list elementClass="java.net.URL">
+ </list>
+ </property>
+ </bean>
+
+ <!--
+ ********************************
+ * *
+ * Framework Plugins *
+ * *
+ ********************************
+ -->
+
+ <bean name="jboss.osgi:plugin=ClassLoaderFactory" class="org.jboss.osgi.jbossmc.framework.ClassLoaderFactoryPluginImpl"/>
+
+</deployment>
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider (from rev 92602, projects/jboss-osgi/trunk/testsuite/example/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider 2009-08-20 12:03:26 UTC (rev 92607)
@@ -0,0 +1,2 @@
+org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
+org.jboss.osgi.jbossmc.framework.FrameworkBootstrapProvider
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider 2009-08-20 11:43:14 UTC (rev 92606)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider 2009-08-20 12:03:26 UTC (rev 92607)
@@ -1 +0,0 @@
-org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
\ No newline at end of file
16 years, 11 months
JBoss-OSGI SVN: r92605 - in projects/jboss-osgi: projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing and 7 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-20 06:29:21 -0400 (Thu, 20 Aug 2009)
New Revision: 92605
Removed:
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-jbossmc.properties
Modified:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.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/management/ManagedFrameworkMBean.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.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/RemoteFramework.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/AbstractPlugin.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/AbstractPluginImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryBean.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java
projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java
Log:
Support bundle version in managed bundle oname
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedBundle.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -32,6 +32,7 @@
import org.jboss.osgi.spi.Constants;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Version;
/**
* The managed view of an OSGi Bundle
@@ -47,7 +48,11 @@
public ManagedBundle(Bundle bundle)
{
this.bundle = bundle;
- this.oname = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":bundle=" + bundle.getSymbolicName() + ",id=" + bundle.getBundleId());
+
+ long id = bundle.getBundleId();
+ String name = bundle.getSymbolicName();
+ Version version = bundle.getVersion();
+ this.oname = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":id=" + id + ",bundle=" + name + ",version=" + version);
}
public ObjectName getObjectName()
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-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFramework.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -79,18 +79,37 @@
}
@SuppressWarnings("unchecked")
- public ObjectName getBundle(String symbolicName)
+ public ObjectName getBundle(String symbolicName, String version)
{
+ ObjectName oname = null;
+
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() > 0)
+ {
+ // [TODO] Support bundle version
+ if (names.size() > 1)
+ throw new IllegalArgumentException("Multiple bundles found: " + names);
+
+ oname = names.iterator().next();
+ }
- if (names.size() > 1)
- throw new IllegalArgumentException("Multiple bundles found: " + names);
+ return oname;
+ }
- return names.iterator().next();
+ @SuppressWarnings("unchecked")
+ public ObjectName getBundle(long bundleId)
+ {
+ ObjectName oname = null;
+
+ ObjectName pattern = ObjectNameFactory.create(Constants.DOMAIN_NAME + ":id=" + bundleId + ",*");
+ Set<ObjectName> names = mbeanServer.queryNames(pattern, null);
+
+ if (names.size() > 0)
+ oname = names.iterator().next();
+
+ return oname;
}
@SuppressWarnings("unchecked")
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFrameworkMBean.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFrameworkMBean.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/management/ManagedFrameworkMBean.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -48,9 +48,14 @@
/**
* Get the installed bundle
*/
- ObjectName getBundle(String symbolicName);
+ ObjectName getBundle(String symbolicName, String version);
/**
+ * Get the installed bundle
+ */
+ ObjectName getBundle(long bundleId);
+
+ /**
* Returns a ServiceReference object for a service that implements and was registered
* under the specified class.
*/
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/OSGiRuntime.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -75,6 +75,13 @@
OSGiBundle getBundle(String symbolicName, String version);
/**
+ * Get the {@link OSGiBundle} for a given bundle id.
+ *
+ * @return The bundle or null if there is none
+ */
+ OSGiBundle getBundle(long bundleId);
+
+ /**
* Get an abstraction of the {@link PackageAdmin}.
*/
OSGiPackageAdmin getPackageAdmin();
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/EmbeddedRuntime.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -44,6 +44,7 @@
import org.osgi.framework.Bundle;
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.framework.launch.Framework;
@@ -64,14 +65,15 @@
public OSGiBundle installBundle(String location) throws BundleException
{
- String symbolicName = getSymbolicName(location);
+ String symbolicName = getManifestEntry(location, Constants.BUNDLE_SYMBOLICNAME);
+ String version = getManifestEntry(location, Constants.BUNDLE_VERSION);
URL bundleURL = getTestHelper().getTestArchiveURL(location);
ServiceReference sref = getBundleContext().getServiceReference(DeployerService.class.getName());
DeployerService service = (DeployerService)getBundleContext().getService(sref);
service.deploy(bundleURL);
- OSGiBundle bundle = getBundle(symbolicName, null);
+ OSGiBundle bundle = getBundle(symbolicName, version);
return registerBundle(location, bundle);
}
@@ -87,6 +89,12 @@
return bundleArr;
}
+ public OSGiBundle getBundle(long bundleId)
+ {
+ Bundle bundle = getBundleContext().getBundle(bundleId);
+ return bundle != null ? new EmbeddedBundle(this, bundle) : null;
+ }
+
public OSGiServiceReference getServiceReference(String clazz)
{
ServiceReference sref = getBundleContext().getServiceReference(clazz);
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-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/OSGiRuntimeImpl.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -88,7 +88,7 @@
for (String location : capability.getBundles())
{
- String symName = getSymbolicName(location);
+ String symName = getManifestEntry(location, Constants.BUNDLE_SYMBOLICNAME);
if (bundles.get(location) == null && getBundle(symName, null) == null)
{
OSGiBundle bundle = installBundle(location);
@@ -198,8 +198,16 @@
return bundle;
}
- protected String getSymbolicName(String location)
+ protected String getManifestEntry(String location, String key)
{
+ Manifest manifest = getManifest(location);
+ Attributes attribs = manifest.getMainAttributes();
+ String value = attribs.getValue(key);
+ return value;
+ }
+
+ private Manifest getManifest(String location)
+ {
Manifest manifest;
try
{
@@ -213,13 +221,7 @@
throw new IllegalStateException("Cannot get manifest from: " + location);
}
-
- Attributes attribs = manifest.getMainAttributes();
- String symbolicName = attribs.getValue(Constants.BUNDLE_SYMBOLICNAME);
- if (symbolicName == null)
- throw new IllegalArgumentException("Cannot obtain Bundle-SymbolicName for: " + location);
-
- return symbolicName;
+ return manifest;
}
OSGiBundle registerBundle(String location, OSGiBundle bundle)
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteFramework.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteFramework.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteFramework.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -45,9 +45,14 @@
/**
* Get the installed bundle
*/
- ManagedBundleMBean getBundle(String symbolicName);
+ ManagedBundleMBean getBundle(String symbolicName, String version);
/**
+ * Get the installed bundle by id
+ */
+ ManagedBundleMBean getBundle(long bundleId);
+
+ /**
* Returns a ServiceReference object for a service that implements and was registered
* under the specified class.
*/
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/testing/internal/RemoteRuntime.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -47,6 +47,7 @@
import org.jboss.osgi.spi.testing.OSGiTestHelper;
import org.jboss.osgi.spi.util.BundleDeploymentFactory;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
import org.osgi.framework.InvalidSyntaxException;
/**
@@ -67,11 +68,12 @@
public OSGiBundle installBundle(String location) throws BundleException
{
- String symbolicName = getSymbolicName(location);
+ String symbolicName = getManifestEntry(location, Constants.BUNDLE_SYMBOLICNAME);
+ String version = getManifestEntry(location, Constants.BUNDLE_VERSION);
try
{
deploy(location);
- ManagedBundleMBean bundleMBean = getRemoteFramework().getBundle(symbolicName);
+ ManagedBundleMBean bundleMBean = getRemoteFramework().getBundle(symbolicName, version);
RemoteBundle bundle = new RemoteBundle(this, bundleMBean, location);
return registerBundle(location, bundle);
}
@@ -149,6 +151,12 @@
}
}
+ public OSGiBundle getBundle(long bundleId)
+ {
+ ManagedBundleMBean bundle = getRemoteFramework().getBundle(bundleId);
+ return bundle != null ? new RemoteBundle(this, bundle, null) : null;
+ }
+
public OSGiServiceReference getServiceReference(String clazz)
{
ManagedServiceReference manref = getRemoteFramework().getServiceReference(clazz);
@@ -213,9 +221,9 @@
return new RemoteFramework()
{
- public ManagedBundleMBean getBundle(String symbolicName)
+ public ManagedBundleMBean getBundle(String symbolicName, String version)
{
- ObjectName oname = managedFramework.getBundle(symbolicName);
+ ObjectName oname = managedFramework.getBundle(symbolicName, version);
if (oname == null)
throw new IllegalArgumentException("Cannot get remote bundle for: " + symbolicName);
@@ -229,6 +237,22 @@
}
}
+ public ManagedBundleMBean getBundle(long bundleId)
+ {
+ ObjectName oname = managedFramework.getBundle(bundleId);
+ if (oname == null)
+ throw new IllegalArgumentException("Cannot get remote bundle for: " + bundleId);
+
+ try
+ {
+ return MBeanProxy.get(ManagedBundleMBean.class, oname, getMBeanServer());
+ }
+ catch (MBeanProxyException ex)
+ {
+ throw new RemoteFrameworkException(ex);
+ }
+ }
+
public Set<ManagedBundleMBean> getBundles()
{
Set<ManagedBundleMBean> remBundles = new HashSet<ManagedBundleMBean>();
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/AbstractPlugin.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/AbstractPlugin.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/AbstractPlugin.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -31,11 +31,14 @@
* @author thomas.diesler(a)jboss.com
* @since 20-Aug-2009
*/
-public interface AbstractPlugin
+public interface AbstractPlugin
{
Framework getFramework();
-
+
void setFramework(Framework framework);
- <T extends AbstractPlugin> T getPlugin(Class<T> pluginClass);
+ <T extends AbstractPlugin> T getPlugin(Class<T> clazz);
+
+ <T extends AbstractPlugin> T getOptionalPlugin(Class<T> clazz);
+
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/AbstractPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/AbstractPluginImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/AbstractPluginImpl.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -46,9 +46,15 @@
this.framework = framework;
}
- public <T extends AbstractPlugin> T getPlugin(Class<T> pluginClass)
+ public <T extends AbstractPlugin> T getPlugin(Class<T> clazz)
{
FrameworkImpl frameworkImpl = (FrameworkImpl)framework;
- return frameworkImpl.getPlugin(pluginClass);
+ return frameworkImpl.getPlugin(clazz);
}
+
+ public <T extends AbstractPlugin> T getOptionalPlugin(Class<T> clazz)
+ {
+ FrameworkImpl frameworkImpl = (FrameworkImpl)framework;
+ return frameworkImpl.getOptionalPlugin(clazz);
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -32,6 +32,7 @@
import java.util.List;
import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.AbstractPlugin;
import org.jboss.osgi.jbossmc.api.BundleEventsPlugin;
import org.jboss.osgi.jbossmc.api.BundleFactoryPlugin;
import org.jboss.osgi.jbossmc.api.BundleStoragePlugin;
@@ -78,56 +79,62 @@
this.bundle = bundle;
}
- public FrameworkImpl getFramework()
+ public Framework getFramework()
{
- return (FrameworkImpl)framework;
+ return framework;
}
+ public <T extends AbstractPlugin> T getPlugin(Class<T> clazz)
+ {
+ FrameworkImpl frameworkImpl = (FrameworkImpl)framework;
+ return frameworkImpl.getPlugin(clazz);
+ }
+
public void addBundleListener(BundleListener listener)
{
- BundleEventsPlugin eventManager = getFramework().getPlugin(BundleEventsPlugin.class);
+ BundleEventsPlugin eventManager = getPlugin(BundleEventsPlugin.class);
eventManager.addBundleListener(listener);
registeredListeners.add(listener);
}
public void removeBundleListener(BundleListener listener)
{
- BundleEventsPlugin eventManager = getFramework().getPlugin(BundleEventsPlugin.class);
+ BundleEventsPlugin eventManager = getPlugin(BundleEventsPlugin.class);
eventManager.removeBundleListener(listener);
registeredListeners.remove(listener);
}
public void addFrameworkListener(FrameworkListener listener)
{
- FrameworkEventsPlugin eventManager = getFramework().getPlugin(FrameworkEventsPlugin.class);
+ FrameworkEventsPlugin eventManager = getPlugin(FrameworkEventsPlugin.class);
eventManager.addFrameworkListener(listener);
registeredListeners.add(listener);
}
public void removeFrameworkListener(FrameworkListener listener)
{
- FrameworkEventsPlugin eventManager = getFramework().getPlugin(FrameworkEventsPlugin.class);
+ FrameworkEventsPlugin eventManager = getPlugin(FrameworkEventsPlugin.class);
eventManager.removeFrameworkListener(listener);
registeredListeners.remove(listener);
}
public void addServiceListener(ServiceListener listener)
{
- ServiceEventsPlugin eventManager = getFramework().getPlugin(ServiceEventsPlugin.class);
+ ServiceEventsPlugin eventManager = getPlugin(ServiceEventsPlugin.class);
eventManager.addServiceListener(listener);
registeredListeners.add(listener);
}
public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException
{
- ServiceEventsPlugin eventManager = getFramework().getPlugin(ServiceEventsPlugin.class);
+ ServiceEventsPlugin eventManager = getPlugin(ServiceEventsPlugin.class);
eventManager.addServiceListener(listener, filter);
registeredListeners.add(listener);
}
public void removeServiceListener(ServiceListener listener)
{
- ServiceEventsPlugin eventManager = getFramework().getPlugin(ServiceEventsPlugin.class);
+ ServiceEventsPlugin eventManager = getPlugin(ServiceEventsPlugin.class);
eventManager.removeServiceListener(listener);
registeredListeners.remove(listener);
}
@@ -144,13 +151,13 @@
public Bundle getBundle(long id)
{
- BundleRegistryPlugin bundleRegistry = getFramework().getPlugin(BundleRegistryPlugin.class);
+ BundleRegistryPlugin bundleRegistry = getPlugin(BundleRegistryPlugin.class);
return bundleRegistry.getBundleById(id);
}
public Bundle[] getBundles()
{
- BundleRegistryPlugin bundleRegistry = getFramework().getPlugin(BundleRegistryPlugin.class);
+ BundleRegistryPlugin bundleRegistry = getPlugin(BundleRegistryPlugin.class);
List<Bundle> bundleList = bundleRegistry.getBundles();
Bundle[] bundles = new Bundle[bundleList.size()];
return bundleList.toArray(bundles);
@@ -158,13 +165,14 @@
public File getDataFile(String filename)
{
- BundleStoragePlugin bundleStorage = getFramework().getPlugin(BundleStoragePlugin.class);
+ BundleStoragePlugin bundleStorage = getPlugin(BundleStoragePlugin.class);
return bundleStorage.getDataFile(bundle, filename);
}
public String getProperty(String key)
{
- String property = (String)getFramework().getProperty(key);
+ FrameworkImpl frameworkImpl = (FrameworkImpl)framework;
+ String property = (String)frameworkImpl.getProperty(key);
if (property == null)
property = System.getProperty(key);
@@ -173,7 +181,7 @@
public Object getService(ServiceReference reference)
{
- ServiceRegistryPlugin serviceRegistry = getFramework().getPlugin(ServiceRegistryPlugin.class);
+ ServiceRegistryPlugin serviceRegistry = getPlugin(ServiceRegistryPlugin.class);
Object service = serviceRegistry.getService(bundle, reference);
if (service != null)
{
@@ -184,19 +192,19 @@
public boolean ungetService(ServiceReference reference)
{
- ServiceRegistryPlugin serviceRegistry = getFramework().getPlugin(ServiceRegistryPlugin.class);
+ ServiceRegistryPlugin serviceRegistry = getPlugin(ServiceRegistryPlugin.class);
return serviceRegistry.ungetService(bundle, reference);
}
public ServiceReference getServiceReference(String clazz)
{
- ServiceRegistryPlugin serviceRegistry = getFramework().getPlugin(ServiceRegistryPlugin.class);
+ ServiceRegistryPlugin serviceRegistry = getPlugin(ServiceRegistryPlugin.class);
return serviceRegistry.getServiceReference(clazz);
}
public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
{
- ServiceRegistryPlugin serviceRegistry = getFramework().getPlugin(ServiceRegistryPlugin.class);
+ ServiceRegistryPlugin serviceRegistry = getPlugin(ServiceRegistryPlugin.class);
return serviceRegistry.getServiceReferences(clazz, filter);
}
@@ -209,11 +217,11 @@
public Bundle installBundle(String location) throws BundleException
{
// Convert location to a virtual file URL
- BundleFactoryPlugin bundleFactory = getFramework().getPlugin(BundleFactoryPlugin.class);
+ BundleFactoryPlugin bundleFactory = getPlugin(BundleFactoryPlugin.class);
location = bundleFactory.getVirtualLocation(location);
// 1. If a bundle containing the same location identifier is already installed, the Bundle object for that bundle is returned.
- BundleRegistryPlugin bundleRegistry = getFramework().getPlugin(BundleRegistryPlugin.class);
+ BundleRegistryPlugin bundleRegistry = getPlugin(BundleRegistryPlugin.class);
Bundle bundle = bundleRegistry.getBundleByLocation(location);
if (bundle != null)
return bundle;
@@ -228,7 +236,7 @@
bundleImpl.setState(Bundle.INSTALLED);
// 5. A bundle event of type BundleEvent.INSTALLED is fired.
- BundleEventsPlugin eventManager = getFramework().getPlugin(BundleEventsPlugin.class);
+ BundleEventsPlugin eventManager = getPlugin(BundleEventsPlugin.class);
eventManager.fireBundleEvent(new BundleEvent(BundleEvent.INSTALLED, bundle));
// 6. The Bundle object for the newly or previously installed bundle is returned.
@@ -244,7 +252,7 @@
@SuppressWarnings("unchecked")
public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties)
{
- ServiceRegistryPlugin serviceRegistry = getFramework().getPlugin(ServiceRegistryPlugin.class);
+ ServiceRegistryPlugin serviceRegistry = getPlugin(ServiceRegistryPlugin.class);
ServiceRegistration sreg = serviceRegistry.registerService(bundle, clazzes, service, properties);
registeredServices.add(sreg);
return sreg;
@@ -253,7 +261,7 @@
@SuppressWarnings("unchecked")
public ServiceRegistration registerService(String clazz, Object service, Dictionary properties)
{
- ServiceRegistryPlugin serviceRegistry = getFramework().getPlugin(ServiceRegistryPlugin.class);
+ ServiceRegistryPlugin serviceRegistry = getPlugin(ServiceRegistryPlugin.class);
ServiceRegistration sreg = serviceRegistry.registerService(bundle, clazz, service, properties);
registeredServices.add(sreg);
return sreg;
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -37,11 +37,12 @@
import java.util.jar.Manifest;
import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.ClassLoaderFactoryPlugin;
-import org.jboss.osgi.jbossmc.api.RuntimeClassLoader;
+import org.jboss.osgi.jbossmc.api.AbstractPlugin;
import org.jboss.osgi.jbossmc.api.BundleLifecyclePlugin;
import org.jboss.osgi.jbossmc.api.BundleResolverPlugin;
+import org.jboss.osgi.jbossmc.api.ClassLoaderFactoryPlugin;
import org.jboss.osgi.jbossmc.api.FrameworkEventsPlugin;
+import org.jboss.osgi.jbossmc.api.RuntimeClassLoader;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileFilter;
@@ -130,11 +131,6 @@
return getHeader(Constants.BUNDLE_SYMBOLICNAME);
}
- public void start() throws BundleException
- {
- start(0);
- }
-
public BundleActivator getBundleActivator()
{
return activator;
@@ -149,32 +145,39 @@
{
if (runtimeLoader == null)
{
- ClassLoaderFactoryPlugin factory = getFramework().getPlugin(ClassLoaderFactoryPlugin.class);
+ ClassLoaderFactoryPlugin factory = getPlugin(ClassLoaderFactoryPlugin.class);
runtimeLoader = factory.createClassLoader(this);
}
return runtimeLoader;
}
+ public void start() throws BundleException
+ {
+ BundleLifecyclePlugin bundleLifecycle = getPlugin(BundleLifecyclePlugin.class);
+ bundleLifecycle.start(this, 0);
+ }
+
public void start(int options) throws BundleException
{
- BundleLifecyclePlugin bundleLifecycle = getFramework().getPlugin(BundleLifecyclePlugin.class);
+ BundleLifecyclePlugin bundleLifecycle = getPlugin(BundleLifecyclePlugin.class);
bundleLifecycle.start(this, options);
}
public void stop() throws BundleException
{
- stop(0);
+ BundleLifecyclePlugin bundleLifecycle = getPlugin(BundleLifecyclePlugin.class);
+ bundleLifecycle.stop(this, 0);
}
public void stop(int options) throws BundleException
{
- BundleLifecyclePlugin bundleLifecycle = getFramework().getPlugin(BundleLifecyclePlugin.class);
+ BundleLifecyclePlugin bundleLifecycle = getPlugin(BundleLifecyclePlugin.class);
bundleLifecycle.stop(this, options);
}
public void uninstall() throws BundleException
{
- BundleLifecyclePlugin bundleLifecycle = getFramework().getPlugin(BundleLifecyclePlugin.class);
+ BundleLifecyclePlugin bundleLifecycle = getPlugin(BundleLifecyclePlugin.class);
bundleLifecycle.uninstall(this);
}
@@ -379,7 +382,7 @@
// before attempting to load the class.
if (state == Bundle.INSTALLED)
{
- BundleResolverPlugin resolver = getFramework().getPlugin(BundleResolverPlugin.class);
+ BundleResolverPlugin resolver = getPlugin(BundleResolverPlugin.class);
try
{
resolver.resolveBundle(this);
@@ -387,7 +390,7 @@
catch (BundleException ex)
{
// If this bundle cannot be resolved, a Framework event of type FrameworkEvent.ERROR is fired
- FrameworkEventsPlugin eventManager = getFramework().getPlugin(FrameworkEventsPlugin.class);
+ FrameworkEventsPlugin eventManager = getPlugin(FrameworkEventsPlugin.class);
eventManager.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.ERROR, this, ex));
throw new ClassNotFoundException("Cannot load class: " + name, ex);
@@ -402,12 +405,12 @@
return (String)getHeaders().get(header);
}
- private FrameworkImpl getFramework()
+ private <T extends AbstractPlugin> T getPlugin(Class<T> clazz)
{
BundleContextImpl contextImpl = (BundleContextImpl)context;
- return contextImpl.getFramework();
+ return contextImpl.getPlugin(clazz);
}
-
+
private void assertNotUninstalled()
{
if (state == Bundle.UNINSTALLED)
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryBean.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryBean.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryBean.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -27,7 +27,9 @@
import java.util.List;
import java.util.Map;
+import org.jboss.kernel.Kernel;
import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.AbstractPlugin;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
@@ -45,15 +47,23 @@
public static final String BEAN_FRAMEWORK_FACTORY = "jboss.osgi:service=FrameworkFactory";
private Map<String, Object> properties;
+ private List<AbstractPlugin> plugins;
private List<URL> autoInstall;
private List<URL> autoStart;
+ private Kernel kernel;
+
private Framework framework;
-
+
public void setProperties(Map<String, Object> properties)
{
this.properties = properties;
}
+ public void setPlugins(List<AbstractPlugin> plugins)
+ {
+ this.plugins = plugins;
+ }
+
public void setAutoInstall(List<URL> autoInstall)
{
this.autoInstall = autoInstall;
@@ -64,15 +74,34 @@
this.autoStart = autoStart;
}
+ public void setKernel(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
@SuppressWarnings("unchecked")
public Framework newFramework(Map configuration)
{
if (framework == null)
{
+ if (properties == null)
+ throw new IllegalStateException("Cannot obtain framework properties");
+
if (configuration != null)
properties.putAll(configuration);
- FrameworkImpl frameworkImpl = new FrameworkImpl(properties);
+ FrameworkImpl frameworkImpl = new FrameworkImpl(kernel, properties);
+
+ // Copy the configured plugins
+ if (plugins != null)
+ {
+ for (AbstractPlugin plugin : plugins)
+ {
+ plugin.setFramework(frameworkImpl);
+ frameworkImpl.addPlugin(plugin);
+ }
+ }
+
framework = frameworkImpl;
}
return framework;
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -30,6 +30,7 @@
import java.util.List;
import java.util.Map;
+import org.jboss.kernel.Kernel;
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.AbstractPlugin;
import org.jboss.osgi.jbossmc.api.BundleEventsPlugin;
@@ -58,13 +59,20 @@
private Map<String, Object> properties = new HashMap<String, Object>();
private int startLevel;
+ private Kernel kernel;
private Map<Class<?>, AbstractPlugin> plugins = new HashMap<Class<?>, AbstractPlugin>();
- public FrameworkImpl(Map<String, Object> props)
+ public FrameworkImpl(Kernel kernel, Map<String, Object> props)
{
+ if (kernel == null)
+ throw new IllegalArgumentException("Kernel cannot be null");
+
+ this.kernel = kernel;
+
if (props != null)
properties.putAll(props);
+ // Initialize default plugins
addPlugin(new BundleEventsPluginImpl(this));
addPlugin(new BundleFactoryPluginImpl(this));
addPlugin(new BundleLifecyclePluginImpl(this));
@@ -75,22 +83,39 @@
addPlugin(new FrameworkEventsPluginImpl(this));
addPlugin(new ServiceEventsPluginImpl(this));
addPlugin(new ServiceRegistryPluginImpl(this));
+ }
+ public Kernel getKernel()
+ {
+ return kernel;
}
@SuppressWarnings("unchecked")
public <T extends AbstractPlugin> T getPlugin(Class<T> clazz)
{
+ T plugin = (T)plugins.get(clazz);
+ if (plugin == null)
+ throw new IllegalStateException("Cannot obtain plugin for: " + clazz.getName());
+
+ return plugin;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends AbstractPlugin> T getOptionalPlugin(Class<T> clazz)
+ {
return (T)plugins.get(clazz);
}
- @SuppressWarnings("unchecked")
public void addPlugin(AbstractPlugin plugin)
{
- for (Class<?> interf : plugin.getClass().getInterfaces())
+ Class<? extends AbstractPlugin> clazz = plugin.getClass();
+ for (Class<?> interf : clazz.getInterfaces())
{
if (AbstractPlugin.class.isAssignableFrom(interf))
+ {
+ log.debug("Plugin: [" + interf.getName() + "=" + clazz.getName() + "]");
plugins.put(interf, plugin);
+ }
}
}
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml 2009-08-20 10:29:21 UTC (rev 92605)
@@ -14,14 +14,20 @@
********************************
-->
- <!-- The FrameworkBootstrap -->
+ <!-- The OSGi Framework Factory -->
<bean name="jboss.osgi:service=FrameworkFactory" class="org.jboss.osgi.jbossmc.framework.FrameworkFactoryBean">
+ <property name="kernel"><inject bean="jboss.kernel:service=Kernel" /></property>
<property name="properties">
<map keyClass="java.lang.String" valueClass="java.lang.String">
<entry><key>org.osgi.framework.storage</key><value>${log4j.output.dir}/osgi-store</value></entry>
<entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
</map>
</property>
+ <property name="plugins">
+ <list elementClass="org.jboss.osgi.jbossmc.api.AbstractPlugin">
+ <inject bean="jboss.osgi:plugin=ClassLoaderFactory"/>
+ </list>
+ </property>
<property name="autoInstall">
<list elementClass="java.net.URL">
</list>
@@ -32,4 +38,14 @@
</property>
</bean>
+ <!--
+ ********************************
+ * *
+ * Framework Plugins *
+ * *
+ ********************************
+ -->
+
+ <bean name="jboss.osgi:plugin=ClassLoaderFactory" class="org.jboss.osgi.jbossmc.framework.ClassLoaderFactoryPluginImpl"/>
+
</deployment>
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -25,16 +25,15 @@
import static org.junit.Assert.assertEquals;
-import org.jboss.osgi.spi.testing.OSGiTest;
-import org.jboss.osgi.spi.util.ServiceLoader;
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-import org.osgi.framework.launch.Framework;
-import org.osgi.framework.launch.FrameworkFactory;
/**
* A test that deployes a bundle and verifies its state
@@ -42,38 +41,28 @@
* @author thomas.diesler(a)jboss.com
* @since 18-Aug-2009
*/
-public class BundleInstallTestCase extends OSGiTest
+public class BundleInstallTestCase
{
- private static Framework framework;
+ private static OSGiRuntime runtime;
- @BeforeClass
+ //@BeforeClass
public static void beforeClass() throws BundleException
{
- FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
- framework = factory.newFramework(null);
- framework.start();
+ runtime = new OSGiTestHelper().getDefaultRuntime();
}
- @AfterClass
+ //@AfterClass
public static void afterClass() throws BundleException
{
- framework.stop();
+ if (runtime != null)
+ runtime.shutdown();
}
@Test
- public void testFrameworkBundle() throws Exception
- {
- assertEquals("BundleId", 0, framework.getBundleId());
- assertEquals("Location", "System Bundle", framework.getLocation());
- assertEquals("SymbolicName", "org.jboss.osgi.jbossmc", framework.getSymbolicName());
- }
-
- @Test
+ @Ignore
public void testBundleInstall() throws Exception
{
- BundleContext sysContext = framework.getBundleContext();
- String location = getTestArchiveURL("simple-bundle.jar").toString();
- Bundle bundle = sysContext.installBundle(location);
+ OSGiBundle bundle = runtime.installBundle("simple-bundle.jar");
assertEquals("simple-bundle", bundle.getSymbolicName());
Deleted: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-jbossmc.properties
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-jbossmc.properties 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jboss-osgi-jbossmc.properties 2009-08-20 10:29:21 UTC (rev 92605)
@@ -1,22 +0,0 @@
-#
-# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
-#
-# $Id: jboss-osgi-felix.properties 92430 2009-08-17 14:53:52Z thomas.diesler(a)jboss.com $
-#
-
-# Properties to configure the Framework
-org.osgi.framework.storage=${basedir}/target/osgi-store
-org.osgi.framework.storage.clean=onFirstInit
-
-# Extra System Packages
-org.osgi.framework.system.packages.extra=
-
-# Bundles that need to be installed with the Framework automatically
-org.jboss.osgi.spi.framework.autoInstall=\
- file://${test.archive.directory}/bundles/org.osgi.compendium.jar
-
-
-# Bundles that need to be started automatically
-org.jboss.osgi.spi.framework.autoStart=\
- file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
- file://${test.archive.directory}/bundles/jboss-osgi-common.jar
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java 2009-08-20 08:40:11 UTC (rev 92604)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/java/org/jboss/test/osgi/service/microcontainer/MicrocontainerServiceTestCase.java 2009-08-20 10:29:21 UTC (rev 92605)
@@ -99,7 +99,7 @@
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=mcservice-bundleA") > 0);
+ assertTrue("Managed bundle registered", bundles.toString().indexOf("bundle=mcservice-bundleA") > 0);
deployer.undeploy(getTestArchiveURL("service/mcservice-bundleA.jar"));
}
@@ -117,7 +117,7 @@
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=mcservice-bundleB") > 0);
+ assertTrue("Managed bundle registered", bundles.toString().indexOf("bundle=mcservice-bundleB") > 0);
// Check whether the bean is registered
List<String> registeredBeans = mcService.getRegisteredBeans();
16 years, 11 months
JBoss-OSGI SVN: r92604 - in projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main: java/org/jboss/osgi/jbossmc/framework and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-20 04:40:11 -0400 (Thu, 20 Aug 2009)
New Revision: 92604
Added:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/AbstractPlugin.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventsPlugin.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactoryPlugin.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecyclePlugin.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistryPlugin.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolverPlugin.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleStoragePlugin.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ClassLoaderFactoryPlugin.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventsPlugin.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/RuntimeClassLoader.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventsPlugin.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistryPlugin.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/AbstractPluginImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventsPluginImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryPluginImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecyclePluginImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryPluginImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverPluginImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleStoragePluginImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ClassLoaderFactoryPluginImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventsPluginImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryBean.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/RuntimeClassLoaderImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventsPluginImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryPluginImpl.java
Removed:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecycle.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
Modified:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml
Log:
Use framework plugins
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/AbstractPlugin.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/AbstractPlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/AbstractPlugin.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,41 @@
+/*
+ * 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.jbossmc.api;
+
+//$Id: $
+
+import org.osgi.framework.launch.Framework;
+
+/**
+ * The base of all framework plugins
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 20-Aug-2009
+ */
+public interface AbstractPlugin
+{
+ Framework getFramework();
+
+ void setFramework(Framework framework);
+
+ <T extends AbstractPlugin> T getPlugin(Class<T> pluginClass);
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,43 +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.jbossmc.api;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Enumeration;
-
-// $Id: $
-
-/**
- * An abstraction of a bundle class loader.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public interface BundleClassLoader
-{
- Class<?> loadClass(String name) throws ClassNotFoundException;
-
- URL getResource(String name);
-
- Enumeration<URL> getResources(String name) throws IOException;
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,44 +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.jbossmc.api;
-
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
-
-//$Id: $
-
-/**
- * An abstraction of a bundle event manager.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public interface BundleEventManager
-{
- void fireBundleEvent(BundleEvent event);
-
- void addBundleListener(BundleListener listener);
-
- void removeBundleListener(BundleListener listener);
-
- void setEnabled(boolean enabled);
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventsPlugin.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventsPlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventsPlugin.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,44 @@
+/*
+ * 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.jbossmc.api;
+
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+
+//$Id: $
+
+/**
+ * An abstraction of a bundle event manager.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface BundleEventsPlugin extends AbstractPlugin
+{
+ void fireBundleEvent(BundleEvent event);
+
+ void addBundleListener(BundleListener listener);
+
+ void removeBundleListener(BundleListener listener);
+
+ void setEnabled(boolean enabled);
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,42 +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.jbossmc.api;
-
-// $Id: $
-
-import org.jboss.virtual.VirtualFile;
-import org.osgi.framework.Bundle;
-
-/**
- * An abstraction of a bundle factory.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public interface BundleFactory
-{
- String getVirtualLocation(String location);
-
- VirtualFile getVirtualFile(String location);
-
- Bundle createBundle(String location);
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactoryPlugin.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactoryPlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactoryPlugin.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,42 @@
+/*
+ * 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.jbossmc.api;
+
+// $Id: $
+
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
+
+/**
+ * An abstraction of a bundle factory.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface BundleFactoryPlugin extends AbstractPlugin
+{
+ String getVirtualLocation(String location);
+
+ VirtualFile getVirtualFile(String location);
+
+ Bundle createBundle(String location);
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecycle.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecycle.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecycle.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,41 +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.jbossmc.api;
-
-//$Id$
-
-import org.osgi.framework.BundleException;
-
-/**
- * An abstraction the OSGi bundle lifecycle
- *
- * @author thomas.diesler(a)jboss.com
- * @since 29-Jul-2009
- */
-public interface BundleLifecycle
-{
- void start(int options) throws BundleException;
-
- void stop(int options) throws BundleException;
-
- void uninstall() throws BundleException;
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecyclePlugin.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecycle.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecyclePlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecyclePlugin.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,42 @@
+/*
+ * 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.jbossmc.api;
+
+//$Id$
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * An abstraction the OSGi bundle lifecycle
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 29-Jul-2009
+ */
+public interface BundleLifecyclePlugin extends AbstractPlugin
+{
+ void start(Bundle bundle, int options) throws BundleException;
+
+ void stop(Bundle bundle, int options) throws BundleException;
+
+ void uninstall(Bundle bundle) throws BundleException;
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,39 +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.jbossmc.api;
-
-// $Id: $
-
-import java.io.File;
-
-import org.osgi.framework.Bundle;
-
-/**
- * An abstraction of a bundle persistent storage system.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public interface BundlePersistentStorage
-{
- File getDataFile(Bundle bundle, String filename);
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,47 +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.jbossmc.api;
-
-//$Id: $
-
-import java.util.List;
-
-import org.osgi.framework.Bundle;
-
-/**
- * An abstraction of a bundle registry.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public interface BundleRegistry
-{
- long registerBundle(Bundle bundle);
-
- void unregisterBundle(Bundle bundle);
-
- Bundle getBundleById(long id);
-
- Bundle getBundleByLocation(String location);
-
- List<Bundle> getBundles();
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistryPlugin.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistryPlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistryPlugin.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,47 @@
+/*
+ * 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.jbossmc.api;
+
+//$Id: $
+
+import java.util.List;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * An abstraction of a bundle registry.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface BundleRegistryPlugin extends AbstractPlugin
+{
+ long registerBundle(Bundle bundle);
+
+ void unregisterBundle(Bundle bundle);
+
+ Bundle getBundleById(long id);
+
+ Bundle getBundleByLocation(String location);
+
+ List<Bundle> getBundles();
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,38 +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.jbossmc.api;
-
-// $Id: $
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-
-/**
- * An abstraction of a bundle resolver.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public interface BundleResolver
-{
- void resolveBundle(Bundle bundle) throws BundleException;
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolverPlugin.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolverPlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolverPlugin.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,38 @@
+/*
+ * 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.jbossmc.api;
+
+// $Id: $
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * An abstraction of a bundle resolver.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface BundleResolverPlugin extends AbstractPlugin
+{
+ void resolveBundle(Bundle bundle) throws BundleException;
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleStoragePlugin.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleStoragePlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleStoragePlugin.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,39 @@
+/*
+ * 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.jbossmc.api;
+
+// $Id: $
+
+import java.io.File;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * An abstraction of a bundle persistent storage system.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface BundleStoragePlugin extends AbstractPlugin
+{
+ File getDataFile(Bundle bundle, String filename);
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ClassLoaderFactoryPlugin.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ClassLoaderFactoryPlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ClassLoaderFactoryPlugin.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,37 @@
+/*
+ * 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.jbossmc.api;
+
+// $Id: $
+
+import org.osgi.framework.Bundle;
+
+/**
+ * An abstraction of a service event manager.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface ClassLoaderFactoryPlugin extends AbstractPlugin
+{
+ RuntimeClassLoader createClassLoader(Bundle bundle);
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,39 +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.jbossmc.api;
-
-//$Id$
-
-import org.osgi.framework.launch.Framework;
-
-/**
- * An abstration of a bootstrap bean that can provide an OSGi Framework.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 29-Jul-2009
- */
-public interface FrameworkBootstrap
-{
- public static final String BEAN_FRAMEWORK_BOOTSTRAP = "jboss.osgi:service=FrameworkBootstrap";
-
- Framework getFramework();
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,44 +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.jbossmc.api;
-
-//$Id: $
-
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
-
-/**
- * An abstraction of a framework event manager.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public interface FrameworkEventManager
-{
- void fireFrameworkEvent(FrameworkEvent event);
-
- void addFrameworkListener(FrameworkListener listener);
-
- void removeFrameworkListener(FrameworkListener listener);
-
- void setEnabled(boolean enabled);
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventsPlugin.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventsPlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventsPlugin.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,44 @@
+/*
+ * 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.jbossmc.api;
+
+//$Id: $
+
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
+
+/**
+ * An abstraction of a framework event manager.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface FrameworkEventsPlugin extends AbstractPlugin
+{
+ void fireFrameworkEvent(FrameworkEvent event);
+
+ void addFrameworkListener(FrameworkListener listener);
+
+ void removeFrameworkListener(FrameworkListener listener);
+
+ void setEnabled(boolean enabled);
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/RuntimeClassLoader.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/RuntimeClassLoader.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/RuntimeClassLoader.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,43 @@
+/*
+ * 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.jbossmc.api;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+
+// $Id: $
+
+/**
+ * An abstraction of a bundle class loader.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface RuntimeClassLoader
+{
+ Class<?> loadClass(String name) throws ClassNotFoundException;
+
+ URL getResource(String name);
+
+ Enumeration<URL> getResources(String name) throws IOException;
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,46 +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.jbossmc.api;
-
-// $Id: $
-
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-
-/**
- * An abstraction of a service event manager.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public interface ServiceEventManager
-{
- void fireServiceEvent(ServiceEvent event);
-
- void addServiceListener(ServiceListener listener);
-
- void addServiceListener(ServiceListener listener, String filter);
-
- void removeServiceListener(ServiceListener listener);
-
- void setEnabled(boolean enabled);
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventsPlugin.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventsPlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventsPlugin.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.jbossmc.api;
+
+// $Id: $
+
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+
+/**
+ * An abstraction of a service event manager.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface ServiceEventsPlugin extends AbstractPlugin
+{
+ void fireServiceEvent(ServiceEvent event);
+
+ void addServiceListener(ServiceListener listener);
+
+ void addServiceListener(ServiceListener listener, String filter);
+
+ void removeServiceListener(ServiceListener listener);
+
+ void setEnabled(boolean enabled);
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,54 +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.jbossmc.api;
-
-//$Id: $
-
-import java.util.Dictionary;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * An abstraction of a service registry.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public interface ServiceRegistry
-{
- ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary<String, Object> properties);
-
- ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary<String, Object> properties);
-
- void unregisterService(ServiceRegistration registration);
-
- ServiceReference getServiceReference(String clazz);
-
- ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException;
-
- Object getService(Bundle bundle, ServiceReference sref);
-
- boolean ungetService(Bundle bundle, ServiceReference reference);
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistryPlugin.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistryPlugin.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistryPlugin.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,54 @@
+/*
+ * 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.jbossmc.api;
+
+//$Id: $
+
+import java.util.Dictionary;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * An abstraction of a service registry.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface ServiceRegistryPlugin extends AbstractPlugin
+{
+ ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary<String, Object> properties);
+
+ ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary<String, Object> properties);
+
+ void unregisterService(ServiceRegistration registration);
+
+ ServiceReference getServiceReference(String clazz);
+
+ ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException;
+
+ Object getService(Bundle bundle, ServiceReference sref);
+
+ boolean ungetService(Bundle bundle, ServiceReference reference);
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/AbstractPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/AbstractPluginImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/AbstractPluginImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,54 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id: $
+
+import org.jboss.osgi.jbossmc.api.AbstractPlugin;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * The base class of all framework plugins.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public abstract class AbstractPluginImpl implements AbstractPlugin
+{
+ private Framework framework;
+
+ public Framework getFramework()
+ {
+ return framework;
+ }
+
+ public void setFramework(Framework framework)
+ {
+ this.framework = framework;
+ }
+
+ public <T extends AbstractPlugin> T getPlugin(Class<T> pluginClass)
+ {
+ FrameworkImpl frameworkImpl = (FrameworkImpl)framework;
+ return frameworkImpl.getPlugin(pluginClass);
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -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.jbossmc.framework;
-
-//$Id: $
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Enumeration;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.BundleClassLoader;
-import org.jboss.osgi.spi.NotImplementedException;
-import org.jboss.virtual.VirtualFile;
-import org.osgi.framework.Bundle;
-
-/**
- * A simple implementation of a BundleClassLoader
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public class BundleClassLoaderImpl implements BundleClassLoader
-{
- // Provide logging
- final Logger log = Logger.getLogger(BundleClassLoaderImpl.class);
-
- private VirtualFile virtualFile;
- private ClassLoader loader;
-
- public BundleClassLoaderImpl(Bundle bundle)
- {
- BundleImpl bundleImpl = (BundleImpl)bundle;
- virtualFile = bundleImpl.getVirtualFile();
-
- URL location;
- try
- {
- location = virtualFile.toURL();
- }
- catch (Exception ex)
- {
- throw new IllegalStateException("Cannot obtain bundle location", ex);
- }
-
- loader = new URLClassLoader(new URL[] { location });
- }
-
- public Class<?> loadClass(String name) throws ClassNotFoundException
- {
- return loader.loadClass(name);
- }
-
- public URL getResource(String name)
- {
- URL resourceURL = null;
- try
- {
- VirtualFile child = virtualFile.getChild(name);
- if (child != null)
- resourceURL = child.toURL();
- }
- catch (Exception ex)
- {
- // ignore
- }
- return resourceURL;
- }
-
- public Enumeration<URL> getResources(String name) throws IOException
- {
- // [TODO] Bundle.getResources(String name)
- throw new NotImplementedException();
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -32,13 +32,13 @@
import java.util.List;
import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.BundleEventManager;
-import org.jboss.osgi.jbossmc.api.BundleFactory;
-import org.jboss.osgi.jbossmc.api.BundlePersistentStorage;
-import org.jboss.osgi.jbossmc.api.BundleRegistry;
-import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
-import org.jboss.osgi.jbossmc.api.ServiceEventManager;
-import org.jboss.osgi.jbossmc.api.ServiceRegistry;
+import org.jboss.osgi.jbossmc.api.BundleEventsPlugin;
+import org.jboss.osgi.jbossmc.api.BundleFactoryPlugin;
+import org.jboss.osgi.jbossmc.api.BundleStoragePlugin;
+import org.jboss.osgi.jbossmc.api.BundleRegistryPlugin;
+import org.jboss.osgi.jbossmc.api.FrameworkEventsPlugin;
+import org.jboss.osgi.jbossmc.api.ServiceEventsPlugin;
+import org.jboss.osgi.jbossmc.api.ServiceRegistryPlugin;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -52,6 +52,7 @@
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.launch.Framework;
/**
* An implementation of an OSGi BundleContext
@@ -64,14 +65,14 @@
// Provide logging
final Logger log = Logger.getLogger(BundleContextImpl.class);
- private FrameworkImpl framework;
+ private Framework framework;
private Bundle bundle;
private List<EventListener> registeredListeners = new ArrayList<EventListener>();
private List<ServiceRegistration> registeredServices = new ArrayList<ServiceRegistration>();
private List<ServiceReference> usedServices = new ArrayList<ServiceReference>();
- public BundleContextImpl(FrameworkImpl framework, Bundle bundle)
+ public BundleContextImpl(Framework framework, Bundle bundle)
{
this.framework = framework;
this.bundle = bundle;
@@ -79,54 +80,54 @@
public FrameworkImpl getFramework()
{
- return framework;
+ return (FrameworkImpl)framework;
}
-
+
public void addBundleListener(BundleListener listener)
{
- BundleEventManager eventManager = getFramework().getBundleEventManager();
+ BundleEventsPlugin eventManager = getFramework().getPlugin(BundleEventsPlugin.class);
eventManager.addBundleListener(listener);
registeredListeners.add(listener);
}
public void removeBundleListener(BundleListener listener)
{
- BundleEventManager eventManager = getFramework().getBundleEventManager();
+ BundleEventsPlugin eventManager = getFramework().getPlugin(BundleEventsPlugin.class);
eventManager.removeBundleListener(listener);
registeredListeners.remove(listener);
}
public void addFrameworkListener(FrameworkListener listener)
{
- FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
+ FrameworkEventsPlugin eventManager = getFramework().getPlugin(FrameworkEventsPlugin.class);
eventManager.addFrameworkListener(listener);
registeredListeners.add(listener);
}
public void removeFrameworkListener(FrameworkListener listener)
{
- FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
+ FrameworkEventsPlugin eventManager = getFramework().getPlugin(FrameworkEventsPlugin.class);
eventManager.removeFrameworkListener(listener);
registeredListeners.remove(listener);
}
public void addServiceListener(ServiceListener listener)
{
- ServiceEventManager eventManager = getFramework().getServiceEventManager();
+ ServiceEventsPlugin eventManager = getFramework().getPlugin(ServiceEventsPlugin.class);
eventManager.addServiceListener(listener);
registeredListeners.add(listener);
}
public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException
{
- ServiceEventManager eventManager = getFramework().getServiceEventManager();
+ ServiceEventsPlugin eventManager = getFramework().getPlugin(ServiceEventsPlugin.class);
eventManager.addServiceListener(listener, filter);
registeredListeners.add(listener);
}
public void removeServiceListener(ServiceListener listener)
{
- ServiceEventManager eventManager = getFramework().getServiceEventManager();
+ ServiceEventsPlugin eventManager = getFramework().getPlugin(ServiceEventsPlugin.class);
eventManager.removeServiceListener(listener);
registeredListeners.remove(listener);
}
@@ -143,13 +144,13 @@
public Bundle getBundle(long id)
{
- BundleRegistry bundleRegistry = getFramework().getBundleRegistry();
+ BundleRegistryPlugin bundleRegistry = getFramework().getPlugin(BundleRegistryPlugin.class);
return bundleRegistry.getBundleById(id);
}
public Bundle[] getBundles()
{
- BundleRegistry bundleRegistry = getFramework().getBundleRegistry();
+ BundleRegistryPlugin bundleRegistry = getFramework().getPlugin(BundleRegistryPlugin.class);
List<Bundle> bundleList = bundleRegistry.getBundles();
Bundle[] bundles = new Bundle[bundleList.size()];
return bundleList.toArray(bundles);
@@ -157,7 +158,7 @@
public File getDataFile(String filename)
{
- BundlePersistentStorage bundleStorage = getFramework().getBundlePersistentStorage();
+ BundleStoragePlugin bundleStorage = getFramework().getPlugin(BundleStoragePlugin.class);
return bundleStorage.getDataFile(bundle, filename);
}
@@ -172,7 +173,7 @@
public Object getService(ServiceReference reference)
{
- ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
+ ServiceRegistryPlugin serviceRegistry = getFramework().getPlugin(ServiceRegistryPlugin.class);
Object service = serviceRegistry.getService(bundle, reference);
if (service != null)
{
@@ -183,19 +184,19 @@
public boolean ungetService(ServiceReference reference)
{
- ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
+ ServiceRegistryPlugin serviceRegistry = getFramework().getPlugin(ServiceRegistryPlugin.class);
return serviceRegistry.ungetService(bundle, reference);
}
public ServiceReference getServiceReference(String clazz)
{
- ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
+ ServiceRegistryPlugin serviceRegistry = getFramework().getPlugin(ServiceRegistryPlugin.class);
return serviceRegistry.getServiceReference(clazz);
}
public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException
{
- ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
+ ServiceRegistryPlugin serviceRegistry = getFramework().getPlugin(ServiceRegistryPlugin.class);
return serviceRegistry.getServiceReferences(clazz, filter);
}
@@ -208,11 +209,11 @@
public Bundle installBundle(String location) throws BundleException
{
// Convert location to a virtual file URL
- BundleFactory bundleFactory = getFramework().getBundleFactory();
+ BundleFactoryPlugin bundleFactory = getFramework().getPlugin(BundleFactoryPlugin.class);
location = bundleFactory.getVirtualLocation(location);
// 1. If a bundle containing the same location identifier is already installed, the Bundle object for that bundle is returned.
- BundleRegistry bundleRegistry = getFramework().getBundleRegistry();
+ BundleRegistryPlugin bundleRegistry = getFramework().getPlugin(BundleRegistryPlugin.class);
Bundle bundle = bundleRegistry.getBundleByLocation(location);
if (bundle != null)
return bundle;
@@ -227,7 +228,7 @@
bundleImpl.setState(Bundle.INSTALLED);
// 5. A bundle event of type BundleEvent.INSTALLED is fired.
- BundleEventManager eventManager = getFramework().getBundleEventManager();
+ BundleEventsPlugin eventManager = getFramework().getPlugin(BundleEventsPlugin.class);
eventManager.fireBundleEvent(new BundleEvent(BundleEvent.INSTALLED, bundle));
// 6. The Bundle object for the newly or previously installed bundle is returned.
@@ -243,8 +244,8 @@
@SuppressWarnings("unchecked")
public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties)
{
- ServiceRegistry registry = getFramework().getServiceRegistry();
- ServiceRegistration sreg = registry.registerService(bundle, clazzes, service, properties);
+ ServiceRegistryPlugin serviceRegistry = getFramework().getPlugin(ServiceRegistryPlugin.class);
+ ServiceRegistration sreg = serviceRegistry.registerService(bundle, clazzes, service, properties);
registeredServices.add(sreg);
return sreg;
}
@@ -252,8 +253,8 @@
@SuppressWarnings("unchecked")
public ServiceRegistration registerService(String clazz, Object service, Dictionary properties)
{
- ServiceRegistry registry = getFramework().getServiceRegistry();
- ServiceRegistration sreg = registry.registerService(bundle, clazz, service, properties);
+ ServiceRegistryPlugin serviceRegistry = getFramework().getPlugin(ServiceRegistryPlugin.class);
+ ServiceRegistration sreg = serviceRegistry.registerService(bundle, clazz, service, properties);
registeredServices.add(sreg);
return sreg;
}
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -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.jbossmc.framework;
-
-//$Id: $
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.BundleEventManager;
-import org.jboss.osgi.spi.util.ConstantsHelper;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleListener;
-
-/**
- * A simple implementation of a BundleEventManager
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public class BundleEventManagerImpl implements BundleEventManager
-{
- // Provide logging
- final Logger log = Logger.getLogger(BundleEventManagerImpl.class);
-
- private List<BundleListener> listeners = new ArrayList<BundleListener>();
- private boolean enabled = true;
-
- public BundleEventManagerImpl(FrameworkImpl framework)
- {
-
- }
-
- public boolean isEnabled()
- {
- return enabled;
- }
-
- public void setEnabled(boolean enabled)
- {
- this.enabled = enabled;
- }
-
- public void fireBundleEvent(BundleEvent event)
- {
- if (enabled == false)
- return;
-
- String typeStr = ConstantsHelper.bundleEvent(event.getType());
- log.debug("BundleEvent " + typeStr + " " + event.getSource());
-
- // [TODO] When a BundleEvent is fired, it is asynchronously delivered to a BundleListener
-
- for (BundleListener listener : new ArrayList<BundleListener>(listeners))
- listener.bundleChanged(event);
- }
-
- public void addBundleListener(BundleListener listener)
- {
- listeners.add(listener);
- }
-
- public void removeBundleListener(BundleListener listener)
- {
- listeners.remove(listener);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventsPluginImpl.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventsPluginImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventsPluginImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,92 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id: $
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleEventsPlugin;
+import org.jboss.osgi.spi.util.ConstantsHelper;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * A simple implementation of a BundleEventManager
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleEventsPluginImpl extends AbstractPluginImpl implements BundleEventsPlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundleEventsPluginImpl.class);
+
+ private List<BundleListener> listeners = new ArrayList<BundleListener>();
+ private boolean enabled = true;
+
+ public BundleEventsPluginImpl()
+ {
+ }
+
+ public BundleEventsPluginImpl(Framework framework)
+ {
+ setFramework(framework);
+ }
+
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+
+ public void fireBundleEvent(BundleEvent event)
+ {
+ if (enabled == false)
+ return;
+
+ String typeStr = ConstantsHelper.bundleEvent(event.getType());
+ log.debug("BundleEvent " + typeStr + " " + event.getSource());
+
+ // [TODO] When a BundleEvent is fired, it is asynchronously delivered to a BundleListener
+
+ for (BundleListener listener : new ArrayList<BundleListener>(listeners))
+ listener.bundleChanged(event);
+ }
+
+ public void addBundleListener(BundleListener listener)
+ {
+ listeners.add(listener);
+ }
+
+ public void removeBundleListener(BundleListener listener)
+ {
+ listeners.remove(listener);
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,89 +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.jbossmc.framework;
-
-//$Id: $
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.BundleFactory;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-import org.osgi.framework.Bundle;
-
-/**
- * A simple implementation of a BundleFactory
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public class BundleFactoryImpl implements BundleFactory
-{
- // Provide logging
- final Logger log = Logger.getLogger(BundleFactoryImpl.class);
-
- private FrameworkImpl framework;
-
- public BundleFactoryImpl(FrameworkImpl framework)
- {
- this.framework = framework;
- }
-
- public Bundle createBundle(String location)
- {
- VirtualFile vfsRoot = getVirtualFile(location);
- BundleImpl bundle = new BundleImpl(vfsRoot);
- bundle.setBundleContext(new BundleContextImpl(framework, bundle));
- return bundle;
- }
-
- public String getVirtualLocation(String location)
- {
- try
- {
- VirtualFile vFile = getVirtualFile(location);
- URL locationURL = vFile.toURL();
- return locationURL.toExternalForm();
- }
- catch (Exception ex)
- {
- throw new IllegalStateException("Cannot obtain virtual bundle location", ex);
- }
- }
-
- public VirtualFile getVirtualFile(String location)
- {
- VirtualFile vfsRoot;
- try
- {
- URL locationURL = new URL(location);
- vfsRoot = VFS.createNewRoot(locationURL);
- }
- catch (IOException ex)
- {
- throw new IllegalArgumentException("Invalid bundle location URL: " + location);
- }
- return vfsRoot;
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryPluginImpl.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryPluginImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryPluginImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,92 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id: $
+
+import java.io.IOException;
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleFactoryPlugin;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * A simple implementation of a BundleFactory
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleFactoryPluginImpl extends AbstractPluginImpl implements BundleFactoryPlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundleFactoryPluginImpl.class);
+
+ public BundleFactoryPluginImpl()
+ {
+ }
+
+ public BundleFactoryPluginImpl(Framework framework)
+ {
+ setFramework(framework);
+ }
+
+ public Bundle createBundle(String location)
+ {
+ VirtualFile vfsRoot = getVirtualFile(location);
+ BundleImpl bundle = new BundleImpl(vfsRoot);
+ bundle.setBundleContext(new BundleContextImpl(getFramework(), bundle));
+ return bundle;
+ }
+
+ public String getVirtualLocation(String location)
+ {
+ try
+ {
+ VirtualFile vFile = getVirtualFile(location);
+ URL locationURL = vFile.toURL();
+ return locationURL.toExternalForm();
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot obtain virtual bundle location", ex);
+ }
+ }
+
+ public VirtualFile getVirtualFile(String location)
+ {
+ VirtualFile vfsRoot;
+ try
+ {
+ URL locationURL = new URL(location);
+ vfsRoot = VFS.createNewRoot(locationURL);
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalArgumentException("Invalid bundle location URL: " + location);
+ }
+ return vfsRoot;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -37,14 +37,16 @@
import java.util.jar.Manifest;
import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.BundleClassLoader;
-import org.jboss.osgi.jbossmc.api.BundleLifecycle;
-import org.jboss.osgi.jbossmc.api.BundleResolver;
-import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
+import org.jboss.osgi.jbossmc.api.ClassLoaderFactoryPlugin;
+import org.jboss.osgi.jbossmc.api.RuntimeClassLoader;
+import org.jboss.osgi.jbossmc.api.BundleLifecyclePlugin;
+import org.jboss.osgi.jbossmc.api.BundleResolverPlugin;
+import org.jboss.osgi.jbossmc.api.FrameworkEventsPlugin;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.VirtualFileFilter;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -71,22 +73,19 @@
private long bundleId;
private BundleContext context;
private Dictionary<String, String> headers;
- private BundleLifecycle bundleLifecycle;
- private BundleClassLoader classLoader;
+ private RuntimeClassLoader runtimeLoader;
+ private BundleActivator activator;
private String toStringCache;
public BundleImpl()
{
// ctor used by the framework
// [TODO] remove when we have a VFS root for the framework
-
- this.bundleLifecycle = new BundleLifecycleImpl(this);
}
public BundleImpl(VirtualFile vFile)
{
this.vFile = vFile;
- this.bundleLifecycle = new BundleLifecycleImpl(this);
}
public VirtualFile getVirtualFile()
@@ -131,24 +130,35 @@
return getHeader(Constants.BUNDLE_SYMBOLICNAME);
}
- public BundleClassLoader getClassLoader()
+ public void start() throws BundleException
{
- return classLoader;
+ start(0);
}
- public void setClassLoader(BundleClassLoader classLoader)
+ public BundleActivator getBundleActivator()
{
- this.classLoader = classLoader;
+ return activator;
}
- public void start() throws BundleException
+ public void setBundleActivator(BundleActivator activator)
{
- start(0);
+ this.activator = activator;
}
+ private RuntimeClassLoader getClassLoader()
+ {
+ if (runtimeLoader == null)
+ {
+ ClassLoaderFactoryPlugin factory = getFramework().getPlugin(ClassLoaderFactoryPlugin.class);
+ runtimeLoader = factory.createClassLoader(this);
+ }
+ return runtimeLoader;
+ }
+
public void start(int options) throws BundleException
{
- bundleLifecycle.start(options);
+ BundleLifecyclePlugin bundleLifecycle = getFramework().getPlugin(BundleLifecyclePlugin.class);
+ bundleLifecycle.start(this, options);
}
public void stop() throws BundleException
@@ -158,12 +168,14 @@
public void stop(int options) throws BundleException
{
- bundleLifecycle.stop(options);
+ BundleLifecyclePlugin bundleLifecycle = getFramework().getPlugin(BundleLifecyclePlugin.class);
+ bundleLifecycle.stop(this, options);
}
public void uninstall() throws BundleException
{
- bundleLifecycle.uninstall();
+ BundleLifecyclePlugin bundleLifecycle = getFramework().getPlugin(BundleLifecyclePlugin.class);
+ bundleLifecycle.uninstall(this);
}
public void update() throws BundleException
@@ -367,7 +379,7 @@
// before attempting to load the class.
if (state == Bundle.INSTALLED)
{
- BundleResolver resolver = getFramework().getBundleResolver();
+ BundleResolverPlugin resolver = getFramework().getPlugin(BundleResolverPlugin.class);
try
{
resolver.resolveBundle(this);
@@ -375,7 +387,7 @@
catch (BundleException ex)
{
// If this bundle cannot be resolved, a Framework event of type FrameworkEvent.ERROR is fired
- FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
+ FrameworkEventsPlugin eventManager = getFramework().getPlugin(FrameworkEventsPlugin.class);
eventManager.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.ERROR, this, ex));
throw new ClassNotFoundException("Cannot load class: " + name, ex);
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,258 +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.jbossmc.framework;
-
-//$Id$
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.BundleEventManager;
-import org.jboss.osgi.jbossmc.api.BundleLifecycle;
-import org.jboss.osgi.jbossmc.api.BundleRegistry;
-import org.jboss.osgi.jbossmc.api.BundleResolver;
-import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.FrameworkEvent;
-
-/**
- * An implementation of the OSGi bundle lifecycle
- *
- * @author thomas.diesler(a)jboss.com
- * @since 29-Jul-2009
- */
-public class BundleLifecycleImpl implements BundleLifecycle
-{
- // Provide logging
- final Logger log = Logger.getLogger(BundleLifecycleImpl.class);
-
- private Bundle bundle;
- private BundleActivator activator;
-
- public BundleLifecycleImpl(Bundle bundle)
- {
- this.bundle = bundle;
- }
-
- public void start(int options) throws BundleException
- {
- // If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
- if (getState() == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already uninstalled: " + bundle);
-
- // [TODO] Implement the optional Start Level service
-
- // [TODO] If this bundle is in the process of being activated or deactivated then this method must wait
- // for activation or deactivation to complete before continuing.
- if (getState() == Bundle.STARTING || getState() == Bundle.STARTING)
- throw new IllegalStateException("Bundle already staring/stopping: " + bundle);
-
- // If this bundle's state is not RESOLVED, an attempt is made to resolve this bundle.
- if (getState() != Bundle.RESOLVED)
- {
- BundleResolver resolver = getFramework().getBundleResolver();
- resolver.resolveBundle(bundle);
-
- BundleEventManager eventManager = getFramework().getBundleEventManager();
- eventManager.fireBundleEvent(new BundleEvent(BundleEvent.RESOLVED, bundle));
- }
-
- // [TODO] Lazy bundle activation
-
- // This bundle's state is set to STARTING.
- setState(Bundle.STARTING);
-
- // A bundle event of type BundleEvent.STARTING is fired.
- BundleEventManager eventManager = getFramework().getBundleEventManager();
- eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTING, bundle));
-
- // The BundleActivator is called
- String activatorClass = (String)bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR);
- if (activatorClass != null)
- {
- try
- {
- activator = (BundleActivator)bundle.loadClass(activatorClass).newInstance();
- activator.start(bundle.getBundleContext());
- }
- catch (Exception ex)
- {
- // This bundle's state is set to STOPPING.
- setState(Bundle.STOPPING);
-
- // A bundle event of type BundleEvent.STOPPING is fired
- eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, bundle));
-
- // Any services registered by this bundle must be unregistered.
- BundleContextImpl contextImpl = (BundleContextImpl)bundle.getBundleContext();
- contextImpl.releaseRegisteredServices();
-
- // Any services used by this bundle must be released.
- contextImpl.releaseUsedServices();
-
- // Any listeners registered by this bundle must be removed.
- contextImpl.releaseRegisteredListeners();
-
- // This bundle's state is set to RESOLVED.
- setState(Bundle.RESOLVED);
-
- // A bundle event of type BundleEvent.STOPPED is fired.
- eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, bundle));
-
- // A BundleException is then thrown.
- throw new BundleException("Cannot call BundleActivator: " + activatorClass, ex);
- }
- }
-
- // If this bundle's state is UNINSTALLED, because this bundle was uninstalled while
- // the BundleActivator.start was running
- if (getState() == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already uninstalled: " + bundle);
-
- // This bundle's state is set to ACTIVE
- setState(Bundle.ACTIVE);
-
- // A bundle event of type BundleEvent.STARTED is fired
- eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTED, bundle));
- }
-
- public void stop(int options) throws BundleException
- {
- // 1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
- if (getState() == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already unistalled: " + bundle);
-
- // [TODO] 2. If this bundle is in the process of being activated or deactivated then this method must wait for activation or deactivation to complete
-
- // [TODO] 3. If the STOP_TRANSIENT option is not set then then set this bundle's persistent autostart setting to to Stopped. When the Framework is restarted and this bundle's autostart setting is Stopped, this bundle must not be automatically started.
-
- // 4. If this bundle's state is not STARTING or ACTIVE then this method returns immediately.
- if (!(getState() == Bundle.STARTING || getState() == Bundle.ACTIVE))
- return;
-
- // 5. This bundle's state is set to STOPPING.
- int statePriorToStopping = getState();
- setState(Bundle.STOPPING);
-
- // 6. A bundle event of type BundleEvent.STOPPING is fired.
- BundleEventManager eventManager = getFramework().getBundleEventManager();
- eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, bundle));
-
- // 7. If this bundle's state was ACTIVE prior to setting the state to STOPPING, the BundleActivator.stop(org.osgi.framework.BundleContext) method of this bundle's BundleActivator, if one is specified, is called.
- Exception activatorStopException = null;
- if (statePriorToStopping == Bundle.ACTIVE && activator != null)
- {
- try
- {
- activator.stop(bundle.getBundleContext());
- }
- catch (Exception ex)
- {
- // This method must continue to stop this bundle and a BundleException must be thrown after completion of the remaining steps.
- activatorStopException = ex;
- }
- }
-
- // 8. Any services registered by this bundle must be unregistered.
- BundleContextImpl contextImpl = (BundleContextImpl)bundle.getBundleContext();
- contextImpl.releaseRegisteredServices();
-
- // 9. Any services used by this bundle must be released.
- contextImpl.releaseUsedServices();
-
- // 10. Any listeners registered by this bundle must be removed.
- contextImpl.releaseRegisteredListeners();
-
- // 11. If this bundle's state is UNINSTALLED, because this bundle was uninstalled while the BundleActivator.stop method was running, a BundleException must be thrown.
- if (getState() == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already unistalled: " + bundle);
-
- // 12. This bundle's state is set to RESOLVED.
- setState(Bundle.RESOLVED);
-
- // 13. A bundle event of type BundleEvent.STOPPED is fired.
- eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, bundle));
-
- // A BundleException must be thrown after completion of the remaining steps
- if (activatorStopException != null)
- {
- if (activatorStopException instanceof BundleException)
- throw (BundleException)activatorStopException;
-
- throw new BundleException("Exception in BundleActivator.stop()", activatorStopException);
- }
- }
-
- public void uninstall() throws BundleException
- {
- // 1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
- if (getState() == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already unistalled: " + bundle);
-
- // 2. If this bundle's state is ACTIVE, STARTING or STOPPING, this bundle is stopped as described in the Bundle.stop method.
- if (getState() == Bundle.ACTIVE || getState() == Bundle.STARTING || getState() == Bundle.STOPPING)
- {
- try
- {
- stop(0);
- }
- catch (Exception ex)
- {
- // If Bundle.stop throws an exception, a Framework event of type FrameworkEvent.ERROR is fired containing the exception.
- FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
- eventManager.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.ERROR, bundle, ex));
- }
- }
-
- // 3. This bundle's state is set to UNINSTALLED.
- setState(Bundle.UNINSTALLED);
-
- // 4. A bundle event of type BundleEvent.UNINSTALLED is fired.
- BundleEventManager eventManager = getFramework().getBundleEventManager();
- eventManager.fireBundleEvent(new BundleEvent(BundleEvent.UNINSTALLED, bundle));
-
- // 5. This bundle and any persistent storage area provided for this bundle by the Framework are removed.
- BundleRegistry bundleRegistry = getFramework().getBundleRegistry();
- bundleRegistry.unregisterBundle(bundle);
-
- // [TODO] Any persistent storage area provided for this bundle are removed.
- }
-
- private int getState()
- {
- return bundle.getState();
- }
-
- private void setState(int state)
- {
- BundleImpl bundleImpl = (BundleImpl)bundle;
- bundleImpl.setState(state);
- }
-
- private FrameworkImpl getFramework()
- {
- BundleContextImpl context = (BundleContextImpl)bundle.getBundleContext();
- return context.getFramework();
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecyclePluginImpl.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecyclePluginImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecyclePluginImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,254 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id$
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleEventsPlugin;
+import org.jboss.osgi.jbossmc.api.BundleLifecyclePlugin;
+import org.jboss.osgi.jbossmc.api.BundleRegistryPlugin;
+import org.jboss.osgi.jbossmc.api.BundleResolverPlugin;
+import org.jboss.osgi.jbossmc.api.FrameworkEventsPlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * An implementation of the OSGi bundle lifecycle
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 29-Jul-2009
+ */
+public class BundleLifecyclePluginImpl extends AbstractPluginImpl implements BundleLifecyclePlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundleLifecyclePluginImpl.class);
+
+ public BundleLifecyclePluginImpl()
+ {
+ }
+
+ public BundleLifecyclePluginImpl(Framework framework)
+ {
+ setFramework(framework);
+ }
+
+ public void start(Bundle bundle, int options) throws BundleException
+ {
+ // If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
+ if (bundle.getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already uninstalled: " + bundle);
+
+ // [TODO] Implement the optional Start Level service
+
+ // [TODO] If this bundle is in the process of being activated or deactivated then this method must wait
+ // for activation or deactivation to complete before continuing.
+ if (bundle.getState() == Bundle.STARTING || bundle.getState() == Bundle.STARTING)
+ throw new IllegalStateException("Bundle already staring/stopping: " + bundle);
+
+ // If this bundle's state is not RESOLVED, an attempt is made to resolve this bundle.
+ if (bundle.getState() != Bundle.RESOLVED)
+ {
+ BundleResolverPlugin resolver = getPlugin(BundleResolverPlugin.class);
+ resolver.resolveBundle(bundle);
+
+ BundleEventsPlugin eventManager = getPlugin(BundleEventsPlugin.class);
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.RESOLVED, bundle));
+ }
+
+ // [TODO] Lazy bundle activation
+
+ // This bundle's state is set to STARTING.
+ setState(bundle, Bundle.STARTING);
+
+ // A bundle event of type BundleEvent.STARTING is fired.
+ BundleEventsPlugin eventManager = getPlugin(BundleEventsPlugin.class);
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTING, bundle));
+
+ // The BundleActivator is called
+ String activatorClass = (String)bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR);
+ if (activatorClass != null)
+ {
+ try
+ {
+ BundleActivator activator = (BundleActivator)bundle.loadClass(activatorClass).newInstance();
+ activator.start(bundle.getBundleContext());
+
+ BundleImpl bundleImpl = (BundleImpl)bundle;
+ bundleImpl.setBundleActivator(activator);
+ }
+ catch (Exception ex)
+ {
+ // This bundle's state is set to STOPPING.
+ setState(bundle, Bundle.STOPPING);
+
+ // A bundle event of type BundleEvent.STOPPING is fired
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, bundle));
+
+ // Any services registered by this bundle must be unregistered.
+ BundleContextImpl contextImpl = (BundleContextImpl)bundle.getBundleContext();
+ contextImpl.releaseRegisteredServices();
+
+ // Any services used by this bundle must be released.
+ contextImpl.releaseUsedServices();
+
+ // Any listeners registered by this bundle must be removed.
+ contextImpl.releaseRegisteredListeners();
+
+ // This bundle's state is set to RESOLVED.
+ setState(bundle, Bundle.RESOLVED);
+
+ // A bundle event of type BundleEvent.STOPPED is fired.
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, bundle));
+
+ // A BundleException is then thrown.
+ throw new BundleException("Cannot call BundleActivator: " + activatorClass, ex);
+ }
+ }
+
+ // If this bundle's state is UNINSTALLED, because this bundle was uninstalled while
+ // the BundleActivator.start was running
+ if (bundle.getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already uninstalled: " + bundle);
+
+ // This bundle's state is set to ACTIVE
+ setState(bundle, Bundle.ACTIVE);
+
+ // A bundle event of type BundleEvent.STARTED is fired
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTED, bundle));
+ }
+
+ public void stop(Bundle bundle, int options) throws BundleException
+ {
+ // 1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
+ if (bundle.getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already unistalled: " + bundle);
+
+ // [TODO] 2. If this bundle is in the process of being activated or deactivated then this method must wait for activation or deactivation to complete
+
+ // [TODO] 3. If the STOP_TRANSIENT option is not set then then set this bundle's persistent autostart setting to to Stopped. When the Framework is restarted and this bundle's autostart setting is Stopped, this bundle must not be automatically started.
+
+ // 4. If this bundle's state is not STARTING or ACTIVE then this method returns immediately.
+ if (!(bundle.getState() == Bundle.STARTING || bundle.getState() == Bundle.ACTIVE))
+ return;
+
+ // 5. This bundle's state is set to STOPPING.
+ int statePriorToStopping = bundle.getState();
+ setState(bundle, Bundle.STOPPING);
+
+ // 6. A bundle event of type BundleEvent.STOPPING is fired.
+ BundleEventsPlugin eventManager = getPlugin(BundleEventsPlugin.class);
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, bundle));
+
+ // 7. If this bundle's state was ACTIVE prior to setting the state to STOPPING, the BundleActivator.stop(org.osgi.framework.BundleContext) method of this bundle's BundleActivator, if one is specified, is called.
+ Exception activatorStopException = null;
+ BundleImpl bundleImpl = (BundleImpl)bundle;
+ BundleActivator activator = bundleImpl.getBundleActivator();
+ if (statePriorToStopping == Bundle.ACTIVE && activator != null)
+ {
+ try
+ {
+ activator.stop(bundle.getBundleContext());
+ }
+ catch (Exception ex)
+ {
+ // This method must continue to stop this bundle and a BundleException must be thrown after completion of the remaining steps.
+ activatorStopException = ex;
+ }
+ }
+
+ // 8. Any services registered by this bundle must be unregistered.
+ BundleContextImpl contextImpl = (BundleContextImpl)bundle.getBundleContext();
+ contextImpl.releaseRegisteredServices();
+
+ // 9. Any services used by this bundle must be released.
+ contextImpl.releaseUsedServices();
+
+ // 10. Any listeners registered by this bundle must be removed.
+ contextImpl.releaseRegisteredListeners();
+
+ // 11. If this bundle's state is UNINSTALLED, because this bundle was uninstalled while the BundleActivator.stop method was running, a BundleException must be thrown.
+ if (bundle.getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already unistalled: " + bundle);
+
+ // 12. This bundle's state is set to RESOLVED.
+ setState(bundle, Bundle.RESOLVED);
+
+ // 13. A bundle event of type BundleEvent.STOPPED is fired.
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, bundle));
+
+ // A BundleException must be thrown after completion of the remaining steps
+ if (activatorStopException != null)
+ {
+ if (activatorStopException instanceof BundleException)
+ throw (BundleException)activatorStopException;
+
+ throw new BundleException("Exception in BundleActivator.stop()", activatorStopException);
+ }
+ }
+
+ public void uninstall(Bundle bundle) throws BundleException
+ {
+ // 1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
+ if (bundle.getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already unistalled: " + bundle);
+
+ // 2. If this bundle's state is ACTIVE, STARTING or STOPPING, this bundle is stopped as described in the Bundle.stop method.
+ if (bundle.getState() == Bundle.ACTIVE || bundle.getState() == Bundle.STARTING || bundle.getState() == Bundle.STOPPING)
+ {
+ try
+ {
+ stop(bundle, 0);
+ }
+ catch (Exception ex)
+ {
+ // If Bundle.stop throws an exception, a Framework event of type FrameworkEvent.ERROR is fired containing the exception.
+ FrameworkEventsPlugin eventManager = getPlugin(FrameworkEventsPlugin.class);
+ eventManager.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.ERROR, bundle, ex));
+ }
+ }
+
+ // 3. This bundle's state is set to UNINSTALLED.
+ setState(bundle, Bundle.UNINSTALLED);
+
+ // 4. A bundle event of type BundleEvent.UNINSTALLED is fired.
+ BundleEventsPlugin eventManager = getPlugin(BundleEventsPlugin.class);
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.UNINSTALLED, bundle));
+
+ // 5. This bundle and any persistent storage area provided for this bundle by the Framework are removed.
+ BundleRegistryPlugin bundleRegistry = getPlugin(BundleRegistryPlugin.class);
+ bundleRegistry.unregisterBundle(bundle);
+
+ // [TODO] Any persistent storage area provided for this bundle are removed.
+ }
+
+ private void setState(Bundle bundle, int state)
+ {
+ BundleImpl bundleImpl = (BundleImpl)bundle;
+ bundleImpl.setState(state);
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,81 +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.jbossmc.framework;
-
-//$Id: $
-
-import java.io.File;
-import java.io.IOException;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.BundlePersistentStorage;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-
-/**
- * A simple implementation of a BundleStorage
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public class BundlePersistentStorageImpl implements BundlePersistentStorage
-{
- // Provide logging
- final Logger log = Logger.getLogger(BundlePersistentStorageImpl.class);
-
- private FrameworkImpl framework;
-
- public BundlePersistentStorageImpl(FrameworkImpl framework)
- {
- this.framework = framework;
- }
-
- public File getDataFile(Bundle bundle, String filename)
- {
- File bundleDir = getBundleStorageDir(bundle);
- File dataFile = new File(bundleDir.getAbsolutePath() + "/" + filename);
- return dataFile;
- }
-
- private File getBundleStorageDir(Bundle bundle)
- {
- String dirName = (String)framework.getProperty(Constants.FRAMEWORK_STORAGE);
- if (dirName == null)
- {
- try
- {
- File tmpFile = File.createTempFile("Constants.FRAMEWORK_STORAGE", null);
- dirName = tmpFile.getParent();
- tmpFile.delete();
- }
- catch (IOException ex)
- {
- throw new IllegalStateException("Cannot create temp storage file", ex);
- }
- }
-
- File bundleDir = new File(dirName + "/bundle-" + bundle.getBundleId());
- if (bundleDir.exists() == false)
- bundleDir.mkdirs();
- return bundleDir;
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,100 +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.jbossmc.framework;
-
-//$Id: $
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.BundleRegistry;
-import org.osgi.framework.Bundle;
-
-/**
- * A simple implementation of a BundleRegistry
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public class BundleRegistryImpl implements BundleRegistry
-{
- // Provide logging
- final Logger log = Logger.getLogger(BundleRegistryImpl.class);
-
- private long globalId;
- private Map<String, Bundle> registry = new LinkedHashMap<String, Bundle>();
-
- public BundleRegistryImpl(FrameworkImpl framework)
- {
- }
-
- public long registerBundle(Bundle bundle)
- {
- if (bundle == null)
- throw new IllegalArgumentException("Cannot install null bundle");
-
- BundleImpl bundleImpl = (BundleImpl)bundle;
- bundleImpl.setBundleId(globalId++);
-
- registry.put(bundle.getLocation(), bundle);
-
- return bundle.getBundleId();
- }
-
- public void unregisterBundle(Bundle bundle)
- {
- if (bundle == null)
- throw new IllegalArgumentException("Cannot uninstall null bundle");
-
- if (registry.remove(bundle.getLocation()) == null)
- throw new IllegalStateException("Cannot unregister bundle: " + bundle);
- }
-
- public Bundle getBundleById(long id)
- {
- Bundle bundle = null;
- for (Bundle aux : new ArrayList<Bundle>(registry.values()))
- {
- if (id == aux.getBundleId())
- {
- bundle = aux;
- break;
- }
- }
- return bundle;
- }
-
- public Bundle getBundleByLocation(String location)
- {
- return registry.get(location);
- }
-
- public List<Bundle> getBundles()
- {
- ArrayList<Bundle> bundles = new ArrayList<Bundle>(registry.values());
- return Collections.unmodifiableList(bundles);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryPluginImpl.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryPluginImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryPluginImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,106 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id: $
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleRegistryPlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * A simple implementation of a BundleRegistry
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleRegistryPluginImpl extends AbstractPluginImpl implements BundleRegistryPlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundleRegistryPluginImpl.class);
+
+ private long globalId;
+ private Map<String, Bundle> registry = new LinkedHashMap<String, Bundle>();
+
+ public BundleRegistryPluginImpl()
+ {
+ }
+
+ public BundleRegistryPluginImpl(Framework framework)
+ {
+ setFramework(framework);
+ }
+
+ public long registerBundle(Bundle bundle)
+ {
+ if (bundle == null)
+ throw new IllegalArgumentException("Cannot install null bundle");
+
+ BundleImpl bundleImpl = (BundleImpl)bundle;
+ bundleImpl.setBundleId(globalId++);
+
+ registry.put(bundle.getLocation(), bundle);
+
+ return bundle.getBundleId();
+ }
+
+ public void unregisterBundle(Bundle bundle)
+ {
+ if (bundle == null)
+ throw new IllegalArgumentException("Cannot uninstall null bundle");
+
+ if (registry.remove(bundle.getLocation()) == null)
+ throw new IllegalStateException("Cannot unregister bundle: " + bundle);
+ }
+
+ public Bundle getBundleById(long id)
+ {
+ Bundle bundle = null;
+ for (Bundle aux : new ArrayList<Bundle>(registry.values()))
+ {
+ if (id == aux.getBundleId())
+ {
+ bundle = aux;
+ break;
+ }
+ }
+ return bundle;
+ }
+
+ public Bundle getBundleByLocation(String location)
+ {
+ return registry.get(location);
+ }
+
+ public List<Bundle> getBundles()
+ {
+ ArrayList<Bundle> bundles = new ArrayList<Bundle>(registry.values());
+ return Collections.unmodifiableList(bundles);
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,57 +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.jbossmc.framework;
-
-//$Id: $
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.BundleClassLoader;
-import org.jboss.osgi.jbossmc.api.BundleResolver;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-
-/**
- * A simple implementation of a BundleResolver
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public class BundleResolverImpl implements BundleResolver
-{
- // Provide logging
- final Logger log = Logger.getLogger(BundleResolverImpl.class);
-
- public BundleResolverImpl(FrameworkImpl framework)
- {
- }
-
- public void resolveBundle(Bundle bundle) throws BundleException
- {
- // [TODO] resolve bundle properly
-
- BundleImpl bundleImpl = (BundleImpl)bundle;
- BundleClassLoader loader = new BundleClassLoaderImpl(bundleImpl);
- bundleImpl.setClassLoader(loader);
-
- bundleImpl.setState(Bundle.RESOLVED);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverPluginImpl.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverPluginImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverPluginImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,60 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id: $
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleResolverPlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * A simple implementation of a BundleResolver
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleResolverPluginImpl extends AbstractPluginImpl implements BundleResolverPlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundleResolverPluginImpl.class);
+
+ public BundleResolverPluginImpl()
+ {
+ }
+
+ public BundleResolverPluginImpl(Framework framework)
+ {
+ setFramework(framework);
+ }
+
+ public void resolveBundle(Bundle bundle) throws BundleException
+ {
+ // [TODO] resolve bundle properly
+
+ BundleImpl bundleImpl = (BundleImpl)bundle;
+
+ bundleImpl.setState(Bundle.RESOLVED);
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleStoragePluginImpl.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleStoragePluginImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleStoragePluginImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,86 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id: $
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleStoragePlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * A simple implementation of a BundleStorage
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleStoragePluginImpl extends AbstractPluginImpl implements BundleStoragePlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundleStoragePluginImpl.class);
+
+ public BundleStoragePluginImpl()
+ {
+ }
+
+ public BundleStoragePluginImpl(Framework framework)
+ {
+ setFramework(framework);
+ }
+
+ public File getDataFile(Bundle bundle, String filename)
+ {
+ File bundleDir = getBundleStorageDir(bundle);
+ File dataFile = new File(bundleDir.getAbsolutePath() + "/" + filename);
+ return dataFile;
+ }
+
+ private File getBundleStorageDir(Bundle bundle)
+ {
+ BundleContext context = getFramework().getBundleContext();
+ String dirName = context.getProperty(Constants.FRAMEWORK_STORAGE);
+ if (dirName == null)
+ {
+ try
+ {
+ File tmpFile = File.createTempFile("Constants.FRAMEWORK_STORAGE", null);
+ dirName = tmpFile.getParent();
+ tmpFile.delete();
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot create temp storage file", ex);
+ }
+ }
+
+ File bundleDir = new File(dirName + "/bundle-" + bundle.getBundleId());
+ if (bundleDir.exists() == false)
+ bundleDir.mkdirs();
+ return bundleDir;
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ClassLoaderFactoryPluginImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ClassLoaderFactoryPluginImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ClassLoaderFactoryPluginImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,52 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id: BundleLifecycleImpl.java 92578 2009-08-19 14:33:04Z thomas.diesler(a)jboss.com $
+
+import org.jboss.osgi.jbossmc.api.ClassLoaderFactoryPlugin;
+import org.jboss.osgi.jbossmc.api.RuntimeClassLoader;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * An implementation of bundle class loader factory
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 29-Jul-2009
+ */
+public class ClassLoaderFactoryPluginImpl extends AbstractPluginImpl implements ClassLoaderFactoryPlugin
+{
+ public ClassLoaderFactoryPluginImpl()
+ {
+ }
+
+ public ClassLoaderFactoryPluginImpl(Framework framework)
+ {
+ setFramework(framework);
+ }
+
+ public RuntimeClassLoader createClassLoader(Bundle bundle)
+ {
+ return new RuntimeClassLoaderImpl(bundle);
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,139 +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.jbossmc.framework;
-
-//$Id$
-
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.BundleEventManager;
-import org.jboss.osgi.jbossmc.api.BundleFactory;
-import org.jboss.osgi.jbossmc.api.BundlePersistentStorage;
-import org.jboss.osgi.jbossmc.api.BundleRegistry;
-import org.jboss.osgi.jbossmc.api.BundleResolver;
-import org.jboss.osgi.jbossmc.api.FrameworkBootstrap;
-import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
-import org.jboss.osgi.jbossmc.api.ServiceEventManager;
-import org.jboss.osgi.jbossmc.api.ServiceRegistry;
-import org.osgi.framework.launch.Framework;
-
-/**
- * An implementation of a bootstrap bean that can provide an OSGi Framework.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 29-Jul-2009
- */
-public class FrameworkBootstrapImpl implements FrameworkBootstrap
-{
- // Provide logging
- final Logger log = Logger.getLogger(FrameworkBootstrapImpl.class);
-
- private Map<String, Object> properties;
- private List<URL> autoInstall;
- private List<URL> autoStart;
- private Framework framework;
-
- private BundleRegistry bundleRegistry;
- private BundleFactory bundleFactory;
- private BundleResolver bundleResolver;
- private BundleEventManager bundleEventManager;
- private BundlePersistentStorage bundlePersistentStorage;
- private FrameworkEventManager frameworkEventManager;
- private ServiceEventManager serviceEventManager;
- private ServiceRegistry serviceRegistry;
-
- public void setProperties(Map<String, Object> properties)
- {
- this.properties = properties;
- }
-
- public void setAutoInstall(List<URL> autoInstall)
- {
- this.autoInstall = autoInstall;
- }
-
- public void setAutoStart(List<URL> autoStart)
- {
- this.autoStart = autoStart;
- }
-
- public void setBundleRegistry(BundleRegistry bundleRegistry)
- {
- this.bundleRegistry = bundleRegistry;
- }
-
- public void setBundleFactory(BundleFactory bundleFactory)
- {
- this.bundleFactory = bundleFactory;
- }
-
- public void setBundleResolver(BundleResolver bundleResolver)
- {
- this.bundleResolver = bundleResolver;
- }
-
- public void setBundleEventManager(BundleEventManager bundleEventManager)
- {
- this.bundleEventManager = bundleEventManager;
- }
-
- public void setBundlePersistentStorage(BundlePersistentStorage bundlePersistentStorage)
- {
- this.bundlePersistentStorage = bundlePersistentStorage;
- }
-
- public void setServiceEventManager(ServiceEventManager serviceEventManager)
- {
- this.serviceEventManager = serviceEventManager;
- }
-
- public void setServiceRegistry(ServiceRegistry serviceRegistry)
- {
- this.serviceRegistry = serviceRegistry;
- }
-
- public void setFrameworkEventManager(FrameworkEventManager frameworkEventManager)
- {
- this.frameworkEventManager = frameworkEventManager;
- }
-
- public Framework getFramework()
- {
- if (framework == null)
- {
- FrameworkImpl frameworkImpl = new FrameworkImpl(properties);
- frameworkImpl.setBundleFactory(bundleFactory);
- frameworkImpl.setBundleResolver(bundleResolver);
- frameworkImpl.setBundleRegistry(bundleRegistry);
- frameworkImpl.setBundlePersistentStorage(bundlePersistentStorage);
- frameworkImpl.setServiceRegistry(serviceRegistry);
- frameworkImpl.setBundleEventManager(bundleEventManager);
- frameworkImpl.setFrameworkEventManager(frameworkEventManager);
- frameworkImpl.setServiceEventManager(serviceEventManager);
- framework = frameworkImpl;
- }
- return framework;
- }
-}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -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.jbossmc.framework;
-
-//$Id: $
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
-import org.jboss.osgi.spi.util.ConstantsHelper;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
-
-/**
- * A simple implementation of a FrameworkEventManager
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public class FrameworkEventManagerImpl implements FrameworkEventManager
-{
- // Provide logging
- final Logger log = Logger.getLogger(FrameworkEventManagerImpl.class);
-
- private List<FrameworkListener> listeners = new ArrayList<FrameworkListener>();
- private boolean enabled = true;
-
- public FrameworkEventManagerImpl(FrameworkImpl framework)
- {
- }
-
- public boolean isEnabled()
- {
- return enabled;
- }
-
- public void setEnabled(boolean enabled)
- {
- this.enabled = enabled;
- }
-
- public void fireFrameworkEvent(FrameworkEvent event)
- {
- if (enabled == false)
- return;
-
- String typeStr = ConstantsHelper.frameworkEvent(event.getType());
- String message = "FrameworkEvent " + typeStr + " " + event.getSource();
-
- if (event.getType() == FrameworkEvent.ERROR)
- log.error(message);
- else if (event.getType() == FrameworkEvent.WARNING)
- log.warn(message);
- else if (event.getType() == FrameworkEvent.INFO)
- log.info(message);
- else
- log.debug(message);
-
- // [TODO] When a FrameworkEvent is fired, it is asynchronously delivered to a FrameworkListener.
-
- for (FrameworkListener listener : new ArrayList<FrameworkListener>(listeners))
- listener.frameworkEvent(event);
- }
-
- public void addFrameworkListener(FrameworkListener listener)
- {
- listeners.add(listener);
- }
-
- public void removeFrameworkListener(FrameworkListener listener)
- {
- listeners.remove(listener);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventsPluginImpl.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventsPluginImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventsPluginImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,101 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id: $
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.FrameworkEventsPlugin;
+import org.jboss.osgi.spi.util.ConstantsHelper;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * A simple implementation of a FrameworkEventManager
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class FrameworkEventsPluginImpl extends AbstractPluginImpl implements FrameworkEventsPlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(FrameworkEventsPluginImpl.class);
+
+ private List<FrameworkListener> listeners = new ArrayList<FrameworkListener>();
+ private boolean enabled = true;
+
+ public FrameworkEventsPluginImpl()
+ {
+ }
+
+ public FrameworkEventsPluginImpl(Framework framework)
+ {
+ setFramework(framework);
+ }
+
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+
+ public void fireFrameworkEvent(FrameworkEvent event)
+ {
+ if (enabled == false)
+ return;
+
+ String typeStr = ConstantsHelper.frameworkEvent(event.getType());
+ String message = "FrameworkEvent " + typeStr + " " + event.getSource();
+
+ if (event.getType() == FrameworkEvent.ERROR)
+ log.error(message);
+ else if (event.getType() == FrameworkEvent.WARNING)
+ log.warn(message);
+ else if (event.getType() == FrameworkEvent.INFO)
+ log.info(message);
+ else
+ log.debug(message);
+
+ // [TODO] When a FrameworkEvent is fired, it is asynchronously delivered to a FrameworkListener.
+
+ for (FrameworkListener listener : new ArrayList<FrameworkListener>(listeners))
+ listener.frameworkEvent(event);
+ }
+
+ public void addFrameworkListener(FrameworkListener listener)
+ {
+ listeners.add(listener);
+ }
+
+ public void removeFrameworkListener(FrameworkListener listener)
+ {
+ listeners.remove(listener);
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryBean.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryBean.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryBean.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,80 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id$
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * An implementation of a bootstrap bean that can provide an OSGi Framework.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 29-Jul-2009
+ */
+public class FrameworkFactoryBean implements FrameworkFactory
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(FrameworkFactoryBean.class);
+
+ public static final String BEAN_FRAMEWORK_FACTORY = "jboss.osgi:service=FrameworkFactory";
+
+ private Map<String, Object> properties;
+ private List<URL> autoInstall;
+ private List<URL> autoStart;
+ private Framework framework;
+
+ public void setProperties(Map<String, Object> properties)
+ {
+ this.properties = properties;
+ }
+
+ public void setAutoInstall(List<URL> autoInstall)
+ {
+ this.autoInstall = autoInstall;
+ }
+
+ public void setAutoStart(List<URL> autoStart)
+ {
+ this.autoStart = autoStart;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Framework newFramework(Map configuration)
+ {
+ if (framework == null)
+ {
+ if (configuration != null)
+ properties.putAll(configuration);
+
+ FrameworkImpl frameworkImpl = new FrameworkImpl(properties);
+ framework = frameworkImpl;
+ }
+ return framework;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -32,7 +32,6 @@
import org.jboss.bootstrap.spi.mc.server.MCServer;
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.FrameworkBootstrap;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
@@ -69,12 +68,12 @@
throw new IllegalStateException("Cannot bootstrap MC server", ex);
}
- ControllerContext context = server.getKernel().getController().getInstalledContext(FrameworkBootstrap.BEAN_FRAMEWORK_BOOTSTRAP);
+ ControllerContext context = server.getKernel().getController().getInstalledContext(FrameworkFactoryBean.BEAN_FRAMEWORK_FACTORY);
if (context == null)
- throw new IllegalStateException("Cannot obtain: " + FrameworkBootstrap.BEAN_FRAMEWORK_BOOTSTRAP);
+ throw new IllegalStateException("Cannot obtain: " + FrameworkFactoryBean.BEAN_FRAMEWORK_FACTORY);
- FrameworkBootstrap frameworkBootstrap = (FrameworkBootstrap)context.getTarget();
- return frameworkBootstrap.getFramework();
+ FrameworkFactory frameworkBootstrap = (FrameworkFactory)context.getTarget();
+ return frameworkBootstrap.newFramework(configuration);
}
private String getBootstrapHome()
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -31,14 +31,12 @@
import java.util.Map;
import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.BundleEventManager;
-import org.jboss.osgi.jbossmc.api.BundleFactory;
-import org.jboss.osgi.jbossmc.api.BundlePersistentStorage;
-import org.jboss.osgi.jbossmc.api.BundleRegistry;
-import org.jboss.osgi.jbossmc.api.BundleResolver;
-import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
-import org.jboss.osgi.jbossmc.api.ServiceEventManager;
-import org.jboss.osgi.jbossmc.api.ServiceRegistry;
+import org.jboss.osgi.jbossmc.api.AbstractPlugin;
+import org.jboss.osgi.jbossmc.api.BundleEventsPlugin;
+import org.jboss.osgi.jbossmc.api.BundleRegistryPlugin;
+import org.jboss.osgi.jbossmc.api.FrameworkEventsPlugin;
+import org.jboss.osgi.jbossmc.api.ServiceEventsPlugin;
+import org.jboss.osgi.jbossmc.api.ServiceRegistryPlugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
@@ -60,96 +58,42 @@
private Map<String, Object> properties = new HashMap<String, Object>();
private int startLevel;
- private BundleRegistry bundleRegistry;
- private BundleFactory bundleFactory;
- private BundleResolver bundleResolver;
- private BundleEventManager bundleEventManager;
- private BundlePersistentStorage bundlePersistentStorage;
- private FrameworkEventManager frameworkEventManager;
- private ServiceEventManager serviceEventManager;
- private ServiceRegistry serviceRegistry;
+ private Map<Class<?>, AbstractPlugin> plugins = new HashMap<Class<?>, AbstractPlugin>();
public FrameworkImpl(Map<String, Object> props)
{
if (props != null)
properties.putAll(props);
- }
+
+ addPlugin(new BundleEventsPluginImpl(this));
+ addPlugin(new BundleFactoryPluginImpl(this));
+ addPlugin(new BundleLifecyclePluginImpl(this));
+ addPlugin(new BundleResolverPluginImpl(this));
+ addPlugin(new BundleRegistryPluginImpl(this));
+ addPlugin(new BundleStoragePluginImpl(this));
+ addPlugin(new ClassLoaderFactoryPluginImpl(this));
+ addPlugin(new FrameworkEventsPluginImpl(this));
+ addPlugin(new ServiceEventsPluginImpl(this));
+ addPlugin(new ServiceRegistryPluginImpl(this));
- public BundleRegistry getBundleRegistry()
- {
- return bundleRegistry;
}
- public void setBundleRegistry(BundleRegistry bundleRegistry)
+ @SuppressWarnings("unchecked")
+ public <T extends AbstractPlugin> T getPlugin(Class<T> clazz)
{
- this.bundleRegistry = bundleRegistry;
+ return (T)plugins.get(clazz);
}
-
- public BundleFactory getBundleFactory()
+
+ @SuppressWarnings("unchecked")
+ public void addPlugin(AbstractPlugin plugin)
{
- return bundleFactory;
+ for (Class<?> interf : plugin.getClass().getInterfaces())
+ {
+ if (AbstractPlugin.class.isAssignableFrom(interf))
+ plugins.put(interf, plugin);
+ }
}
-
- public void setBundleFactory(BundleFactory bundleFactory)
- {
- this.bundleFactory = bundleFactory;
- }
-
- public BundleResolver getBundleResolver()
- {
- return bundleResolver;
- }
-
- public void setBundleResolver(BundleResolver bundleResolver)
- {
- this.bundleResolver = bundleResolver;
- }
-
- public BundleEventManager getBundleEventManager()
- {
- return bundleEventManager;
- }
-
- public void setBundleEventManager(BundleEventManager bundleEventManager)
- {
- this.bundleEventManager = bundleEventManager;
- }
-
- public BundlePersistentStorage getBundlePersistentStorage()
- {
- return bundlePersistentStorage;
- }
-
- public void setBundlePersistentStorage(BundlePersistentStorage bundlePersistentStorage)
- {
- this.bundlePersistentStorage = bundlePersistentStorage;
- }
-
- public ServiceEventManager getServiceEventManager()
- {
- return serviceEventManager;
- }
-
- public void setServiceEventManager(ServiceEventManager serviceEventManager)
- {
- this.serviceEventManager = serviceEventManager;
- }
-
- public ServiceRegistry getServiceRegistry()
- {
- return serviceRegistry;
- }
-
- public void setServiceRegistry(ServiceRegistry serviceRegistry)
- {
- this.serviceRegistry = serviceRegistry;
- }
-
- public void setFrameworkEventManager(FrameworkEventManager frameworkEventManager)
- {
- this.frameworkEventManager = frameworkEventManager;
- }
-
+
/**
* Returns the Framework unique identifier. This Framework is assigned the unique identifier zero (0) since this Framework is also a System Bundle.
*/
@@ -275,19 +219,10 @@
// Have a valid Bundle Context
setBundleContext(new SystemBundleContext(this));
- bundleFactory = new BundleFactoryImpl(this);
- bundleResolver = new BundleResolverImpl(this);
- bundleRegistry = new BundleRegistryImpl(this);
- bundlePersistentStorage = new BundlePersistentStorageImpl(this);
- serviceRegistry = new ServiceRegistryImpl(this);
-
// Be at start level 0
setStartLevel(0);
// Have event handling enabled
- bundleEventManager = new BundleEventManagerImpl(this);
- frameworkEventManager = new FrameworkEventManagerImpl(this);
- serviceEventManager = new ServiceEventManagerImpl(this);
// [TODO] Have reified Bundle objects for all installed bundles
@@ -306,7 +241,8 @@
setState(ACTIVE);
// A framework event of type STARTED is fired
- frameworkEventManager.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.STARTED, this, null));
+ FrameworkEventsPlugin frameworkEvents = getPlugin(FrameworkEventsPlugin.class);
+ frameworkEvents.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.STARTED, this, null));
}
private void stopInternal()
@@ -315,6 +251,7 @@
setState(STOPPING);
// All installed bundles must be stopped
+ BundleRegistryPlugin bundleRegistry = getPlugin(BundleRegistryPlugin.class);
List<Bundle> reverseList = bundleRegistry.getBundles();
Collections.reverse(reverseList);
for (Bundle bundle : reverseList)
@@ -333,6 +270,7 @@
ServiceReference[] srefs = null;
try
{
+ ServiceRegistryPlugin serviceRegistry = getPlugin(ServiceRegistryPlugin.class);
srefs = serviceRegistry.getServiceReferences(null, null);
}
catch (InvalidSyntaxException ex)
@@ -356,9 +294,12 @@
}
// Event handling is disabled
- bundleEventManager.setEnabled(false);
- serviceEventManager.setEnabled(false);
- frameworkEventManager.setEnabled(false);
+ ServiceEventsPlugin serviceEvents = getPlugin(ServiceEventsPlugin.class);
+ serviceEvents.setEnabled(false);
+ BundleEventsPlugin bundleEvents = getPlugin(BundleEventsPlugin.class);
+ bundleEvents.setEnabled(false);
+ FrameworkEventsPlugin frameworkEvents = getPlugin(FrameworkEventsPlugin.class);
+ frameworkEvents.setEnabled(false);
// This Framework's state is set to RESOLVED
setState(RESOLVED);
@@ -383,11 +324,6 @@
return new FrameworkEvent(FrameworkEvent.STOPPED, this, null);
}
- public FrameworkEventManager getFrameworkEventManager()
- {
- return frameworkEventManager;
- }
-
@Override
public String toString()
{
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/RuntimeClassLoaderImpl.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/RuntimeClassLoaderImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/RuntimeClassLoaderImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -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.jbossmc.framework;
+
+//$Id: $
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Enumeration;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.RuntimeClassLoader;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
+
+/**
+ * A simple implementation of a BundleClassLoader
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class RuntimeClassLoaderImpl implements RuntimeClassLoader
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(RuntimeClassLoaderImpl.class);
+
+ private VirtualFile virtualFile;
+ private ClassLoader loader;
+
+ public RuntimeClassLoaderImpl(Bundle bundle)
+ {
+ BundleImpl bundleImpl = (BundleImpl)bundle;
+ virtualFile = bundleImpl.getVirtualFile();
+
+ URL location;
+ try
+ {
+ location = virtualFile.toURL();
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot obtain bundle location", ex);
+ }
+
+ loader = new URLClassLoader(new URL[] { location });
+ }
+
+ public Class<?> loadClass(String name) throws ClassNotFoundException
+ {
+ return loader.loadClass(name);
+ }
+
+ public URL getResource(String name)
+ {
+ URL resourceURL = null;
+ try
+ {
+ VirtualFile child = virtualFile.getChild(name);
+ if (child != null)
+ resourceURL = child.toURL();
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ return resourceURL;
+ }
+
+ public Enumeration<URL> getResources(String name) throws IOException
+ {
+ // [TODO] Bundle.getResources(String name)
+ throw new NotImplementedException();
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,143 +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.jbossmc.framework;
-
-//$Id: $
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.ServiceEventManager;
-import org.jboss.osgi.spi.util.ConstantsHelper;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-
-/**
- * A simple implementation of a BundleEventManager
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public class ServiceEventManagerImpl implements ServiceEventManager
-{
- // Provide logging
- final Logger log = Logger.getLogger(ServiceEventManagerImpl.class);
-
- private Map<ServiceListener, ListenerRegistration> listeners = new LinkedHashMap<ServiceListener, ListenerRegistration>();
- private boolean enabled = true;
-
- public ServiceEventManagerImpl(FrameworkImpl framework)
- {
- }
-
- public boolean isEnabled()
- {
- return enabled;
- }
-
- public void setEnabled(boolean enabled)
- {
- this.enabled = enabled;
- }
-
- public void fireServiceEvent(ServiceEvent event)
- {
- if (enabled == false)
- return;
-
- String typeStr = ConstantsHelper.serviceEvent(event.getType());
- log.debug("ServiceEvent " + typeStr + " " + event.getSource());
-
- ServiceReference sref = event.getServiceReference();
- String[] clazzes = (String[])sref.getProperty(Constants.OBJECTCLASS);
- if (clazzes == null)
- throw new IllegalStateException("Cannot obtain property '" + Constants.OBJECTCLASS + "' from: " + sref);
-
- // When a ServiceEvent is fired, it is synchronously delivered to a ServiceListener.
- for (ListenerRegistration reg : new ArrayList<ListenerRegistration>(listeners.values()))
- {
- ServiceListener listener = reg.getListener();
-
- // ServiceEvent object delivery to ServiceListener objects is filtered
- Filter filter = reg.getFilter();
- if (filter == null || filter.match(sref))
- listener.serviceChanged(event);
- }
-
- // [TODO] ServiceEvent object delivery to ServiceListener objects is further filtered according to package sources
- }
-
- public void addServiceListener(ServiceListener listener)
- {
- listeners.put(listener, new ListenerRegistration(listener, null));
- }
-
- public void addServiceListener(ServiceListener listener, String filter)
- {
- listeners.put(listener, new ListenerRegistration(listener, filter));
- }
-
- public void removeServiceListener(ServiceListener listener)
- {
- listeners.remove(listener);
- }
-
- private static class ListenerRegistration
- {
- ServiceListener listener;
- Filter filter;
-
- ListenerRegistration(ServiceListener listener, String filterStr)
- {
- this.listener = listener;
-
- if (filterStr != null)
- {
- try
- {
- filter = FrameworkUtil.createFilter(filterStr);
- }
- catch (InvalidSyntaxException ex)
- {
- throw new IllegalArgumentException(ex);
- }
- }
- }
-
- public ServiceListener getListener()
- {
- return listener;
- }
-
- public Filter getFilter()
- {
- return filter;
- }
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventsPluginImpl.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventsPluginImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventsPluginImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,149 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id: $
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.ServiceEventsPlugin;
+import org.jboss.osgi.spi.util.ConstantsHelper;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * A simple implementation of a BundleEventManager
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class ServiceEventsPluginImpl extends AbstractPluginImpl implements ServiceEventsPlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(ServiceEventsPluginImpl.class);
+
+ private Map<ServiceListener, ListenerRegistration> listeners = new LinkedHashMap<ServiceListener, ListenerRegistration>();
+ private boolean enabled = true;
+
+ public ServiceEventsPluginImpl()
+ {
+ }
+
+ public ServiceEventsPluginImpl(Framework framework)
+ {
+ setFramework(framework);
+ }
+
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+
+ public void fireServiceEvent(ServiceEvent event)
+ {
+ if (enabled == false)
+ return;
+
+ String typeStr = ConstantsHelper.serviceEvent(event.getType());
+ log.debug("ServiceEvent " + typeStr + " " + event.getSource());
+
+ ServiceReference sref = event.getServiceReference();
+ String[] clazzes = (String[])sref.getProperty(Constants.OBJECTCLASS);
+ if (clazzes == null)
+ throw new IllegalStateException("Cannot obtain property '" + Constants.OBJECTCLASS + "' from: " + sref);
+
+ // When a ServiceEvent is fired, it is synchronously delivered to a ServiceListener.
+ for (ListenerRegistration reg : new ArrayList<ListenerRegistration>(listeners.values()))
+ {
+ ServiceListener listener = reg.getListener();
+
+ // ServiceEvent object delivery to ServiceListener objects is filtered
+ Filter filter = reg.getFilter();
+ if (filter == null || filter.match(sref))
+ listener.serviceChanged(event);
+ }
+
+ // [TODO] ServiceEvent object delivery to ServiceListener objects is further filtered according to package sources
+ }
+
+ public void addServiceListener(ServiceListener listener)
+ {
+ listeners.put(listener, new ListenerRegistration(listener, null));
+ }
+
+ public void addServiceListener(ServiceListener listener, String filter)
+ {
+ listeners.put(listener, new ListenerRegistration(listener, filter));
+ }
+
+ public void removeServiceListener(ServiceListener listener)
+ {
+ listeners.remove(listener);
+ }
+
+ private static class ListenerRegistration
+ {
+ ServiceListener listener;
+ Filter filter;
+
+ ListenerRegistration(ServiceListener listener, String filterStr)
+ {
+ this.listener = listener;
+
+ if (filterStr != null)
+ {
+ try
+ {
+ filter = FrameworkUtil.createFilter(filterStr);
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ throw new IllegalArgumentException(ex);
+ }
+ }
+ }
+
+ public ServiceListener getListener()
+ {
+ return listener;
+ }
+
+ public Filter getFilter()
+ {
+ return filter;
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -26,7 +26,7 @@
import java.util.Dictionary;
import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.ServiceRegistry;
+import org.jboss.osgi.jbossmc.api.ServiceRegistryPlugin;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -42,10 +42,10 @@
// Provide logging
final Logger log = Logger.getLogger(ServiceRegistrationImpl.class);
- private ServiceRegistry serviceRegistry;
+ private ServiceRegistryPlugin serviceRegistry;
private ServiceReferenceImpl serviceRef;
- public ServiceRegistrationImpl(ServiceRegistry serviceRegistry, ServiceReferenceImpl serviceRef)
+ public ServiceRegistrationImpl(ServiceRegistryPlugin serviceRegistry, ServiceReferenceImpl serviceRef)
{
this.serviceRegistry = serviceRegistry;
this.serviceRef = serviceRef;
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -1,303 +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.jbossmc.framework;
-
-//$Id: $
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.jboss.logging.Logger;
-import org.jboss.osgi.jbossmc.api.ServiceEventManager;
-import org.jboss.osgi.jbossmc.api.ServiceRegistry;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceFactory;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * A simple implementation of a BundleRegistry
- *
- * @author thomas.diesler(a)jboss.com
- * @since 18-Aug-2009
- */
-public class ServiceRegistryImpl implements ServiceRegistry
-{
- // Provide logging
- final Logger log = Logger.getLogger(ServiceRegistryImpl.class);
-
- private Map<String, List<ServiceReference>> registry = new HashMap<String, List<ServiceReference>>();
- private FrameworkImpl framework;
- private long serviceId;
-
- public ServiceRegistryImpl(FrameworkImpl framework)
- {
- this.framework = framework;
- }
-
- public ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary<String, Object> properties)
- {
- return registerServiceInternal(bundle, new String[] {clazz}, service, properties);
- }
-
- public ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary<String, Object> properties)
- {
- return registerServiceInternal(bundle, clazzes, service, properties);
- }
-
- public void unregisterService(ServiceRegistration registration)
- {
- ServiceReference sref = registration.getReference();
- String[] clazzes = (String[])sref.getProperty(Constants.OBJECTCLASS);
- for (String clazz : clazzes)
- {
- List<ServiceReference> srefs = registry.get(clazz);
- if (srefs != null)
- {
- Iterator<ServiceReference> itRefs = srefs.iterator();
- while (itRefs.hasNext())
- {
- ServiceReference next = itRefs.next();
- if (sref == next)
- itRefs.remove();
- }
- }
- }
- }
-
- public ServiceReference getServiceReference(String clazz)
- {
- ServiceReference srefBest = null;
-
- List<ServiceReference> srefs = registry.get(clazz);
- if (srefs != null && srefs.size() > 0)
- {
- // If multiple such services exist, the service with the highest ranking is returned.
- // If there is a tie in ranking, the service with the lowest service ID (i.e. the service that was registered first) is returned.
- for (ServiceReference sref : srefs)
- {
- if (srefBest != null)
- {
- Integer bestRanking = (Integer)srefBest.getProperty(Constants.SERVICE_RANKING);
- Long bestId = (Long)srefBest.getProperty(Constants.SERVICE_ID);
-
- Integer thisRanking = (Integer)sref.getProperty(Constants.SERVICE_RANKING);
- Long thisId = (Long)sref.getProperty(Constants.SERVICE_ID);
- if (thisRanking != null)
- {
- if (bestRanking == null)
- bestRanking = new Integer(0);
-
- if (bestRanking < thisRanking)
- srefBest = sref;
-
- if (bestRanking.equals(thisRanking) && bestId < thisId)
- srefBest = sref;
- }
- }
-
- if (srefBest == null)
- srefBest = sref;
- }
- }
-
- return srefBest;
- }
-
- public ServiceReference[] getServiceReferences(String clazz, String filterStr) throws InvalidSyntaxException
- {
- Set<ServiceReference> resultRefs = new LinkedHashSet<ServiceReference>();
-
- // If the specified class name, clazz, is not null, the service must have been registered with the specified class name.
- if (clazz != null)
- {
- List<ServiceReference> srefs = registry.get(clazz);
- if (srefs != null)
- resultRefs.addAll(srefs);
- }
-
- // null for all services
- if (clazz == null)
- {
- for (String auxclazz : registry.keySet())
- {
- List<ServiceReference> srefs = registry.get(auxclazz);
- if (srefs != null)
- resultRefs.addAll(srefs);
- }
- }
-
- // If the specified filter is not null, the filter expression must match the service.
- if (filterStr != null)
- {
- Filter filter = FrameworkUtil.createFilter(filterStr);
- Iterator<ServiceReference> itref = resultRefs.iterator();
- while (itref.hasNext())
- {
- ServiceReference sref = itref.next();
- if (filter.match(sref) == false)
- itref.remove();
- }
- }
-
- // [TODO] If the Java Runtime Environment supports permissions, the caller must have ServicePermission with the GET action for at least one of the class names under which the service was registered.
-
- // [TODO] For each class name with which the service was registered, calling ServiceReference.isAssignableTo(Bundle, String) with the context bundle and the class name on the service's ServiceReference object must return true
-
- // Return null if no services are registered which satisfy the search
- if (resultRefs.size() == 0)
- return null;
-
- ServiceReference[] srefArr = new ServiceReference[resultRefs.size()];
- return resultRefs.toArray(srefArr);
- }
-
- public Object getService(Bundle bundle, ServiceReference sref)
- {
- ServiceReferenceImpl srefImpl = (ServiceReferenceImpl)sref;
-
- // If the service has been unregistered, null is returned.
- if (srefImpl.isUnregistered())
- return null;
-
- // The context bundle's use count for this service is incremented by one.
- srefImpl.incrementUseCount(bundle);
-
- // The service was registered with an object implementing the ServiceFactory interface
- Object service = srefImpl.getService();
- if (service instanceof ServiceFactory)
- {
- if (srefImpl.getUseCount(bundle) == 1)
- {
- ServiceFactory factory = (ServiceFactory)service;
- service = factory.getService(bundle, srefImpl.getServiceRegistration());
- srefImpl.setCachedService(bundle, service);
- }
- else
- {
- service = srefImpl.getCachedService(bundle);
- }
- }
-
- // The service object for the service is returned.
- return service;
- }
-
- public boolean ungetService(Bundle bundle, ServiceReference sref)
- {
- ServiceReferenceImpl srefImpl = (ServiceReferenceImpl)sref;
-
- // 1. If the context bundle's use count for the service is zero or the service has been unregistered, false is returned.
- if (srefImpl.getUseCount(bundle) == 0 || srefImpl.isUnregistered())
- return false;
-
- // 2. The context bundle's use count for this service is decremented by one.
- srefImpl.decrementUseCount(bundle);
-
- // 3. If the context bundle's use count for the service is currently zero and the service was registered with a ServiceFactory object,
- // the ServiceFactory.ungetService(Bundle, ServiceRegistration, Object) method is called to release the service object for the context bundle.
- Object service = srefImpl.getService();
- if (srefImpl.getUseCount(bundle) == 0 && service instanceof ServiceFactory)
- {
- ServiceFactory factory = (ServiceFactory)service;
- service = srefImpl.getCachedService(bundle);
- factory.ungetService(bundle, srefImpl.getServiceRegistration(), service);
- srefImpl.setCachedService(bundle, null);
- }
-
- // 4. true is returned.
- return true;
- }
-
- private ServiceRegistration registerServiceInternal(Bundle bundle, String[] clazzes, Object service, Dictionary<String, Object> props)
- {
- // If service is not a ServiceFactory, an IllegalArgumentException is thrown if service
- // is not an instanceof all the specified class names.
- if ((service instanceof ServiceFactory) == false)
- {
- for (String clazz : clazzes)
- {
- try
- {
- Class<?> interf = bundle.loadClass(clazz);
- if (interf.isAssignableFrom(service.getClass()) == false)
- throw new IllegalArgumentException("Service is not assignable to: " + clazz);
- }
- catch (ClassNotFoundException ex)
- {
- throw new IllegalArgumentException("Cannot load service interface: " + clazz, ex);
- }
- }
- }
-
- // 2. The Framework adds the following service properties to the service properties from the specified Dictionary (which may be null):
- // A property named Constants.SERVICE_ID identifying the registration number of the service
- // A property named Constants.OBJECTCLASS containing all the specified classes.
- Dictionary<String, Object> properties = new Hashtable<String, Object>();
- properties.put(Constants.SERVICE_ID, new Long(serviceId++));
- properties.put(Constants.OBJECTCLASS, clazzes);
-
- if (props != null)
- {
- Enumeration<String> keys = props.keys();
- while(keys.hasMoreElements())
- {
- String key = keys.nextElement();
- Object value = props.get(key);
- properties.put(key, value);
- }
- }
-
- // 3. The service is added to the Framework service registry and may now be used by other bundles.
- ServiceReferenceImpl sref = new ServiceReferenceImpl(bundle, service, properties);
- for (String clazz : clazzes)
- {
- List<ServiceReference> list = registry.get(clazz);
- if (list == null)
- {
- list = new ArrayList<ServiceReference>();
- registry.put(clazz, list);
- }
- list.add(sref);
- }
-
- // 4. A service event of type ServiceEvent.REGISTERED is fired.
- ServiceEventManager eventManager = framework.getServiceEventManager();
- eventManager.fireServiceEvent(new ServiceEvent(ServiceEvent.REGISTERED, sref));
-
- // 5. A ServiceRegistration object for this registration is returned.
- return new ServiceRegistrationImpl(this, sref);
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryPluginImpl.java (from rev 92602, projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java)
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryPluginImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryPluginImpl.java 2009-08-20 08:40:11 UTC (rev 92604)
@@ -0,0 +1,307 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id: $
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.ServiceEventsPlugin;
+import org.jboss.osgi.jbossmc.api.ServiceRegistryPlugin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceFactory;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * A simple implementation of a BundleRegistry
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class ServiceRegistryPluginImpl extends AbstractPluginImpl implements ServiceRegistryPlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(ServiceRegistryPluginImpl.class);
+
+ private Map<String, List<ServiceReference>> registry = new HashMap<String, List<ServiceReference>>();
+ private long serviceId;
+
+ public ServiceRegistryPluginImpl()
+ {
+ }
+
+ public ServiceRegistryPluginImpl(Framework framework)
+ {
+ setFramework(framework);
+ }
+
+ public ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary<String, Object> properties)
+ {
+ return registerServiceInternal(bundle, new String[] {clazz}, service, properties);
+ }
+
+ public ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary<String, Object> properties)
+ {
+ return registerServiceInternal(bundle, clazzes, service, properties);
+ }
+
+ public void unregisterService(ServiceRegistration registration)
+ {
+ ServiceReference sref = registration.getReference();
+ String[] clazzes = (String[])sref.getProperty(Constants.OBJECTCLASS);
+ for (String clazz : clazzes)
+ {
+ List<ServiceReference> srefs = registry.get(clazz);
+ if (srefs != null)
+ {
+ Iterator<ServiceReference> itRefs = srefs.iterator();
+ while (itRefs.hasNext())
+ {
+ ServiceReference next = itRefs.next();
+ if (sref == next)
+ itRefs.remove();
+ }
+ }
+ }
+ }
+
+ public ServiceReference getServiceReference(String clazz)
+ {
+ ServiceReference srefBest = null;
+
+ List<ServiceReference> srefs = registry.get(clazz);
+ if (srefs != null && srefs.size() > 0)
+ {
+ // If multiple such services exist, the service with the highest ranking is returned.
+ // If there is a tie in ranking, the service with the lowest service ID (i.e. the service that was registered first) is returned.
+ for (ServiceReference sref : srefs)
+ {
+ if (srefBest != null)
+ {
+ Integer bestRanking = (Integer)srefBest.getProperty(Constants.SERVICE_RANKING);
+ Long bestId = (Long)srefBest.getProperty(Constants.SERVICE_ID);
+
+ Integer thisRanking = (Integer)sref.getProperty(Constants.SERVICE_RANKING);
+ Long thisId = (Long)sref.getProperty(Constants.SERVICE_ID);
+ if (thisRanking != null)
+ {
+ if (bestRanking == null)
+ bestRanking = new Integer(0);
+
+ if (bestRanking < thisRanking)
+ srefBest = sref;
+
+ if (bestRanking.equals(thisRanking) && bestId < thisId)
+ srefBest = sref;
+ }
+ }
+
+ if (srefBest == null)
+ srefBest = sref;
+ }
+ }
+
+ return srefBest;
+ }
+
+ public ServiceReference[] getServiceReferences(String clazz, String filterStr) throws InvalidSyntaxException
+ {
+ Set<ServiceReference> resultRefs = new LinkedHashSet<ServiceReference>();
+
+ // If the specified class name, clazz, is not null, the service must have been registered with the specified class name.
+ if (clazz != null)
+ {
+ List<ServiceReference> srefs = registry.get(clazz);
+ if (srefs != null)
+ resultRefs.addAll(srefs);
+ }
+
+ // null for all services
+ if (clazz == null)
+ {
+ for (String auxclazz : registry.keySet())
+ {
+ List<ServiceReference> srefs = registry.get(auxclazz);
+ if (srefs != null)
+ resultRefs.addAll(srefs);
+ }
+ }
+
+ // If the specified filter is not null, the filter expression must match the service.
+ if (filterStr != null)
+ {
+ Filter filter = FrameworkUtil.createFilter(filterStr);
+ Iterator<ServiceReference> itref = resultRefs.iterator();
+ while (itref.hasNext())
+ {
+ ServiceReference sref = itref.next();
+ if (filter.match(sref) == false)
+ itref.remove();
+ }
+ }
+
+ // [TODO] If the Java Runtime Environment supports permissions, the caller must have ServicePermission with the GET action for at least one of the class names under which the service was registered.
+
+ // [TODO] For each class name with which the service was registered, calling ServiceReference.isAssignableTo(Bundle, String) with the context bundle and the class name on the service's ServiceReference object must return true
+
+ // Return null if no services are registered which satisfy the search
+ if (resultRefs.size() == 0)
+ return null;
+
+ ServiceReference[] srefArr = new ServiceReference[resultRefs.size()];
+ return resultRefs.toArray(srefArr);
+ }
+
+ public Object getService(Bundle bundle, ServiceReference sref)
+ {
+ ServiceReferenceImpl srefImpl = (ServiceReferenceImpl)sref;
+
+ // If the service has been unregistered, null is returned.
+ if (srefImpl.isUnregistered())
+ return null;
+
+ // The context bundle's use count for this service is incremented by one.
+ srefImpl.incrementUseCount(bundle);
+
+ // The service was registered with an object implementing the ServiceFactory interface
+ Object service = srefImpl.getService();
+ if (service instanceof ServiceFactory)
+ {
+ if (srefImpl.getUseCount(bundle) == 1)
+ {
+ ServiceFactory factory = (ServiceFactory)service;
+ service = factory.getService(bundle, srefImpl.getServiceRegistration());
+ srefImpl.setCachedService(bundle, service);
+ }
+ else
+ {
+ service = srefImpl.getCachedService(bundle);
+ }
+ }
+
+ // The service object for the service is returned.
+ return service;
+ }
+
+ public boolean ungetService(Bundle bundle, ServiceReference sref)
+ {
+ ServiceReferenceImpl srefImpl = (ServiceReferenceImpl)sref;
+
+ // 1. If the context bundle's use count for the service is zero or the service has been unregistered, false is returned.
+ if (srefImpl.getUseCount(bundle) == 0 || srefImpl.isUnregistered())
+ return false;
+
+ // 2. The context bundle's use count for this service is decremented by one.
+ srefImpl.decrementUseCount(bundle);
+
+ // 3. If the context bundle's use count for the service is currently zero and the service was registered with a ServiceFactory object,
+ // the ServiceFactory.ungetService(Bundle, ServiceRegistration, Object) method is called to release the service object for the context bundle.
+ Object service = srefImpl.getService();
+ if (srefImpl.getUseCount(bundle) == 0 && service instanceof ServiceFactory)
+ {
+ ServiceFactory factory = (ServiceFactory)service;
+ service = srefImpl.getCachedService(bundle);
+ factory.ungetService(bundle, srefImpl.getServiceRegistration(), service);
+ srefImpl.setCachedService(bundle, null);
+ }
+
+ // 4. true is returned.
+ return true;
+ }
+
+ private ServiceRegistration registerServiceInternal(Bundle bundle, String[] clazzes, Object service, Dictionary<String, Object> props)
+ {
+ // If service is not a ServiceFactory, an IllegalArgumentException is thrown if service
+ // is not an instanceof all the specified class names.
+ if ((service instanceof ServiceFactory) == false)
+ {
+ for (String clazz : clazzes)
+ {
+ try
+ {
+ Class<?> interf = bundle.loadClass(clazz);
+ if (interf.isAssignableFrom(service.getClass()) == false)
+ throw new IllegalArgumentException("Service is not assignable to: " + clazz);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ throw new IllegalArgumentException("Cannot load service interface: " + clazz, ex);
+ }
+ }
+ }
+
+ // 2. The Framework adds the following service properties to the service properties from the specified Dictionary (which may be null):
+ // A property named Constants.SERVICE_ID identifying the registration number of the service
+ // A property named Constants.OBJECTCLASS containing all the specified classes.
+ Dictionary<String, Object> properties = new Hashtable<String, Object>();
+ properties.put(Constants.SERVICE_ID, new Long(serviceId++));
+ properties.put(Constants.OBJECTCLASS, clazzes);
+
+ if (props != null)
+ {
+ Enumeration<String> keys = props.keys();
+ while(keys.hasMoreElements())
+ {
+ String key = keys.nextElement();
+ Object value = props.get(key);
+ properties.put(key, value);
+ }
+ }
+
+ // 3. The service is added to the Framework service registry and may now be used by other bundles.
+ ServiceReferenceImpl sref = new ServiceReferenceImpl(bundle, service, properties);
+ for (String clazz : clazzes)
+ {
+ List<ServiceReference> list = registry.get(clazz);
+ if (list == null)
+ {
+ list = new ArrayList<ServiceReference>();
+ registry.put(clazz, list);
+ }
+ list.add(sref);
+ }
+
+ // 4. A service event of type ServiceEvent.REGISTERED is fired.
+ ServiceEventsPlugin eventManager = getPlugin(ServiceEventsPlugin.class);
+ eventManager.fireServiceEvent(new ServiceEvent(ServiceEvent.REGISTERED, sref));
+
+ // 5. A ServiceRegistration object for this registration is returned.
+ return new ServiceRegistrationImpl(this, sref);
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml 2009-08-20 06:58:39 UTC (rev 92603)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml 2009-08-20 08:40:11 UTC (rev 92604)
@@ -15,7 +15,7 @@
-->
<!-- The FrameworkBootstrap -->
- <bean name="jboss.osgi:service=FrameworkBootstrap" class="org.jboss.osgi.jbossmc.framework.FrameworkBootstrapImpl">
+ <bean name="jboss.osgi:service=FrameworkFactory" class="org.jboss.osgi.jbossmc.framework.FrameworkFactoryBean">
<property name="properties">
<map keyClass="java.lang.String" valueClass="java.lang.String">
<entry><key>org.osgi.framework.storage</key><value>${log4j.output.dir}/osgi-store</value></entry>
16 years, 11 months
JBoss-OSGI SVN: r92586 - in projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc: framework and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-19 16:15:29 -0400 (Wed, 19 Aug 2009)
New Revision: 92586
Modified:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
Log:
Prepare MC Framework configuration
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java 2009-08-19 19:56:30 UTC (rev 92585)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java 2009-08-19 20:15:29 UTC (rev 92586)
@@ -26,12 +26,14 @@
import org.osgi.framework.launch.Framework;
/**
- * An impementation of an OSGi Framework
+ * An abstration of a bootstrap bean that can provide an OSGi Framework.
*
* @author thomas.diesler(a)jboss.com
* @since 29-Jul-2009
*/
public interface FrameworkBootstrap
{
+ public static final String BEAN_FRAMEWORK_BOOTSTRAP = "jboss.osgi:service=FrameworkBootstrap";
+
Framework getFramework();
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java 2009-08-19 19:56:30 UTC (rev 92585)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java 2009-08-19 20:15:29 UTC (rev 92586)
@@ -28,11 +28,19 @@
import java.util.Map;
import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleEventManager;
+import org.jboss.osgi.jbossmc.api.BundleFactory;
+import org.jboss.osgi.jbossmc.api.BundlePersistentStorage;
+import org.jboss.osgi.jbossmc.api.BundleRegistry;
+import org.jboss.osgi.jbossmc.api.BundleResolver;
import org.jboss.osgi.jbossmc.api.FrameworkBootstrap;
+import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
+import org.jboss.osgi.jbossmc.api.ServiceEventManager;
+import org.jboss.osgi.jbossmc.api.ServiceRegistry;
import org.osgi.framework.launch.Framework;
/**
- * An impementation of an OSGi Framework
+ * An implementation of a bootstrap bean that can provide an OSGi Framework.
*
* @author thomas.diesler(a)jboss.com
* @since 29-Jul-2009
@@ -47,6 +55,15 @@
private List<URL> autoStart;
private Framework framework;
+ private BundleRegistry bundleRegistry;
+ private BundleFactory bundleFactory;
+ private BundleResolver bundleResolver;
+ private BundleEventManager bundleEventManager;
+ private BundlePersistentStorage bundlePersistentStorage;
+ private FrameworkEventManager frameworkEventManager;
+ private ServiceEventManager serviceEventManager;
+ private ServiceRegistry serviceRegistry;
+
public void setProperties(Map<String, Object> properties)
{
this.properties = properties;
@@ -62,11 +79,60 @@
this.autoStart = autoStart;
}
+ public void setBundleRegistry(BundleRegistry bundleRegistry)
+ {
+ this.bundleRegistry = bundleRegistry;
+ }
+
+ public void setBundleFactory(BundleFactory bundleFactory)
+ {
+ this.bundleFactory = bundleFactory;
+ }
+
+ public void setBundleResolver(BundleResolver bundleResolver)
+ {
+ this.bundleResolver = bundleResolver;
+ }
+
+ public void setBundleEventManager(BundleEventManager bundleEventManager)
+ {
+ this.bundleEventManager = bundleEventManager;
+ }
+
+ public void setBundlePersistentStorage(BundlePersistentStorage bundlePersistentStorage)
+ {
+ this.bundlePersistentStorage = bundlePersistentStorage;
+ }
+
+ public void setServiceEventManager(ServiceEventManager serviceEventManager)
+ {
+ this.serviceEventManager = serviceEventManager;
+ }
+
+ public void setServiceRegistry(ServiceRegistry serviceRegistry)
+ {
+ this.serviceRegistry = serviceRegistry;
+ }
+
+ public void setFrameworkEventManager(FrameworkEventManager frameworkEventManager)
+ {
+ this.frameworkEventManager = frameworkEventManager;
+ }
+
public Framework getFramework()
{
if (framework == null)
{
- framework = new FrameworkImpl(properties);
+ FrameworkImpl frameworkImpl = new FrameworkImpl(properties);
+ frameworkImpl.setBundleFactory(bundleFactory);
+ frameworkImpl.setBundleResolver(bundleResolver);
+ frameworkImpl.setBundleRegistry(bundleRegistry);
+ frameworkImpl.setBundlePersistentStorage(bundlePersistentStorage);
+ frameworkImpl.setServiceRegistry(serviceRegistry);
+ frameworkImpl.setBundleEventManager(bundleEventManager);
+ frameworkImpl.setFrameworkEventManager(frameworkEventManager);
+ frameworkImpl.setServiceEventManager(serviceEventManager);
+ framework = frameworkImpl;
}
return framework;
}
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java 2009-08-19 19:56:30 UTC (rev 92585)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java 2009-08-19 20:15:29 UTC (rev 92586)
@@ -44,7 +44,6 @@
*/
public class FrameworkFactoryImpl implements FrameworkFactory
{
- private static final String BEAN_FRAMEWORK_BOOTSTRAP = "jboss.osgi:service=FrameworkBootstrap";
// Provide logging
final Logger log = Logger.getLogger(FrameworkFactoryImpl.class);
@@ -70,9 +69,9 @@
throw new IllegalStateException("Cannot bootstrap MC server", ex);
}
- ControllerContext context = server.getKernel().getController().getInstalledContext(BEAN_FRAMEWORK_BOOTSTRAP);
+ ControllerContext context = server.getKernel().getController().getInstalledContext(FrameworkBootstrap.BEAN_FRAMEWORK_BOOTSTRAP);
if (context == null)
- throw new IllegalStateException("Cannot obtain: " + BEAN_FRAMEWORK_BOOTSTRAP);
+ throw new IllegalStateException("Cannot obtain: " + FrameworkBootstrap.BEAN_FRAMEWORK_BOOTSTRAP);
FrameworkBootstrap frameworkBootstrap = (FrameworkBootstrap)context.getTarget();
return frameworkBootstrap.getFramework();
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-19 19:56:30 UTC (rev 92585)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-19 20:15:29 UTC (rev 92586)
@@ -75,6 +75,81 @@
properties.putAll(props);
}
+ public BundleRegistry getBundleRegistry()
+ {
+ return bundleRegistry;
+ }
+
+ public void setBundleRegistry(BundleRegistry bundleRegistry)
+ {
+ this.bundleRegistry = bundleRegistry;
+ }
+
+ public BundleFactory getBundleFactory()
+ {
+ return bundleFactory;
+ }
+
+ public void setBundleFactory(BundleFactory bundleFactory)
+ {
+ this.bundleFactory = bundleFactory;
+ }
+
+ public BundleResolver getBundleResolver()
+ {
+ return bundleResolver;
+ }
+
+ public void setBundleResolver(BundleResolver bundleResolver)
+ {
+ this.bundleResolver = bundleResolver;
+ }
+
+ public BundleEventManager getBundleEventManager()
+ {
+ return bundleEventManager;
+ }
+
+ public void setBundleEventManager(BundleEventManager bundleEventManager)
+ {
+ this.bundleEventManager = bundleEventManager;
+ }
+
+ public BundlePersistentStorage getBundlePersistentStorage()
+ {
+ return bundlePersistentStorage;
+ }
+
+ public void setBundlePersistentStorage(BundlePersistentStorage bundlePersistentStorage)
+ {
+ this.bundlePersistentStorage = bundlePersistentStorage;
+ }
+
+ public ServiceEventManager getServiceEventManager()
+ {
+ return serviceEventManager;
+ }
+
+ public void setServiceEventManager(ServiceEventManager serviceEventManager)
+ {
+ this.serviceEventManager = serviceEventManager;
+ }
+
+ public ServiceRegistry getServiceRegistry()
+ {
+ return serviceRegistry;
+ }
+
+ public void setServiceRegistry(ServiceRegistry serviceRegistry)
+ {
+ this.serviceRegistry = serviceRegistry;
+ }
+
+ public void setFrameworkEventManager(FrameworkEventManager frameworkEventManager)
+ {
+ this.frameworkEventManager = frameworkEventManager;
+ }
+
/**
* Returns the Framework unique identifier. This Framework is assigned the unique identifier zero (0) since this Framework is also a System Bundle.
*/
@@ -308,41 +383,6 @@
return new FrameworkEvent(FrameworkEvent.STOPPED, this, null);
}
- public BundleFactory getBundleFactory()
- {
- return bundleFactory;
- }
-
- public BundleRegistry getBundleRegistry()
- {
- return bundleRegistry;
- }
-
- public BundleResolver getBundleResolver()
- {
- return bundleResolver;
- }
-
- public BundlePersistentStorage getBundlePersistentStorage()
- {
- return bundlePersistentStorage;
- }
-
- public ServiceRegistry getServiceRegistry()
- {
- return serviceRegistry;
- }
-
- public BundleEventManager getBundleEventManager()
- {
- return bundleEventManager;
- }
-
- public ServiceEventManager getServiceEventManager()
- {
- return serviceEventManager;
- }
-
public FrameworkEventManager getFrameworkEventManager()
{
return frameworkEventManager;
16 years, 11 months
JBoss-OSGI SVN: r92585 - in projects/jboss-osgi/trunk/reactor/runtime/jbossmc: src/main/java/org/jboss/osgi/jbossmc/api and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-19 15:56:30 -0400 (Wed, 19 Aug 2009)
New Revision: 92585
Added:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/bootstrap.xml
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml
Removed:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/jboss-osgi-jbossmc.properties
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/tst.policy
Modified:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/pom.xml
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java
Log:
Use jboss-bootstrap in the FrameworkFactory
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/pom.xml 2009-08-19 19:11:16 UTC (rev 92584)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/pom.xml 2009-08-19 19:56:30 UTC (rev 92585)
@@ -31,6 +31,7 @@
<properties>
<version.jboss.osgi.spi>1.0.1-SNAPSHOT</version.jboss.osgi.spi>
+ <version.jboss.bootsrap>2.0.0-alpha-2</version.jboss.bootsrap>
<version.osgi>r4v42-20090728</version.osgi>
</properties>
@@ -41,6 +42,11 @@
<artifactId>bnd</artifactId>
</dependency>
<dependency>
+ <groupId>org.jboss.bootstrap</groupId>
+ <artifactId>jboss-bootstrap-impl-mc</artifactId>
+ <version>${version.jboss.bootsrap}</version>
+ </dependency>
+ <dependency>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-spi</artifactId>
<version>${version.jboss.osgi.spi}</version>
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java 2009-08-19 19:56:30 UTC (rev 92585)
@@ -0,0 +1,37 @@
+/*
+ * 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.jbossmc.api;
+
+//$Id$
+
+import org.osgi.framework.launch.Framework;
+
+/**
+ * An impementation of an OSGi Framework
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 29-Jul-2009
+ */
+public interface FrameworkBootstrap
+{
+ Framework getFramework();
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkBootstrap.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java 2009-08-19 19:56:30 UTC (rev 92585)
@@ -0,0 +1,73 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id$
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.FrameworkBootstrap;
+import org.osgi.framework.launch.Framework;
+
+/**
+ * An impementation of an OSGi Framework
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 29-Jul-2009
+ */
+public class FrameworkBootstrapImpl implements FrameworkBootstrap
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(FrameworkBootstrapImpl.class);
+
+ private Map<String, Object> properties;
+ private List<URL> autoInstall;
+ private List<URL> autoStart;
+ private Framework framework;
+
+ public void setProperties(Map<String, Object> properties)
+ {
+ this.properties = properties;
+ }
+
+ public void setAutoInstall(List<URL> autoInstall)
+ {
+ this.autoInstall = autoInstall;
+ }
+
+ public void setAutoStart(List<URL> autoStart)
+ {
+ this.autoStart = autoStart;
+ }
+
+ public Framework getFramework()
+ {
+ if (framework == null)
+ {
+ framework = new FrameworkImpl(properties);
+ }
+ return framework;
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkBootstrapImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java 2009-08-19 19:11:16 UTC (rev 92584)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java 2009-08-19 19:56:30 UTC (rev 92585)
@@ -23,9 +23,16 @@
//$Id$
+import java.net.URL;
import java.util.Map;
+import org.jboss.bootstrap.impl.mc.config.BasicMCServerConfig;
+import org.jboss.bootstrap.impl.mc.server.MCServerImpl;
+import org.jboss.bootstrap.spi.mc.config.MCServerConfig;
+import org.jboss.bootstrap.spi.mc.server.MCServer;
+import org.jboss.dependency.spi.ControllerContext;
import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.FrameworkBootstrap;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
@@ -37,12 +44,55 @@
*/
public class FrameworkFactoryImpl implements FrameworkFactory
{
+ private static final String BEAN_FRAMEWORK_BOOTSTRAP = "jboss.osgi:service=FrameworkBootstrap";
// Provide logging
final Logger log = Logger.getLogger(FrameworkFactoryImpl.class);
@SuppressWarnings("unchecked")
public Framework newFramework(Map configuration)
{
- return new FrameworkImpl(configuration);
+ // Create a configuration
+ MCServerConfig config = new BasicMCServerConfig();
+ config.bootstrapHome(getBootstrapHome());
+
+ // Create the server
+ final MCServer server = new MCServerImpl(config);
+ try
+ {
+ server.start();
+ }
+ catch (RuntimeException rte)
+ {
+ throw rte;
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot bootstrap MC server", ex);
+ }
+
+ ControllerContext context = server.getKernel().getController().getInstalledContext(BEAN_FRAMEWORK_BOOTSTRAP);
+ if (context == null)
+ throw new IllegalStateException("Cannot obtain: " + BEAN_FRAMEWORK_BOOTSTRAP);
+
+ FrameworkBootstrap frameworkBootstrap = (FrameworkBootstrap)context.getTarget();
+ return frameworkBootstrap.getFramework();
}
+
+ private String getBootstrapHome()
+ {
+ String bootstrapHome = null;
+ URL homeUrl = getBootstrapUrl();
+ if (homeUrl != null)
+ {
+ String path = homeUrl.toExternalForm();
+ bootstrapHome = path.substring(0, path.lastIndexOf('/'));
+ }
+ return bootstrapHome;
+ }
+
+ private URL getBootstrapUrl()
+ {
+ ClassLoader cl = getClass().getClassLoader();
+ return cl.getResource("META-INF/bootstrap.xml");
+ }
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/bootstrap.xml (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/bootstrap.xml 2009-08-19 19:56:30 UTC (rev 92585)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<bootstrap xmlns="urn:jboss:bootstrap:1.0">
+
+ <url>jboss-osgi-framework.xml</url>
+
+</bootstrap>
Property changes on: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/bootstrap.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml 2009-08-19 19:56:30 UTC (rev 92585)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ $Id$
+-->
+
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!--
+ ********************************
+ * *
+ * Framework *
+ * *
+ ********************************
+ -->
+
+ <!-- The FrameworkBootstrap -->
+ <bean name="jboss.osgi:service=FrameworkBootstrap" class="org.jboss.osgi.jbossmc.framework.FrameworkBootstrapImpl">
+ <property name="properties">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry><key>org.osgi.framework.storage</key><value>${log4j.output.dir}/osgi-store</value></entry>
+ <entry><key>org.osgi.framework.storage.clean</key><value>onFirstInit</value></entry>
+ </map>
+ </property>
+ <property name="autoInstall">
+ <list elementClass="java.net.URL">
+ </list>
+ </property>
+ <property name="autoStart">
+ <list elementClass="java.net.URL">
+ </list>
+ </property>
+ </bean>
+
+</deployment>
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/resources/META-INF/jboss-osgi-framework.xml
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/jboss-osgi-jbossmc.properties
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/jboss-osgi-jbossmc.properties 2009-08-19 19:11:16 UTC (rev 92584)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/jboss-osgi-jbossmc.properties 2009-08-19 19:56:30 UTC (rev 92585)
@@ -1,22 +0,0 @@
-#
-# Properties read by the org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
-#
-# $Id: jboss-osgi-felix.properties 92430 2009-08-17 14:53:52Z thomas.diesler(a)jboss.com $
-#
-
-# Properties to configure the Framework
-org.osgi.framework.storage=${basedir}/target/osgi-store
-org.osgi.framework.storage.clean=onFirstInit
-
-# Extra System Packages
-org.osgi.framework.system.packages.extra=
-
-# Bundles that need to be installed with the Framework automatically
-org.jboss.osgi.spi.framework.autoInstall=\
- file://${test.archive.directory}/bundles/org.osgi.compendium.jar
-
-
-# Bundles that need to be started automatically
-org.jboss.osgi.spi.framework.autoStart=\
- file://${test.archive.directory}/bundles/org.apache.felix.log.jar \
- file://${test.archive.directory}/bundles/jboss-osgi-common.jar
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider 2009-08-19 19:11:16 UTC (rev 92584)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/org.jboss.osgi.spi.framework.OSGiBootstrapProvider 2009-08-19 19:56:30 UTC (rev 92585)
@@ -1 +0,0 @@
-org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
\ No newline at end of file
Deleted: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/tst.policy
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/tst.policy 2009-08-19 19:11:16 UTC (rev 92584)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/resources/tst.policy 2009-08-19 19:56:30 UTC (rev 92585)
@@ -1,4 +0,0 @@
-grant {
- permission java.security.AllPermission;
-};
-
16 years, 11 months
JBoss-OSGI SVN: r92578 - in projects/jboss-osgi: trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api and 5 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-19 10:33:04 -0400 (Wed, 19 Aug 2009)
New Revision: 92578
Added:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ConstantsHelper.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleEntriesTestCase.java
Removed:
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/OSGiConstantsHelper.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/log/
Modified:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/EndpointServlet.java
Log:
All examples good when run one-by-one. Cleanup issue.
Copied: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ConstantsHelper.java (from rev 92562, projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/OSGiConstantsHelper.java)
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ConstantsHelper.java (rev 0)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/ConstantsHelper.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -0,0 +1,159 @@
+/*
+ * 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.util;
+
+//$Id$
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.ServiceEvent;
+
+/**
+ * String representation for common OSGi Constants
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 04-Mar-2009
+ */
+public abstract class ConstantsHelper
+{
+ /**
+ * Return the string representation of a {@link Bundle} state
+ */
+ public static String bundleState(int bundleState)
+ {
+ String retState = "[" + bundleState + "]";
+ if (Bundle.UNINSTALLED == bundleState)
+ retState = "UNINSTALLED";
+ else if (Bundle.INSTALLED == bundleState)
+ retState = "INSTALLED";
+ else if (Bundle.RESOLVED == bundleState)
+ retState = "RESOLVED";
+ else if (Bundle.STARTING == bundleState)
+ retState = "STARTING";
+ else if (Bundle.STOPPING == bundleState)
+ retState = "STOPPING";
+ else if (Bundle.ACTIVE == bundleState)
+ retState = "ACTIVE";
+ return retState;
+ }
+
+ /**
+ * Return the string representation of a {@link BundleEvent} type
+ */
+ public static String bundleEvent(int eventType)
+ {
+ String retType = "[" + eventType + "]";
+ if (BundleEvent.INSTALLED == eventType)
+ retType = "INSTALLED";
+ else if (BundleEvent.LAZY_ACTIVATION == eventType)
+ retType = "LAZY_ACTIVATION";
+ else if (BundleEvent.RESOLVED == eventType)
+ retType = "RESOLVED";
+ else if (BundleEvent.STARTING == eventType)
+ retType = "STARTING";
+ else if (BundleEvent.STARTED == eventType)
+ retType = "STARTED";
+ else if (BundleEvent.STOPPING == eventType)
+ retType = "STOPPING";
+ else if (BundleEvent.STOPPED == eventType)
+ retType = "STOPPED";
+ else if (BundleEvent.UNINSTALLED == eventType)
+ retType = "UNINSTALLED";
+ else if (BundleEvent.UNRESOLVED == eventType)
+ retType = "UNRESOLVED";
+ else if (BundleEvent.UPDATED == eventType)
+ retType = "UPDATED";
+ return retType;
+ }
+
+ /**
+ * Return the string representation of a {@link ServiceEvent} type
+ */
+ public static String serviceEvent(int eventType)
+ {
+ String retType = "[" + eventType + "]";
+ if (ServiceEvent.REGISTERED == eventType)
+ retType = "REGISTERED";
+ else if (ServiceEvent.UNREGISTERING == eventType)
+ retType = "UNREGISTERING";
+ else if (ServiceEvent.MODIFIED == eventType)
+ retType = "MODIFIED";
+ else if (ServiceEvent.MODIFIED_ENDMATCH == eventType)
+ retType = "MODIFIED_ENDMATCH";
+ return retType;
+ }
+
+ public static String frameworkEvent(int eventType)
+ {
+ String retType = "[" + eventType + "]";
+ if (FrameworkEvent.ERROR == eventType)
+ retType = "ERROR";
+ else if (FrameworkEvent.INFO == eventType)
+ retType = "INFO";
+ else if (FrameworkEvent.PACKAGES_REFRESHED == eventType)
+ retType = "PACKAGES_REFRESHED";
+ else if (FrameworkEvent.STARTED == eventType)
+ retType = "STARTED";
+ else if (FrameworkEvent.STARTLEVEL_CHANGED == eventType)
+ retType = "STARTLEVEL_CHANGED";
+ else if (FrameworkEvent.STOPPED == eventType)
+ retType = "STOPPED";
+ else if (FrameworkEvent.STOPPED_BOOTCLASSPATH_MODIFIED == eventType)
+ retType = "STOPPED_BOOTCLASSPATH_MODIFIED";
+ else if (FrameworkEvent.STOPPED_UPDATE == eventType)
+ retType = "STOPPED_UPDATE";
+ else if (FrameworkEvent.WAIT_TIMEDOUT == eventType)
+ retType = "WAIT_TIMEDOUT";
+ else if (FrameworkEvent.WARNING == eventType)
+ retType = "WARNING";
+ return retType;
+ }
+
+ /**
+ * Return the string representation of a LogService level
+ */
+ public static String logLevel(int level)
+ {
+ String logLevel = "[" + level + "]";
+ switch (level)
+ {
+ // LogService.LOG_DEBUG:
+ case 0x4:
+ logLevel = "DEBUG";
+ break;
+ // LogService.LOG_INFO:
+ case 0x3:
+ logLevel = "INFO";
+ break;
+ // LogService.LOG_WARNING:
+ case 0x2:
+ logLevel = "WARN";
+ break;
+ // LogService.LOG_ERROR
+ case 0x1:
+ logLevel = "ERROR";
+ break;
+ }
+ return logLevel;
+ }
+}
Deleted: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/OSGiConstantsHelper.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/OSGiConstantsHelper.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/OSGiConstantsHelper.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -1,114 +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.util;
-
-//$Id$
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleEvent;
-
-/**
- * String representation for common OSGi Constants
- *
- * @author thomas.diesler(a)jboss.com
- * @since 04-Mar-2009
- */
-public abstract class OSGiConstantsHelper
-{
- /**
- * Return the string representation of a {@link Bundle} state
- */
- public static String bundleState(int bundleState)
- {
- String retState = "[" + bundleState + "]";
- if (Bundle.UNINSTALLED == bundleState)
- retState = "UNINSTALLED";
- else if (Bundle.INSTALLED == bundleState)
- retState = "INSTALLED";
- else if (Bundle.RESOLVED == bundleState)
- retState = "RESOLVED";
- else if (Bundle.STARTING == bundleState)
- retState = "STARTING";
- else if (Bundle.STOPPING == bundleState)
- retState = "STOPPING";
- else if (Bundle.ACTIVE == bundleState)
- retState = "ACTIVE";
- return retState;
- }
-
- /**
- * Return the string representation of a {@link BundleEvent} type
- */
- public static String bundleEvent(int eventType)
- {
- String retType = "[" + eventType + "]";
- if (BundleEvent.INSTALLED == eventType)
- retType = "INSTALLED";
- else if (BundleEvent.LAZY_ACTIVATION == eventType)
- retType = "LAZY_ACTIVATION";
- else if (BundleEvent.RESOLVED == eventType)
- retType = "RESOLVED";
- else if (BundleEvent.STARTING == eventType)
- retType = "STARTING";
- else if (BundleEvent.STARTED == eventType)
- retType = "STARTED";
- else if (BundleEvent.STOPPING == eventType)
- retType = "STOPPING";
- else if (BundleEvent.STOPPED == eventType)
- retType = "STOPPED";
- else if (BundleEvent.UNINSTALLED == eventType)
- retType = "UNINSTALLED";
- else if (BundleEvent.UNRESOLVED == eventType)
- retType = "UNRESOLVED";
- else if (BundleEvent.UPDATED == eventType)
- retType = "UPDATED";
- return retType;
- }
-
- /**
- * Return the string representation of a LogService level
- */
- public static String logLevel(int level)
- {
- String logLevel = "[" + level + "]";
- switch (level)
- {
- // LogService.LOG_DEBUG:
- case 0x4:
- logLevel = "DEBUG";
- break;
- // LogService.LOG_INFO:
- case 0x3:
- logLevel = "INFO";
- break;
- // LogService.LOG_WARNING:
- case 0x2:
- logLevel = "WARN";
- break;
- // LogService.LOG_ERROR
- case 0x1:
- logLevel = "ERROR";
- break;
- }
- return logLevel;
- }
-}
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -25,7 +25,7 @@
import java.net.URL;
import java.util.Enumeration;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+// $Id: $
/**
* An abstraction of a bundle class loader.
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -24,7 +24,7 @@
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
/**
* An abstraction of a bundle event manager.
@@ -39,4 +39,6 @@
void addBundleListener(BundleListener listener);
void removeBundleListener(BundleListener listener);
+
+ void setEnabled(boolean enabled);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleFactory.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,11 +21,11 @@
*/
package org.jboss.osgi.jbossmc.api;
+// $Id: $
+
+import org.jboss.virtual.VirtualFile;
import org.osgi.framework.Bundle;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
-
-
/**
* An abstraction of a bundle factory.
*
@@ -34,5 +34,9 @@
*/
public interface BundleFactory
{
+ String getVirtualLocation(String location);
+
+ VirtualFile getVirtualFile(String location);
+
Bundle createBundle(String location);
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundlePersistentStorage.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -0,0 +1,39 @@
+/*
+ * 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.jbossmc.api;
+
+// $Id: $
+
+import java.io.File;
+
+import org.osgi.framework.Bundle;
+
+/**
+ * An abstraction of a bundle persistent storage system.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public interface BundlePersistentStorage
+{
+ File getDataFile(Bundle bundle, String filename);
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,7 +21,7 @@
*/
package org.jboss.osgi.jbossmc.api;
-// $Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import java.util.List;
@@ -35,11 +35,13 @@
*/
public interface BundleRegistry
{
- long installBundle(Bundle bundle);
+ long registerBundle(Bundle bundle);
- void uninstallBundle(Bundle bundle);
+ void unregisterBundle(Bundle bundle);
Bundle getBundleById(long id);
+ Bundle getBundleByLocation(String location);
+
List<Bundle> getBundles();
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleResolver.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,12 +21,11 @@
*/
package org.jboss.osgi.jbossmc.api;
+// $Id: $
+
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
-
-
/**
* An abstraction of a bundle resolver.
*
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,7 +21,7 @@
*/
package org.jboss.osgi.jbossmc.api;
-// $Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
@@ -39,4 +39,6 @@
void addFrameworkListener(FrameworkListener listener);
void removeFrameworkListener(FrameworkListener listener);
+
+ void setEnabled(boolean enabled);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,11 +21,11 @@
*/
package org.jboss.osgi.jbossmc.api;
+// $Id: $
+
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
-
/**
* An abstraction of a service event manager.
*
@@ -41,4 +41,6 @@
void addServiceListener(ServiceListener listener, String filter);
void removeServiceListener(ServiceListener listener);
+
+ void setEnabled(boolean enabled);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceRegistry.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,11 +21,12 @@
*/
package org.jboss.osgi.jbossmc.api;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import java.util.Dictionary;
import org.osgi.framework.Bundle;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -37,13 +38,17 @@
*/
public interface ServiceRegistry
{
- ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary properties);
+ ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary<String, Object> properties);
- ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary properties);
+ ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary<String, Object> properties);
+ void unregisterService(ServiceRegistration registration);
+
ServiceReference getServiceReference(String clazz);
- ServiceReference[] getServiceReferences(String clazz, String filter);
+ ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException;
Object getService(Bundle bundle, ServiceReference sref);
+
+ boolean ungetService(Bundle bundle, ServiceReference reference);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,7 +21,7 @@
*/
package org.jboss.osgi.jbossmc.framework;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import java.io.IOException;
import java.net.URL;
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -25,12 +25,16 @@
import java.io.File;
import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Dictionary;
+import java.util.EventListener;
import java.util.List;
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.BundleEventManager;
import org.jboss.osgi.jbossmc.api.BundleFactory;
+import org.jboss.osgi.jbossmc.api.BundlePersistentStorage;
import org.jboss.osgi.jbossmc.api.BundleRegistry;
import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
import org.jboss.osgi.jbossmc.api.ServiceEventManager;
@@ -38,6 +42,7 @@
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
import org.osgi.framework.BundleListener;
import org.osgi.framework.Filter;
@@ -62,6 +67,10 @@
private FrameworkImpl framework;
private Bundle bundle;
+ private List<EventListener> registeredListeners = new ArrayList<EventListener>();
+ private List<ServiceRegistration> registeredServices = new ArrayList<ServiceRegistration>();
+ private List<ServiceReference> usedServices = new ArrayList<ServiceReference>();
+
public BundleContextImpl(FrameworkImpl framework, Bundle bundle)
{
this.framework = framework;
@@ -77,42 +86,49 @@
{
BundleEventManager eventManager = getFramework().getBundleEventManager();
eventManager.addBundleListener(listener);
+ registeredListeners.add(listener);
}
public void removeBundleListener(BundleListener listener)
{
BundleEventManager eventManager = getFramework().getBundleEventManager();
eventManager.removeBundleListener(listener);
+ registeredListeners.remove(listener);
}
public void addFrameworkListener(FrameworkListener listener)
{
FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
eventManager.addFrameworkListener(listener);
+ registeredListeners.add(listener);
}
public void removeFrameworkListener(FrameworkListener listener)
{
FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
eventManager.removeFrameworkListener(listener);
+ registeredListeners.remove(listener);
}
public void addServiceListener(ServiceListener listener)
{
ServiceEventManager eventManager = getFramework().getServiceEventManager();
eventManager.addServiceListener(listener);
+ registeredListeners.add(listener);
}
public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException
{
ServiceEventManager eventManager = getFramework().getServiceEventManager();
eventManager.addServiceListener(listener, filter);
+ registeredListeners.add(listener);
}
public void removeServiceListener(ServiceListener listener)
{
ServiceEventManager eventManager = getFramework().getServiceEventManager();
eventManager.removeServiceListener(listener);
+ registeredListeners.remove(listener);
}
public Filter createFilter(String filter) throws InvalidSyntaxException
@@ -141,13 +157,13 @@
public File getDataFile(String filename)
{
- // [TODO] BundleContext.getDataFile(String filename)
- throw new NotImplementedException();
+ BundlePersistentStorage bundleStorage = getFramework().getBundlePersistentStorage();
+ return bundleStorage.getDataFile(bundle, filename);
}
public String getProperty(String key)
{
- String property = getFramework().getProperty(key);
+ String property = (String)getFramework().getProperty(key);
if (property == null)
property = System.getProperty(key);
@@ -157,9 +173,20 @@
public Object getService(ServiceReference reference)
{
ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
- return serviceRegistry.getService(getBundle(), reference);
+ Object service = serviceRegistry.getService(bundle, reference);
+ if (service != null)
+ {
+ usedServices.add(reference);
+ }
+ return service;
}
+ public boolean ungetService(ServiceReference reference)
+ {
+ ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
+ return serviceRegistry.ungetService(bundle, reference);
+ }
+
public ServiceReference getServiceReference(String clazz)
{
ServiceRegistry serviceRegistry = getFramework().getServiceRegistry();
@@ -180,14 +207,30 @@
public Bundle installBundle(String location) throws BundleException
{
- // Create the bundle from the location
+ // Convert location to a virtual file URL
BundleFactory bundleFactory = getFramework().getBundleFactory();
- Bundle bundle = bundleFactory.createBundle(location);
+ location = bundleFactory.getVirtualLocation(location);
- // Register the bundle
+ // 1. If a bundle containing the same location identifier is already installed, the Bundle object for that bundle is returned.
BundleRegistry bundleRegistry = getFramework().getBundleRegistry();
- bundleRegistry.installBundle(bundle);
+ Bundle bundle = bundleRegistry.getBundleByLocation(location);
+ if (bundle != null)
+ return bundle;
+ // 2. The bundle's content is read from the input stream. If this fails, a BundleException is thrown.
+ // 3. The bundle's associated resources are allocated. The associated resources minimally consist of a unique identifier and a persistent storage area if the platform has file system support.
+ bundle = bundleFactory.createBundle(location);
+ bundleRegistry.registerBundle(bundle);
+
+ // 4. The bundle's state is set to INSTALLED.
+ BundleImpl bundleImpl = (BundleImpl)bundle;
+ bundleImpl.setState(Bundle.INSTALLED);
+
+ // 5. A bundle event of type BundleEvent.INSTALLED is fired.
+ BundleEventManager eventManager = getFramework().getBundleEventManager();
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.INSTALLED, bundle));
+
+ // 6. The Bundle object for the newly or previously installed bundle is returned.
return bundle;
}
@@ -197,21 +240,83 @@
throw new NotImplementedException();
}
+ @SuppressWarnings("unchecked")
public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties)
{
ServiceRegistry registry = getFramework().getServiceRegistry();
- return registry.registerService(getBundle(), clazzes, service, properties);
+ ServiceRegistration sreg = registry.registerService(bundle, clazzes, service, properties);
+ registeredServices.add(sreg);
+ return sreg;
}
+ @SuppressWarnings("unchecked")
public ServiceRegistration registerService(String clazz, Object service, Dictionary properties)
{
ServiceRegistry registry = getFramework().getServiceRegistry();
- return registry.registerService(getBundle(), clazz, service, properties);
+ ServiceRegistration sreg = registry.registerService(bundle, clazz, service, properties);
+ registeredServices.add(sreg);
+ return sreg;
}
- public boolean ungetService(ServiceReference reference)
+ public void releaseRegisteredListeners()
{
- // [TODO] BundleContext.ungetService
- throw new NotImplementedException();
+ ArrayList<EventListener> reverseList = new ArrayList<EventListener>(registeredListeners);
+ Collections.reverse(reverseList);
+
+ for (EventListener listener : reverseList)
+ {
+ try
+ {
+ if (listener instanceof FrameworkListener)
+ removeFrameworkListener((FrameworkListener)listener);
+ else if (listener instanceof ServiceListener)
+ removeServiceListener((ServiceListener)listener);
+ else if (listener instanceof BundleListener)
+ removeBundleListener((BundleListener)listener);
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot release registered listener", ex);
+ }
+ }
+ registeredListeners.clear();
}
+
+ public void releaseRegisteredServices()
+ {
+ ArrayList<ServiceRegistration> reverseList = new ArrayList<ServiceRegistration>(registeredServices);
+ Collections.reverse(reverseList);
+
+ for (ServiceRegistration sreg : reverseList)
+ {
+ try
+ {
+ sreg.unregister();
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot release registered service", ex);
+ }
+ }
+ registeredServices.clear();
+ }
+
+ public void releaseUsedServices()
+ {
+ ArrayList<ServiceReference> reverseList = new ArrayList<ServiceReference>(usedServices);
+ Collections.reverse(reverseList);
+
+ for (ServiceReference sref : reverseList)
+ {
+ try
+ {
+ ungetService(sref);
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot release used service", ex);
+ }
+ }
+ usedServices.clear();
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,13 +21,14 @@
*/
package org.jboss.osgi.jbossmc.framework;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import java.util.ArrayList;
import java.util.List;
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.BundleEventManager;
+import org.jboss.osgi.spi.util.ConstantsHelper;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleListener;
@@ -42,16 +43,32 @@
// Provide logging
final Logger log = Logger.getLogger(BundleEventManagerImpl.class);
- private FrameworkImpl framework;
private List<BundleListener> listeners = new ArrayList<BundleListener>();
+ private boolean enabled = true;
public BundleEventManagerImpl(FrameworkImpl framework)
{
- this.framework = framework;
+
}
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+
public void fireBundleEvent(BundleEvent event)
{
+ if (enabled == false)
+ return;
+
+ String typeStr = ConstantsHelper.bundleEvent(event.getType());
+ log.debug("BundleEvent " + typeStr + " " + event.getSource());
+
// [TODO] When a BundleEvent is fired, it is asynchronously delivered to a BundleListener
for (BundleListener listener : new ArrayList<BundleListener>(listeners))
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleFactoryImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,7 +21,7 @@
*/
package org.jboss.osgi.jbossmc.framework;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import java.io.IOException;
import java.net.URL;
@@ -52,6 +52,28 @@
public Bundle createBundle(String location)
{
+ VirtualFile vfsRoot = getVirtualFile(location);
+ BundleImpl bundle = new BundleImpl(vfsRoot);
+ bundle.setBundleContext(new BundleContextImpl(framework, bundle));
+ return bundle;
+ }
+
+ public String getVirtualLocation(String location)
+ {
+ try
+ {
+ VirtualFile vFile = getVirtualFile(location);
+ URL locationURL = vFile.toURL();
+ return locationURL.toExternalForm();
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot obtain virtual bundle location", ex);
+ }
+ }
+
+ public VirtualFile getVirtualFile(String location)
+ {
VirtualFile vfsRoot;
try
{
@@ -62,9 +84,6 @@
{
throw new IllegalArgumentException("Invalid bundle location URL: " + location);
}
-
- BundleImpl bundle = new BundleImpl(vfsRoot);
- bundle.setBundleContext(new BundleContextImpl(framework, bundle));
- return bundle;
+ return vfsRoot;
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -26,10 +26,13 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.security.cert.X509Certificate;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Hashtable;
+import java.util.List;
import java.util.Map;
+import java.util.Vector;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
@@ -40,11 +43,15 @@
import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
@@ -66,13 +73,13 @@
private Dictionary<String, String> headers;
private BundleLifecycle bundleLifecycle;
private BundleClassLoader classLoader;
- private String toStringValue;
-
+ private String toStringCache;
+
public BundleImpl()
{
// ctor used by the framework
// [TODO] remove when we have a VFS root for the framework
-
+
this.bundleLifecycle = new BundleLifecycleImpl(this);
}
@@ -183,23 +190,100 @@
public URL getEntry(String path)
{
- // [TODO] Bundle.getEntry(String path)
- throw new NotImplementedException();
+ assertNotUninstalled();
+
+ URL entryURL = null;
+ try
+ {
+ VirtualFile child = vFile.getChild(path);
+ if (child != null)
+ entryURL = child.toURL();
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ return entryURL;
}
- public Enumeration<URL> getEntryPaths(String path)
+ public Enumeration<String> getEntryPaths(String path)
{
- // [TODO] Bundle.getEntryPaths(String path)
- throw new NotImplementedException();
+ assertNotUninstalled();
+
+ Vector<String> paths = new Vector<String>();
+ try
+ {
+ VirtualFile child = vFile.getChild(path);
+ if (child != null)
+ {
+ for (VirtualFile vf : child.getChildrenRecursively())
+ {
+ String entry = vf.getPathName();
+ if (vf.isLeaf() == false)
+ entry = entry + "/";
+
+ paths.add(entry);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ return paths.size() > 0 ? paths.elements() : null;
}
- public Enumeration findEntries(String path, String filePattern, boolean recurse)
+ public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse)
{
- // [TODO] Bundle.findEntries(String path, String filePattern, boolean recurse)
- throw new NotImplementedException();
+ assertNotUninstalled();
+
+ // If null is specified, this is equivalent to "*" and matches all files.
+ if (filePattern == null)
+ filePattern = "*";
+
+ final Filter filter;
+ try
+ {
+ filter = FrameworkUtil.createFilter("(name=" + filePattern + ")");
+ }
+ catch (InvalidSyntaxException e)
+ {
+ throw new IllegalArgumentException("Cannot create filter from: " + filePattern);
+ }
+
+ final Hashtable<String, String> dictionary = new Hashtable<String, String>();
+ VirtualFileFilter vfFilter = new VirtualFileFilter()
+ {
+ public boolean accepts(VirtualFile file)
+ {
+ String name = file.getName();
+ dictionary.put("name", name);
+ boolean match = filter.match(dictionary);
+ return match;
+ }
+ };
+
+ Vector<URL> paths = new Vector<URL>();
+ try
+ {
+ VirtualFile child = vFile.getChild(path);
+ if (child != null)
+ {
+ List<VirtualFile> matchedFiles = (recurse ? child.getChildrenRecursively(vfFilter) : child.getChildren(vfFilter));
+ for (VirtualFile vf : matchedFiles)
+ {
+ paths.add(vf.toURL());
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ return paths.size() > 0 ? paths.elements() : null;
}
- public Dictionary getHeaders()
+ public Dictionary<String, String> getHeaders()
{
if (headers == null)
{
@@ -223,7 +307,7 @@
return headers;
}
- public Dictionary getHeaders(String locale)
+ public Dictionary<String, String> getHeaders(String locale)
{
// [TODO] Bundle.getHeaders(String locale)
throw new NotImplementedException();
@@ -257,7 +341,7 @@
return getClassLoader().getResources(name);
}
- public Map getSignerCertificates(int signersType)
+ public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType)
{
// [TODO] Bundle.getSignerCertificates(int signersType)
throw new NotImplementedException();
@@ -312,16 +396,34 @@
return contextImpl.getFramework();
}
+ private void assertNotUninstalled()
+ {
+ if (state == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already uninstalled: " + this);
+ }
+
@Override
+ public boolean equals(Object obj)
+ {
+ if (!(obj instanceof BundleImpl))
+ return false;
+
+ BundleImpl other = (BundleImpl)obj;
+ return other.getBundleId() == getBundleId();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return new Long(getBundleId()).hashCode();
+ }
+
+ @Override
public String toString()
{
- if (toStringValue == null)
- {
- long id = getBundleId();
- String name = getSymbolicName();
- Version version = getVersion();
- toStringValue = "[id=" + id + ",name=" + name + ",version=" + version + "]";
- }
- return toStringValue;
+ if (toStringCache == null || getBundleId() == 0)
+ toStringCache = "[" + getBundleId() + "] " + getSymbolicName() + "-" + getVersion();
+
+ return toStringCache;
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -59,20 +59,23 @@
{
// If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
if (getState() == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already uninstalled: " + this);
+ throw new IllegalStateException("Bundle already uninstalled: " + bundle);
// [TODO] Implement the optional Start Level service
// [TODO] If this bundle is in the process of being activated or deactivated then this method must wait
// for activation or deactivation to complete before continuing.
if (getState() == Bundle.STARTING || getState() == Bundle.STARTING)
- throw new IllegalStateException("Bundle already staring/stopping: " + this);
+ throw new IllegalStateException("Bundle already staring/stopping: " + bundle);
// If this bundle's state is not RESOLVED, an attempt is made to resolve this bundle.
if (getState() != Bundle.RESOLVED)
{
BundleResolver resolver = getFramework().getBundleResolver();
resolver.resolveBundle(bundle);
+
+ BundleEventManager eventManager = getFramework().getBundleEventManager();
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.RESOLVED, bundle));
}
// [TODO] Lazy bundle activation
@@ -101,11 +104,15 @@
// A bundle event of type BundleEvent.STOPPING is fired
eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, bundle));
- // [TODO] Any services registered by this bundle must be unregistered.
+ // Any services registered by this bundle must be unregistered.
+ BundleContextImpl contextImpl = (BundleContextImpl)bundle.getBundleContext();
+ contextImpl.releaseRegisteredServices();
- // [TODO] Any services used by this bundle must be released.
+ // Any services used by this bundle must be released.
+ contextImpl.releaseUsedServices();
- // [TODO] Any listeners registered by this bundle must be removed.
+ // Any listeners registered by this bundle must be removed.
+ contextImpl.releaseRegisteredListeners();
// This bundle's state is set to RESOLVED.
setState(Bundle.RESOLVED);
@@ -121,22 +128,20 @@
// If this bundle's state is UNINSTALLED, because this bundle was uninstalled while
// the BundleActivator.start was running
if (getState() == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already uninstalled: " + this);
+ throw new IllegalStateException("Bundle already uninstalled: " + bundle);
// This bundle's state is set to ACTIVE
setState(Bundle.ACTIVE);
// A bundle event of type BundleEvent.STARTED is fired
eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTED, bundle));
-
- log.debug("Bundle STARTED " + bundle);
}
public void stop(int options) throws BundleException
{
// 1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
if (getState() == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already unistalled: " + this);
+ throw new IllegalStateException("Bundle already unistalled: " + bundle);
// [TODO] 2. If this bundle is in the process of being activated or deactivated then this method must wait for activation or deactivation to complete
@@ -169,15 +174,19 @@
}
}
- // [TODO] 8. Any services registered by this bundle must be unregistered.
+ // 8. Any services registered by this bundle must be unregistered.
+ BundleContextImpl contextImpl = (BundleContextImpl)bundle.getBundleContext();
+ contextImpl.releaseRegisteredServices();
- // [TODO] 9. Any services used by this bundle must be released.
+ // 9. Any services used by this bundle must be released.
+ contextImpl.releaseUsedServices();
- // [TODO] 10. Any listeners registered by this bundle must be removed.
+ // 10. Any listeners registered by this bundle must be removed.
+ contextImpl.releaseRegisteredListeners();
// 11. If this bundle's state is UNINSTALLED, because this bundle was uninstalled while the BundleActivator.stop method was running, a BundleException must be thrown.
if (getState() == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already unistalled: " + this);
+ throw new IllegalStateException("Bundle already unistalled: " + bundle);
// 12. This bundle's state is set to RESOLVED.
setState(Bundle.RESOLVED);
@@ -185,14 +194,21 @@
// 13. A bundle event of type BundleEvent.STOPPED is fired.
eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, bundle));
- log.debug("Bundle STOPPED " + bundle);
+ // A BundleException must be thrown after completion of the remaining steps
+ if (activatorStopException != null)
+ {
+ if (activatorStopException instanceof BundleException)
+ throw (BundleException)activatorStopException;
+
+ throw new BundleException("Exception in BundleActivator.stop()", activatorStopException);
+ }
}
public void uninstall() throws BundleException
{
// 1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
if (getState() == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already unistalled: " + this);
+ throw new IllegalStateException("Bundle already unistalled: " + bundle);
// 2. If this bundle's state is ACTIVE, STARTING or STOPPING, this bundle is stopped as described in the Bundle.stop method.
if (getState() == Bundle.ACTIVE || getState() == Bundle.STARTING || getState() == Bundle.STOPPING)
@@ -218,11 +234,9 @@
// 5. This bundle and any persistent storage area provided for this bundle by the Framework are removed.
BundleRegistry bundleRegistry = getFramework().getBundleRegistry();
- bundleRegistry.uninstallBundle(bundle);
+ bundleRegistry.unregisterBundle(bundle);
// [TODO] Any persistent storage area provided for this bundle are removed.
-
- log.debug("Bundle UNINSTALLED " + bundle);
}
private int getState()
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundlePersistentStorageImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -0,0 +1,81 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id: $
+
+import java.io.File;
+import java.io.IOException;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundlePersistentStorage;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+/**
+ * A simple implementation of a BundleStorage
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundlePersistentStorageImpl implements BundlePersistentStorage
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundlePersistentStorageImpl.class);
+
+ private FrameworkImpl framework;
+
+ public BundlePersistentStorageImpl(FrameworkImpl framework)
+ {
+ this.framework = framework;
+ }
+
+ public File getDataFile(Bundle bundle, String filename)
+ {
+ File bundleDir = getBundleStorageDir(bundle);
+ File dataFile = new File(bundleDir.getAbsolutePath() + "/" + filename);
+ return dataFile;
+ }
+
+ private File getBundleStorageDir(Bundle bundle)
+ {
+ String dirName = (String)framework.getProperty(Constants.FRAMEWORK_STORAGE);
+ if (dirName == null)
+ {
+ try
+ {
+ File tmpFile = File.createTempFile("Constants.FRAMEWORK_STORAGE", null);
+ dirName = tmpFile.getParent();
+ tmpFile.delete();
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot create temp storage file", ex);
+ }
+ }
+
+ File bundleDir = new File(dirName + "/bundle-" + bundle.getBundleId());
+ if (bundleDir.exists() == false)
+ bundleDir.mkdirs();
+ return bundleDir;
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,10 +21,9 @@
*/
package org.jboss.osgi.jbossmc.framework;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
@@ -46,13 +45,13 @@
final Logger log = Logger.getLogger(BundleRegistryImpl.class);
private long globalId;
- private Map<Long, Bundle> registry = new LinkedHashMap<Long, Bundle>();
+ private Map<String, Bundle> registry = new LinkedHashMap<String, Bundle>();
public BundleRegistryImpl(FrameworkImpl framework)
{
}
- public long installBundle(Bundle bundle)
+ public long registerBundle(Bundle bundle)
{
if (bundle == null)
throw new IllegalArgumentException("Cannot install null bundle");
@@ -60,27 +59,39 @@
BundleImpl bundleImpl = (BundleImpl)bundle;
bundleImpl.setBundleId(globalId++);
- Long bundleId = new Long(bundle.getBundleId());
- registry.put(bundleId, bundle);
+ registry.put(bundle.getLocation(), bundle);
- return bundleId;
+ return bundle.getBundleId();
}
- public void uninstallBundle(Bundle bundle)
+ public void unregisterBundle(Bundle bundle)
{
if (bundle == null)
throw new IllegalArgumentException("Cannot uninstall null bundle");
- Long bundleId = new Long(bundle.getBundleId());
- if (registry.remove(bundleId) == null)
+ if (registry.remove(bundle.getLocation()) == null)
throw new IllegalStateException("Cannot unregister bundle: " + bundle);
}
public Bundle getBundleById(long id)
{
- return registry.get(new Long(id));
+ Bundle bundle = null;
+ for (Bundle aux : new ArrayList<Bundle>(registry.values()))
+ {
+ if (id == aux.getBundleId())
+ {
+ bundle = aux;
+ break;
+ }
+ }
+ return bundle;
}
+ public Bundle getBundleByLocation(String location)
+ {
+ return registry.get(location);
+ }
+
public List<Bundle> getBundles()
{
ArrayList<Bundle> bundles = new ArrayList<Bundle>(registry.values());
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleResolverImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,7 +21,7 @@
*/
package org.jboss.osgi.jbossmc.framework;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.BundleClassLoader;
@@ -40,11 +40,8 @@
// Provide logging
final Logger log = Logger.getLogger(BundleResolverImpl.class);
- private FrameworkImpl framework;
-
public BundleResolverImpl(FrameworkImpl framework)
{
- this.framework = framework;
}
public void resolveBundle(Bundle bundle) throws BundleException
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,13 +21,14 @@
*/
package org.jboss.osgi.jbossmc.framework;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import java.util.ArrayList;
import java.util.List;
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
+import org.jboss.osgi.spi.util.ConstantsHelper;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
@@ -42,16 +43,40 @@
// Provide logging
final Logger log = Logger.getLogger(FrameworkEventManagerImpl.class);
- private FrameworkImpl framework;
private List<FrameworkListener> listeners = new ArrayList<FrameworkListener>();
+ private boolean enabled = true;
public FrameworkEventManagerImpl(FrameworkImpl framework)
{
- this.framework = framework;
}
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+
public void fireFrameworkEvent(FrameworkEvent event)
{
+ if (enabled == false)
+ return;
+
+ String typeStr = ConstantsHelper.frameworkEvent(event.getType());
+ String message = "FrameworkEvent " + typeStr + " " + event.getSource();
+
+ if (event.getType() == FrameworkEvent.ERROR)
+ log.error(message);
+ else if (event.getType() == FrameworkEvent.WARNING)
+ log.warn(message);
+ else if (event.getType() == FrameworkEvent.INFO)
+ log.info(message);
+ else
+ log.debug(message);
+
// [TODO] When a FrameworkEvent is fired, it is asynchronously delivered to a FrameworkListener.
for (FrameworkListener listener : new ArrayList<FrameworkListener>(listeners))
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkFactoryImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -40,6 +40,7 @@
// Provide logging
final Logger log = Logger.getLogger(FrameworkFactoryImpl.class);
+ @SuppressWarnings("unchecked")
public Framework newFramework(Map configuration)
{
return new FrameworkImpl(configuration);
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -25,19 +25,25 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.BundleEventManager;
import org.jboss.osgi.jbossmc.api.BundleFactory;
+import org.jboss.osgi.jbossmc.api.BundlePersistentStorage;
import org.jboss.osgi.jbossmc.api.BundleRegistry;
import org.jboss.osgi.jbossmc.api.BundleResolver;
import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
import org.jboss.osgi.jbossmc.api.ServiceEventManager;
import org.jboss.osgi.jbossmc.api.ServiceRegistry;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
import org.osgi.framework.launch.Framework;
/**
@@ -51,18 +57,19 @@
// Provide logging
final Logger log = Logger.getLogger(FrameworkImpl.class);
- private Map<String, String> properties = new HashMap<String, String>();
+ private Map<String, Object> properties = new HashMap<String, Object>();
private int startLevel;
-
+
private BundleRegistry bundleRegistry;
private BundleFactory bundleFactory;
private BundleResolver bundleResolver;
private BundleEventManager bundleEventManager;
+ private BundlePersistentStorage bundlePersistentStorage;
private FrameworkEventManager frameworkEventManager;
private ServiceEventManager serviceEventManager;
private ServiceRegistry serviceRegistry;
- public FrameworkImpl(Map props)
+ public FrameworkImpl(Map<String, Object> props)
{
if (props != null)
properties.putAll(props);
@@ -102,11 +109,11 @@
this.startLevel = startLevel;
}
- public String getProperty(String key)
+ public Object getProperty(String key)
{
return properties.get(key);
}
-
+
public void init() throws BundleException
{
initInternal();
@@ -192,19 +199,20 @@
// Have a valid Bundle Context
setBundleContext(new SystemBundleContext(this));
-
+
bundleFactory = new BundleFactoryImpl(this);
bundleResolver = new BundleResolverImpl(this);
bundleRegistry = new BundleRegistryImpl(this);
+ bundlePersistentStorage = new BundlePersistentStorageImpl(this);
serviceRegistry = new ServiceRegistryImpl(this);
- bundleEventManager = new BundleEventManagerImpl(this);
- frameworkEventManager = new FrameworkEventManagerImpl(this);
- serviceEventManager = new ServiceEventManagerImpl(this);
// Be at start level 0
setStartLevel(0);
- // [TODO] Have event handling enabled
+ // Have event handling enabled
+ bundleEventManager = new BundleEventManagerImpl(this);
+ frameworkEventManager = new FrameworkEventManagerImpl(this);
+ serviceEventManager = new ServiceEventManagerImpl(this);
// [TODO] Have reified Bundle objects for all installed bundles
@@ -219,23 +227,66 @@
// [TODO] All installed bundles must be started
- // [TODO] This Framework's state is set to ACTIVE
+ // This Framework's state is set to ACTIVE
setState(ACTIVE);
- // [TODO] A framework event of type STARTED is fired
+ // A framework event of type STARTED is fired
+ frameworkEventManager.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.STARTED, this, null));
}
private void stopInternal()
{
- // [TODO] This Framework's state is set to STOPPING
+ // This Framework's state is set to STOPPING
+ setState(STOPPING);
- // [TODO] All installed bundles must be stopped
+ // All installed bundles must be stopped
+ List<Bundle> reverseList = bundleRegistry.getBundles();
+ Collections.reverse(reverseList);
+ for (Bundle bundle : reverseList)
+ {
+ try
+ {
+ bundle.stop();
+ }
+ catch (BundleException ex)
+ {
+ log.error("Cannot stop bundle: " + bundle, ex);
+ }
+ }
- // [TODO] Unregister all services registered by this Framework
+ // Unregister all services registered by this Framework
+ ServiceReference[] srefs = null;
+ try
+ {
+ srefs = serviceRegistry.getServiceReferences(null, null);
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ // ignore
+ }
+ if (srefs != null)
+ {
+ for (ServiceReference sref : srefs)
+ {
+ ServiceReferenceImpl srefImpl = (ServiceReferenceImpl)sref;
+ try
+ {
+ srefImpl.getServiceRegistration().unregister();
+ }
+ catch (Exception ex)
+ {
+ log.error("Cannot unregister service: " + sref, ex);
+ }
+ }
+ }
- // [TODO] Event handling is disabled
+ // Event handling is disabled
+ bundleEventManager.setEnabled(false);
+ serviceEventManager.setEnabled(false);
+ frameworkEventManager.setEnabled(false);
- // [TODO] This Framework's state is set to RESOLVED
+ // This Framework's state is set to RESOLVED
+ setState(RESOLVED);
// [TODO] All resources held by this Framework are released.
@@ -272,6 +323,11 @@
return bundleResolver;
}
+ public BundlePersistentStorage getBundlePersistentStorage()
+ {
+ return bundlePersistentStorage;
+ }
+
public ServiceRegistry getServiceRegistry()
{
return serviceRegistry;
@@ -291,4 +347,10 @@
{
return frameworkEventManager;
}
+
+ @Override
+ public String toString()
+ {
+ return "[" + getBundleId() + "] " + getSymbolicName();
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,7 +21,7 @@
*/
package org.jboss.osgi.jbossmc.framework;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -29,6 +29,7 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.ServiceEventManager;
+import org.jboss.osgi.spi.util.ConstantsHelper;
import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
@@ -48,16 +49,31 @@
// Provide logging
final Logger log = Logger.getLogger(ServiceEventManagerImpl.class);
- private FrameworkImpl framework;
private Map<ServiceListener, ListenerRegistration> listeners = new LinkedHashMap<ServiceListener, ListenerRegistration>();
-
+ private boolean enabled = true;
+
public ServiceEventManagerImpl(FrameworkImpl framework)
{
- this.framework = framework;
}
+ public boolean isEnabled()
+ {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled)
+ {
+ this.enabled = enabled;
+ }
+
public void fireServiceEvent(ServiceEvent event)
{
+ if (enabled == false)
+ return;
+
+ String typeStr = ConstantsHelper.serviceEvent(event.getType());
+ log.debug("ServiceEvent " + typeStr + " " + event.getSource());
+
ServiceReference sref = event.getServiceReference();
String[] clazzes = (String[])sref.getProperty(Constants.OBJECTCLASS);
if (clazzes == null)
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,16 +21,20 @@
*/
package org.jboss.osgi.jbossmc.framework;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Dictionary;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.jboss.logging.Logger;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -49,7 +53,10 @@
private Object service;
private Dictionary<String, Object> properties;
private ServiceRegistration registration;
+ private Map<Bundle, Long> bundleUseCount = new HashMap<Bundle, Long>();
+ private Map<Bundle, Object> cachedService = new HashMap<Bundle, Object>();
private boolean unregistered;
+ private String toStringCache;
public ServiceReferenceImpl(Bundle bundle, Object service, Dictionary<String, Object> props)
{
@@ -58,6 +65,39 @@
this.properties = props;
}
+ public Long getUseCount(Bundle bundle)
+ {
+ Long useCount = bundleUseCount.get(bundle);
+ return useCount != null ? useCount : new Long(0);
+ }
+
+ public Long incrementUseCount(Bundle bundle)
+ {
+ Long useCount = new Long(getUseCount(bundle) + 1);
+ bundleUseCount.put(bundle, useCount);
+ return useCount;
+ }
+
+ public Long decrementUseCount(Bundle bundle)
+ {
+ Long useCount = new Long(getUseCount(bundle) - 1);
+ bundleUseCount.put(bundle, useCount);
+ return useCount;
+ }
+
+ public Object getCachedService(Bundle bundle)
+ {
+ return cachedService.get(bundle);
+ }
+
+ public void setCachedService(Bundle bundle, Object service)
+ {
+ if (service != null)
+ cachedService.put(bundle, service);
+ else
+ cachedService.remove(bundle);
+ }
+
public boolean isUnregistered()
{
return unregistered;
@@ -123,4 +163,25 @@
// [TODO] ServiceReference.isAssignableTo(Bundle bundle, String className)
throw new NotImplementedException();
}
+
+ @Override
+ public String toString()
+ {
+ if (toStringCache == null)
+ {
+ Long id = (Long)properties.get(Constants.SERVICE_ID);
+ StringBuffer buffer = new StringBuffer("[" + id + "] ");
+ buffer.append(Arrays.asList((String[])properties.get(Constants.OBJECTCLASS)));
+
+ for (String key : getPropertyKeys())
+ {
+ if (!key.equals(Constants.SERVICE_ID) && !key.equals(Constants.OBJECTCLASS))
+ {
+ buffer.append("\n " + key + "=" + properties.get(key));
+ }
+ }
+ toStringCache = buffer.toString();
+ }
+ return toStringCache;
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,11 +21,12 @@
*/
package org.jboss.osgi.jbossmc.framework;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import java.util.Dictionary;
import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.ServiceRegistry;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -41,10 +42,12 @@
// Provide logging
final Logger log = Logger.getLogger(ServiceRegistrationImpl.class);
+ private ServiceRegistry serviceRegistry;
private ServiceReferenceImpl serviceRef;
- public ServiceRegistrationImpl(ServiceReferenceImpl serviceRef)
+ public ServiceRegistrationImpl(ServiceRegistry serviceRegistry, ServiceReferenceImpl serviceRef)
{
+ this.serviceRegistry = serviceRegistry;
this.serviceRef = serviceRef;
serviceRef.setServiceRegistration(this);
}
@@ -54,6 +57,7 @@
return serviceRef;
}
+ @SuppressWarnings("unchecked")
public void setProperties(Dictionary properties)
{
// [TODO] ServiceRegistration.setProperties(Dictionary properties)
@@ -62,7 +66,6 @@
public void unregister()
{
- // [TODO] ServiceRegistration.unregister()
- throw new NotImplementedException();
+ serviceRegistry.unregisterService(this);
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -21,21 +21,27 @@
*/
package org.jboss.osgi.jbossmc.framework;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+//$Id: $
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.ServiceEventManager;
import org.jboss.osgi.jbossmc.api.ServiceRegistry;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceReference;
@@ -61,16 +67,36 @@
this.framework = framework;
}
- public ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary properties)
+ public ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary<String, Object> properties)
{
return registerServiceInternal(bundle, new String[] {clazz}, service, properties);
}
- public ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary properties)
+ public ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary<String, Object> properties)
{
return registerServiceInternal(bundle, clazzes, service, properties);
}
+ public void unregisterService(ServiceRegistration registration)
+ {
+ ServiceReference sref = registration.getReference();
+ String[] clazzes = (String[])sref.getProperty(Constants.OBJECTCLASS);
+ for (String clazz : clazzes)
+ {
+ List<ServiceReference> srefs = registry.get(clazz);
+ if (srefs != null)
+ {
+ Iterator<ServiceReference> itRefs = srefs.iterator();
+ while (itRefs.hasNext())
+ {
+ ServiceReference next = itRefs.next();
+ if (sref == next)
+ itRefs.remove();
+ }
+ }
+ }
+ }
+
public ServiceReference getServiceReference(String clazz)
{
ServiceReference srefBest = null;
@@ -89,8 +115,11 @@
Integer thisRanking = (Integer)sref.getProperty(Constants.SERVICE_RANKING);
Long thisId = (Long)sref.getProperty(Constants.SERVICE_ID);
- if (bestRanking != null && thisRanking != null)
+ if (thisRanking != null)
{
+ if (bestRanking == null)
+ bestRanking = new Integer(0);
+
if (bestRanking < thisRanking)
srefBest = sref;
@@ -107,23 +136,52 @@
return srefBest;
}
- public ServiceReference[] getServiceReferences(String clazz, String filter)
+ public ServiceReference[] getServiceReferences(String clazz, String filterStr) throws InvalidSyntaxException
{
- ServiceReference[] srefArr = null;
+ Set<ServiceReference> resultRefs = new LinkedHashSet<ServiceReference>();
- // [TODO] The result is an array of ServiceReference objects for all services that meet all of the following conditions:
- // * If the specified class name, clazz, is not null, the service must have been registered with the specified class name. The complete list of class names with which a service was registered is available from the service's objectClass property.
- // * If the specified filter is not null, the filter expression must match the service.
- // * If the Java Runtime Environment supports permissions, the caller must have ServicePermission with the GET action for at least one of the class names under which the service was registered.
- // * For each class name with which the service was registered, calling ServiceReference.isAssignableTo(Bundle, String) with the context bundle and the class name on the service's ServiceReference object must return true
+ // If the specified class name, clazz, is not null, the service must have been registered with the specified class name.
+ if (clazz != null)
+ {
+ List<ServiceReference> srefs = registry.get(clazz);
+ if (srefs != null)
+ resultRefs.addAll(srefs);
+ }
- List<ServiceReference> srefs = registry.get(clazz);
- if (srefs != null)
+ // null for all services
+ if (clazz == null)
{
- srefArr = new ServiceReference[srefs.size()];
- srefs.toArray(srefArr);
+ for (String auxclazz : registry.keySet())
+ {
+ List<ServiceReference> srefs = registry.get(auxclazz);
+ if (srefs != null)
+ resultRefs.addAll(srefs);
+ }
}
- return srefArr;
+
+ // If the specified filter is not null, the filter expression must match the service.
+ if (filterStr != null)
+ {
+ Filter filter = FrameworkUtil.createFilter(filterStr);
+ Iterator<ServiceReference> itref = resultRefs.iterator();
+ while (itref.hasNext())
+ {
+ ServiceReference sref = itref.next();
+ if (filter.match(sref) == false)
+ itref.remove();
+ }
+ }
+
+ // [TODO] If the Java Runtime Environment supports permissions, the caller must have ServicePermission with the GET action for at least one of the class names under which the service was registered.
+
+ // [TODO] For each class name with which the service was registered, calling ServiceReference.isAssignableTo(Bundle, String) with the context bundle and the class name on the service's ServiceReference object must return true
+
+ // Return null if no services are registered which satisfy the search
+ if (resultRefs.size() == 0)
+ return null;
+
+ ServiceReference[] srefArr = new ServiceReference[resultRefs.size()];
+ return resultRefs.toArray(srefArr);
}
public Object getService(Bundle bundle, ServiceReference sref)
@@ -134,22 +192,57 @@
if (srefImpl.isUnregistered())
return null;
- // [TODO] The context bundle's use count for this service is incremented by one.
+ // The context bundle's use count for this service is incremented by one.
+ srefImpl.incrementUseCount(bundle);
- // [TODO] The service was registered with an object implementing the ServiceFactory interface
+ // The service was registered with an object implementing the ServiceFactory interface
Object service = srefImpl.getService();
if (service instanceof ServiceFactory)
{
- ServiceFactory factory = (ServiceFactory)service;
- service = factory.getService(bundle, srefImpl.getServiceRegistration());
+ if (srefImpl.getUseCount(bundle) == 1)
+ {
+ ServiceFactory factory = (ServiceFactory)service;
+ service = factory.getService(bundle, srefImpl.getServiceRegistration());
+ srefImpl.setCachedService(bundle, service);
+ }
+ else
+ {
+ service = srefImpl.getCachedService(bundle);
+ }
}
// The service object for the service is returned.
return service;
}
- private ServiceRegistration registerServiceInternal(Bundle bundle, String[] clazzes, Object service, Dictionary<String, String> props)
+ public boolean ungetService(Bundle bundle, ServiceReference sref)
{
+ ServiceReferenceImpl srefImpl = (ServiceReferenceImpl)sref;
+
+ // 1. If the context bundle's use count for the service is zero or the service has been unregistered, false is returned.
+ if (srefImpl.getUseCount(bundle) == 0 || srefImpl.isUnregistered())
+ return false;
+
+ // 2. The context bundle's use count for this service is decremented by one.
+ srefImpl.decrementUseCount(bundle);
+
+ // 3. If the context bundle's use count for the service is currently zero and the service was registered with a ServiceFactory object,
+ // the ServiceFactory.ungetService(Bundle, ServiceRegistration, Object) method is called to release the service object for the context bundle.
+ Object service = srefImpl.getService();
+ if (srefImpl.getUseCount(bundle) == 0 && service instanceof ServiceFactory)
+ {
+ ServiceFactory factory = (ServiceFactory)service;
+ service = srefImpl.getCachedService(bundle);
+ factory.ungetService(bundle, srefImpl.getServiceRegistration(), service);
+ srefImpl.setCachedService(bundle, null);
+ }
+
+ // 4. true is returned.
+ return true;
+ }
+
+ private ServiceRegistration registerServiceInternal(Bundle bundle, String[] clazzes, Object service, Dictionary<String, Object> props)
+ {
// If service is not a ServiceFactory, an IllegalArgumentException is thrown if service
// is not an instanceof all the specified class names.
if ((service instanceof ServiceFactory) == false)
@@ -191,7 +284,6 @@
ServiceReferenceImpl sref = new ServiceReferenceImpl(bundle, service, properties);
for (String clazz : clazzes)
{
- log.debug("Register Service: " + clazz);
List<ServiceReference> list = registry.get(clazz);
if (list == null)
{
@@ -206,6 +298,6 @@
eventManager.fireServiceEvent(new ServiceEvent(ServiceEvent.REGISTERED, sref));
// 5. A ServiceRegistration object for this registration is returned.
- return new ServiceRegistrationImpl(sref);
+ return new ServiceRegistrationImpl(this, sref);
}
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleEntriesTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleEntriesTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleEntriesTestCase.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.jbossmc.simple;
+
+//$Id: SimpleTestCase.java 91196 2009-07-14 09:41:15Z thomas.diesler(a)jboss.com $
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URL;
+import java.util.Enumeration;
+
+import org.jboss.osgi.spi.testing.OSGiTest;
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * Install a bundle and verifies its entries
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 18-Aug-2009
+ */
+public class BundleEntriesTestCase extends OSGiTest
+{
+ private static Framework framework;
+
+ /*
+ * /META-INF/
+ * /META-INF/MANIFEST.MF
+ * /org/
+ * /org/jboss/
+ * /org/jboss/test/
+ * /org/jboss/test/osgi/
+ * /org/jboss/test/osgi/jbossmc/
+ * /org/jboss/test/osgi/jbossmc/simple/
+ * /org/jboss/test/osgi/jbossmc/simple/bundle/
+ * /org/jboss/test/osgi/jbossmc/simple/bundle/SimpleActivator.class
+ * /org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.class
+ */
+
+ @BeforeClass
+ public static void beforeClass() throws BundleException
+ {
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ framework = factory.newFramework(null);
+ framework.start();
+ }
+
+ @AfterClass
+ public static void afterClass() throws BundleException
+ {
+ framework.stop();
+ }
+
+ @Test
+ public void testGetEntryPaths() throws Exception
+ {
+ BundleContext sysContext = framework.getBundleContext();
+ String location = getTestArchiveURL("simple-bundle.jar").toString();
+ Bundle bundle = sysContext.installBundle(location);
+
+ String path = "/";
+ assertEquals(11, countEntryPaths(bundle.getEntryPaths(path)));
+
+ path = "META-INF";
+ assertEquals(1, countEntryPaths(bundle.getEntryPaths(path)));
+
+ path = "org/jboss/test/osgi/jbossmc/simple/bundle";
+ assertEquals(2, countEntryPaths(bundle.getEntryPaths(path)));
+
+ bundle.uninstall();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testFindEntries() throws Exception
+ {
+ BundleContext sysContext = framework.getBundleContext();
+ String location = getTestArchiveURL("simple-bundle.jar").toString();
+ Bundle bundle = sysContext.installBundle(location);
+
+ Enumeration entries = bundle.findEntries("META-INF", "M*.*", false);
+ assertTrue("One entry", entries.hasMoreElements());
+ URL entryURL = (URL)entries.nextElement();
+ assertTrue("Ends with MANIFEST.MF", entryURL.toExternalForm().endsWith("simple-bundle.jar/META-INF/MANIFEST.MF"));
+
+ bundle.uninstall();
+ }
+
+ @SuppressWarnings("unchecked")
+ private int countEntryPaths(Enumeration entries)
+ {
+ int count = 0;
+ while (entries.hasMoreElements())
+ {
+ entries.nextElement();
+ count++;
+ }
+ return count;
+ }
+
+ @SuppressWarnings({ "unused", "unchecked" })
+ private void printEntryPaths(Enumeration entries)
+ {
+ while (entries.hasMoreElements())
+ System.out.println(entries.nextElement());
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/BundleInstallTestCase.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -69,15 +69,18 @@
}
@Test
- public void testSimpleBundle() throws Exception
+ public void testBundleInstall() throws Exception
{
- BundleContext context = framework.getBundleContext();
+ BundleContext sysContext = framework.getBundleContext();
String location = getTestArchiveURL("simple-bundle.jar").toString();
- Bundle bundle = context.installBundle(location);
+ Bundle bundle = sysContext.installBundle(location);
assertEquals("simple-bundle", bundle.getSymbolicName());
bundle.start();
- assertEquals("Bundle active", Bundle.ACTIVE, bundle.getState());
+ assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
+
+ bundle.uninstall();
+ assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/test/java/org/jboss/test/osgi/jbossmc/simple/bundle/SimpleService.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -24,7 +24,6 @@
//$Id: SimpleService.java 91196 2009-07-14 09:41:15Z thomas.diesler(a)jboss.com $
import org.osgi.framework.BundleContext;
-import org.osgi.service.log.LogService;
/**
* A SimpleService
@@ -34,8 +33,6 @@
*/
public class SimpleService
{
- private LogService log;
-
public SimpleService(BundleContext context)
{
}
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/EndpointServlet.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/EndpointServlet.java 2009-08-19 13:22:07 UTC (rev 92577)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/http/bundle/EndpointServlet.java 2009-08-19 14:33:04 UTC (rev 92578)
@@ -71,7 +71,7 @@
tracker.open();
StartLevel service = (StartLevel)tracker.getService();
- out.println("startLevel=" + service.getStartLevel());
+ out.println("startLevel=" + (service != null ? service.getStartLevel() : 1));
}
else
{
16 years, 11 months
JBoss-OSGI SVN: r92558 - in projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc: framework and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-19 00:10:53 -0400 (Wed, 19 Aug 2009)
New Revision: 92558
Modified:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
Log:
Bundle.getResource(). XML Parser tests - ok
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java 2009-08-19 04:00:42 UTC (rev 92557)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleEventManager.java 2009-08-19 04:10:53 UTC (rev 92558)
@@ -37,4 +37,6 @@
void fireBundleEvent(BundleEvent event);
void addBundleListener(BundleListener listener);
+
+ void removeBundleListener(BundleListener listener);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java 2009-08-19 04:00:42 UTC (rev 92557)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/FrameworkEventManager.java 2009-08-19 04:10:53 UTC (rev 92558)
@@ -21,11 +21,11 @@
*/
package org.jboss.osgi.jbossmc.api;
+// $Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
-
/**
* An abstraction of a framework event manager.
*
@@ -37,4 +37,6 @@
void fireFrameworkEvent(FrameworkEvent event);
void addFrameworkListener(FrameworkListener listener);
+
+ void removeFrameworkListener(FrameworkListener listener);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java 2009-08-19 04:00:42 UTC (rev 92557)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/ServiceEventManager.java 2009-08-19 04:10:53 UTC (rev 92558)
@@ -39,4 +39,6 @@
void addServiceListener(ServiceListener listener);
void addServiceListener(ServiceListener listener, String filter);
+
+ void removeServiceListener(ServiceListener listener);
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java 2009-08-19 04:00:42 UTC (rev 92557)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java 2009-08-19 04:10:53 UTC (rev 92558)
@@ -24,16 +24,13 @@
//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Enumeration;
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.BundleClassLoader;
-import org.jboss.osgi.jbossmc.api.BundleFactory;
-import org.jboss.virtual.VFS;
+import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.Bundle;
@@ -47,24 +44,26 @@
{
// Provide logging
final Logger log = Logger.getLogger(BundleClassLoaderImpl.class);
-
+
+ private VirtualFile virtualFile;
private ClassLoader loader;
-
+
public BundleClassLoaderImpl(Bundle bundle)
{
BundleImpl bundleImpl = (BundleImpl)bundle;
-
+ virtualFile = bundleImpl.getVirtualFile();
+
URL location;
try
{
- location = bundleImpl.getVirtualFile().toURL();
+ location = virtualFile.toURL();
}
catch (Exception ex)
{
throw new IllegalStateException("Cannot obtain bundle location", ex);
}
-
- loader = new URLClassLoader(new URL[]{ location });
+
+ loader = new URLClassLoader(new URL[] { location });
}
public Class<?> loadClass(String name) throws ClassNotFoundException
@@ -74,12 +73,23 @@
public URL getResource(String name)
{
- return loader.getResource(name);
+ URL resourceURL = null;
+ try
+ {
+ VirtualFile child = virtualFile.getChild(name);
+ if (child != null)
+ resourceURL = child.toURL();
+ }
+ catch (Exception ex)
+ {
+ // ignore
+ }
+ return resourceURL;
}
public Enumeration<URL> getResources(String name) throws IOException
{
- return loader.getResources(name);
+ // [TODO] Bundle.getResources(String name)
+ throw new NotImplementedException();
}
-
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-19 04:00:42 UTC (rev 92557)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-19 04:10:53 UTC (rev 92558)
@@ -79,12 +79,24 @@
eventManager.addBundleListener(listener);
}
+ public void removeBundleListener(BundleListener listener)
+ {
+ BundleEventManager eventManager = getFramework().getBundleEventManager();
+ eventManager.removeBundleListener(listener);
+ }
+
public void addFrameworkListener(FrameworkListener listener)
{
FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
eventManager.addFrameworkListener(listener);
}
+ public void removeFrameworkListener(FrameworkListener listener)
+ {
+ FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
+ eventManager.removeFrameworkListener(listener);
+ }
+
public void addServiceListener(ServiceListener listener)
{
ServiceEventManager eventManager = getFramework().getServiceEventManager();
@@ -97,14 +109,15 @@
eventManager.addServiceListener(listener, filter);
}
- public Filter createFilter(String filter) throws InvalidSyntaxException
+ public void removeServiceListener(ServiceListener listener)
{
- return FrameworkUtil.createFilter(filter);
+ ServiceEventManager eventManager = getFramework().getServiceEventManager();
+ eventManager.removeServiceListener(listener);
}
- public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException
+ public Filter createFilter(String filter) throws InvalidSyntaxException
{
- throw new NotImplementedException();
+ return FrameworkUtil.createFilter(filter);
}
public Bundle getBundle()
@@ -128,6 +141,7 @@
public File getDataFile(String filename)
{
+ // [TODO] BundleContext.getDataFile(String filename)
throw new NotImplementedException();
}
@@ -158,6 +172,12 @@
return serviceRegistry.getServiceReferences(clazz, filter);
}
+ public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException
+ {
+ // [TODO] BundleContext.getAllServiceReferences(String clazz, String filter)
+ throw new NotImplementedException();
+ }
+
public Bundle installBundle(String location) throws BundleException
{
// Create the bundle from the location
@@ -173,6 +193,7 @@
public Bundle installBundle(String location, InputStream input) throws BundleException
{
+ // [TODO] BundleContext.installBundle(String location, InputStream input)
throw new NotImplementedException();
}
@@ -188,23 +209,9 @@
return registry.registerService(getBundle(), clazz, service, properties);
}
- public void removeBundleListener(BundleListener listener)
- {
- throw new NotImplementedException();
- }
-
- public void removeFrameworkListener(FrameworkListener listener)
- {
- throw new NotImplementedException();
- }
-
- public void removeServiceListener(ServiceListener listener)
- {
- throw new NotImplementedException();
- }
-
public boolean ungetService(ServiceReference reference)
{
+ // [TODO] BundleContext.ungetService
throw new NotImplementedException();
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java 2009-08-19 04:00:42 UTC (rev 92557)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleEventManagerImpl.java 2009-08-19 04:10:53 UTC (rev 92558)
@@ -54,7 +54,7 @@
{
// [TODO] When a BundleEvent is fired, it is asynchronously delivered to a BundleListener
- for (BundleListener listener : listeners)
+ for (BundleListener listener : new ArrayList<BundleListener>(listeners))
listener.bundleChanged(event);
}
@@ -62,4 +62,9 @@
{
listeners.add(listener);
}
+
+ public void removeBundleListener(BundleListener listener)
+ {
+ listeners.remove(listener);
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-19 04:00:42 UTC (rev 92557)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-19 04:10:53 UTC (rev 92558)
@@ -161,19 +161,16 @@
public void update() throws BundleException
{
+ // [TODO] Bundle.update()
throw new NotImplementedException();
}
public void update(InputStream in) throws BundleException
{
+ // [TODO] Bundle.update(InputStream in)
throw new NotImplementedException();
}
- public Enumeration findEntries(String path, String filePattern, boolean recurse)
- {
- throw new NotImplementedException();
- }
-
public BundleContext getBundleContext()
{
return context;
@@ -186,14 +183,22 @@
public URL getEntry(String path)
{
+ // [TODO] Bundle.getEntry(String path)
throw new NotImplementedException();
}
- public Enumeration getEntryPaths(String path)
+ public Enumeration<URL> getEntryPaths(String path)
{
+ // [TODO] Bundle.getEntryPaths(String path)
throw new NotImplementedException();
}
+ public Enumeration findEntries(String path, String filePattern, boolean recurse)
+ {
+ // [TODO] Bundle.findEntries(String path, String filePattern, boolean recurse)
+ throw new NotImplementedException();
+ }
+
public Dictionary getHeaders()
{
if (headers == null)
@@ -220,19 +225,28 @@
public Dictionary getHeaders(String locale)
{
+ // [TODO] Bundle.getHeaders(String locale)
throw new NotImplementedException();
}
public long getLastModified()
{
+ // [TODO] Bundle.getLastModified()
throw new NotImplementedException();
}
public ServiceReference[] getRegisteredServices()
{
+ // [TODO] Bundle.getRegisteredServices()
throw new NotImplementedException();
}
+ public ServiceReference[] getServicesInUse()
+ {
+ // [TODO] Bundle.getServicesInUse()
+ throw new NotImplementedException();
+ }
+
public URL getResource(String name)
{
return getClassLoader().getResource(name);
@@ -243,24 +257,21 @@
return getClassLoader().getResources(name);
}
- public ServiceReference[] getServicesInUse()
- {
- throw new NotImplementedException();
-
- }
-
public Map getSignerCertificates(int signersType)
{
+ // [TODO] Bundle.getSignerCertificates(int signersType)
throw new NotImplementedException();
}
public Version getVersion()
{
- throw new NotImplementedException();
+ String versionStr = getHeader(Constants.BUNDLE_VERSION);
+ return new Version(versionStr);
}
public boolean hasPermission(Object permission)
{
+ // [TODO] Bundle.hasPermission(Object permission)
throw new NotImplementedException();
}
@@ -308,7 +319,7 @@
{
long id = getBundleId();
String name = getSymbolicName();
- String version = getHeader(Constants.BUNDLE_VERSION);
+ Version version = getVersion();
toStringValue = "[id=" + id + ",name=" + name + ",version=" + version + "]";
}
return toStringValue;
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java 2009-08-19 04:00:42 UTC (rev 92557)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/FrameworkEventManagerImpl.java 2009-08-19 04:10:53 UTC (rev 92558)
@@ -54,7 +54,7 @@
{
// [TODO] When a FrameworkEvent is fired, it is asynchronously delivered to a FrameworkListener.
- for (FrameworkListener listener : listeners)
+ for (FrameworkListener listener : new ArrayList<FrameworkListener>(listeners))
listener.frameworkEvent(event);
}
@@ -62,4 +62,9 @@
{
listeners.add(listener);
}
+
+ public void removeFrameworkListener(FrameworkListener listener)
+ {
+ listeners.remove(listener);
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-19 04:00:42 UTC (rev 92557)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-19 04:10:53 UTC (rev 92558)
@@ -24,7 +24,8 @@
//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
import java.util.ArrayList;
-import java.util.List;
+import java.util.LinkedHashMap;
+import java.util.Map;
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.ServiceEventManager;
@@ -48,7 +49,7 @@
final Logger log = Logger.getLogger(ServiceEventManagerImpl.class);
private FrameworkImpl framework;
- private List<ListenerRegistration> listeners = new ArrayList<ListenerRegistration>();
+ private Map<ServiceListener, ListenerRegistration> listeners = new LinkedHashMap<ServiceListener, ListenerRegistration>();
public ServiceEventManagerImpl(FrameworkImpl framework)
{
@@ -63,7 +64,7 @@
throw new IllegalStateException("Cannot obtain property '" + Constants.OBJECTCLASS + "' from: " + sref);
// When a ServiceEvent is fired, it is synchronously delivered to a ServiceListener.
- for (ListenerRegistration reg : listeners)
+ for (ListenerRegistration reg : new ArrayList<ListenerRegistration>(listeners.values()))
{
ServiceListener listener = reg.getListener();
@@ -78,16 +79,21 @@
public void addServiceListener(ServiceListener listener)
{
- listeners.add(new ListenerRegistration(listener, null));
+ listeners.put(listener, new ListenerRegistration(listener, null));
}
public void addServiceListener(ServiceListener listener, String filter)
{
- listeners.add(new ListenerRegistration(listener, filter));
+ listeners.put(listener, new ListenerRegistration(listener, filter));
}
- static class ListenerRegistration
+ public void removeServiceListener(ServiceListener listener)
{
+ listeners.remove(listener);
+ }
+
+ private static class ListenerRegistration
+ {
ServiceListener listener;
Filter filter;
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java 2009-08-19 04:00:42 UTC (rev 92557)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java 2009-08-19 04:10:53 UTC (rev 92558)
@@ -85,6 +85,7 @@
public int compareTo(Object reference)
{
+ // [TODO] ServiceReference.compareTo(Object reference)
throw new NotImplementedException();
}
@@ -113,11 +114,13 @@
public Bundle[] getUsingBundles()
{
+ // [TODO] ServiceReference.getUsingBundles()
throw new NotImplementedException();
}
public boolean isAssignableTo(Bundle bundle, String className)
{
+ // [TODO] ServiceReference.isAssignableTo(Bundle bundle, String className)
throw new NotImplementedException();
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java 2009-08-19 04:00:42 UTC (rev 92557)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistrationImpl.java 2009-08-19 04:10:53 UTC (rev 92558)
@@ -56,11 +56,13 @@
public void setProperties(Dictionary properties)
{
+ // [TODO] ServiceRegistration.setProperties(Dictionary properties)
throw new NotImplementedException();
}
public void unregister()
{
+ // [TODO] ServiceRegistration.unregister()
throw new NotImplementedException();
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-19 04:00:42 UTC (rev 92557)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-19 04:10:53 UTC (rev 92558)
@@ -73,17 +73,38 @@
public ServiceReference getServiceReference(String clazz)
{
- ServiceReference sref = null;
+ ServiceReference srefBest = null;
- // [TODO] If multiple such services exist, the service with the highest ranking (as specified in its Constants.SERVICE_RANKING property) is returned.
-
- // [TODO] If there is a tie in ranking, the service with the lowest service ID (as specified in its Constants.SERVICE_ID property); that is, the service that was registered first is returned.
-
List<ServiceReference> srefs = registry.get(clazz);
if (srefs != null && srefs.size() > 0)
- sref = srefs.iterator().next();
+ {
+ // If multiple such services exist, the service with the highest ranking is returned.
+ // If there is a tie in ranking, the service with the lowest service ID (i.e. the service that was registered first) is returned.
+ for (ServiceReference sref : srefs)
+ {
+ if (srefBest != null)
+ {
+ Integer bestRanking = (Integer)srefBest.getProperty(Constants.SERVICE_RANKING);
+ Long bestId = (Long)srefBest.getProperty(Constants.SERVICE_ID);
+
+ Integer thisRanking = (Integer)sref.getProperty(Constants.SERVICE_RANKING);
+ Long thisId = (Long)sref.getProperty(Constants.SERVICE_ID);
+ if (bestRanking != null && thisRanking != null)
+ {
+ if (bestRanking < thisRanking)
+ srefBest = sref;
+
+ if (bestRanking.equals(thisRanking) && bestId < thisId)
+ srefBest = sref;
+ }
+ }
+
+ if (srefBest == null)
+ srefBest = sref;
+ }
+ }
- return sref;
+ return srefBest;
}
public ServiceReference[] getServiceReferences(String clazz, String filter)
16 years, 11 months
JBoss-OSGI SVN: r92552 - projects/jboss-osgi/trunk/hudson.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-18 22:49:27 -0400 (Tue, 18 Aug 2009)
New Revision: 92552
Modified:
projects/jboss-osgi/trunk/hudson/build.xml
Log:
Copy jboss-5.1.0.GA.zip to hudson setup
Modified: projects/jboss-osgi/trunk/hudson/build.xml
===================================================================
--- projects/jboss-osgi/trunk/hudson/build.xml 2009-08-19 00:16:25 UTC (rev 92551)
+++ projects/jboss-osgi/trunk/hudson/build.xml 2009-08-19 02:49:27 UTC (rev 92552)
@@ -84,6 +84,7 @@
-->
<target name="thirdparty" depends="init-thirdparty,get-tomcat,get-hudson,get-jboss501,get-jboss510">
<copy todir="${hudson.root}/jboss" file="${thirdparty.dir}/jboss-5.0.1.GA.zip"/>
+ <copy todir="${hudson.root}/jboss" file="${thirdparty.dir}/jboss-5.1.0.GA.zip"/>
</target>
<target name="get-tomcat" depends="init-thirdparty" unless="apache.tomcat.available">
<get src="http://www.apache.org/dist/tomcat/tomcat-5/v${apache-tomcat}/bin/apache-t..." dest="${thirdparty.dir}/apache-tomcat.zip" usetimestamp="true" verbose="true"/>
16 years, 11 months
JBoss-OSGI SVN: r92547 - in projects/jboss-osgi/trunk: reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework and 1 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-08-18 17:32:41 -0400 (Tue, 18 Aug 2009)
New Revision: 92547
Added:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecycle.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java
Modified:
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
projects/jboss-osgi/trunk/testsuite/pom.xml
Log:
Add BundleLifecycle. Example SimpleTestCase - ok
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java 2009-08-18 20:38:10 UTC (rev 92546)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleClassLoader.java 2009-08-18 21:32:41 UTC (rev 92547)
@@ -21,6 +21,10 @@
*/
package org.jboss.osgi.jbossmc.api;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Enumeration;
+
//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
/**
@@ -31,5 +35,9 @@
*/
public interface BundleClassLoader
{
- Class loadClass(String name) throws ClassNotFoundException;
+ Class<?> loadClass(String name) throws ClassNotFoundException;
+
+ URL getResource(String name);
+
+ Enumeration<URL> getResources(String name) throws IOException;
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecycle.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecycle.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecycle.java 2009-08-18 21:32:41 UTC (rev 92547)
@@ -0,0 +1,41 @@
+/*
+ * 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.jbossmc.api;
+
+//$Id$
+
+import org.osgi.framework.BundleException;
+
+/**
+ * An abstraction the OSGi bundle lifecycle
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 29-Jul-2009
+ */
+public interface BundleLifecycle
+{
+ void start(int options) throws BundleException;
+
+ void stop(int options) throws BundleException;
+
+ void uninstall() throws BundleException;
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleLifecycle.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java 2009-08-18 20:38:10 UTC (rev 92546)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/api/BundleRegistry.java 2009-08-18 21:32:41 UTC (rev 92547)
@@ -21,10 +21,11 @@
*/
package org.jboss.osgi.jbossmc.api;
-import org.osgi.framework.Bundle;
+// $Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
-//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
+import java.util.List;
+import org.osgi.framework.Bundle;
/**
* An abstraction of a bundle registry.
@@ -37,4 +38,8 @@
long installBundle(Bundle bundle);
void uninstallBundle(Bundle bundle);
+
+ Bundle getBundleById(long id);
+
+ List<Bundle> getBundles();
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java 2009-08-18 20:38:10 UTC (rev 92546)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleClassLoaderImpl.java 2009-08-18 21:32:41 UTC (rev 92547)
@@ -28,6 +28,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.Enumeration;
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.BundleClassLoader;
@@ -66,9 +67,19 @@
loader = new URLClassLoader(new URL[]{ location });
}
- public Class loadClass(String name) throws ClassNotFoundException
+ public Class<?> loadClass(String name) throws ClassNotFoundException
{
return loader.loadClass(name);
}
+ public URL getResource(String name)
+ {
+ return loader.getResource(name);
+ }
+
+ public Enumeration<URL> getResources(String name) throws IOException
+ {
+ return loader.getResources(name);
+ }
+
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-18 20:38:10 UTC (rev 92546)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleContextImpl.java 2009-08-18 21:32:41 UTC (rev 92547)
@@ -26,6 +26,7 @@
import java.io.File;
import java.io.InputStream;
import java.util.Dictionary;
+import java.util.List;
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.BundleEventManager;
@@ -113,12 +114,16 @@
public Bundle getBundle(long id)
{
- throw new NotImplementedException();
+ BundleRegistry bundleRegistry = getFramework().getBundleRegistry();
+ return bundleRegistry.getBundleById(id);
}
public Bundle[] getBundles()
{
- throw new NotImplementedException();
+ BundleRegistry bundleRegistry = getFramework().getBundleRegistry();
+ List<Bundle> bundleList = bundleRegistry.getBundles();
+ Bundle[] bundles = new Bundle[bundleList.size()];
+ return bundleList.toArray(bundles);
}
public File getDataFile(String filename)
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-18 20:38:10 UTC (rev 92546)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleImpl.java 2009-08-18 21:32:41 UTC (rev 92547)
@@ -35,22 +35,19 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.BundleClassLoader;
-import org.jboss.osgi.jbossmc.api.BundleEventManager;
+import org.jboss.osgi.jbossmc.api.BundleLifecycle;
import org.jboss.osgi.jbossmc.api.BundleResolver;
import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.virtual.VirtualFile;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
-import aQute.lib.osgi.Constants;
-
/**
* An implementation of an OSGi Bundle
*
@@ -62,22 +59,27 @@
// Provide logging
final Logger log = Logger.getLogger(BundleImpl.class);
- private int state;
+ private int state;
private VirtualFile vFile;
private long bundleId;
- private BundleContextImpl context;
+ private BundleContext context;
private Dictionary<String, String> headers;
+ private BundleLifecycle bundleLifecycle;
private BundleClassLoader classLoader;
+ private String toStringValue;
public BundleImpl()
{
// ctor used by the framework
- // [TODO] remove when we have a VFS root for the framework
+ // [TODO] remove when we have a VFS root for the framework
+
+ this.bundleLifecycle = new BundleLifecycleImpl(this);
}
public BundleImpl(VirtualFile vFile)
{
this.vFile = vFile;
+ this.bundleLifecycle = new BundleLifecycleImpl(this);
}
public VirtualFile getVirtualFile()
@@ -139,93 +141,22 @@
public void start(int options) throws BundleException
{
- // If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
- if (state == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already uninstalled: " + this);
-
- // [TODO] Implement the optional Start Level service
-
- // [TODO] If this bundle is in the process of being activated or deactivated then this method must wait
- // for activation or deactivation to complete before continuing.
- if (state == Bundle.STARTING || state == Bundle.STARTING)
- throw new IllegalStateException("Bundle already staring/stopping: " + this);
-
- // If this bundle's state is not RESOLVED, an attempt is made to resolve this bundle.
- if (state != Bundle.RESOLVED)
- {
- BundleResolver resolver = getFramework().getBundleResolver();
- resolver.resolveBundle(this);
- }
-
- // [TODO] Lazy bundle activation
-
- // This bundle's state is set to STARTING.
- state = Bundle.STARTING;
-
- // A bundle event of type BundleEvent.STARTING is fired.
- BundleEventManager eventManager = getFramework().getBundleEventManager();
- eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTING, this));
-
- // The BundleActivator is called
- String activatorClass = getHeader(Constants.BUNDLE_ACTIVATOR);
- if (activatorClass != null)
- {
- BundleActivator activator;
- try
- {
- activator = (BundleActivator)loadClass(activatorClass).newInstance();
- activator.start(context);
- }
- catch (Exception ex)
- {
- // This bundle's state is set to STOPPING.
- state = Bundle.STOPPING;
-
- // A bundle event of type BundleEvent.STOPPING is fired
- eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, this));
-
- // [TODO] Any services registered by this bundle must be unregistered.
-
- // [TODO] Any services used by this bundle must be released.
-
- // [TODO] Any listeners registered by this bundle must be removed.
-
- // This bundle's state is set to RESOLVED.
- state = Bundle.RESOLVED;
-
- // A bundle event of type BundleEvent.STOPPED is fired.
- eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, this));
-
- // A BundleException is then thrown.
- throw new BundleException("Cannot call BundleActivator: " + activatorClass, ex);
- }
- }
-
- // If this bundle's state is UNINSTALLED, because this bundle was uninstalled while
- // the BundleActivator.start was running
- if (state == Bundle.UNINSTALLED)
- throw new IllegalStateException("Bundle already uninstalled: " + this);
-
- // This bundle's state is set to ACTIVE
- state = Bundle.ACTIVE;
-
- // A bundle event of type BundleEvent.STARTED is fired
- eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTED, this));
+ bundleLifecycle.start(options);
}
public void stop() throws BundleException
{
- throw new NotImplementedException();
+ stop(0);
}
public void stop(int options) throws BundleException
{
- throw new NotImplementedException();
+ bundleLifecycle.stop(options);
}
public void uninstall() throws BundleException
{
- throw new NotImplementedException();
+ bundleLifecycle.uninstall();
}
public void update() throws BundleException
@@ -304,18 +235,18 @@
public URL getResource(String name)
{
- throw new NotImplementedException();
+ return getClassLoader().getResource(name);
}
- public Enumeration getResources(String name) throws IOException
+ public Enumeration<URL> getResources(String name) throws IOException
{
- throw new NotImplementedException();
+ return getClassLoader().getResources(name);
}
public ServiceReference[] getServicesInUse()
{
throw new NotImplementedException();
-
+
}
public Map getSignerCertificates(int signersType)
@@ -336,7 +267,7 @@
public Class<?> loadClass(String name) throws ClassNotFoundException
{
// [TODO] If this bundle is a fragment bundle then this method must throw a ClassNotFoundException
-
+
// If this bundle's state is INSTALLED, this method must attempt to resolve this bundle
// before attempting to load the class.
if (state == Bundle.INSTALLED)
@@ -351,11 +282,11 @@
// If this bundle cannot be resolved, a Framework event of type FrameworkEvent.ERROR is fired
FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
eventManager.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.ERROR, this, ex));
-
+
throw new ClassNotFoundException("Cannot load class: " + name, ex);
}
}
-
+
return getClassLoader().loadClass(name);
}
@@ -366,6 +297,20 @@
private FrameworkImpl getFramework()
{
- return context.getFramework();
+ BundleContextImpl contextImpl = (BundleContextImpl)context;
+ return contextImpl.getFramework();
}
+
+ @Override
+ public String toString()
+ {
+ if (toStringValue == null)
+ {
+ long id = getBundleId();
+ String name = getSymbolicName();
+ String version = getHeader(Constants.BUNDLE_VERSION);
+ toStringValue = "[id=" + id + ",name=" + name + ",version=" + version + "]";
+ }
+ return toStringValue;
+ }
}
\ No newline at end of file
Added: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java (rev 0)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java 2009-08-18 21:32:41 UTC (rev 92547)
@@ -0,0 +1,244 @@
+/*
+ * 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.jbossmc.framework;
+
+//$Id$
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.jbossmc.api.BundleEventManager;
+import org.jboss.osgi.jbossmc.api.BundleLifecycle;
+import org.jboss.osgi.jbossmc.api.BundleRegistry;
+import org.jboss.osgi.jbossmc.api.BundleResolver;
+import org.jboss.osgi.jbossmc.api.FrameworkEventManager;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkEvent;
+
+/**
+ * An implementation of the OSGi bundle lifecycle
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 29-Jul-2009
+ */
+public class BundleLifecycleImpl implements BundleLifecycle
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(BundleLifecycleImpl.class);
+
+ private Bundle bundle;
+ private BundleActivator activator;
+
+ public BundleLifecycleImpl(Bundle bundle)
+ {
+ this.bundle = bundle;
+ }
+
+ public void start(int options) throws BundleException
+ {
+ // If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
+ if (getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already uninstalled: " + this);
+
+ // [TODO] Implement the optional Start Level service
+
+ // [TODO] If this bundle is in the process of being activated or deactivated then this method must wait
+ // for activation or deactivation to complete before continuing.
+ if (getState() == Bundle.STARTING || getState() == Bundle.STARTING)
+ throw new IllegalStateException("Bundle already staring/stopping: " + this);
+
+ // If this bundle's state is not RESOLVED, an attempt is made to resolve this bundle.
+ if (getState() != Bundle.RESOLVED)
+ {
+ BundleResolver resolver = getFramework().getBundleResolver();
+ resolver.resolveBundle(bundle);
+ }
+
+ // [TODO] Lazy bundle activation
+
+ // This bundle's state is set to STARTING.
+ setState(Bundle.STARTING);
+
+ // A bundle event of type BundleEvent.STARTING is fired.
+ BundleEventManager eventManager = getFramework().getBundleEventManager();
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTING, bundle));
+
+ // The BundleActivator is called
+ String activatorClass = (String)bundle.getHeaders().get(Constants.BUNDLE_ACTIVATOR);
+ if (activatorClass != null)
+ {
+ try
+ {
+ activator = (BundleActivator)bundle.loadClass(activatorClass).newInstance();
+ activator.start(bundle.getBundleContext());
+ }
+ catch (Exception ex)
+ {
+ // This bundle's state is set to STOPPING.
+ setState(Bundle.STOPPING);
+
+ // A bundle event of type BundleEvent.STOPPING is fired
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, bundle));
+
+ // [TODO] Any services registered by this bundle must be unregistered.
+
+ // [TODO] Any services used by this bundle must be released.
+
+ // [TODO] Any listeners registered by this bundle must be removed.
+
+ // This bundle's state is set to RESOLVED.
+ setState(Bundle.RESOLVED);
+
+ // A bundle event of type BundleEvent.STOPPED is fired.
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, bundle));
+
+ // A BundleException is then thrown.
+ throw new BundleException("Cannot call BundleActivator: " + activatorClass, ex);
+ }
+ }
+
+ // If this bundle's state is UNINSTALLED, because this bundle was uninstalled while
+ // the BundleActivator.start was running
+ if (getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already uninstalled: " + this);
+
+ // This bundle's state is set to ACTIVE
+ setState(Bundle.ACTIVE);
+
+ // A bundle event of type BundleEvent.STARTED is fired
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STARTED, bundle));
+
+ log.debug("Bundle STARTED " + bundle);
+ }
+
+ public void stop(int options) throws BundleException
+ {
+ // 1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
+ if (getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already unistalled: " + this);
+
+ // [TODO] 2. If this bundle is in the process of being activated or deactivated then this method must wait for activation or deactivation to complete
+
+ // [TODO] 3. If the STOP_TRANSIENT option is not set then then set this bundle's persistent autostart setting to to Stopped. When the Framework is restarted and this bundle's autostart setting is Stopped, this bundle must not be automatically started.
+
+ // 4. If this bundle's state is not STARTING or ACTIVE then this method returns immediately.
+ if (!(getState() == Bundle.STARTING || getState() == Bundle.ACTIVE))
+ return;
+
+ // 5. This bundle's state is set to STOPPING.
+ int statePriorToStopping = getState();
+ setState(Bundle.STOPPING);
+
+ // 6. A bundle event of type BundleEvent.STOPPING is fired.
+ BundleEventManager eventManager = getFramework().getBundleEventManager();
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPING, bundle));
+
+ // 7. If this bundle's state was ACTIVE prior to setting the state to STOPPING, the BundleActivator.stop(org.osgi.framework.BundleContext) method of this bundle's BundleActivator, if one is specified, is called.
+ Exception activatorStopException = null;
+ if (statePriorToStopping == Bundle.ACTIVE && activator != null)
+ {
+ try
+ {
+ activator.stop(bundle.getBundleContext());
+ }
+ catch (Exception ex)
+ {
+ // This method must continue to stop this bundle and a BundleException must be thrown after completion of the remaining steps.
+ activatorStopException = ex;
+ }
+ }
+
+ // [TODO] 8. Any services registered by this bundle must be unregistered.
+
+ // [TODO] 9. Any services used by this bundle must be released.
+
+ // [TODO] 10. Any listeners registered by this bundle must be removed.
+
+ // 11. If this bundle's state is UNINSTALLED, because this bundle was uninstalled while the BundleActivator.stop method was running, a BundleException must be thrown.
+ if (getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already unistalled: " + this);
+
+ // 12. This bundle's state is set to RESOLVED.
+ setState(Bundle.RESOLVED);
+
+ // 13. A bundle event of type BundleEvent.STOPPED is fired.
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.STOPPED, bundle));
+
+ log.debug("Bundle STOPPED " + bundle);
+ }
+
+ public void uninstall() throws BundleException
+ {
+ // 1. If this bundle's state is UNINSTALLED then an IllegalStateException is thrown.
+ if (getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already unistalled: " + this);
+
+ // 2. If this bundle's state is ACTIVE, STARTING or STOPPING, this bundle is stopped as described in the Bundle.stop method.
+ if (getState() == Bundle.ACTIVE || getState() == Bundle.STARTING || getState() == Bundle.STOPPING)
+ {
+ try
+ {
+ stop(0);
+ }
+ catch (Exception ex)
+ {
+ // If Bundle.stop throws an exception, a Framework event of type FrameworkEvent.ERROR is fired containing the exception.
+ FrameworkEventManager eventManager = getFramework().getFrameworkEventManager();
+ eventManager.fireFrameworkEvent(new FrameworkEvent(FrameworkEvent.ERROR, bundle, ex));
+ }
+ }
+
+ // 3. This bundle's state is set to UNINSTALLED.
+ setState(Bundle.UNINSTALLED);
+
+ // 4. A bundle event of type BundleEvent.UNINSTALLED is fired.
+ BundleEventManager eventManager = getFramework().getBundleEventManager();
+ eventManager.fireBundleEvent(new BundleEvent(BundleEvent.UNINSTALLED, bundle));
+
+ // 5. This bundle and any persistent storage area provided for this bundle by the Framework are removed.
+ BundleRegistry bundleRegistry = getFramework().getBundleRegistry();
+ bundleRegistry.uninstallBundle(bundle);
+
+ // [TODO] Any persistent storage area provided for this bundle are removed.
+
+ log.debug("Bundle UNINSTALLED " + bundle);
+ }
+
+ private int getState()
+ {
+ return bundle.getState();
+ }
+
+ private void setState(int state)
+ {
+ BundleImpl bundleImpl = (BundleImpl)bundle;
+ bundleImpl.setState(state);
+ }
+
+ private FrameworkImpl getFramework()
+ {
+ BundleContextImpl context = (BundleContextImpl)bundle.getBundleContext();
+ return context.getFramework();
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleLifecycleImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java 2009-08-18 20:38:10 UTC (rev 92546)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/BundleRegistryImpl.java 2009-08-18 21:32:41 UTC (rev 92547)
@@ -23,7 +23,12 @@
//$Id: SystemBundleContext.java 91789 2009-07-29 20:49:03Z thomas.diesler(a)jboss.com $
-import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.BundleRegistry;
@@ -40,40 +45,45 @@
// Provide logging
final Logger log = Logger.getLogger(BundleRegistryImpl.class);
- private long bundleId;
- private FrameworkImpl framework;
- private HashMap<String, Bundle> registry = new HashMap<String, Bundle>();
+ private long globalId;
+ private Map<Long, Bundle> registry = new LinkedHashMap<Long, Bundle>();
public BundleRegistryImpl(FrameworkImpl framework)
{
- this.framework = framework;
}
public long installBundle(Bundle bundle)
{
- String location = getBundleLocation(bundle);
- registry.put(location, bundle);
+ if (bundle == null)
+ throw new IllegalArgumentException("Cannot install null bundle");
- ((BundleImpl)bundle).setBundleId(bundleId++);
- return bundle.getBundleId();
+ BundleImpl bundleImpl = (BundleImpl)bundle;
+ bundleImpl.setBundleId(globalId++);
+
+ Long bundleId = new Long(bundle.getBundleId());
+ registry.put(bundleId, bundle);
+
+ return bundleId;
}
public void uninstallBundle(Bundle bundle)
{
- String location = getBundleLocation(bundle);
- if (registry.remove(location) == null)
+ if (bundle == null)
+ throw new IllegalArgumentException("Cannot uninstall null bundle");
+
+ Long bundleId = new Long(bundle.getBundleId());
+ if (registry.remove(bundleId) == null)
throw new IllegalStateException("Cannot unregister bundle: " + bundle);
}
- private String getBundleLocation(Bundle bundle)
+ public Bundle getBundleById(long id)
{
- if (bundle == null)
- throw new IllegalArgumentException("Cannot unregister null bundle");
-
- String location = bundle.getLocation();
- if (location == null)
- throw new IllegalArgumentException("Cannot obtain bundle location");
-
- return location;
+ return registry.get(new Long(id));
}
+
+ public List<Bundle> getBundles()
+ {
+ ArrayList<Bundle> bundles = new ArrayList<Bundle>(registry.values());
+ return Collections.unmodifiableList(bundles);
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-18 20:38:10 UTC (rev 92546)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceEventManagerImpl.java 2009-08-18 21:32:41 UTC (rev 92547)
@@ -28,8 +28,13 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.ServiceEventManager;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
/**
* A simple implementation of a BundleEventManager
@@ -43,7 +48,7 @@
final Logger log = Logger.getLogger(ServiceEventManagerImpl.class);
private FrameworkImpl framework;
- private List<ServiceListener> listeners = new ArrayList<ServiceListener>();
+ private List<ListenerRegistration> listeners = new ArrayList<ListenerRegistration>();
public ServiceEventManagerImpl(FrameworkImpl framework)
{
@@ -52,20 +57,65 @@
public void fireServiceEvent(ServiceEvent event)
{
+ ServiceReference sref = event.getServiceReference();
+ String[] clazzes = (String[])sref.getProperty(Constants.OBJECTCLASS);
+ if (clazzes == null)
+ throw new IllegalStateException("Cannot obtain property '" + Constants.OBJECTCLASS + "' from: " + sref);
+
// When a ServiceEvent is fired, it is synchronously delivered to a ServiceListener.
- for (ServiceListener listener : listeners)
- listener.serviceChanged(event);
+ for (ListenerRegistration reg : listeners)
+ {
+ ServiceListener listener = reg.getListener();
+
+ // ServiceEvent object delivery to ServiceListener objects is filtered
+ Filter filter = reg.getFilter();
+ if (filter == null || filter.match(sref))
+ listener.serviceChanged(event);
+ }
- // [TODO] ServiceEvent object delivery to ServiceListener objects is filtered
+ // [TODO] ServiceEvent object delivery to ServiceListener objects is further filtered according to package sources
}
public void addServiceListener(ServiceListener listener)
{
- listeners.add(listener);
+ listeners.add(new ListenerRegistration(listener, null));
}
public void addServiceListener(ServiceListener listener, String filter)
{
- listeners.add(listener);
+ listeners.add(new ListenerRegistration(listener, filter));
}
+
+ static class ListenerRegistration
+ {
+ ServiceListener listener;
+ Filter filter;
+
+ ListenerRegistration(ServiceListener listener, String filterStr)
+ {
+ this.listener = listener;
+
+ if (filterStr != null)
+ {
+ try
+ {
+ filter = FrameworkUtil.createFilter(filterStr);
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ throw new IllegalArgumentException(ex);
+ }
+ }
+ }
+
+ public ServiceListener getListener()
+ {
+ return listener;
+ }
+
+ public Filter getFilter()
+ {
+ return filter;
+ }
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java 2009-08-18 20:38:10 UTC (rev 92546)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceReferenceImpl.java 2009-08-18 21:32:41 UTC (rev 92547)
@@ -47,15 +47,15 @@
private Bundle bundle;
private Object service;
- private Dictionary<String, String> properties;
+ private Dictionary<String, Object> properties;
private ServiceRegistration registration;
private boolean unregistered;
- public ServiceReferenceImpl(Bundle bundle, Object service, Dictionary<String, String> properties)
+ public ServiceReferenceImpl(Bundle bundle, Object service, Dictionary<String, Object> props)
{
this.bundle = bundle;
this.service = service;
- this.properties = properties;
+ this.properties = props;
}
public boolean isUnregistered()
Modified: projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-18 20:38:10 UTC (rev 92546)
+++ projects/jboss-osgi/trunk/reactor/runtime/jbossmc/src/main/java/org/jboss/osgi/jbossmc/framework/ServiceRegistryImpl.java 2009-08-18 21:32:41 UTC (rev 92547)
@@ -25,15 +25,17 @@
import java.util.ArrayList;
import java.util.Dictionary;
+import java.util.Enumeration;
import java.util.HashMap;
+import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.jboss.logging.Logger;
import org.jboss.osgi.jbossmc.api.ServiceEventManager;
import org.jboss.osgi.jbossmc.api.ServiceRegistry;
-import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceReference;
@@ -52,6 +54,7 @@
private Map<String, List<ServiceReference>> registry = new HashMap<String, List<ServiceReference>>();
private FrameworkImpl framework;
+ private long serviceId;
public ServiceRegistryImpl(FrameworkImpl framework)
{
@@ -60,12 +63,12 @@
public ServiceRegistration registerService(Bundle bundle, String clazz, Object service, Dictionary properties)
{
- return registerServiceInternal(bundle, clazz, service, properties);
+ return registerServiceInternal(bundle, new String[] {clazz}, service, properties);
}
public ServiceRegistration registerService(Bundle bundle, String[] clazzes, Object service, Dictionary properties)
{
- throw new NotImplementedException();
+ return registerServiceInternal(bundle, clazzes, service, properties);
}
public ServiceReference getServiceReference(String clazz)
@@ -117,46 +120,65 @@
if (service instanceof ServiceFactory)
{
ServiceFactory factory = (ServiceFactory)service;
- factory.getService(bundle, srefImpl.getServiceRegistration());
+ service = factory.getService(bundle, srefImpl.getServiceRegistration());
}
// The service object for the service is returned.
-
return service;
}
- private ServiceRegistration registerServiceInternal(Bundle bundle, String clazz, Object service, Dictionary properties)
+ private ServiceRegistration registerServiceInternal(Bundle bundle, String[] clazzes, Object service, Dictionary<String, String> props)
{
// If service is not a ServiceFactory, an IllegalArgumentException is thrown if service
// is not an instanceof all the specified class names.
if ((service instanceof ServiceFactory) == false)
{
- try
+ for (String clazz : clazzes)
{
- Class<?> interf = bundle.loadClass(clazz);
- if (interf.isAssignableFrom(service.getClass()) == false)
- throw new IllegalArgumentException("Service is not assignable to: " + clazz);
+ try
+ {
+ Class<?> interf = bundle.loadClass(clazz);
+ if (interf.isAssignableFrom(service.getClass()) == false)
+ throw new IllegalArgumentException("Service is not assignable to: " + clazz);
+ }
+ catch (ClassNotFoundException ex)
+ {
+ throw new IllegalArgumentException("Cannot load service interface: " + clazz, ex);
+ }
}
- catch (ClassNotFoundException ex)
- {
- throw new IllegalArgumentException("Cannot load service interface: " + clazz, ex);
- }
}
- ServiceReferenceImpl sref = new ServiceReferenceImpl(bundle, service, properties);
-
// 2. The Framework adds the following service properties to the service properties from the specified Dictionary (which may be null):
// A property named Constants.SERVICE_ID identifying the registration number of the service
// A property named Constants.OBJECTCLASS containing all the specified classes.
+ Dictionary<String, Object> properties = new Hashtable<String, Object>();
+ properties.put(Constants.SERVICE_ID, new Long(serviceId++));
+ properties.put(Constants.OBJECTCLASS, clazzes);
+ if (props != null)
+ {
+ Enumeration<String> keys = props.keys();
+ while(keys.hasMoreElements())
+ {
+ String key = keys.nextElement();
+ Object value = props.get(key);
+ properties.put(key, value);
+ }
+ }
+
// 3. The service is added to the Framework service registry and may now be used by other bundles.
- List<ServiceReference> list = registry.get(clazz);
- if (list == null)
+ ServiceReferenceImpl sref = new ServiceReferenceImpl(bundle, service, properties);
+ for (String clazz : clazzes)
{
- list = new ArrayList<ServiceReference>();
- registry.put(clazz, list);
+ log.debug("Register Service: " + clazz);
+ List<ServiceReference> list = registry.get(clazz);
+ if (list == null)
+ {
+ list = new ArrayList<ServiceReference>();
+ registry.put(clazz, list);
+ }
+ list.add(sref);
}
- list.add(sref);
// 4. A service event of type ServiceEvent.REGISTERED is fired.
ServiceEventManager eventManager = framework.getServiceEventManager();
Modified: projects/jboss-osgi/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/pom.xml 2009-08-18 20:38:10 UTC (rev 92546)
+++ projects/jboss-osgi/trunk/testsuite/pom.xml 2009-08-18 21:32:41 UTC (rev 92547)
@@ -183,8 +183,24 @@
<name>!framework</name>
</property>
</activation>
+
+ <!-- default to jbossmc
+ <properties>
+ <jboss.osgi.framework.properties>jboss-osgi-jbossmc.properties</jboss.osgi.framework.properties>
+ </properties>
<dependencies>
<dependency>
+ <groupId>org.jboss.osgi.runtime</groupId>
+ <artifactId>jboss-osgi-runtime-jbossmc</artifactId>
+ <version>${version.jboss.osgi.runtime.jbossmc}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+ -->
+
+ <!-- default to felix -->
+ <dependencies>
+ <dependency>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-runtime-felix</artifactId>
<version>${version.jboss.osgi.runtime.felix}</version>
16 years, 11 months