[jboss-cvs] JBossAS SVN: r92857 - in projects/jboss-osgi/projects/runtime/microcontainer/trunk/src: main/java/org/jboss/osgi/plugins/facade/classloading and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Aug 27 06:20:06 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-08-27 06:20:06 -0400 (Thu, 27 Aug 2009)
New Revision: 92857
Modified:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiBundleClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/plugins/SystemPackagesPluginImpl.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleContextUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml
Log:
Added framework properties handling.
Removed ISE on metaData.getBundleSymbolicName()
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/AbstractBundleState.java 2009-08-27 09:12:02 UTC (rev 92856)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/AbstractBundleState.java 2009-08-27 10:20:06 UTC (rev 92857)
@@ -45,6 +45,7 @@
import org.jboss.osgi.plugins.filter.NoFilter;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.metadata.OSGiMetaData;
+import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.util.collection.ConcurrentSet;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
@@ -52,6 +53,7 @@
import org.osgi.framework.BundleEvent;
import org.osgi.framework.BundleException;
import org.osgi.framework.BundleListener;
+import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
@@ -134,7 +136,10 @@
public String getSymbolicName()
{
- return osgiMetaData.getBundleSymbolicName();
+ String symbolicName = osgiMetaData.getBundleSymbolicName();
+ if (symbolicName == null)
+ throw new IllegalStateException("Cannot obtain " + Constants.BUNDLE_SYMBOLICNAME);
+ return symbolicName;
}
public Version getVersion()
@@ -732,7 +737,7 @@
throw new IllegalArgumentException("Unknown bundle state: " + state);
}
this.state.set(state);
- log.debug(this + " change state=" + toHumanReadableStateString(state));
+ log.debug(this + " change state=" + ConstantsHelper.bundleState(state));
BundleEvent event = new BundleEvent(type, getBundleInternal());
fireBundleEvent(event);
}
@@ -915,32 +920,6 @@
}
/**
- * Get a human readable version of the state
- *
- * @param state the state
- * @return the human readable form
- */
- private static String toHumanReadableStateString(int state)
- {
- switch (state)
- {
- case Bundle.INSTALLED:
- return "INSTALLED";
- case Bundle.RESOLVED:
- return "RESOLVED";
- case Bundle.STARTING:
- return "STARTING";
- case Bundle.ACTIVE:
- return "ACTIVE";
- case Bundle.STOPPING:
- return "STOPPING";
- case Bundle.UNINSTALLED:
- return "UNINSTALLED";
- }
- return "???" + state;
- }
-
- /**
* ServiceListenerRegistration.
*/
private static class ServiceListenerRegistration
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java 2009-08-27 09:12:02 UTC (rev 92856)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java 2009-08-27 10:20:06 UTC (rev 92857)
@@ -75,38 +75,38 @@
public class OSGiBundleManager
{
/** The log */
- private static final Logger log = Logger.getLogger(OSGiBundleManager.class);
+ private static final Logger log = Logger.getLogger(OSGiBundleManager.class);
/** The bundle manager's bean name: OSGiBundleManager */
public static final String BEAN_BUNDLE_MANAGER = "OSGiBundleManager";
-
+
/** The framework version */
private static String OSGi_FRAMEWORK_VERSION = "r4v42"; // [TODO] externalise
-
+
/** The framework vendor */
private static String OSGi_FRAMEWORK_VENDOR = "jboss.org"; // [TODO] externalise
-
+
/** The framework language */
private static String OSGi_FRAMEWORK_LANGUAGE = Locale.getDefault().getISO3Language(); // REVIEW correct?
-
+
/** The os name */
private static String OSGi_FRAMEWORK_OS_NAME;
-
+
/** The os version */
private static String OSGi_FRAMEWORK_OS_VERSION;
-
+
/** The os version */
private static String OSGi_FRAMEWORK_PROCESSOR;
-
+
/** The bundles by id */
private Map<Long, AbstractBundleState> bundlesById = new ConcurrentHashMap<Long, AbstractBundleState>();
/** The registered services */
private Set<OSGiServiceState> registeredServices = new ConcurrentSet<OSGiServiceState>();
-
+
/** The main deployer */
private DeployerClient deployerClient;
-
+
/** The deployment structure */
private MainDeployerStructure deployerStructure;
@@ -115,30 +115,29 @@
/** The system bundle */
private OSGiSystemState systemBundle;
-
+
/** The registered manager plugins */
private Map<Class<?>, AbstractPlugin> plugins = new HashMap<Class<?>, AbstractPlugin>();
-
+
/** The frame work properties */
- @SuppressWarnings("unused") // [TODO] ????
private Map<String, Object> properties = new HashMap<String, Object>();
-
+
static
{
AccessController.doPrivileged(new PrivilegedAction<Object>()
{
public Object run()
{
- OSGi_FRAMEWORK_OS_NAME=System.getProperty("os.name");
- OSGi_FRAMEWORK_OS_VERSION=System.getProperty("os.version");
- OSGi_FRAMEWORK_PROCESSOR=System.getProperty("os.arch");
-
+ OSGi_FRAMEWORK_OS_NAME = System.getProperty("os.name");
+ OSGi_FRAMEWORK_OS_VERSION = System.getProperty("os.version");
+ OSGi_FRAMEWORK_PROCESSOR = System.getProperty("os.arch");
+
System.setProperty("org.osgi.vendor.framework", "org.jboss.osgi.plugins.framework");
return null;
}
});
}
-
+
/**
* Create a new OSGiBundleManager.
*
@@ -149,7 +148,7 @@
{
this(deployerClient, null);
}
-
+
/**
* Create a new OSGiBundleManager.
*
@@ -163,16 +162,16 @@
throw new IllegalArgumentException("Null deployerClient");
if (deployerClient instanceof MainDeployerStructure == false)
throw new IllegalArgumentException("Deployer client does not implement " + MainDeployerStructure.class.getName());
-
+
this.deployerClient = deployerClient;
this.deployerStructure = (MainDeployerStructure)deployerClient;
-
+
// TODO thread factory
if (executor == null)
executor = Executors.newFixedThreadPool(10);
-
+
this.executor = executor;
-
+
// Create the system bundle
createSystemBundle();
}
@@ -196,9 +195,51 @@
public void setProperties(Map<String, Object> properties)
{
this.properties = properties;
+
+ // Init default framework properties
+ if (getProperty(Constants.FRAMEWORK_VERSION) == null)
+ setProperty(Constants.FRAMEWORK_VERSION, OSGi_FRAMEWORK_VERSION);
+ if (getProperty(Constants.FRAMEWORK_VENDOR) == null)
+ setProperty(Constants.FRAMEWORK_VENDOR, OSGi_FRAMEWORK_VENDOR);
+ if (getProperty(Constants.FRAMEWORK_LANGUAGE) == null)
+ setProperty(Constants.FRAMEWORK_LANGUAGE, OSGi_FRAMEWORK_LANGUAGE);
+ if (getProperty(Constants.FRAMEWORK_OS_NAME) == null)
+ setProperty(Constants.FRAMEWORK_OS_NAME, OSGi_FRAMEWORK_OS_NAME);
+ if (getProperty(Constants.FRAMEWORK_OS_VERSION) == null)
+ setProperty(Constants.FRAMEWORK_OS_VERSION, OSGi_FRAMEWORK_OS_VERSION);
+ if (getProperty(Constants.FRAMEWORK_PROCESSOR) == null)
+ setProperty(Constants.FRAMEWORK_PROCESSOR, OSGi_FRAMEWORK_PROCESSOR);
}
/**
+ * Get a property
+ *
+ * @param key the property key
+ * @return the property
+ * @throws SecurityException if the caller doesn't have the relevant property permission
+ */
+ public String getProperty(String key)
+ {
+ Object value = properties.get(key);
+ if (value == null)
+ value = System.getProperty(key);
+
+ if (value instanceof String == false)
+ return null;
+
+ return (String)value;
+ }
+
+ /**
+ * Set a property.
+ * This is used at the frame work init state.
+ */
+ public void setProperty(String key, String value)
+ {
+ properties.put(key, value);
+ }
+
+ /**
* Get a plugin that is registered with the bundle manager.
*
* @param <T> the pluging type
@@ -227,7 +268,7 @@
{
return (T)plugins.get(clazz);
}
-
+
/**
* Add a plugin
*
@@ -245,7 +286,7 @@
}
}
}
-
+
/**
* Remove a plugin
*
@@ -263,7 +304,7 @@
}
}
}
-
+
/**
* Are we active
*
@@ -275,7 +316,7 @@
AbstractBundleState bundleState = getSystemBundle();
return bundleState.getState() >= Bundle.STARTING;
}
-
+
/**
* Install a bundle
*
@@ -287,7 +328,7 @@
{
if (url == null)
throw new BundleException("Null url");
-
+
try
{
VirtualFile root = VFS.getRoot(url);
@@ -312,7 +353,7 @@
throw new BundleException("Error installing bundle from location=" + url, e);
}
}
-
+
/**
* Install a bundle
*
@@ -324,7 +365,7 @@
{
if (file == null)
throw new BundleException("Null file");
-
+
try
{
VFSDeployment deployment = VFSDeploymentFactory.getInstance().createVFSDeployment(file);
@@ -348,7 +389,7 @@
throw new BundleException("Error installing bundle from location=" + file, e);
}
}
-
+
/**
* Uninstall a bundle
*
@@ -360,14 +401,14 @@
long id = bundle.getBundleId();
if (id == 0)
throw new IllegalArgumentException("Cannot uninstall system bundle");
-
+
OSGiBundleState state = (OSGiBundleState)getBundle(id);
if (state == null)
throw new BundleException(bundle + " not installed");
-
+
uninstall(state);
}
-
+
/**
* Uninstall a bundle
*
@@ -387,7 +428,7 @@
throw new BundleException("Unable to uninstall " + bundleState, e);
}
}
-
+
/**
* Add a deployment
*
@@ -423,7 +464,7 @@
addBundle(bundleState);
return bundleState;
}
-
+
/**
* Generate a name for the deployment unit
*
@@ -445,7 +486,7 @@
}
return result.toString();
}
-
+
/**
* Add a bundle
*
@@ -469,12 +510,12 @@
throw new IllegalStateException("Cannot install singleton " + bundleState + " another singleton is already installed: " + bundle);
}
}
-
+
bundleState.setBundleManager(this);
bundlesById.put(bundleState.getBundleId(), bundleState);
log.debug("Added " + bundleState.getCanonicalName() + " id=" + bundleState.getBundleId());
}
-
+
/**
* Remove a bundle
*
@@ -523,11 +564,11 @@
{
if (id == 0)
throw new IllegalArgumentException("Cannot get deployment from system bundle");
-
+
OSGiBundleState bundleState = (OSGiBundleState)getBundle(id);
if (bundleState == null)
return null;
-
+
return bundleState.getDeploymentUnit();
}
@@ -542,33 +583,6 @@
}
/**
- * Get a property
- *
- * @param key the property key
- * @return the property
- * @throws SecurityException if the caller doesn't have the relevant property permission
- */
- public String getProperty(String key)
- {
- if (key == null)
- return null;
- if (Constants.FRAMEWORK_VERSION.equals(key))
- return OSGi_FRAMEWORK_VERSION;
- if (Constants.FRAMEWORK_VENDOR.equals(key))
- return OSGi_FRAMEWORK_VENDOR;
- if (Constants.FRAMEWORK_LANGUAGE.equals(key))
- return OSGi_FRAMEWORK_LANGUAGE;
- if (Constants.FRAMEWORK_OS_NAME.equals(key))
- return OSGi_FRAMEWORK_OS_NAME;
- if (Constants.FRAMEWORK_OS_VERSION.equals(key))
- return OSGi_FRAMEWORK_OS_VERSION;
- if (Constants.FRAMEWORK_PROCESSOR.equals(key))
- return OSGi_FRAMEWORK_PROCESSOR;
-
- return System.getProperty(key);
- }
-
- /**
* Resolve a bundle
*
* @param bundleState the bundle state
@@ -586,7 +600,7 @@
catch (DeploymentException e)
{
if (errorOnFail)
- throw new IllegalStateException("Error resolving bundle: " + bundleState, e);
+ throw new IllegalStateException("Error resolving bundle: " + bundleState, e);
return false;
}
}
@@ -609,7 +623,7 @@
{
Throwable t = e.getCause();
if (t instanceof BundleException)
- throw (BundleException) t;
+ throw (BundleException)t;
throw new BundleException("Error starting " + bundleState, e);
}
}
@@ -624,13 +638,13 @@
{
try
{
- deployerClient.change(bundleState.getDeploymentUnit().getName(), DeploymentStages.CLASSLOADER);
+ deployerClient.change(bundleState.getDeploymentUnit().getName(), DeploymentStages.CLASSLOADER);
}
catch (DeploymentException e)
{
Throwable t = e.getCause();
if (t instanceof BundleException)
- throw (BundleException) t;
+ throw (BundleException)t;
throw new BundleException("Error stopping " + bundleState, e);
}
}
@@ -644,17 +658,17 @@
* @param checkAssignable whether to check isAssignable
* @return the services
*/
- Collection<OSGiServiceState> getServices(AbstractBundleState bundleState, String clazz, Filter filter, boolean checkAssignable)
+ Collection<OSGiServiceState> getServices(AbstractBundleState bundleState, String clazz, Filter filter, boolean checkAssignable)
{
if (filter == null)
filter = NoFilter.INSTANCE;
-
+
if (registeredServices.isEmpty())
return null;
// review: optimise this, e.g. index by class
// Use a sorted set to order services according to spec
- Set<OSGiServiceState> result = new TreeSet<OSGiServiceState>(ServiceComparator.INSTANCE);
+ Set<OSGiServiceState> result = new TreeSet<OSGiServiceState>(ServiceComparator.INSTANCE);
for (OSGiServiceState service : registeredServices)
{
// Check the state, filter and permission
@@ -679,15 +693,15 @@
* @param clazz any class
* @return the reference
*/
- ServiceReference getServiceReference(AbstractBundleState bundleState, String clazz)
+ ServiceReference getServiceReference(AbstractBundleState bundleState, String clazz)
{
// Ignore isAssignable for the system context
boolean checkAssignable = (bundleState.getBundleId() != 0);
-
+
Collection<OSGiServiceState> services = getServices(bundleState, clazz, null, checkAssignable);
if (services == null || services.isEmpty())
return null;
-
+
OSGiServiceState service = services.iterator().next();
return service.getReferenceInternal();
}
@@ -701,7 +715,7 @@
* @param checkAssignable whether to check isAssignable
* @return the services
*/
- ServiceReference[] getServiceReferences(AbstractBundleState bundleState, String clazz, Filter filter, boolean checkAssignable)
+ ServiceReference[] getServiceReferences(AbstractBundleState bundleState, String clazz, Filter filter, boolean checkAssignable)
{
Collection<OSGiServiceState> services = getServices(bundleState, clazz, filter, checkAssignable);
if (services == null || services.isEmpty())
@@ -763,7 +777,7 @@
registeredServices.remove(serviceState);
serviceState.internalUnregister();
}
-
+
/**
* Get a service
*
@@ -773,14 +787,14 @@
*/
Object getService(AbstractBundleState bundleState, ServiceReference reference)
{
- OSGiServiceReferenceWrapper serviceReference = (OSGiServiceReferenceWrapper) reference;
+ OSGiServiceReferenceWrapper serviceReference = (OSGiServiceReferenceWrapper)reference;
OSGiServiceState serviceState = serviceReference.getServiceState();
Object result = serviceState.getService();
if (result != null)
bundleState.addServiceInUse(serviceState);
return result;
}
-
+
/**
* Unget a service
*
@@ -792,11 +806,11 @@
{
if (reference == null)
throw new IllegalArgumentException("Null reference");
- OSGiServiceReferenceWrapper serviceReference = (OSGiServiceReferenceWrapper) reference;
+ OSGiServiceReferenceWrapper serviceReference = (OSGiServiceReferenceWrapper)reference;
OSGiServiceState serviceState = serviceReference.getServiceState();
return ungetService(bundleState, serviceState);
}
-
+
/**
* Unget a service
*
@@ -808,7 +822,7 @@
{
return bundleState.removeServiceInUse(service);
}
-
+
/**
* Get the executor.
*
@@ -818,14 +832,14 @@
{
return executor;
}
-
+
/**
* Init the Framework
*/
public void initFramework()
{
int state = systemBundle.getState();
-
+
// This method does nothing if called when this Framework is in the STARTING, ACTIVE or STOPPING state
if (state == Bundle.STARTING || state == Bundle.ACTIVE || state == Bundle.STOPPING)
return;
@@ -854,10 +868,10 @@
// If this Framework is not in the STARTING state, initialize this Framework
if (systemBundle.getState() != Bundle.STARTING)
initFramework();
-
+
// Create the system bundl context
systemBundle.createBundleContext();
-
+
// All installed bundles must be started
AutoInstallPlugin autoInstall = getOptionalPlugin(AutoInstallPlugin.class);
if (autoInstall != null)
@@ -868,11 +882,11 @@
// This Framework's state is set to ACTIVE
systemBundle.changeState(Bundle.ACTIVE);
-
+
// A framework event of type STARTED is fired
systemBundle.fireFrameworkEvent(FrameworkEvent.STARTED, null);
}
-
+
/**
* Stop the framework
*/
@@ -881,7 +895,7 @@
AbstractBundleState systemBundle = getSystemBundle();
if (systemBundle.getState() != Bundle.ACTIVE)
return;
-
+
systemBundle.changeState(Bundle.STOPPING);
for (AbstractBundleState bundle : getBundles())
{
@@ -900,7 +914,7 @@
}
systemBundle.changeState(Bundle.RESOLVED);
}
-
+
/**
* Stop the framework
*/
@@ -947,7 +961,7 @@
systemBundle.fireFrameworkEvent(FrameworkEvent.ERROR, t);
else if (bundleState != null)
systemBundle.fireFrameworkEvent(FrameworkEvent.ERROR, new BundleException("Error " + context + " bundle: " + bundleState.getCanonicalName(), t));
- else
+ else
systemBundle.fireFrameworkEvent(FrameworkEvent.ERROR, new BundleException("Error " + context, t));
}
@@ -963,17 +977,17 @@
systemBundle.fireFrameworkEvent(FrameworkEvent.WARNING, t);
else if (bundleState != null)
systemBundle.fireFrameworkEvent(FrameworkEvent.WARNING, new BundleException("Error " + context + " bundle: " + bundleState.getCanonicalName(), t));
- else
+ else
systemBundle.fireFrameworkEvent(FrameworkEvent.WARNING, new BundleException("Error " + context, t));
}
-
+
/**
* ServiceComparator, reverses the order of compareTo
*/
static class ServiceComparator implements Comparator<OSGiServiceState>
{
public static ServiceComparator INSTANCE = new ServiceComparator();
-
+
public int compare(OSGiServiceState o1, OSGiServiceState o2)
{
return -o1.compareTo(o2);
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiBundleClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiBundleClassLoadingDeployer.java 2009-08-27 09:12:02 UTC (rev 92856)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiBundleClassLoadingDeployer.java 2009-08-27 10:20:06 UTC (rev 92857)
@@ -21,7 +21,6 @@
*/
package org.jboss.osgi.plugins.facade.classloading;
-import java.util.ArrayList;
import java.util.List;
import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/plugins/SystemPackagesPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/plugins/SystemPackagesPluginImpl.java 2009-08-27 09:12:02 UTC (rev 92856)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/plugins/SystemPackagesPluginImpl.java 2009-08-27 10:20:06 UTC (rev 92857)
@@ -30,6 +30,7 @@
import org.jboss.logging.Logger;
import org.jboss.osgi.plugins.facade.api.SystemPackagesPlugin;
import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
+import org.osgi.framework.Constants;
/**
* A plugin that installs/starts bundles on framework startup.
@@ -42,11 +43,6 @@
// Provide logging
final Logger log = Logger.getLogger(SystemPackagesPluginImpl.class);
- /** The configured system packages */
- private List<String> systemPackages = new ArrayList<String>();
- /** The configured extra system packages */
- private List<String> extraPackages = new ArrayList<String>();
-
/** The derived combination of all system packages */
private List<String> allPackages = new ArrayList<String>();
/** The derived combination of all system packages without version specifier */
@@ -57,28 +53,31 @@
super(bundleManager);
}
- public void setSystemPackages(List<String> systemPackages)
- {
- this.systemPackages = systemPackages;
- }
- public void setExtraPackages(List<String> extraPackages)
- {
- this.extraPackages = extraPackages;
- }
-
public void start()
{
- if (systemPackages.size() == 0)
+ String systemPackages = bundleManager.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES);
+ if (systemPackages != null)
{
- systemPackages.add("javax.management");
- systemPackages.add("org.osgi.framework");
- systemPackages.add("org.osgi.service.startlevel");
- systemPackages.add("org.osgi.service.packageadmin");
- systemPackages.add("org.osgi.util.tracker");
+ allPackages.addAll(packagesAsList(systemPackages));
}
+ else
+ {
+ // The default system packages
+ allPackages.add("javax.management");
+ allPackages.add("org.osgi.framework");
+ allPackages.add("org.osgi.service.startlevel");
+ allPackages.add("org.osgi.service.packageadmin");
+ allPackages.add("org.osgi.util.tracker");
+
+ String asString = packagesAsString(allPackages);
+ bundleManager.setProperty(Constants.FRAMEWORK_SYSTEMPACKAGES, asString);
+ }
- allPackages.addAll(systemPackages);
- allPackages.addAll(extraPackages);
+ String extraPackages = bundleManager.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA);
+ if (extraPackages != null)
+ {
+ allPackages.addAll(packagesAsList(extraPackages));
+ }
Collections.sort(allPackages);
@@ -109,4 +108,26 @@
return allPackageNames.contains(name);
}
+
+ private String packagesAsString(List<String> sysPackages)
+ {
+ StringBuffer result = new StringBuffer();
+ for (int i = 0; i < sysPackages.size(); i++)
+ {
+ if (i > 0)
+ result.append(",");
+ result.append(sysPackages.get(i));
+ }
+ return result.toString();
+ }
+
+ private List<String> packagesAsList(String sysPackages)
+ {
+ List<String> result = new ArrayList<String>();
+ for (String name : sysPackages.split(","))
+ {
+ result.add(name);
+ }
+ return result;
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java 2009-08-27 09:12:02 UTC (rev 92856)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/metadata/AbstractOSGiMetaData.java 2009-08-27 10:20:06 UTC (rev 92857)
@@ -181,9 +181,6 @@
if (symbolicName == null)
symbolicName = getMainAttribute(Constants.BUNDLE_SYMBOLICNAME);
- if (symbolicName == null)
- throw new IllegalStateException("Cannot obtain " + Constants.BUNDLE_SYMBOLICNAME);
-
return symbolicName;
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleContextUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleContextUnitTestCase.java 2009-08-27 09:12:02 UTC (rev 92856)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleContextUnitTestCase.java 2009-08-27 10:20:06 UTC (rev 92857)
@@ -181,8 +181,8 @@
bundle.start();
BundleContext bundleContext = bundle.getBundleContext();
assertNotNull(bundleContext);
- assertEquals("r4v42", bundleContext.getProperty(Constants.FRAMEWORK_VERSION)); // TODO externalise
- assertEquals("jboss.org", bundleContext.getProperty(Constants.FRAMEWORK_VENDOR)); // TODO externalise
+ assertEquals("r4v42", bundleContext.getProperty(Constants.FRAMEWORK_VERSION));
+ assertEquals("jboss.org", bundleContext.getProperty(Constants.FRAMEWORK_VENDOR));
assertEquals(Locale.getDefault().getISO3Language(), bundleContext.getProperty(Constants.FRAMEWORK_LANGUAGE));
assertSystemProperty(bundleContext, "os.name", Constants.FRAMEWORK_OS_NAME);
assertSystemProperty(bundleContext, "os.version", Constants.FRAMEWORK_OS_VERSION);
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml 2009-08-27 09:12:02 UTC (rev 92856)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml 2009-08-27 10:20:06 UTC (rev 92857)
@@ -14,6 +14,16 @@
<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>
+ <entry>
+ <key>org.osgi.framework.system.packages.extra</key>
+ <value>
+ org.jboss.logging;version=2.0,
+ org.jboss.osgi.spi.logging;version=1.0,
+ org.jboss.osgi.spi.management;version=1.0,
+ org.jboss.osgi.spi.service;version=1.0,
+ org.jboss.osgi.spi.util;version=1.0
+ </value>
+ </entry>
</map>
</property>
<incallback method="addPlugin" />
@@ -22,17 +32,7 @@
<bean name="OSGiSystemPackages" class="org.jboss.osgi.plugins.facade.plugins.SystemPackagesPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
- <property name="extraPackages">
- <list elementClass="java.lang.String">
- <value>org.jboss.logging;version=2.0</value>
- <value>org.jboss.osgi.spi.logging;version=1.0</value>
- <value>org.jboss.osgi.spi.management;version=1.0</value>
- <value>org.jboss.osgi.spi.service;version=1.0</value>
- <value>org.jboss.osgi.spi.util;version=1.0</value>
- </list>
- </property>
</bean>
-
<bean name="OSGiStoragePlugin" class="org.jboss.osgi.plugins.facade.plugins.BundleStoragePluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
More information about the jboss-cvs-commits
mailing list