JBoss-OSGI SVN: r98958 - in projects/jboss-osgi/projects/runtime/framework/trunk/src: main/java/org/jboss/osgi/framework/deployers and 8 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-31 10:51:37 -0500 (Thu, 31 Dec 2009)
New Revision: 98958
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/invalid01/
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/invalid01/META-INF/
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/invalid01/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/invalid02/
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/invalid02/META-INF/
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/invalid02/META-INF/MANIFEST.MF
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateAddDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java
Log:
Work on bundle validation.
Initial fragment support.
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-30 22:48:50 UTC (rev 98957)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-31 15:51:37 UTC (rev 98958)
@@ -29,6 +29,7 @@
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.HashSet;
@@ -71,7 +72,7 @@
import org.osgi.framework.Version;
/**
- * BundleState.
+ * The abstract state of all bundles.
*
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @author Thomas.Diesler(a)jboss.com
@@ -153,6 +154,8 @@
return state.get();
}
+ public abstract boolean isFragment();
+
public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType)
{
throw new NotImplementedException();
@@ -350,7 +353,10 @@
}
// Get the entry without checking permissions and bundle state.
- abstract URL getEntryInternal(String path);
+ protected URL getEntryInternal(String path)
+ {
+ return null;
+ }
public String getProperty(String key)
{
@@ -418,7 +424,10 @@
*
* @return the registered contexts
*/
- protected abstract Set<ControllerContext> getRegisteredContexts();
+ protected Set<ControllerContext> getRegisteredContexts()
+ {
+ return Collections.emptySet();
+ }
public ServiceReference[] getRegisteredServices()
{
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java 2009-12-31 15:51:37 UTC (rev 98958)
@@ -0,0 +1,158 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.bundle;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.osgi.deployment.deployer.Deployment;
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
+
+/**
+ * The abstract state of a deployed bundle or fragment.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 25-Dec-2009
+ */
+public abstract class AbstractDeployedBundleState extends AbstractBundleState
+{
+ /** Used to generate a unique id */
+ private static final AtomicLong bundleIDGenerator = new AtomicLong();
+
+ /** The bundle id */
+ private long bundleId;
+
+ /** The bundle location */
+ private String location;
+
+ /** The bundle root file */
+ private VirtualFile rootFile;
+
+ /** The list of deployment units */
+ private List<DeploymentUnit> units = new ArrayList<DeploymentUnit>();
+
+ /** The headers localized with the default locale */
+ Dictionary<String, String> headersOnUninstall;
+
+ /**
+ * Create a new BundleState.
+ *
+ * @param unit the deployment unit
+ * @throws IllegalArgumentException for a null parameter
+ */
+ public AbstractDeployedBundleState(DeploymentUnit unit)
+ {
+ if (unit == null)
+ throw new IllegalArgumentException("Null deployment unit");
+
+ // The bundle location is not necessarily the bundle root url
+ // The framework is expected to preserve the location passed into installBundle(String)
+ Deployment dep = unit.getAttachment(Deployment.class);
+ location = (dep != null ? dep.getLocation() : unit.getName());
+ rootFile = (dep != null ? dep.getRoot() : ((VFSDeploymentUnit)unit).getRoot());
+
+ bundleId = bundleIDGenerator.incrementAndGet();
+
+ addDeploymentUnit(unit);
+ }
+
+ /**
+ * Get the root file for this bundle
+ */
+ public VirtualFile getRoot()
+ {
+ return rootFile;
+ }
+
+ @Override
+ public OSGiMetaData getOSGiMetaData()
+ {
+ DeploymentUnit unit = getDeploymentUnit();
+ OSGiMetaData osgiMetaData = unit.getAttachment(OSGiMetaData.class);
+ return osgiMetaData;
+ }
+
+ public long getBundleId()
+ {
+ return bundleId;
+ }
+
+ /**
+ * Get the DeploymentUnit that was added last.
+ *
+ * Initially, an OSGiBundleState is associated with just one DeploymentUnit.
+ * A sucessful call to {@link #update()} or its variants pushes an additional
+ * DeploymentUnit to the stack.
+ *
+ * @return the unit that corresponds to the last sucessful update.
+ */
+ public DeploymentUnit getDeploymentUnit()
+ {
+ int index = (units.size() - 1);
+ return units.get(index);
+ }
+
+ /**
+ * Add a DeploymentUnit to the list.
+ *
+ * @see {@link OSGiBundleManager#updateBundle(DeployedBundleState, InputStream)}
+ */
+ void addDeploymentUnit(DeploymentUnit unit)
+ {
+ unit.getMutableMetaData().addMetaData(unit, DeploymentUnit.class);
+ units.add(unit);
+ }
+
+ /**
+ * Get the list of DeploymentUnits.
+ *
+ * @see {@link OSGiBundleManager#uninstallBundle(DeployedBundleState)}
+ */
+ List<DeploymentUnit> getDeploymentUnits()
+ {
+ return Collections.unmodifiableList(units);
+ }
+
+ public String getLocation()
+ {
+ return location;
+ }
+
+ @Override
+ public Dictionary<String, String> getHeaders(String locale)
+ {
+ // This method must continue to return Manifest header information while this bundle is in the UNINSTALLED state,
+ // however the header values must only be available in the raw and default locale values
+ if (getState() == Bundle.UNINSTALLED)
+ return headersOnUninstall;
+
+ return super.getHeaders(locale);
+ }
+}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-30 22:48:50 UTC (rev 98957)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-31 15:51:37 UTC (rev 98958)
@@ -91,8 +91,8 @@
import org.jboss.osgi.framework.plugins.ServicePlugin;
import org.jboss.osgi.framework.util.NoFilter;
import org.jboss.osgi.framework.util.URLHelper;
-import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.util.BundleInfo;
+import org.jboss.util.platform.Java;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VFSUtils;
import org.jboss.virtual.VirtualFile;
@@ -126,10 +126,8 @@
/** 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";
- /** The framework vendor */
- private static String OSGi_FRAMEWORK_VENDOR = "jboss.org";
+ /** The framework execution environment */
+ private static String OSGi_FRAMEWORK_EXECUTIONENVIRONMENT;
/** The framework language */
private static String OSGi_FRAMEWORK_LANGUAGE = Locale.getDefault().getISO3Language(); // REVIEW correct?
/** The os name */
@@ -138,8 +136,12 @@
private static String OSGi_FRAMEWORK_OS_VERSION;
/** The os version */
private static String OSGi_FRAMEWORK_PROCESSOR;
+ /** The framework vendor */
+ private static String OSGi_FRAMEWORK_VENDOR = "jboss.org";
+ /** The framework version */
+ private static String OSGi_FRAMEWORK_VERSION = "r4v42";
/** The bundles by id */
- private List<AbstractBundleState> bundles = new CopyOnWriteArrayList<AbstractBundleState>();
+ private List<AbstractBundleState> allBundles = new CopyOnWriteArrayList<AbstractBundleState>();
/** The kernel */
private Kernel kernel;
/** The main deployer */
@@ -167,6 +169,16 @@
{
public Object run()
{
+ List<String> execEnvironments = new ArrayList<String>();
+ if (Java.isCompatible(Java.VERSION_1_5))
+ execEnvironments.add("J2SE-1.5");
+ if (Java.isCompatible(Java.VERSION_1_6))
+ execEnvironments.add("JavaSE-1.6");
+
+ String envlist = execEnvironments.toString();
+ envlist = envlist.substring(1, envlist.length() - 1);
+ OSGi_FRAMEWORK_EXECUTIONENVIRONMENT = envlist;
+
OSGi_FRAMEWORK_OS_NAME = System.getProperty("os.name");
OSGi_FRAMEWORK_OS_VERSION = System.getProperty("os.version");
OSGi_FRAMEWORK_PROCESSOR = System.getProperty("os.arch");
@@ -359,9 +371,24 @@
OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
if (bundleState == null)
{
+ OSGiMetaData osgiMetaData = unit.getAttachment(OSGiMetaData.class);
+ if (osgiMetaData == null)
+ {
+ Manifest manifest = unit.getAttachment(Manifest.class);
+ // [TODO] we need a mechanism to construct an OSGiMetaData from an easier factory
+ if (manifest == null)
+ manifest = new Manifest();
+ // [TODO] populate some bundle information
+ Attributes attributes = manifest.getMainAttributes();
+ attributes.put(new Name(Constants.BUNDLE_NAME), unit.getName());
+ attributes.put(new Name(Constants.BUNDLE_SYMBOLICNAME), unit.getName());
+ osgiMetaData = new AbstractOSGiMetaData(manifest);
+ unit.addAttachment(OSGiMetaData.class, osgiMetaData);
+ }
+
try
{
- bundleState = addDeployment(unit);
+ bundleState = (OSGiBundleState)addDeployment(unit);
bundleState.startInternal();
unit.addAttachment(OSGiBundleState.class, bundleState);
}
@@ -425,10 +452,8 @@
properties.putAll(props);
// 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_EXECUTIONENVIRONMENT) == null)
+ setProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, OSGi_FRAMEWORK_EXECUTIONENVIRONMENT);
if (getProperty(Constants.FRAMEWORK_LANGUAGE) == null)
setProperty(Constants.FRAMEWORK_LANGUAGE, OSGi_FRAMEWORK_LANGUAGE);
if (getProperty(Constants.FRAMEWORK_OS_NAME) == null)
@@ -437,6 +462,10 @@
setProperty(Constants.FRAMEWORK_OS_VERSION, OSGi_FRAMEWORK_OS_VERSION);
if (getProperty(Constants.FRAMEWORK_PROCESSOR) == null)
setProperty(Constants.FRAMEWORK_PROCESSOR, OSGi_FRAMEWORK_PROCESSOR);
+ if (getProperty(Constants.FRAMEWORK_VENDOR) == null)
+ setProperty(Constants.FRAMEWORK_VENDOR, OSGi_FRAMEWORK_VENDOR);
+ if (getProperty(Constants.FRAMEWORK_VERSION) == null)
+ setProperty(Constants.FRAMEWORK_VERSION, OSGi_FRAMEWORK_VERSION);
}
/**
@@ -686,9 +715,17 @@
if (location == null)
throw new IllegalArgumentException("Null location");
- BundleInfo info = BundleInfo.createBundleInfo(root, location);
- Deployment dep = DeploymentFactory.createDeployment(info);
- dep.setAutoStart(autoStart);
+ Deployment dep;
+ try
+ {
+ BundleInfo info = BundleInfo.createBundleInfo(root, location);
+ dep = DeploymentFactory.createDeployment(info);
+ dep.setAutoStart(autoStart);
+ }
+ catch (RuntimeException ex)
+ {
+ throw new BundleException("Cannot install bundle: " + root, ex);
+ }
return installBundle(dep);
}
@@ -710,11 +747,16 @@
MutableAttachments att = (MutableAttachments)deployment.getPredeterminedManagedObjects();
att.addAttachment(Deployment.class, dep);
+ // In case of update the OSGiBundleState is attached
+ OSGiBundleState bundleState = dep.getAttachment(OSGiBundleState.class);
+ if (bundleState != null)
+ att.addAttachment(OSGiBundleState.class, bundleState);
+
deployerClient.deploy(deployment);
try
{
DeploymentUnit unit = deployerStructure.getDeploymentUnit(deployment.getName());
- OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
+ bundleState = unit.getAttachment(OSGiBundleState.class);
if (bundleState == null)
throw new IllegalStateException("Unable to determine bundle state for " + deployment.getName());
@@ -740,11 +782,11 @@
private String getIncompleteDeploymentInfo(Deployment dep, IncompleteDeploymentException ex)
{
IncompleteDeployments deployments = ex.getIncompleteDeployments();
-
+
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
printWriter.println("Error installing bundle from: " + dep);
-
+
// Contexts in error
Collection<Throwable> contextsError = deployments.getContextsInError().values();
if (contextsError.size() > 0)
@@ -905,12 +947,27 @@
public void uninstallBundle(OSGiBundleState bundleState) throws BundleException
{
long id = bundleState.getBundleId();
- if (id == 0)
- throw new IllegalArgumentException("Cannot uninstall system bundle");
-
if (getBundleById(id) == null)
throw new BundleException(bundleState + " not installed");
+ // If this bundle's state is ACTIVE, STARTING or STOPPING, this bundle is stopped
+ // as described in the Bundle.stop method.
+ int state = bundleState.getState();
+ if (state == Bundle.ACTIVE || state == Bundle.STARTING || state == Bundle.STOPPING)
+ {
+ try
+ {
+ stopBundle(bundleState);
+ }
+ catch (Exception ex)
+ {
+ // If Bundle.stop throws an exception, a Framework event of type FrameworkEvent.ERROR is
+ // fired containing the exception
+ fireError(bundleState, "Error stopping bundle: " + bundleState, ex);
+ }
+ }
+
+ DeploymentException depEx = null;
for (DeploymentUnit unit : bundleState.getDeploymentUnits())
{
try
@@ -918,11 +975,21 @@
deployerClient.undeploy(unit.getName());
bundleState.updateLastModified();
}
- catch (DeploymentException e)
+ catch (DeploymentException ex)
{
- throw new BundleException("Unable to uninstall " + bundleState, e);
+ log.error("Cannot undeploy: " + unit.getName(), depEx = ex);
}
}
+
+ // Rethrow deployment exception
+ if (depEx != null)
+ {
+ Throwable cause = depEx.getCause();
+ if (cause instanceof BundleException)
+ throw (BundleException)cause;
+
+ throw new BundleException("Unable to uninstall " + bundleState, cause);
+ }
}
/**
@@ -932,39 +999,41 @@
* @return the bundle state
* @throws IllegalArgumentException for a null parameter
*/
- public OSGiBundleState addDeployment(DeploymentUnit unit)
+ public AbstractDeployedBundleState addDeployment(DeploymentUnit unit)
{
if (unit == null)
throw new IllegalArgumentException("Null unit");
- OSGiMetaData osgiMetaData = unit.getAttachment(OSGiMetaData.class);
- if (osgiMetaData == null)
+ // In case of Bundle.update() the OSGiBundleState is attached
+ AbstractDeployedBundleState absBundle = unit.getAttachment(OSGiBundleState.class);
+ if (absBundle != null)
{
- Manifest manifest = unit.getAttachment(Manifest.class);
- // [TODO] we need a mechanism to construct an OSGiMetaData from an easier factory
- if (manifest == null)
- manifest = new Manifest();
- // [TODO] populate some bundle information
- Attributes attributes = manifest.getMainAttributes();
- attributes.put(new Name(Constants.BUNDLE_NAME), unit.getName());
- attributes.put(new Name(Constants.BUNDLE_SYMBOLICNAME), unit.getName());
- osgiMetaData = new AbstractOSGiMetaData(manifest);
- unit.addAttachment(OSGiMetaData.class, osgiMetaData);
+ // Add the DeploymentUnit to the OSGiBundleState
+ absBundle.addDeploymentUnit(unit);
}
-
- // In case of Bundle.update() the OSGiBundleState should be attached. We add the DeploymentUnit
- Deployment dep = unit.getAttachment(Deployment.class);
- OSGiBundleState bundleState = (dep != null ? dep.getAttachment(OSGiBundleState.class) : null);
- if (bundleState != null)
- bundleState.addDeploymentUnit(unit);
-
- // Create a new OSGiBundleState and add it to the manager
- if (bundleState == null)
+ else
{
- bundleState = new OSGiBundleState(unit);
- addBundle(bundleState);
+ OSGiMetaData osgiMetaData = unit.getAttachment(OSGiMetaData.class);
+ ParameterizedAttribute fragmentHost = osgiMetaData.getFragmentHost();
+ if (fragmentHost != null)
+ {
+ // Create a new OSGiFragmentState
+ OSGiFragmentState fragmentBundle = new OSGiFragmentState(unit);
+ unit.addAttachment(OSGiFragmentState.class, fragmentBundle);
+ absBundle = fragmentBundle;
+ addBundle(fragmentBundle);
+ }
+ else
+ {
+ // Create a new OSGiBundleState
+ OSGiBundleState bundleState = new OSGiBundleState(unit);
+ unit.addAttachment(OSGiBundleState.class, bundleState);
+ absBundle = bundleState;
+ addBundle(bundleState);
+ }
}
- return bundleState;
+
+ return absBundle;
}
/**
@@ -1004,7 +1073,7 @@
validateBundle(bundleState);
bundleState.setBundleManager(this);
- bundles.add(bundleState);
+ allBundles.add(bundleState);
// Only fire the INSTALLED event if this is not an update
boolean fireEvent = true;
@@ -1037,13 +1106,9 @@
if (osgiMetaData == null)
return;
- ParameterizedAttribute fragmentHost = osgiMetaData.getFragmentHost();
- if (fragmentHost != null)
- throw new NotImplementedException("Fragments not implemented: " + fragmentHost);
-
// Delegate to the validator for the appropriate revision
OSGiBundleValidator validator = new OSGiBundleValidatorR3(this);
- if(osgiMetaData.getBundleManifestVersion() > 1)
+ if (osgiMetaData.getBundleManifestVersion() > 1)
validator = new OSGiBundleValidatorR4(this);
validator.validateBundle(bundleState);
@@ -1068,7 +1133,7 @@
if (bundleResolver != null)
bundleResolver.removeBundle(bundleState);
- bundles.remove(bundleState);
+ allBundles.remove(bundleState);
log.debug("Removed " + bundleState.getCanonicalName());
}
@@ -1119,7 +1184,7 @@
public AbstractBundleState getBundleById(long id)
{
AbstractBundleState result = null;
- for (AbstractBundleState aux : bundles)
+ for (AbstractBundleState aux : allBundles)
{
if (id == aux.getBundleId())
{
@@ -1140,7 +1205,7 @@
public AbstractBundleState getBundle(String symbolicName, Version version)
{
AbstractBundleState result = null;
- for (AbstractBundleState aux : bundles)
+ for (AbstractBundleState aux : allBundles)
{
String auxName = aux.getSymbolicName();
Version auxVersion = aux.getVersion();
@@ -1184,7 +1249,7 @@
AbstractBundleState result = null;
- for (AbstractBundleState aux : bundles)
+ for (AbstractBundleState aux : allBundles)
{
String auxLocation = aux.getLocation();
if (location.equals(auxLocation))
@@ -1214,6 +1279,12 @@
*/
public Collection<AbstractBundleState> getBundles()
{
+ List<AbstractBundleState> bundles = new ArrayList<AbstractBundleState>();
+ for (AbstractBundleState aux : allBundles)
+ {
+ if (aux.isFragment() == false)
+ bundles.add(aux);
+ }
return Collections.unmodifiableList(bundles);
}
@@ -1226,12 +1297,12 @@
public Collection<AbstractBundleState> getBundles(int state)
{
List<AbstractBundleState> bundles = new ArrayList<AbstractBundleState>();
- for (AbstractBundleState aux : getBundles())
+ for (AbstractBundleState aux : allBundles)
{
- if (aux.getState() == state)
+ if (aux.isFragment() == false && aux.getState() == state)
bundles.add(aux);
}
- return bundles;
+ return Collections.unmodifiableList(bundles);
}
/**
@@ -1241,12 +1312,39 @@
* @param errorOnFail whether to throw an error if it cannot be resolved
* @return true when resolved
*/
- public boolean resolveBundle(OSGiBundleState bundleState, boolean errorOnFail)
+ public boolean resolveBundle(OSGiBundleState bundleState, boolean errorOnFail) throws BundleException
{
int state = bundleState.getState();
if (state != Bundle.INSTALLED)
return true;
+ // A bundle can only resolve if the framework is running on a VM which
+ // implements one of the listed required execution environments.
+ List<String> reqExecEnvironments = bundleState.getOSGiMetaData().getRequiredExecutionEnvironment();
+ if (reqExecEnvironments != null)
+ {
+ boolean foundExecEnv = false;
+ String fwExecEnvs = getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
+ for (String aux : reqExecEnvironments)
+ {
+ if (fwExecEnvs.contains(aux))
+ {
+ foundExecEnv = true;
+ break;
+ }
+ }
+
+ if (foundExecEnv == false)
+ {
+ String msg = "Cannot find any of the required execution environments " + reqExecEnvironments + ", we have: " + fwExecEnvs;
+ if (errorOnFail == true)
+ throw new BundleException(msg);
+
+ log.error(msg);
+ return false;
+ }
+ }
+
DeploymentUnit unit = bundleState.getDeploymentUnit();
ControllerContext context = unit.getAttachment(ControllerContext.class);
@@ -1267,7 +1365,7 @@
context.setRequiredState(requiredState);
if (errorOnFail)
- throw new IllegalStateException("Error resolving bundle: " + bundleState, ex);
+ throw new BundleException("Error resolving bundle: " + bundleState, ex);
return false;
}
@@ -1333,6 +1431,7 @@
deployerClient.change(unit.getName(), DeploymentStages.CLASSLOADER);
deployerClient.checkComplete(unit.getName());
+ // Rethrow the attached BundleException
throw startEx;
}
}
@@ -1381,6 +1480,7 @@
BundleException stopEx = unit.removeAttachment(BundleException.class);
if (stopEx != null)
{
+ // Rethrow the attached BundleException
throw stopEx;
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-12-30 22:48:50 UTC (rev 98957)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-12-31 15:51:37 UTC (rev 98958)
@@ -24,18 +24,13 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
-import java.util.List;
import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.plugins.PackageAdminPlugin;
import org.jboss.virtual.VirtualFile;
@@ -53,26 +48,8 @@
* @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
* @version $Revision: 1.1 $
*/
-public class OSGiBundleState extends AbstractBundleState
+public class OSGiBundleState extends AbstractDeployedBundleState
{
- /** Used to generate a unique id */
- private static final AtomicLong bundleIDGenerator = new AtomicLong();
-
- /** The bundle id */
- private long bundleId;
-
- /** The bundle location */
- private String location;
-
- /** The bundle root file */
- private VirtualFile rootFile;
-
- /** The list of deployment units */
- private List<DeploymentUnit> units = new ArrayList<DeploymentUnit>();
-
- /** The headers localized with the default locale */
- Dictionary<String, String> headersOnUninstall;
-
/**
* Create a new BundleState.
*
@@ -81,18 +58,7 @@
*/
public OSGiBundleState(DeploymentUnit unit)
{
- if (unit == null)
- throw new IllegalArgumentException("Null deployment unit");
-
- // The bundle location is not necessarily the bundle root url
- // The framework is expected to preserve the location passed into installBundle(String)
- Deployment dep = unit.getAttachment(Deployment.class);
- location = (dep != null ? dep.getLocation() : unit.getName());
- rootFile = (dep != null ? dep.getRoot() : ((VFSDeploymentUnit)unit).getRoot());
-
- bundleId = bundleIDGenerator.incrementAndGet();
-
- addDeploymentUnit(unit);
+ super(unit);
}
/**
@@ -108,73 +74,16 @@
return (OSGiBundleState)bundle;
}
- /**
- * Get the root file for this bundle
- */
- public VirtualFile getRoot()
+ public boolean isFragment()
{
- return rootFile;
+ return false;
}
-
- @Override
- public OSGiMetaData getOSGiMetaData()
- {
- DeploymentUnit unit = getDeploymentUnit();
- OSGiMetaData osgiMetaData = unit.getAttachment(OSGiMetaData.class);
- return osgiMetaData;
- }
-
+
protected Set<ControllerContext> getRegisteredContexts()
{
return getBundleManager().getRegisteredContext(this);
}
- public long getBundleId()
- {
- return bundleId;
- }
-
- /**
- * Get the DeploymentUnit that was added last.
- *
- * Initially, an OSGiBundleState is associated with just one DeploymentUnit.
- * A sucessful call to {@link #update()} or its variants pushes an additional
- * DeploymentUnit to the stack.
- *
- * @return the unit that corresponds to the last sucessful update.
- */
- public DeploymentUnit getDeploymentUnit()
- {
- int index = (units.size() - 1);
- return units.get(index);
- }
-
- /**
- * Add a DeploymentUnit to the list.
- *
- * @see {@link OSGiBundleManager#updateBundle(OSGiBundleState, InputStream)}
- */
- void addDeploymentUnit(DeploymentUnit unit)
- {
- unit.getMutableMetaData().addMetaData(unit, DeploymentUnit.class);
- units.add(unit);
- }
-
- /**
- * Get the list of DeploymentUnits.
- *
- * @see {@link OSGiBundleManager#uninstallBundle(OSGiBundleState)}
- */
- List<DeploymentUnit> getDeploymentUnits()
- {
- return Collections.unmodifiableList(units);
- }
-
- public String getLocation()
- {
- return location;
- }
-
public URL getEntry(String path)
{
checkInstalled();
@@ -184,9 +93,8 @@
return getEntryInternal(path);
}
- // Get the entry without checking permissions and bundle state.
@Override
- URL getEntryInternal(String path)
+ protected URL getEntryInternal(String path)
{
DeploymentUnit unit = getDeploymentUnit();
if (unit instanceof VFSDeploymentUnit)
@@ -523,6 +431,10 @@
public void uninstall() throws BundleException
{
checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
+
+ // If this bundle's state is UNINSTALLED then an IllegalStateException is thrown
+ if (getState() == Bundle.UNINSTALLED)
+ throw new IllegalStateException("Bundle already uninstalled: " + this);
// Cache the headers in the default locale
headersOnUninstall = getHeaders(null);
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiFragmentState.java 2009-12-31 15:51:37 UTC (rev 98958)
@@ -0,0 +1,113 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.bundle;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.osgi.framework.BundleException;
+
+/**
+ * OSGiSystemBundle.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 25-Dec-2009
+ */
+public class OSGiFragmentState extends AbstractDeployedBundleState
+{
+ /**
+ * Create a new OSGiFragmentState
+ */
+ public OSGiFragmentState(DeploymentUnit unit)
+ {
+ super(unit);
+ }
+
+ public boolean isFragment()
+ {
+ return true;
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Enumeration findEntries(String path, String filePattern, boolean recurse)
+ {
+ throw new NotImplementedException();
+ }
+
+ public URL getEntry(String path)
+ {
+ throw new NotImplementedException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Enumeration getEntryPaths(String path)
+ {
+ throw new NotImplementedException();
+ }
+
+ public URL getResource(String name)
+ {
+ throw new NotImplementedException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Enumeration getResources(String name) throws IOException
+ {
+ throw new NotImplementedException();
+ }
+
+ @SuppressWarnings("rawtypes")
+ public Class loadClass(String name) throws ClassNotFoundException
+ {
+ throw new NotImplementedException();
+ }
+
+ public void start(int options) throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+
+ public void stop(int options) throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+
+ public void update() throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+
+ public void update(InputStream input) throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+
+ @Override
+ public void uninstall() throws BundleException
+ {
+ throw new NotImplementedException();
+ }
+}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java 2009-12-30 22:48:50 UTC (rev 98957)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java 2009-12-31 15:51:37 UTC (rev 98958)
@@ -70,6 +70,11 @@
return osgiMetaData;
}
+ public boolean isFragment()
+ {
+ return false;
+ }
+
protected Set<ControllerContext> getRegisteredContexts()
{
return registered;
@@ -133,13 +138,6 @@
public URL getEntry(String path)
{
- return getEntryInternal(path);
- }
-
- // Get the entry without checking permissions and bundle state.
- @Override
- URL getEntryInternal(String path)
- {
log.warn("[JBOSGI-138] getEntry(" + path + ")");
return null;
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateAddDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateAddDeployer.java 2009-12-30 22:48:50 UTC (rev 98957)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateAddDeployer.java 2009-12-31 15:51:37 UTC (rev 98958)
@@ -22,11 +22,9 @@
package org.jboss.osgi.framework.deployers;
import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStage;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
/**
@@ -43,9 +41,6 @@
*/
public class OSGiBundleStateAddDeployer extends AbstractOSGiBundleStateDeployer
{
- /** The required stage */
- private DeploymentStage requiredStage;
-
/**
* Create a new BundleStateDeployer.
*
@@ -56,26 +51,14 @@
{
super(bundleManager);
setInput(OSGiMetaData.class);
- this.requiredStage = DeploymentStages.DESCRIBE;
}
@Override
protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
{
// [TODO] look at manifest headers and persistent state for this
- unit.setRequiredStage(requiredStage);
+ unit.setRequiredStage(DeploymentStages.DESCRIBE);
- OSGiBundleState bundleState = bundleManager.addDeployment(unit);
- unit.addAttachment(OSGiBundleState.class, bundleState);
+ bundleManager.addDeployment(unit);
}
-
- /**
- * Set required stage.
- *
- * @param stage the required stage
- */
- public void setRequiredStage(String stage)
- {
- requiredStage = new DeploymentStage(stage);
- }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java 2009-12-30 22:48:50 UTC (rev 98957)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/internal/FrameworkEventsPluginImpl.java 2009-12-31 15:51:37 UTC (rev 98958)
@@ -376,6 +376,18 @@
{
listener.frameworkEvent(event);
}
+ catch (RuntimeException ex)
+ {
+ log.warn("Error while firing " + typeName + " for framework", ex);
+
+ // The Framework must publish a FrameworkEvent.ERROR if a callback to an
+ // event listener generates an unchecked exception - except when the callback
+ // happens while delivering a FrameworkEvent.ERROR
+ if (type != FrameworkEvent.ERROR)
+ {
+ fireFrameworkEvent(bundle, FrameworkEvent.ERROR, ex);
+ }
+ }
catch (Throwable t)
{
log.warn("Error while firing " + typeName + " for framework", t);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2009-12-30 22:48:50 UTC (rev 98957)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2009-12-31 15:51:37 UTC (rev 98958)
@@ -47,6 +47,7 @@
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.Version;
import org.osgi.service.packageadmin.ExportedPackage;
@@ -229,11 +230,19 @@
while (it.hasNext())
{
OSGiBundleState bundleState = it.next();
- if (bundleManager.resolveBundle(bundleState, false))
+ try
{
- it.remove();
- resolved++;
+ boolean bundleResolved = bundleManager.resolveBundle(bundleState, false);
+ if (bundleResolved)
+ {
+ it.remove();
+ resolved++;
+ }
}
+ catch (BundleException ex)
+ {
+ // ignore
+ }
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java 2009-12-30 22:48:50 UTC (rev 98957)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleLifecycleTestCase.java 2009-12-31 15:51:37 UTC (rev 98958)
@@ -27,8 +27,10 @@
import org.jboss.test.osgi.bundle.support.a.FailOnStartActivator;
import org.jboss.test.osgi.bundle.support.b.LifecycleService;
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
/**
* BundleLifecycleTestCase.
@@ -51,16 +53,16 @@
/**
* Verifies that the service bundle can get started
*/
- public void testServiceBundle() throws Exception
+ public void testSimpleStart() throws Exception
{
Bundle bundleA = installBundle(assembleBundle("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class));
try
{
assertBundleState(Bundle.INSTALLED, bundleA.getState());
-
+
bundleA.start();
assertBundleState(Bundle.ACTIVE, bundleA.getState());
-
+
ServiceReference sref = bundleA.getBundleContext().getServiceReference(LifecycleService.class.getName());
assertNotNull("Service available", sref);
}
@@ -70,17 +72,17 @@
assertBundleState(Bundle.UNINSTALLED, bundleA.getState());
}
}
-
+
/**
* Verifies that the bundle state is RESOLVED after a failure in BundleActivator.start()
*/
- public void testServiceNotAvailable() throws Exception
+ public void testDependencyNotAvailable() throws Exception
{
Bundle bundleA = installBundle(assembleBundle("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class));
try
{
assertBundleState(Bundle.INSTALLED, bundleA.getState());
-
+
// BundleA not started - service not available
ServiceReference sref = getSystemBundle().getBundleContext().getServiceReference(LifecycleService.class.getName());
assertNull("Service not available", sref);
@@ -89,7 +91,7 @@
try
{
assertBundleState(Bundle.INSTALLED, bundleB.getState());
-
+
bundleB.start();
fail("BundleException expected");
}
@@ -113,7 +115,7 @@
/**
* Verifies that BundleB can get started when the service is available
*/
- public void testServiceAvailable() throws Exception
+ public void testDependencyAvailable() throws Exception
{
Bundle bundleA = installBundle(assembleBundle("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class));
try
@@ -143,18 +145,18 @@
/**
* Verifies that BundleB can get started when the service is made available
*/
- public void testServiceMakeAvailable() throws Exception
+ public void testStartRetry() throws Exception
{
Bundle bundleA = installBundle(assembleBundle("lifecycle-service", "/bundles/lifecycle/simple-service", LifecycleService.class));
try
{
assertBundleState(Bundle.INSTALLED, bundleA.getState());
-
+
Bundle bundleB = installBundle(assembleBundle("lifecycle-failstart", "/bundles/lifecycle/fail-on-start", FailOnStartActivator.class));
try
{
assertBundleState(Bundle.INSTALLED, bundleB.getState());
-
+
try
{
bundleB.start();
@@ -163,12 +165,12 @@
catch (BundleException ex)
{
assertBundleState(Bundle.RESOLVED, bundleB.getState());
-
+
// Now, make the service available
bundleA.start();
assertBundleState(Bundle.ACTIVE, bundleA.getState());
}
-
+
// BundleB can now be started
bundleB.start();
assertBundleState(Bundle.ACTIVE, bundleB.getState());
@@ -185,4 +187,59 @@
assertBundleState(Bundle.UNINSTALLED, bundleA.getState());
}
}
+
+ /**
+ * Verifies that BundleB is still INSTALLED after a failure in PackageAdmin.resolve()
+ */
+ public void testFailToResolve() throws Exception
+ {
+ Bundle bundleB = installBundle(assembleBundle("lifecycle-failstart", "/bundles/lifecycle/fail-on-start", FailOnStartActivator.class));
+ try
+ {
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
+
+ // Get the PackageAdmin service
+ BundleContext sysContext = getSystemBundle().getBundleContext();
+ ServiceReference sref = sysContext.getServiceReference(PackageAdmin.class.getName());
+ PackageAdmin packageAdmin = (PackageAdmin)sysContext.getService(sref);
+
+ // Attempt to explicitly resolve a bundle with missing dependency
+ boolean allResolved = packageAdmin.resolveBundles(new Bundle[] { bundleB });
+ assertFalse("Resolve fails", allResolved);
+
+ // Verify that the bundkle is still in state INSTALLED
+ assertBundleState(Bundle.INSTALLED, bundleB.getState());
+ }
+ finally
+ {
+ bundleB.uninstall();
+ assertBundleState(Bundle.UNINSTALLED, bundleB.getState());
+ }
+ }
+
+ /**
+ * Verifies that we get a BundleException when an invalid bundle is installed
+ */
+ public void testInstallInvalid() throws Exception
+ {
+ try
+ {
+ installBundle(assembleBundle("missing-symbolic-name", "/bundles/lifecycle/invalid01"));
+ fail("BundleException expected");
+ }
+ catch (BundleException ex)
+ {
+ // expected
+ }
+
+ try
+ {
+ installBundle(assembleBundle("invalid-export", "/bundles/lifecycle/invalid02"));
+ fail("BundleException expected");
+ }
+ catch (BundleException ex)
+ {
+ // expected
+ }
+ }
}
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/invalid01/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/invalid01/META-INF/MANIFEST.MF (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/invalid01/META-INF/MANIFEST.MF 2009-12-31 15:51:37 UTC (rev 98958)
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/invalid02/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/invalid02/META-INF/MANIFEST.MF (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/invalid02/META-INF/MANIFEST.MF 2009-12-31 15:51:37 UTC (rev 98958)
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: invalid-export
+Export-Package: java.lang
+
+
14 years, 4 months
JBoss-OSGI SVN: r98041 - projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-20 03:40:51 -0500 (Sun, 20 Dec 2009)
New Revision: 98041
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java
Log:
javadoc
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java 2009-12-20 08:39:02 UTC (rev 98040)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java 2009-12-20 08:40:51 UTC (rev 98041)
@@ -205,10 +205,6 @@
if (entryURL == null)
throw new DeploymentException("Cannot find native library: " + nativeLib);
- // Get the library name key
- String libfile = new File(nativeLib).getName();
- String libname = libfile.substring(0, libfile.lastIndexOf('.'));
-
// Copy the native library to the bundle storage area
File nativeFileCopy;
try
@@ -225,6 +221,10 @@
throw new DeploymentException("Cannot copy native library: " + nativeLib, ex);
}
+ // Generate the key for the library mapping
+ String libfile = new File(nativeLib).getName();
+ String libname = libfile.substring(0, libfile.lastIndexOf('.'));
+
// Add the native library mapping to the OSGiClassLoaderPolicy
OSGiClassLoaderPolicy policy = (OSGiClassLoaderPolicy)unit.getAttachment(ClassLoaderPolicy.class);
policy.addLibraryMapping(libname, nativeFileCopy);
14 years, 4 months
JBoss-OSGI SVN: r98040 - in projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework: deployers and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-20 03:39:02 -0500 (Sun, 20 Dec 2009)
New Revision: 98040
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java
Log:
Copy the native library to the bundle storage area
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2009-12-20 03:56:40 UTC (rev 98039)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2009-12-20 08:39:02 UTC (rev 98040)
@@ -23,8 +23,7 @@
// $Id$
-import java.net.URL;
-import java.util.Collections;
+import java.io.File;
import java.util.HashMap;
import java.util.Map;
@@ -47,7 +46,7 @@
*/
public class OSGiClassLoaderPolicy extends VFSClassLoaderPolicy
{
- private Map<String, URL> libraryMap = new HashMap<String, URL>();
+ private Map<String, File> libraryMap = new HashMap<String, File>();
public OSGiClassLoaderPolicy(OSGiBundleState bundleState, VirtualFile[] roots)
{
@@ -74,24 +73,19 @@
setDelegates(vfsModule.getDelegates());
}
- public Map<String, URL> getLibraryMapppings()
+ public void addLibraryMapping(String libname, File libfile)
{
- return Collections.unmodifiableMap(libraryMap);
+ libraryMap.put(libname, libfile);
}
- public void addLibraryMapping(String libname, URL liburl)
- {
- libraryMap.put(libname, liburl);
- }
-
public String findLibrary(String libname)
{
- URL liburl = libraryMap.get(libname);
+ File libfile = libraryMap.get(libname);
// [TODO] why does the TCK use 'Native' to mean 'libNative' ?
- if (liburl == null)
- liburl = libraryMap.get("lib" + libname);
+ if (libfile == null)
+ libfile = libraryMap.get("lib" + libname);
- return (liburl != null ? liburl.toExternalForm() : null);
+ return (libfile != null ? libfile.getAbsolutePath() : null);
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java 2009-12-20 03:56:40 UTC (rev 98039)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java 2009-12-20 08:39:02 UTC (rev 98040)
@@ -24,6 +24,8 @@
// $Id: $
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
@@ -43,6 +45,9 @@
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.Parameter;
import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
+import org.jboss.osgi.framework.plugins.BundleStoragePlugin;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
import org.osgi.framework.Constants;
/**
@@ -201,11 +206,27 @@
throw new DeploymentException("Cannot find native library: " + nativeLib);
// Get the library name key
- String libname = new File(nativeLib).getName();
- libname = libname.substring(0, libname.lastIndexOf('.'));
+ String libfile = new File(nativeLib).getName();
+ String libname = libfile.substring(0, libfile.lastIndexOf('.'));
+ // Copy the native library to the bundle storage area
+ File nativeFileCopy;
+ try
+ {
+ VirtualFile nativeVirtualFile = bundleState.getRoot().getChild(nativeLib);
+ BundleStoragePlugin plugin = bundleManager.getPlugin(BundleStoragePlugin.class);
+ nativeFileCopy = plugin.getDataFile(bundleState, nativeLib);
+ FileOutputStream fos = new FileOutputStream(nativeFileCopy);
+ VFSUtils.copyStream(nativeVirtualFile.openStream(), fos);
+ fos.close();
+ }
+ catch (IOException ex)
+ {
+ throw new DeploymentException("Cannot copy native library: " + nativeLib, ex);
+ }
+
// Add the native library mapping to the OSGiClassLoaderPolicy
OSGiClassLoaderPolicy policy = (OSGiClassLoaderPolicy)unit.getAttachment(ClassLoaderPolicy.class);
- policy.addLibraryMapping(libname, entryURL);
+ policy.addLibraryMapping(libname, nativeFileCopy);
}
}
14 years, 4 months
JBoss-OSGI SVN: r98038 - in projects/jboss-osgi/projects/runtime/framework/trunk/src: main/java/org/jboss/osgi/framework/bundle and 5 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-19 18:46:53 -0500 (Sat, 19 Dec 2009)
New Revision: 98038
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java
Removed:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoadingDeployer.java
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR3.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR4.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderSystem.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverBundleImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml
Log:
Add initial support for native code libraries
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml 2009-12-19 23:46:53 UTC (rev 98038)
@@ -143,6 +143,7 @@
<bean name="OSGiBundleStateRemoveDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleStateRemoveDeployer">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="OSGiBundleNativeCodeDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleNativeCodeDeployer" />
<bean name="OSGiBundleActivatorDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleActivatorDeployer" />
<bean name="OSGiContextTrackerDeployer" class="org.jboss.osgi.framework.deployers.OSGiContextTrackerDeployer" />
@@ -163,7 +164,7 @@
<bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
<property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
</bean>
- <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
+ <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -128,7 +128,7 @@
public String getSymbolicName()
{
- String symbolicName = getMetaData().getBundleSymbolicName();
+ String symbolicName = getOSGiMetaData().getBundleSymbolicName();
if (symbolicName == null)
symbolicName = "anonymous-bundle" + getBundleId();
@@ -137,7 +137,7 @@
public Version getVersion()
{
- String versionstr = getMetaData().getBundleVersion();
+ String versionstr = getOSGiMetaData().getBundleVersion();
try
{
return Version.parseVersion(versionstr);
@@ -232,7 +232,7 @@
*
* @return the osgiMetaData.
*/
- public abstract OSGiMetaData getMetaData();
+ public abstract OSGiMetaData getOSGiMetaData();
@SuppressWarnings("rawtypes")
public Dictionary getHeaders()
@@ -248,7 +248,7 @@
checkAdminPermission(AdminPermission.METADATA);
// Get the raw (unlocalized) manifest headers
- Dictionary<String, String> rawHeaders = getMetaData().getHeaders();
+ Dictionary<String, String> rawHeaders = getOSGiMetaData().getHeaders();
// If the specified locale is the empty string, this method will return the
// raw (unlocalized) manifest headers including any leading "%"
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -127,9 +127,9 @@
/** 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
+ private static String OSGi_FRAMEWORK_VERSION = "r4v42";
/** The framework vendor */
- private static String OSGi_FRAMEWORK_VENDOR = "jboss.org"; // [TODO] externalise
+ private static String OSGi_FRAMEWORK_VENDOR = "jboss.org";
/** The framework language */
private static String OSGi_FRAMEWORK_LANGUAGE = Locale.getDefault().getISO3Language(); // REVIEW correct?
/** The os name */
@@ -805,7 +805,7 @@
{
// If the specified InputStream is null, the Framework must create the InputStream from which to read the updated bundle by interpreting,
// in an implementation dependent manner, this bundle's Bundle-UpdateLocation Manifest header, if present, or this bundle's original location.
- URL updateURL = bundleState.getMetaData().getBundleUpdateLocation();
+ URL updateURL = bundleState.getOSGiMetaData().getBundleUpdateLocation();
if (updateURL == null)
{
// This updates the bundle from its original location
@@ -937,8 +937,8 @@
if (unit == null)
throw new IllegalArgumentException("Null unit");
- OSGiMetaData metaData = unit.getAttachment(OSGiMetaData.class);
- if (metaData == null)
+ OSGiMetaData osgiMetaData = unit.getAttachment(OSGiMetaData.class);
+ if (osgiMetaData == null)
{
Manifest manifest = unit.getAttachment(Manifest.class);
// [TODO] we need a mechanism to construct an OSGiMetaData from an easier factory
@@ -948,8 +948,8 @@
Attributes attributes = manifest.getMainAttributes();
attributes.put(new Name(Constants.BUNDLE_NAME), unit.getName());
attributes.put(new Name(Constants.BUNDLE_SYMBOLICNAME), unit.getName());
- metaData = new AbstractOSGiMetaData(manifest);
- unit.addAttachment(OSGiMetaData.class, metaData);
+ osgiMetaData = new AbstractOSGiMetaData(manifest);
+ unit.addAttachment(OSGiMetaData.class, osgiMetaData);
}
// In case of Bundle.update() the OSGiBundleState should be attached. We add the DeploymentUnit
@@ -1033,17 +1033,17 @@
*/
private void validateBundle(AbstractBundleState bundleState)
{
- OSGiMetaData metaData = bundleState.getMetaData();
- if (metaData == null)
+ OSGiMetaData osgiMetaData = bundleState.getOSGiMetaData();
+ if (osgiMetaData == null)
return;
- ParameterizedAttribute fragmentHost = metaData.getFragmentHost();
+ ParameterizedAttribute fragmentHost = osgiMetaData.getFragmentHost();
if (fragmentHost != null)
throw new NotImplementedException("Fragments not implemented: " + fragmentHost);
// Delegate to the validator for the appropriate revision
OSGiBundleValidator validator = new OSGiBundleValidatorR3(this);
- if(metaData.getBundleManifestVersion() > 1)
+ if(osgiMetaData.getBundleManifestVersion() > 1)
validator = new OSGiBundleValidatorR4(this);
validator.validateBundle(bundleState);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -117,11 +117,11 @@
}
@Override
- public OSGiMetaData getMetaData()
+ public OSGiMetaData getOSGiMetaData()
{
DeploymentUnit unit = getDeploymentUnit();
- OSGiMetaData metadata = unit.getAttachment(OSGiMetaData.class);
- return metadata;
+ OSGiMetaData osgiMetaData = unit.getAttachment(OSGiMetaData.class);
+ return osgiMetaData;
}
protected Set<ControllerContext> getRegisteredContexts()
@@ -351,12 +351,12 @@
// The BundleActivator.start(org.osgi.framework.BundleContext) method of this bundle's BundleActivator, if one is specified, is called.
try
{
- OSGiMetaData metaData = getMetaData();
- if (metaData == null)
+ OSGiMetaData osgiMetaData = getOSGiMetaData();
+ if (osgiMetaData == null)
throw new IllegalStateException("Cannot obtain OSGi meta data");
// Do we have a bundle activator
- String bundleActivatorClassName = metaData.getBundleActivator();
+ String bundleActivatorClassName = osgiMetaData.getBundleActivator();
if (bundleActivatorClassName != null)
{
Object result = loadClass(bundleActivatorClassName).newInstance();
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR3.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR3.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR3.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -37,8 +37,8 @@
public void validateBundle(AbstractBundleState bundleState)
{
- OSGiMetaData metaData = bundleState.getMetaData();
- int manifestVersion = metaData.getBundleManifestVersion();
+ OSGiMetaData osgiMetaData = bundleState.getOSGiMetaData();
+ int manifestVersion = osgiMetaData.getBundleManifestVersion();
if (manifestVersion != 1)
throw new IllegalStateException("Unsupported manifest version " + manifestVersion + " for " + bundleState);
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR4.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR4.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR4.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -47,7 +47,7 @@
@SuppressWarnings("deprecation")
public void validateBundle(AbstractBundleState bundleState)
{
- OSGiMetaData metaData = bundleState.getMetaData();
+ OSGiMetaData osgiMetaData = bundleState.getOSGiMetaData();
// Missing Bundle-SymbolicName
String symbolicName = bundleState.getSymbolicName();
@@ -55,14 +55,14 @@
throw new IllegalStateException("Missing Bundle-SymbolicName in: " + bundleState);
// Bundle-ManifestVersion value not equal to 2, unless the Framework specifically recognizes the semantics of a later release.
- int manifestVersion = metaData.getBundleManifestVersion();
+ int manifestVersion = osgiMetaData.getBundleManifestVersion();
if (manifestVersion > 2)
throw new IllegalStateException("Unsupported manifest version " + manifestVersion + " for " + bundleState);
// [TODO] Duplicate attribute or duplicate directive (except in the Bundle-Native code clause).
// Multiple imports of a given package.
- List<PackageAttribute> importPackages = metaData.getImportPackages();
+ List<PackageAttribute> importPackages = osgiMetaData.getImportPackages();
if (importPackages != null && importPackages.isEmpty() == false)
{
Set<String> packages = new HashSet<String>();
@@ -84,7 +84,7 @@
}
// Export or import of java.*.
- List<PackageAttribute> exportPackages = metaData.getExportPackages();
+ List<PackageAttribute> exportPackages = osgiMetaData.getExportPackages();
if (exportPackages != null && exportPackages.isEmpty() == false)
{
for (PackageAttribute packageAttribute : exportPackages)
@@ -100,12 +100,12 @@
// Installing a bundle that has the same symbolic name and version as an already installed bundle.
for (AbstractBundleState bundle : bundleManager.getBundles())
{
- OSGiMetaData other = bundle.getMetaData();
+ OSGiMetaData other = bundle.getOSGiMetaData();
if (symbolicName.equals(other.getBundleSymbolicName()))
{
- if (other.isSingleton() && metaData.isSingleton())
+ if (other.isSingleton() && osgiMetaData.isSingleton())
throw new IllegalStateException("Cannot install singleton " + bundleState + " another singleton is already installed: " + bundle.getLocation());
- if (other.getBundleVersion().equals(metaData.getBundleVersion()))
+ if (other.getBundleVersion().equals(osgiMetaData.getBundleVersion()))
throw new IllegalStateException("Cannot install " + bundleState + " a bundle with that name and version is already installed: "
+ bundle.getLocation());
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -65,7 +65,7 @@
}
@Override
- public OSGiMetaData getMetaData()
+ public OSGiMetaData getOSGiMetaData()
{
return osgiMetaData;
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -90,7 +90,7 @@
*/
public OSGiMetaData getMetaData()
{
- return bundleState.getMetaData();
+ return bundleState.getOSGiMetaData();
}
@Override
@@ -104,8 +104,8 @@
// Review its not clear to me from the spec whether attribute matching
// beyond the version should work for require-bundle?
OSGiBundleRequirement bundleRequirement = (OSGiBundleRequirement) requirement;
- OSGiMetaData metaData = getMetaData();
- ParameterizedAttribute ourParameters = metaData.getBundleParameters();
+ OSGiMetaData osgiMetaData = getMetaData();
+ ParameterizedAttribute ourParameters = osgiMetaData.getBundleParameters();
ParameterizedAttribute otherParameters = bundleRequirement.getRequireBundle();
if (otherParameters != null)
{
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.classloading;
+
+// $Id: OSGiClassLoaderFactory.java 95177 2009-10-20 15:14:31Z thomas.diesler(a)jboss.com $
+
+import org.jboss.classloader.spi.ClassLoaderPolicy;
+import org.jboss.classloader.spi.base.BaseClassLoader;
+import org.jboss.osgi.framework.deployers.OSGiBundleNativeCodeDeployer;
+
+/**
+ * An OSGi bundle class loader.
+ *
+ * This implementation supports the notion of OSGi Native Code Libraries.
+ * The library map is initialized in {@link OSGiBundleNativeCodeDeployer}.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 19-Dec-2209
+ */
+public class OSGiBundleClassLoader extends BaseClassLoader
+{
+ private OSGiClassLoaderPolicy osgiPolicy;
+
+ public OSGiBundleClassLoader(ClassLoaderPolicy policy)
+ {
+ super(policy);
+
+ if (policy instanceof OSGiClassLoaderPolicy)
+ osgiPolicy = (OSGiClassLoaderPolicy)policy;
+ }
+
+ @Override
+ protected String findLibrary(String libname)
+ {
+ String libraryPath = null;
+
+ if (osgiPolicy != null)
+ libraryPath = osgiPolicy.findLibrary(libname);
+
+ if (libraryPath == null)
+ libraryPath = super.findLibrary(libname);
+
+ return libraryPath;
+ }
+
+}
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoadingDeployer.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoadingDeployer.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -1,152 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file 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.framework.classloading;
-
-// $Id: $
-
-import java.util.List;
-
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.classloading.spi.metadata.RequirementsMetaData;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.ClassLoaderFactory;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.framework.metadata.PackageAttribute;
-import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
-import org.jboss.osgi.framework.plugins.SystemPackagesPlugin;
-
-/**
- * OSGiBundleClassLoadingDeployer.<p>
- *
- * This deployer maps osgi metadata into our classloading metadata.
- *
- * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
- * @author Thomas.Diesler(a)jboss.com
- * @version $Revision: 1.1 $
- */
-public class OSGiBundleClassLoadingDeployer extends AbstractSimpleRealDeployer<OSGiMetaData>
-{
- private ClassLoaderDomain domain;
- private ClassLoaderFactory factory;
-
- /**
- * Create a new OSGiBundleClassLoadingDeployer.
- */
- public OSGiBundleClassLoadingDeployer()
- {
- super(OSGiMetaData.class);
- addInput(OSGiBundleState.class);
- setOutput(ClassLoadingMetaData.class);
- setStage(DeploymentStages.POST_PARSE);
- setTopLevelOnly(true);
- }
-
- public void setDomain(ClassLoaderDomain domain)
- {
- this.domain = domain;
- }
-
- public void setFactory(ClassLoaderFactory factory)
- {
- this.factory = factory;
- }
-
- @Override
- public void deploy(DeploymentUnit unit, OSGiMetaData osgiMetaData) throws DeploymentException
- {
- if (unit.isAttachmentPresent(ClassLoadingMetaData.class))
- return;
-
- OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
- if (bundleState == null)
- throw new IllegalStateException("No bundle state");
-
- OSGiBundleManager bundleManager = bundleState.getBundleManager();
-
- ClassLoadingMetaData classLoadingMetaData = new ClassLoadingMetaData();
- classLoadingMetaData.setName(bundleState.getSymbolicName());
- classLoadingMetaData.setVersion(bundleState.getVersion());
- classLoadingMetaData.setDomain(domain != null ? domain.getName() : null);
-
- CapabilitiesMetaData capabilities = classLoadingMetaData.getCapabilities();
- RequirementsMetaData requirements = classLoadingMetaData.getRequirements();
-
- OSGiBundleCapability capability = OSGiBundleCapability.create(bundleState);
- capabilities.addCapability(capability);
-
- List<ParameterizedAttribute> requireBundles = osgiMetaData.getRequireBundles();
- if (requireBundles != null && requireBundles.isEmpty() == false)
- {
- for (ParameterizedAttribute requireBundle : requireBundles)
- {
- OSGiBundleRequirement requirement = OSGiBundleRequirement.create(requireBundle);
- requirements.addRequirement(requirement);
- }
- }
-
- List<PackageAttribute> exported = osgiMetaData.getExportPackages();
- if (exported != null && exported.isEmpty() == false)
- {
- for (PackageAttribute packageAttribute : exported)
- {
- OSGiPackageCapability packageCapability = OSGiPackageCapability.create(bundleState, packageAttribute);
- capabilities.addCapability(packageCapability);
- }
- }
-
- List<PackageAttribute> imported = osgiMetaData.getImportPackages();
- if (imported != null && imported.isEmpty() == false)
- {
- SystemPackagesPlugin syspackPlugin = bundleManager.getPlugin(SystemPackagesPlugin.class);
- for (PackageAttribute packageAttribute : imported)
- {
- String packageName = packageAttribute.getAttribute();
-
- // [TODO] Should system packages be added as capabilities?
- boolean isSystemPackage = syspackPlugin.isSystemPackage(packageName);
- if (isSystemPackage == false)
- {
- OSGiPackageRequirement requirement = OSGiPackageRequirement.create(bundleState, packageAttribute);
- requirements.addRequirement(requirement);
- }
- }
- }
-
- // Add the OSGi ClassLoaderFactory if configured
- if (factory != null)
- unit.addAttachment(ClassLoaderFactory.class, factory);
-
- // [TODO] dynamic imports
-
- unit.addAttachment(ClassLoadingMetaData.class, classLoadingMetaData);
-
- // AnnotationMetaDataDeployer.ANNOTATION_META_DATA_COMPLETE
- unit.addAttachment("org.jboss.deployment.annotation.metadata.complete", Boolean.TRUE);
- }
-}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -71,7 +71,9 @@
VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
VirtualFile[] roots = getClassLoaderPolicyRoots(bundleState, vfsUnit);
- return new OSGiClassLoaderPolicy(bundleState, roots);
+ ClassLoaderPolicy policy = new OSGiClassLoaderPolicy(bundleState, roots);
+ unit.addAttachment(ClassLoaderPolicy.class, policy);
+ return policy;
}
private VirtualFile[] getClassLoaderPolicyRoots(OSGiBundleState bundleState, VFSDeploymentUnit vfsUnit)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -23,24 +23,36 @@
// $Id$
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
import org.jboss.classloading.spi.dependency.Module;
import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.deployers.OSGiBundleNativeCodeDeployer;
import org.jboss.virtual.VirtualFile;
/**
- * OSGiClassLoaderPolicy
+ * The ClassLoaderPolicy for OSGi bundles.
*
+ * This implementation supports the notion of OSGi Native Code Libraries.
+ * The library map is initialized in {@link OSGiBundleNativeCodeDeployer}.
+ *
* @author Thomas.Diesler(a)jboss.com
* @since 11-Sep-2209
*/
public class OSGiClassLoaderPolicy extends VFSClassLoaderPolicy
{
+ private Map<String, URL> libraryMap = new HashMap<String, URL>();
+
public OSGiClassLoaderPolicy(OSGiBundleState bundleState, VirtualFile[] roots)
{
super(roots);
+
if (bundleState == null)
throw new IllegalArgumentException("Null bundleState");
@@ -61,4 +73,25 @@
setBlackListable(vfsModule.isBlackListable());
setDelegates(vfsModule.getDelegates());
}
+
+ public Map<String, URL> getLibraryMapppings()
+ {
+ return Collections.unmodifiableMap(libraryMap);
+ }
+
+ public void addLibraryMapping(String libname, URL liburl)
+ {
+ libraryMap.put(libname, liburl);
+ }
+
+ public String findLibrary(String libname)
+ {
+ URL liburl = libraryMap.get(libname);
+
+ // [TODO] why does the TCK use 'Native' to mean 'libNative' ?
+ if (liburl == null)
+ liburl = libraryMap.get("lib" + libname);
+
+ return (liburl != null ? liburl.toExternalForm() : null);
+ }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderSystem.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderSystem.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderSystem.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -24,8 +24,10 @@
import org.jboss.classloader.plugins.filter.PatternClassFilter;
import org.jboss.classloader.plugins.jdk.AbstractJDKChecker;
import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderPolicy;
import org.jboss.classloader.spi.ClassLoaderSystem;
import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloader.spi.base.BaseClassLoader;
import org.jboss.classloader.spi.filter.ClassFilterUtils;
import org.jboss.classloader.spi.filter.RecursivePackageClassFilter;
import org.jboss.osgi.framework.bundle.AbstractBundleState;
@@ -60,4 +62,10 @@
{
return new ClassLoaderDomain(name);
}
+
+ @Override
+ protected BaseClassLoader createClassLoader(ClassLoaderPolicy policy)
+ {
+ return new OSGiBundleClassLoader(policy);
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -191,7 +191,7 @@
if (reqVersionRange.isInRange(capVersion) == false)
return false;
- OSGiMetaData metaData = bundleState.getMetaData();
+ OSGiMetaData osgiMetaData = bundleState.getOSGiMetaData();
PackageAttribute capParameters = exportPackage;
PackageAttribute reqParameters = packageRequirement.getPackageMetaData();
@@ -223,13 +223,13 @@
if (Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE.equals(name))
{
- if (otherValue.equals(metaData.getBundleSymbolicName()) == false)
+ if (otherValue.equals(osgiMetaData.getBundleSymbolicName()) == false)
validMatch = false;
}
else if (Constants.BUNDLE_VERSION_ATTRIBUTE.equals(name))
{
VersionRange range = (VersionRange)AbstractVersionRange.valueOf(otherValue);
- if (range.isInRange(metaData.getBundleVersion()) == false)
+ if (range.isInRange(osgiMetaData.getBundleVersion()) == false)
validMatch = false;
}
else if (Constants.PACKAGE_SPECIFICATION_VERSION.equals(name) || Constants.VERSION_ATTRIBUTE.equals(name))
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java (from rev 98016, projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoadingDeployer.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -0,0 +1,156 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.deployers;
+
+// $Id: $
+
+import java.util.List;
+
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.classloading.spi.metadata.RequirementsMetaData;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.structure.spi.ClassLoaderFactory;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.classloading.OSGiBundleCapability;
+import org.jboss.osgi.framework.classloading.OSGiBundleRequirement;
+import org.jboss.osgi.framework.classloading.OSGiPackageCapability;
+import org.jboss.osgi.framework.classloading.OSGiPackageRequirement;
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.framework.metadata.PackageAttribute;
+import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
+import org.jboss.osgi.framework.plugins.SystemPackagesPlugin;
+
+/**
+ * OSGiBundleClassLoadingDeployer.<p>
+ *
+ * This deployer maps osgi metadata into our classloading metadata.
+ *
+ * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
+ * @author Thomas.Diesler(a)jboss.com
+ * @version $Revision: 1.1 $
+ */
+public class OSGiBundleClassLoadingDeployer extends AbstractSimpleRealDeployer<OSGiMetaData>
+{
+ private ClassLoaderDomain domain;
+ private ClassLoaderFactory factory;
+
+ /**
+ * Create a new OSGiBundleClassLoadingDeployer.
+ */
+ public OSGiBundleClassLoadingDeployer()
+ {
+ super(OSGiMetaData.class);
+ addInput(OSGiBundleState.class);
+ setOutput(ClassLoadingMetaData.class);
+ setStage(DeploymentStages.POST_PARSE);
+ setTopLevelOnly(true);
+ }
+
+ public void setDomain(ClassLoaderDomain domain)
+ {
+ this.domain = domain;
+ }
+
+ public void setFactory(ClassLoaderFactory factory)
+ {
+ this.factory = factory;
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, OSGiMetaData osgiMetaData) throws DeploymentException
+ {
+ if (unit.isAttachmentPresent(ClassLoadingMetaData.class))
+ return;
+
+ OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
+ if (bundleState == null)
+ throw new IllegalStateException("No bundle state");
+
+ OSGiBundleManager bundleManager = bundleState.getBundleManager();
+
+ ClassLoadingMetaData classLoadingMetaData = new ClassLoadingMetaData();
+ classLoadingMetaData.setName(bundleState.getSymbolicName());
+ classLoadingMetaData.setVersion(bundleState.getVersion());
+ classLoadingMetaData.setDomain(domain != null ? domain.getName() : null);
+
+ CapabilitiesMetaData capabilities = classLoadingMetaData.getCapabilities();
+ RequirementsMetaData requirements = classLoadingMetaData.getRequirements();
+
+ OSGiBundleCapability capability = OSGiBundleCapability.create(bundleState);
+ capabilities.addCapability(capability);
+
+ List<ParameterizedAttribute> requireBundles = osgiMetaData.getRequireBundles();
+ if (requireBundles != null && requireBundles.isEmpty() == false)
+ {
+ for (ParameterizedAttribute requireBundle : requireBundles)
+ {
+ OSGiBundleRequirement requirement = OSGiBundleRequirement.create(requireBundle);
+ requirements.addRequirement(requirement);
+ }
+ }
+
+ List<PackageAttribute> exported = osgiMetaData.getExportPackages();
+ if (exported != null && exported.isEmpty() == false)
+ {
+ for (PackageAttribute packageAttribute : exported)
+ {
+ OSGiPackageCapability packageCapability = OSGiPackageCapability.create(bundleState, packageAttribute);
+ capabilities.addCapability(packageCapability);
+ }
+ }
+
+ List<PackageAttribute> imported = osgiMetaData.getImportPackages();
+ if (imported != null && imported.isEmpty() == false)
+ {
+ SystemPackagesPlugin syspackPlugin = bundleManager.getPlugin(SystemPackagesPlugin.class);
+ for (PackageAttribute packageAttribute : imported)
+ {
+ String packageName = packageAttribute.getAttribute();
+
+ // [TODO] Should system packages be added as capabilities?
+ boolean isSystemPackage = syspackPlugin.isSystemPackage(packageName);
+ if (isSystemPackage == false)
+ {
+ OSGiPackageRequirement requirement = OSGiPackageRequirement.create(bundleState, packageAttribute);
+ requirements.addRequirement(requirement);
+ }
+ }
+ }
+
+ // Add the OSGi ClassLoaderFactory if configured
+ if (factory != null)
+ unit.addAttachment(ClassLoaderFactory.class, factory);
+
+ // [TODO] dynamic imports
+
+ unit.addAttachment(ClassLoadingMetaData.class, classLoadingMetaData);
+
+ // AnnotationMetaDataDeployer.ANNOTATION_META_DATA_COMPLETE
+ unit.addAttachment("org.jboss.deployment.annotation.metadata.complete", Boolean.TRUE);
+ }
+}
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleNativeCodeDeployer.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -0,0 +1,211 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.deployers;
+
+// $Id: $
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.classloader.spi.ClassLoaderPolicy;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
+import org.jboss.deployers.structure.spi.ClassLoaderFactory;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.classloading.OSGiClassLoaderPolicy;
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.framework.metadata.Parameter;
+import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
+import org.osgi.framework.Constants;
+
+/**
+ * A deployer that takes care of loading native code libraries.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 19-Dec-2009
+ */
+public class OSGiBundleNativeCodeDeployer extends AbstractRealDeployer
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(OSGiBundleNativeCodeDeployer.class);
+
+ /** Maps an alias to an OSGi processor name */
+ private static Map<String, String> processorAlias = new HashMap<String, String>();
+ static
+ {
+ processorAlias.put("pentium", "x86");
+ processorAlias.put("i386", "x86");
+ processorAlias.put("i486", "x86");
+ processorAlias.put("i586", "x86");
+ processorAlias.put("i686", "x86");
+ processorAlias.put("amd64", "x86-64");
+ processorAlias.put("em64t", "x86-64");
+ processorAlias.put("x86_64", "x86-64");
+ }
+
+ /** Maps an alias to an OSGi osname */
+ private static Map<String, String> osAlias = new HashMap<String, String>();
+ static
+ {
+ osAlias.put("SymbianOS", "Epoc32");
+ osAlias.put("hp-ux", "HPUX");
+ osAlias.put("Mac OS", "MacOS");
+ osAlias.put("Mac OS X", "MacOSX");
+ osAlias.put("OS/2", "OS2");
+ osAlias.put("procnto", "QNX");
+ osAlias.put("Win95", "Windows95");
+ osAlias.put("Windows 95", "Windows95");
+ osAlias.put("Win32", "Windows95");
+ osAlias.put("Win98", "Windows98");
+ osAlias.put("Windows 98", "Windows98");
+ osAlias.put("Win32", "Windows98");
+ osAlias.put("WinNT", "WindowsNT");
+ osAlias.put("Windows NT", "WindowsNT");
+ osAlias.put("Win32", "WindowsNT");
+ osAlias.put("WinCE", "WindowsCE");
+ osAlias.put("Windows CE", "WindowsCE");
+ osAlias.put("Win2000", "Windows2000");
+ osAlias.put("Windows 2000", "Windows2000");
+ osAlias.put("Win32", "Windows2000");
+ osAlias.put("Win2003", "Windows2003");
+ osAlias.put("Windows 2003", "Windows2003");
+ osAlias.put("Win32", "Windows2003");
+ osAlias.put("Windows Server 2003", "Windows2003");
+ osAlias.put("WinXP", "WindowsXP");
+ osAlias.put("Windows XP", "WindowsXP");
+ osAlias.put("Win32", "WindowsXP");
+ osAlias.put("WinVista", "WindowsVista");
+ osAlias.put("Windows Vista", "WindowsVista");
+ osAlias.put("Win32", "WindowsVista");
+ }
+
+ public OSGiBundleNativeCodeDeployer()
+ {
+ setInput(ClassLoaderFactory.class);
+ addInput(ClassLoaderPolicy.class);
+ addInput(OSGiBundleState.class);
+ setStage(DeploymentStages.CLASSLOADER);
+ setTopLevelOnly(true);
+ }
+
+ @Override
+ protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
+ {
+ OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
+ if (bundleState == null)
+ throw new IllegalStateException("No bundle state");
+
+ OSGiMetaData osgiMetaData = bundleState.getOSGiMetaData();
+ List<ParameterizedAttribute> nativeCodeParams = osgiMetaData.getBundleNativeCode();
+ if (nativeCodeParams == null)
+ return;
+
+ OSGiBundleManager bundleManager = bundleState.getBundleManager();
+ String fwOSName = bundleManager.getProperty(Constants.FRAMEWORK_OS_NAME);
+ String fwProcessor = bundleManager.getProperty(Constants.FRAMEWORK_PROCESSOR);
+ //String fwOSVersion = bundleManager.getProperty(Constants.FRAMEWORK_OS_VERSION);
+
+ List<ParameterizedAttribute> matchedParams = new ArrayList<ParameterizedAttribute>();
+ for (ParameterizedAttribute param : nativeCodeParams)
+ {
+ // Only select the native code clauses for which the following expressions all evaluate to true
+ // * osname ~= [org.osgi.framework.os.name]
+ // * processor ~= [org.osgi.framework.processor]
+ // * osversion range includes [org.osgi.framework.os.version] or osversion is not specified
+ // * language ~= [org.osgi.framework.language] or language is not specified
+ // * selection-filter evaluates to true when using the values of the system properties or selection-filter is not specified
+
+ Parameter osnameParam = param.getAttribute(Constants.BUNDLE_NATIVECODE_OSNAME);
+ Parameter procParam = param.getAttribute(Constants.BUNDLE_NATIVECODE_PROCESSOR);
+ //Parameter osversionParam = param.getAttribute(Constants.BUNDLE_NATIVECODE_OSVERSION);
+
+ boolean match = (osnameParam != null);
+
+ // osname ~= [org.osgi.framework.os.name]
+ if (match && osnameParam != null)
+ {
+ String osname = (String)osnameParam.getValue();
+ match = (osname.equals(fwOSName) || osname.equals(osAlias.get(fwOSName)));
+ }
+
+ // processor ~= [org.osgi.framework.processor]
+ match &= (procParam != null);
+ if (match && procParam != null)
+ {
+ String processor = (String)procParam.getValue();
+ match = (processor.equals(fwProcessor) || processor.equals(processorAlias.get(fwProcessor)));
+ }
+
+ // [TODO] osversion range includes [org.osgi.framework.os.version] or osversion is not specified
+ // [TODO] language ~= [org.osgi.framework.language] or language is not specified
+ // [TODO] selection-filter evaluates to true when using the values of the system properties or selection-filter is not specified
+
+ if (match == true)
+ matchedParams.add(param);
+ }
+
+ // If no native clauses were selected in step 1, this algorithm is terminated
+ // and a BundleException is thrown if the optional clause is not present
+ if (matchedParams.size() == 0)
+ {
+ // [TODO] optional
+ throw new DeploymentException("No native clauses selected from: " + nativeCodeParams);
+ }
+
+ // The selected clauses are now sorted in the following priority order:
+ // * osversion: floor of the osversion range in descending order, osversion not specified
+ // * language: language specified, language not specified
+ // * Position in the Bundle-NativeCode manifest header: lexical left to right
+ if (matchedParams.size() > 1)
+ {
+ // [TODO] selected clauses are now sorted
+ }
+
+ // The first clause of the sorted clauses from step 3 must be used as the selected native code clause
+ ParameterizedAttribute selectedParams = matchedParams.get(0);
+ log.debug("Selected native code clause: " + selectedParams);
+
+ String nativeLib = selectedParams.getAttribute();
+ URL entryURL = bundleState.getEntry(nativeLib);
+
+ // If a native code library in a selected native code clause cannot be found
+ // within the bundle then the bundle must fail to resolve
+ if (entryURL == null)
+ throw new DeploymentException("Cannot find native library: " + nativeLib);
+
+ // Get the library name key
+ String libname = new File(nativeLib).getName();
+ libname = libname.substring(0, libname.lastIndexOf('.'));
+
+ // Add the native library mapping to the OSGiClassLoaderPolicy
+ OSGiClassLoaderPolicy policy = (OSGiClassLoaderPolicy)unit.getAttachment(ClassLoaderPolicy.class);
+ policy.addLibraryMapping(libname, entryURL);
+ }
+}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -50,25 +50,25 @@
@Override
protected OSGiMetaData createMetaData(Manifest manifest) throws Exception
{
- AbstractOSGiMetaData metaData = new AbstractOSGiMetaData(manifest);
+ AbstractOSGiMetaData osgiMetaData = new AbstractOSGiMetaData(manifest);
// At least one of these manifest headers must be there
// Note, in R3 and R4 there is no common mandatory header
- String bundleName = metaData.getBundleName();
- String bundleVersion = metaData.getBundleVersion();
- String bundleSymbolicName = metaData.getBundleSymbolicName();
+ String bundleName = osgiMetaData.getBundleName();
+ String bundleVersion = osgiMetaData.getBundleVersion();
+ String bundleSymbolicName = osgiMetaData.getBundleSymbolicName();
if (bundleName == null && bundleVersion == null && bundleSymbolicName == null)
- metaData = null;
+ osgiMetaData = null;
- return metaData;
+ return osgiMetaData;
}
@Override
- protected void init(VFSDeploymentUnit unit, OSGiMetaData metaData, VirtualFile file) throws Exception
+ protected void init(VFSDeploymentUnit unit, OSGiMetaData osgiMetaData, VirtualFile file) throws Exception
{
- super.init(unit, metaData, file);
+ super.init(unit, osgiMetaData, file);
- String symbolicName = metaData.getBundleSymbolicName();
+ String symbolicName = osgiMetaData.getBundleSymbolicName();
if (symbolicName != null)
{
// Add a marker that this is an R4 OSGi deployment
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverBundleImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverBundleImpl.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverBundleImpl.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -37,16 +37,16 @@
*/
public class ResolverBundleImpl extends AbstractResolverBundle
{
- private OSGiMetaData metaData;
+ private OSGiMetaData osgiMetaData;
public ResolverBundleImpl(Bundle bundle)
{
super(bundle);
- this.metaData = OSGiBundleState.assertBundleState(bundle).getMetaData();
+ this.osgiMetaData = OSGiBundleState.assertBundleState(bundle).getOSGiMetaData();
// Initialize exported packages
- List<PackageAttribute> exportPackages = metaData.getExportPackages();
+ List<PackageAttribute> exportPackages = osgiMetaData.getExportPackages();
if (exportPackages != null)
{
for (PackageAttribute attr : exportPackages)
@@ -57,7 +57,7 @@
}
// Initialize imported packages
- List<PackageAttribute> importPackages = metaData.getImportPackages();
+ List<PackageAttribute> importPackages = osgiMetaData.getImportPackages();
if (importPackages != null)
{
for (PackageAttribute attr : importPackages)
@@ -68,7 +68,7 @@
}
// Initialize required bundles
- List<ParameterizedAttribute> requireBundles = metaData.getRequireBundles();
+ List<ParameterizedAttribute> requireBundles = osgiMetaData.getRequireBundles();
if (requireBundles != null)
{
for (ParameterizedAttribute attr : requireBundles)
@@ -82,6 +82,6 @@
public boolean isSingleton()
{
- return metaData.isSingleton();
+ return osgiMetaData.isSingleton();
}
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java 2009-12-19 23:46:53 UTC (rev 98038)
@@ -405,7 +405,7 @@
// The Require-Bundle header specifies that all exported packages from
// another bundle must be imported, effectively requiring the public interface
// of another bundle
- OSGiMetaData osgiMetaData = bundle.getMetaData();
+ OSGiMetaData osgiMetaData = bundle.getOSGiMetaData();
List<ParameterizedAttribute> requireBundles = osgiMetaData.getRequireBundles();
if (requireBundles != null)
{
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml 2009-12-19 23:46:38 UTC (rev 98037)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml 2009-12-19 23:46:53 UTC (rev 98038)
@@ -142,6 +142,7 @@
<bean name="OSGiBundleStateRemoveDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleStateRemoveDeployer">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
+ <bean name="OSGiBundleNativeCodeDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleNativeCodeDeployer" />
<bean name="OSGiBundleActivatorDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleActivatorDeployer" />
<bean name="OSGiContextTrackerDeployer" class="org.jboss.osgi.framework.deployers.OSGiContextTrackerDeployer" />
@@ -162,7 +163,7 @@
<bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
<property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
</bean>
- <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
+ <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
14 years, 4 months
JBoss-OSGI SVN: r98037 - in projects/jboss-osgi/trunk: distribution/installer/src/main/resources/runtime/server/conf and 3 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-19 18:46:38 -0500 (Sat, 19 Dec 2009)
New Revision: 98037
Modified:
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/reactor/blueprint/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
Log:
Add initial support for native code libraries
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2009-12-19 20:15:47 UTC (rev 98036)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2009-12-19 23:46:38 UTC (rev 98037)
@@ -196,7 +196,7 @@
<bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
<property name="system"><inject bean="ClassLoaderSystem"/></property>
</bean>
- <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
+ <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2009-12-19 20:15:47 UTC (rev 98036)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2009-12-19 23:46:38 UTC (rev 98037)
@@ -218,7 +218,7 @@
<bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
<property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
</bean>
- <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
+ <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
Modified: projects/jboss-osgi/trunk/reactor/blueprint/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-12-19 20:15:47 UTC (rev 98036)
+++ projects/jboss-osgi/trunk/reactor/blueprint/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-12-19 23:46:38 UTC (rev 98037)
@@ -189,7 +189,7 @@
<bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
<property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
</bean>
- <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
+ <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
Modified: 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 2009-12-19 20:15:47 UTC (rev 98036)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-12-19 23:46:38 UTC (rev 98037)
@@ -201,7 +201,7 @@
<bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
<property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
</bean>
- <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
+ <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-12-19 20:15:47 UTC (rev 98036)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2009-12-19 23:46:38 UTC (rev 98037)
@@ -188,7 +188,7 @@
<bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.framework.classloading.OSGiClassLoaderFactory" >
<property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
</bean>
- <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.classloading.OSGiBundleClassLoadingDeployer">
+ <bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.framework.deployers.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
<property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
14 years, 4 months
JBoss-OSGI SVN: r98020 - in projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework: util and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-19 11:55:52 -0500 (Sat, 19 Dec 2009)
New Revision: 98020
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/URLHelper.java
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
Log:
Add support for Bundle.update() from original location
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-19 14:07:46 UTC (rev 98019)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-19 16:55:52 UTC (rev 98020)
@@ -213,12 +213,16 @@
return bundles.toArray(new Bundle[bundles.size()]);
}
+ /**
+ * Returns the time when this bundle was last modified.
+ * A bundle is considered to be modified when it is installed, updated or uninstalled
+ */
public long getLastModified()
{
return lastModified;
}
- void modified()
+ void updateLastModified()
{
lastModified = System.currentTimeMillis();
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-19 14:07:46 UTC (rev 98019)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-19 16:55:52 UTC (rev 98020)
@@ -90,6 +90,7 @@
import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.plugins.ServicePlugin;
import org.jboss.osgi.framework.util.NoFilter;
+import org.jboss.osgi.framework.util.URLHelper;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.virtual.VFS;
@@ -805,13 +806,16 @@
// If the specified InputStream is null, the Framework must create the InputStream from which to read the updated bundle by interpreting,
// in an implementation dependent manner, this bundle's Bundle-UpdateLocation Manifest header, if present, or this bundle's original location.
URL updateURL = bundleState.getMetaData().getBundleUpdateLocation();
+ if (updateURL == null)
+ {
+ // This updates the bundle from its original location
+ VirtualFile root = bundleState.getRoot();
+ updateURL = URLHelper.toURL(root);
+ }
if (in == null)
{
try
{
- if (updateURL == null)
- throw new IllegalStateException("Cannot obtain Bundle-UpdateLocation for: " + bundleState);
-
in = updateURL.openStream();
}
catch (IOException ex)
@@ -856,6 +860,7 @@
dep.setAutoStart(false);
updatedBundleState = installBundle(dep);
+ updatedBundleState.updateLastModified();
}
catch (Exception ex)
{
@@ -911,7 +916,7 @@
try
{
deployerClient.undeploy(unit.getName());
- bundleState.modified();
+ bundleState.updateLastModified();
}
catch (DeploymentException e)
{
@@ -947,13 +952,8 @@
unit.addAttachment(OSGiMetaData.class, metaData);
}
- // The bundle location is not necessarily the bundle root url
- // The framework is expected to preserve the location passed into installBundle(String)
+ // In case of Bundle.update() the OSGiBundleState should be attached. We add the DeploymentUnit
Deployment dep = unit.getAttachment(Deployment.class);
- String location = (dep != null ? dep.getLocation() : unit.getName());
-
- // In case of Bundle.update() the OSGiBundleState should be attached
- // we add the DeploymentUnit
OSGiBundleState bundleState = (dep != null ? dep.getAttachment(OSGiBundleState.class) : null);
if (bundleState != null)
bundleState.addDeploymentUnit(unit);
@@ -961,7 +961,7 @@
// Create a new OSGiBundleState and add it to the manager
if (bundleState == null)
{
- bundleState = new OSGiBundleState(location, unit);
+ bundleState = new OSGiBundleState(unit);
addBundle(bundleState);
}
return bundleState;
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-12-19 14:07:46 UTC (rev 98019)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-12-19 16:55:52 UTC (rev 98020)
@@ -35,6 +35,7 @@
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.plugins.PackageAdminPlugin;
import org.jboss.virtual.VirtualFile;
@@ -62,6 +63,9 @@
/** The bundle location */
private String location;
+
+ /** The bundle root file */
+ private VirtualFile rootFile;
/** The list of deployment units */
private List<DeploymentUnit> units = new ArrayList<DeploymentUnit>();
@@ -72,20 +76,21 @@
/**
* Create a new BundleState.
*
- * @param location The string representation of this bundle's location identifier
- * @param osgiMetaData the osgi metadata
* @param unit the deployment unit
* @throws IllegalArgumentException for a null parameter
*/
- public OSGiBundleState(String location, DeploymentUnit unit)
+ public OSGiBundleState(DeploymentUnit unit)
{
- if (location == null)
- throw new IllegalArgumentException("Null bundle location");
if (unit == null)
throw new IllegalArgumentException("Null deployment unit");
+
+ // The bundle location is not necessarily the bundle root url
+ // The framework is expected to preserve the location passed into installBundle(String)
+ Deployment dep = unit.getAttachment(Deployment.class);
+ location = (dep != null ? dep.getLocation() : unit.getName());
+ rootFile = (dep != null ? dep.getRoot() : ((VFSDeploymentUnit)unit).getRoot());
- this.location = location;
- this.bundleId = bundleIDGenerator.incrementAndGet();
+ bundleId = bundleIDGenerator.incrementAndGet();
addDeploymentUnit(unit);
}
@@ -103,6 +108,14 @@
return (OSGiBundleState)bundle;
}
+ /**
+ * Get the root file for this bundle
+ */
+ public VirtualFile getRoot()
+ {
+ return rootFile;
+ }
+
@Override
public OSGiMetaData getMetaData()
{
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/URLHelper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/URLHelper.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/URLHelper.java 2009-12-19 16:55:52 UTC (rev 98020)
@@ -0,0 +1,74 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.util;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * A helper for URL convertions that does not throw checked exceptions.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 19-Dec-2009
+ */
+public final class URLHelper
+{
+ // Hide the ctor
+ private URLHelper()
+ {
+ }
+
+ /**
+ * Get a URL from the given string
+ * @throws IllegalArgumentException if the urlstr does not represent a valid URL
+ */
+ public static URL toURL(String urlstr)
+ {
+ try
+ {
+ return new URL(urlstr);
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new IllegalArgumentException("Malformed URL: " + urlstr);
+ }
+ }
+
+ /**
+ * Get a URL from the given virtual file
+ * @throws IllegalArgumentException if the file does not represent a valid URL
+ */
+ public static URL toURL(VirtualFile file)
+ {
+ try
+ {
+ return file.toURL();
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalArgumentException("Cannot convert to URL: " + file, ex);
+ }
+ }
+
+}
14 years, 4 months
JBoss-OSGI SVN: r98019 - in projects/jboss-osgi/projects: spi/trunk/src/main/java/org/jboss/osgi/spi/util and 1 other directory.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-19 09:07:46 -0500 (Sat, 19 Dec 2009)
New Revision: 98019
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
Log:
Cache bundle header for default locale
Fix NPE in BundleInfo.
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-19 11:36:12 UTC (rev 98018)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-19 14:07:46 UTC (rev 98019)
@@ -96,6 +96,24 @@
private AtomicInteger state = new AtomicInteger(Bundle.UNINSTALLED);
/**
+ * Assert that the given bundle is an instance of AbstractBundleState
+ * @throws IllegalArgumentException if the given bundle is not an instance of AbstractBundleState
+ */
+ public static AbstractBundleState assertBundleState(Bundle bundle)
+ {
+ if (bundle == null)
+ throw new IllegalArgumentException("Null bundle");
+
+ if (bundle instanceof OSGiBundleWrapper)
+ bundle = ((OSGiBundleWrapper)bundle).getBundleState();
+
+ if (bundle instanceof AbstractBundleState == false)
+ throw new IllegalArgumentException("Not an AbstractBundleState: " + bundle);
+
+ return (AbstractBundleState)bundle;
+ }
+
+ /**
* Get the bundleManager.
*
* @return the bundleManager.
@@ -220,8 +238,8 @@
return getHeaders(null);
}
- @SuppressWarnings("rawtypes")
- public Dictionary getHeaders(String locale)
+ @SuppressWarnings("unchecked")
+ public Dictionary<String, String> getHeaders(String locale)
{
checkAdminPermission(AdminPermission.METADATA);
@@ -243,33 +261,14 @@
if (baseName == null)
baseName = Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME;
- // The Framework searches for localization entries by appending suffixes to
- // the localization base name according to a specified locale and finally
- // appending the .properties suffix. If a translation is not found, the locale
- // must be made more generic by first removing the variant, then the country
- // and finally the language until an entry is found that contains a valid
- // translation.
- String entryPath = baseName + "_" + locale + ".properties";
- URL entryURL = getEntryInternal(entryPath);
- while (entryURL == null)
+ // Get the resource bundle URL for the given base and locale
+ URL entryURL = getLocalizationEntryPath(baseName, locale);
+
+ // If the specified locale entry could not be found fall back to the default locale entry
+ if (entryURL == null)
{
- if (entryPath.equals(baseName + ".properties"))
- break;
-
- int lastIndex = locale.lastIndexOf('_');
- if (lastIndex > 0)
- {
- locale = locale.substring(0, lastIndex);
- entryPath = baseName + "_" + locale + ".properties";
- }
- else
- {
- entryPath = baseName + ".properties";
- }
-
- // The bundle's class loader is not used to search for localization entries. Only
- // the contents of the bundle and its attached fragments are searched.
- entryURL = getEntryInternal(entryPath);
+ String defaultLocale = Locale.getDefault().toString();
+ entryURL = getLocalizationEntryPath(baseName, defaultLocale);
}
// Read the resource bundle
@@ -313,6 +312,39 @@
return new CaseInsensitiveDictionary(locHeaders);
}
+ private URL getLocalizationEntryPath(String baseName, String locale)
+ {
+ // The Framework searches for localization entries by appending suffixes to
+ // the localization base name according to a specified locale and finally
+ // appending the .properties suffix. If a translation is not found, the locale
+ // must be made more generic by first removing the variant, then the country
+ // and finally the language until an entry is found that contains a valid translation.
+
+ String entryPath = baseName + "_" + locale + ".properties";
+ URL entryURL = getEntryInternal(entryPath);
+ while (entryURL == null)
+ {
+ if (entryPath.equals(baseName + ".properties"))
+ break;
+
+ int lastIndex = locale.lastIndexOf('_');
+ if (lastIndex > 0)
+ {
+ locale = locale.substring(0, lastIndex);
+ entryPath = baseName + "_" + locale + ".properties";
+ }
+ else
+ {
+ entryPath = baseName + ".properties";
+ }
+
+ // The bundle's class loader is not used to search for localization entries. Only
+ // the contents of the bundle and its attached fragments are searched.
+ entryURL = getEntryInternal(entryPath);
+ }
+ return entryURL;
+ }
+
// Get the entry without checking permissions and bundle state.
abstract URL getEntryInternal(String path);
@@ -636,11 +668,7 @@
return bundleState.getBundleInternal();
}
- @Override
- public String toString()
- {
- return "Bundle{" + getCanonicalName() + "}";
- }
+ public abstract void uninstall() throws BundleException;
/**
* Get the canonical name of the bundle
@@ -812,17 +840,9 @@
}
}
- public static AbstractBundleState assertBundleState(Bundle bundle)
+ @Override
+ public String toString()
{
- if (bundle == null)
- throw new IllegalArgumentException("Null bundle");
-
- if (bundle instanceof OSGiBundleWrapper)
- bundle = ((OSGiBundleWrapper)bundle).getBundleState();
-
- if (bundle instanceof AbstractBundleState == false)
- throw new IllegalArgumentException("Not an AbstractBundleState: " + bundle);
-
- return (AbstractBundleState)bundle;
+ return "Bundle{" + getCanonicalName() + "}";
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-12-19 11:36:12 UTC (rev 98018)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-12-19 14:07:46 UTC (rev 98019)
@@ -26,6 +26,7 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.Dictionary;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
@@ -64,7 +65,10 @@
/** The list of deployment units */
private List<DeploymentUnit> units = new ArrayList<DeploymentUnit>();
-
+
+ /** The headers localized with the default locale */
+ Dictionary<String, String> headersOnUninstall;
+
/**
* Create a new BundleState.
*
@@ -86,6 +90,19 @@
addDeploymentUnit(unit);
}
+ /**
+ * Assert that the given bundle is an instance of OSGiBundleState
+ * @throws IllegalArgumentException if the given bundle is not an instance of OSGiBundleState
+ */
+ public static OSGiBundleState assertBundleState(Bundle bundle)
+ {
+ bundle = AbstractBundleState.assertBundleState(bundle);
+ if (bundle instanceof OSGiBundleState == false)
+ throw new IllegalArgumentException("Not an OSGiBundleState: " + bundle);
+
+ return (OSGiBundleState)bundle;
+ }
+
@Override
public OSGiMetaData getMetaData()
{
@@ -479,9 +496,24 @@
}
}
+ @Override
+ public Dictionary<String, String> getHeaders(String locale)
+ {
+ // This method must continue to return Manifest header information while this bundle is in the UNINSTALLED state,
+ // however the header values must only be available in the raw and default locale values
+ if (getState() == Bundle.UNINSTALLED)
+ return headersOnUninstall;
+
+ return super.getHeaders(locale);
+ }
+
public void uninstall() throws BundleException
{
checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
+
+ // Cache the headers in the default locale
+ headersOnUninstall = getHeaders(null);
+
getBundleManager().uninstallBundle(this);
}
@@ -496,18 +528,4 @@
{
getBundleManager().removeContext(service, getDeploymentUnit());
}
-
- public static OSGiBundleState assertBundleState(Bundle bundle)
- {
- if (bundle == null)
- throw new IllegalArgumentException("Null bundle");
-
- if (bundle instanceof OSGiBundleWrapper)
- bundle = ((OSGiBundleWrapper)bundle).getBundleState();
-
- if (bundle instanceof OSGiBundleState == false)
- throw new IllegalArgumentException("Not an OSGiBundleState: " + bundle);
-
- return (OSGiBundleState)bundle;
- }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java 2009-12-19 11:36:12 UTC (rev 98018)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java 2009-12-19 14:07:46 UTC (rev 98019)
@@ -33,7 +33,6 @@
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.internal.AbstractOSGiMetaData;
-import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.util.collection.ConcurrentSet;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
@@ -167,8 +166,7 @@
public void start(int options) throws BundleException
{
- // [JBOSGI-138] Proper system BundleContext implementation
- throw new NotImplementedException();
+ // do nothing
}
public void stop(int options) throws BundleException
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-12-19 11:36:12 UTC (rev 98018)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-12-19 14:07:46 UTC (rev 98019)
@@ -134,8 +134,7 @@
throw new IllegalArgumentException("Invalid Bundle-ManifestVersion:=1 for " + symbolicName);
// Generate default symbolic name
- String name = getManifestHeader(Constants.BUNDLE_NAME);
- symbolicName = name.replace(' ', '-');
+ symbolicName = "anonymous-bundle";
// Parse the Bundle-Version string
try
14 years, 4 months
JBoss-OSGI SVN: r98018 - projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-19 06:36:12 -0500 (Sat, 19 Dec 2009)
New Revision: 98018
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR4.java
Log:
javadoc typo
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR4.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR4.java 2009-12-19 11:35:39 UTC (rev 98017)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR4.java 2009-12-19 11:36:12 UTC (rev 98018)
@@ -30,7 +30,7 @@
import org.osgi.framework.Constants;
/**
- * OSGiBundleManager.
+ * A bundle validator for OSGi R4.
*
* @author Thomas.Diesler(a)jboss.com
* @version $Revision: 1.1 $
@@ -44,12 +44,6 @@
this.bundleManager = bundleManager;
}
-
- /**
- * Validate the bundle
- *
- * @param bundleState the bundle state
- */
@SuppressWarnings("deprecation")
public void validateBundle(AbstractBundleState bundleState)
{
14 years, 4 months
JBoss-OSGI SVN: r98017 - in projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework: classloading and 5 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-19 06:35:39 -0500 (Sat, 19 Dec 2009)
New Revision: 98017
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidator.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR3.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR4.java
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/OSGiMetaData.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverBundleImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/CaseInsensitiveDictionary.java
Log:
Implement bundle header localization.
Differenciate R3/R4 bundle validation.
Fix CaseInsensitiveDictionary
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-19 04:03:09 UTC (rev 98016)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -22,15 +22,23 @@
package org.jboss.osgi.framework.bundle;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import java.security.Permission;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Dictionary;
+import java.util.Enumeration;
import java.util.HashSet;
+import java.util.Hashtable;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.PropertyResourceBundle;
+import java.util.ResourceBundle;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
@@ -41,6 +49,7 @@
import org.jboss.osgi.framework.plugins.BundleStoragePlugin;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
import org.jboss.osgi.framework.plugins.LifecycleInterceptorServicePlugin;
+import org.jboss.osgi.framework.util.CaseInsensitiveDictionary;
import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.util.ConstantsHelper;
import org.jboss.virtual.VirtualFile;
@@ -50,6 +59,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.FrameworkListener;
import org.osgi.framework.FrameworkUtil;
@@ -100,16 +110,16 @@
public String getSymbolicName()
{
- String symbolicName = getOSGiMetaData().getBundleSymbolicName();
+ String symbolicName = getMetaData().getBundleSymbolicName();
if (symbolicName == null)
symbolicName = "anonymous-bundle" + getBundleId();
-
+
return symbolicName;
}
public Version getVersion()
{
- String versionstr = getOSGiMetaData().getBundleVersion();
+ String versionstr = getMetaData().getBundleVersion();
try
{
return Version.parseVersion(versionstr);
@@ -200,11 +210,13 @@
*
* @return the osgiMetaData.
*/
- public abstract OSGiMetaData getOSGiMetaData();
+ public abstract OSGiMetaData getMetaData();
@SuppressWarnings("rawtypes")
public Dictionary getHeaders()
{
+ // If the specified locale is null then the locale returned
+ // by java.util.Locale.getDefault is used.
return getHeaders(null);
}
@@ -212,9 +224,98 @@
public Dictionary getHeaders(String locale)
{
checkAdminPermission(AdminPermission.METADATA);
- return getOSGiMetaData().getHeaders(locale);
+
+ // Get the raw (unlocalized) manifest headers
+ Dictionary<String, String> rawHeaders = getMetaData().getHeaders();
+
+ // If the specified locale is the empty string, this method will return the
+ // raw (unlocalized) manifest headers including any leading "%"
+ if ("".equals(locale))
+ return rawHeaders;
+
+ // If the specified locale is null then the locale
+ // returned by java.util.Locale.getDefault is used
+ if (locale == null)
+ locale = Locale.getDefault().toString();
+
+ // Get the localization base name
+ String baseName = rawHeaders.get(Constants.BUNDLE_LOCALIZATION);
+ if (baseName == null)
+ baseName = Constants.BUNDLE_LOCALIZATION_DEFAULT_BASENAME;
+
+ // The Framework searches for localization entries by appending suffixes to
+ // the localization base name according to a specified locale and finally
+ // appending the .properties suffix. If a translation is not found, the locale
+ // must be made more generic by first removing the variant, then the country
+ // and finally the language until an entry is found that contains a valid
+ // translation.
+ String entryPath = baseName + "_" + locale + ".properties";
+ URL entryURL = getEntryInternal(entryPath);
+ while (entryURL == null)
+ {
+ if (entryPath.equals(baseName + ".properties"))
+ break;
+
+ int lastIndex = locale.lastIndexOf('_');
+ if (lastIndex > 0)
+ {
+ locale = locale.substring(0, lastIndex);
+ entryPath = baseName + "_" + locale + ".properties";
+ }
+ else
+ {
+ entryPath = baseName + ".properties";
+ }
+
+ // The bundle's class loader is not used to search for localization entries. Only
+ // the contents of the bundle and its attached fragments are searched.
+ entryURL = getEntryInternal(entryPath);
+ }
+
+ // Read the resource bundle
+ ResourceBundle resBundle = null;
+ if (entryURL != null)
+ {
+ try
+ {
+ resBundle = new PropertyResourceBundle(entryURL.openStream());
+ }
+ catch (IOException ex)
+ {
+ throw new IllegalStateException("Cannot read resouce bundle: " + entryURL, ex);
+ }
+ }
+
+ Dictionary<String, String> locHeaders = new Hashtable<String, String>();
+ Enumeration<String> e = rawHeaders.keys();
+ while (e.hasMoreElements())
+ {
+ String key = e.nextElement();
+ String value = rawHeaders.get(key);
+ if (value.startsWith("%"))
+ value = value.substring(1);
+
+ if (resBundle != null)
+ {
+ try
+ {
+ value = resBundle.getString(value);
+ }
+ catch (MissingResourceException ex)
+ {
+ // ignore
+ }
+ }
+
+ locHeaders.put(key, value);
+ }
+
+ return new CaseInsensitiveDictionary(locHeaders);
}
+ // Get the entry without checking permissions and bundle state.
+ abstract URL getEntryInternal(String path);
+
public String getProperty(String key)
{
checkValidBundleContext();
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-19 04:03:09 UTC (rev 98016)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -35,7 +35,6 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
-import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
@@ -81,7 +80,7 @@
import org.jboss.osgi.deployment.deployer.DeploymentFactory;
import org.jboss.osgi.framework.deployers.OSGiBundleActivatorDeployer;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.framework.metadata.PackageAttribute;
+import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
import org.jboss.osgi.framework.metadata.internal.AbstractOSGiMetaData;
import org.jboss.osgi.framework.plugins.AutoInstallPlugin;
import org.jboss.osgi.framework.plugins.BundleStoragePlugin;
@@ -91,6 +90,7 @@
import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.plugins.ServicePlugin;
import org.jboss.osgi.framework.util.NoFilter;
+import org.jboss.osgi.spi.NotImplementedException;
import org.jboss.osgi.spi.util.BundleInfo;
import org.jboss.virtual.VFS;
import org.jboss.virtual.VFSUtils;
@@ -804,7 +804,7 @@
{
// If the specified InputStream is null, the Framework must create the InputStream from which to read the updated bundle by interpreting,
// in an implementation dependent manner, this bundle's Bundle-UpdateLocation Manifest header, if present, or this bundle's original location.
- URL updateURL = bundleState.getOSGiMetaData().getBundleUpdateLocation();
+ URL updateURL = bundleState.getMetaData().getBundleUpdateLocation();
if (in == null)
{
try
@@ -1031,62 +1031,22 @@
*
* @param bundleState the bundle state
*/
- @SuppressWarnings("deprecation")
private void validateBundle(AbstractBundleState bundleState)
{
- OSGiMetaData metaData = bundleState.getOSGiMetaData();
+ OSGiMetaData metaData = bundleState.getMetaData();
if (metaData == null)
return;
- int manifestVersion = metaData.getBundleManifestVersion();
- if (manifestVersion > 2)
- throw new IllegalStateException("Unsupported manifest version " + manifestVersion + " for " + bundleState);
+ ParameterizedAttribute fragmentHost = metaData.getFragmentHost();
+ if (fragmentHost != null)
+ throw new NotImplementedException("Fragments not implemented: " + fragmentHost);
+
+ // Delegate to the validator for the appropriate revision
+ OSGiBundleValidator validator = new OSGiBundleValidatorR3(this);
+ if(metaData.getBundleManifestVersion() > 1)
+ validator = new OSGiBundleValidatorR4(this);
- String symbolicName = bundleState.getSymbolicName();
- for (AbstractBundleState bundle : getBundles())
- {
- OSGiMetaData other = bundle.getOSGiMetaData();
- if (symbolicName.equals(other.getBundleSymbolicName()))
- {
- if (other.isSingleton() && metaData.isSingleton())
- throw new IllegalStateException("Cannot install singleton " + bundleState + " another singleton is already installed: " + bundle.getLocation());
- if (other.getBundleVersion().equals(metaData.getBundleVersion()))
- throw new IllegalStateException("Cannot install " + bundleState + " a bundle with that name and version is already installed: "
- + bundle.getLocation());
- }
- }
-
- List<PackageAttribute> importPackages = metaData.getImportPackages();
- if (importPackages != null && importPackages.isEmpty() == false)
- {
- Set<String> packages = new HashSet<String>();
- for (PackageAttribute packageAttribute : importPackages)
- {
- String packageName = packageAttribute.getAttribute();
- if (packages.contains(packageName))
- throw new IllegalStateException("Duplicate import of package " + packageName + " for " + bundleState);
- packages.add(packageName);
-
- if (packageName.startsWith("java."))
- throw new IllegalStateException("Not allowed to import java.* for " + bundleState);
-
- String version = packageAttribute.getAttributeValue(Constants.VERSION_ATTRIBUTE, String.class);
- String specificationVersion = packageAttribute.getAttributeValue(Constants.PACKAGE_SPECIFICATION_VERSION, String.class);
- if (version != null && specificationVersion != null && version.equals(specificationVersion) == false)
- throw new IllegalStateException(packageName + " version and specification version should be the same for " + bundleState);
- }
- }
-
- List<PackageAttribute> exportPackages = metaData.getExportPackages();
- if (exportPackages != null && exportPackages.isEmpty() == false)
- {
- for (PackageAttribute packageAttribute : exportPackages)
- {
- String packageName = packageAttribute.getAttribute();
- if (packageName.startsWith("java."))
- throw new IllegalStateException("Not allowed to export java.* for " + bundleState);
- }
- }
+ validator.validateBundle(bundleState);
}
/**
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-12-19 04:03:09 UTC (rev 98016)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -87,7 +87,7 @@
}
@Override
- public OSGiMetaData getOSGiMetaData()
+ public OSGiMetaData getMetaData()
{
DeploymentUnit unit = getDeploymentUnit();
OSGiMetaData metadata = unit.getAttachment(OSGiMetaData.class);
@@ -151,6 +151,13 @@
if (noAdminPermission(AdminPermission.RESOURCE))
return null;
+ return getEntryInternal(path);
+ }
+
+ // Get the entry without checking permissions and bundle state.
+ @Override
+ URL getEntryInternal(String path)
+ {
DeploymentUnit unit = getDeploymentUnit();
if (unit instanceof VFSDeploymentUnit)
{
@@ -158,6 +165,7 @@
if (path.startsWith("/"))
path = path.substring(1);
+
return vfsDeploymentUnit.getResourceLoader().getResource(path);
}
return null;
@@ -313,7 +321,7 @@
// The BundleActivator.start(org.osgi.framework.BundleContext) method of this bundle's BundleActivator, if one is specified, is called.
try
{
- OSGiMetaData metaData = getOSGiMetaData();
+ OSGiMetaData metaData = getMetaData();
if (metaData == null)
throw new IllegalStateException("Cannot obtain OSGi meta data");
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidator.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidator.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidator.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -0,0 +1,37 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.bundle;
+
+
+/**
+ * A bundle validator.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 19-Dec-2009
+ */
+public interface OSGiBundleValidator
+{
+ /**
+ * Validate the bundle
+ */
+ void validateBundle(AbstractBundleState bundleState);
+}
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR3.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR3.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR3.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -0,0 +1,45 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.bundle;
+
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
+
+/**
+ * A bundle validator for OSGi R3.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @since 19-Dec-2009
+ */
+public class OSGiBundleValidatorR3 implements OSGiBundleValidator
+{
+ public OSGiBundleValidatorR3(OSGiBundleManager bundleManager)
+ {
+ }
+
+ public void validateBundle(AbstractBundleState bundleState)
+ {
+ OSGiMetaData metaData = bundleState.getMetaData();
+ int manifestVersion = metaData.getBundleManifestVersion();
+ if (manifestVersion != 1)
+ throw new IllegalStateException("Unsupported manifest version " + manifestVersion + " for " + bundleState);
+ }
+}
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR4.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR4.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleValidatorR4.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -0,0 +1,130 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.bundle;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.framework.metadata.PackageAttribute;
+import org.osgi.framework.Constants;
+
+/**
+ * OSGiBundleManager.
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @version $Revision: 1.1 $
+ */
+public class OSGiBundleValidatorR4 implements OSGiBundleValidator
+{
+ private OSGiBundleManager bundleManager;
+
+ public OSGiBundleValidatorR4(OSGiBundleManager bundleManager)
+ {
+ this.bundleManager = bundleManager;
+ }
+
+
+ /**
+ * Validate the bundle
+ *
+ * @param bundleState the bundle state
+ */
+ @SuppressWarnings("deprecation")
+ public void validateBundle(AbstractBundleState bundleState)
+ {
+ OSGiMetaData metaData = bundleState.getMetaData();
+
+ // Missing Bundle-SymbolicName
+ String symbolicName = bundleState.getSymbolicName();
+ if (symbolicName == null)
+ throw new IllegalStateException("Missing Bundle-SymbolicName in: " + bundleState);
+
+ // Bundle-ManifestVersion value not equal to 2, unless the Framework specifically recognizes the semantics of a later release.
+ int manifestVersion = metaData.getBundleManifestVersion();
+ if (manifestVersion > 2)
+ throw new IllegalStateException("Unsupported manifest version " + manifestVersion + " for " + bundleState);
+
+ // [TODO] Duplicate attribute or duplicate directive (except in the Bundle-Native code clause).
+
+ // Multiple imports of a given package.
+ List<PackageAttribute> importPackages = metaData.getImportPackages();
+ if (importPackages != null && importPackages.isEmpty() == false)
+ {
+ Set<String> packages = new HashSet<String>();
+ for (PackageAttribute packageAttribute : importPackages)
+ {
+ String packageName = packageAttribute.getAttribute();
+ if (packages.contains(packageName))
+ throw new IllegalStateException("Duplicate import of package " + packageName + " for " + bundleState);
+ packages.add(packageName);
+
+ if (packageName.startsWith("java."))
+ throw new IllegalStateException("Not allowed to import java.* for " + bundleState);
+
+ String version = packageAttribute.getAttributeValue(Constants.VERSION_ATTRIBUTE, String.class);
+ String specificationVersion = packageAttribute.getAttributeValue(Constants.PACKAGE_SPECIFICATION_VERSION, String.class);
+ if (version != null && specificationVersion != null && version.equals(specificationVersion) == false)
+ throw new IllegalStateException(packageName + " version and specification version should be the same for " + bundleState);
+ }
+ }
+
+ // Export or import of java.*.
+ List<PackageAttribute> exportPackages = metaData.getExportPackages();
+ if (exportPackages != null && exportPackages.isEmpty() == false)
+ {
+ for (PackageAttribute packageAttribute : exportPackages)
+ {
+ String packageName = packageAttribute.getAttribute();
+ if (packageName.startsWith("java."))
+ throw new IllegalStateException("Not allowed to export java.* for " + bundleState);
+ }
+ }
+
+ // [TODO] Export-Package with a mandatory attribute that is not defined.
+
+ // Installing a bundle that has the same symbolic name and version as an already installed bundle.
+ for (AbstractBundleState bundle : bundleManager.getBundles())
+ {
+ OSGiMetaData other = bundle.getMetaData();
+ if (symbolicName.equals(other.getBundleSymbolicName()))
+ {
+ if (other.isSingleton() && metaData.isSingleton())
+ throw new IllegalStateException("Cannot install singleton " + bundleState + " another singleton is already installed: " + bundle.getLocation());
+ if (other.getBundleVersion().equals(metaData.getBundleVersion()))
+ throw new IllegalStateException("Cannot install " + bundleState + " a bundle with that name and version is already installed: "
+ + bundle.getLocation());
+ }
+ }
+
+ // [TODO] Updating a bundle to a bundle that has the same symbolic name and version as another installed bundle.
+
+ // [TODO] Any syntactic error (for example, improperly formatted version or bundle symbolic name, unrecognized directive value, etc.).
+
+ // [TODO] Specification-version and version specified together (for the same package(s)) but with different values.
+
+ // [TODO] The manifest lists a OSGI-INF/permission.perm file but no such file is present.
+
+ // [TODO] Requiring the same bundle symbolic name more than once
+ }
+}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2009-12-19 04:03:09 UTC (rev 98016)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -516,7 +516,7 @@
return result.toArray(new String[result.size()]);
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
+ @SuppressWarnings("rawtypes")
public void setProperties(Dictionary properties)
{
checkUnregistered();
@@ -673,7 +673,7 @@
if (used.add(using)) // add so we don't do duplicate work
{
int count = ct.getUsedByCount(this, using);
- while(count > 0)
+ while (count > 0)
{
using.ungetContext(this); // ungetService will cleanup service cache
count--;
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java 2009-12-19 04:03:09 UTC (rev 98016)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiSystemState.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -66,7 +66,7 @@
}
@Override
- public OSGiMetaData getOSGiMetaData()
+ public OSGiMetaData getMetaData()
{
return osgiMetaData;
}
@@ -134,6 +134,13 @@
public URL getEntry(String path)
{
+ return getEntryInternal(path);
+ }
+
+ // Get the entry without checking permissions and bundle state.
+ @Override
+ URL getEntryInternal(String path)
+ {
log.warn("[JBOSGI-138] getEntry(" + path + ")");
return null;
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java 2009-12-19 04:03:09 UTC (rev 98016)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -90,7 +90,7 @@
*/
public OSGiMetaData getMetaData()
{
- return bundleState.getOSGiMetaData();
+ return bundleState.getMetaData();
}
@Override
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java 2009-12-19 04:03:09 UTC (rev 98016)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -191,7 +191,7 @@
if (reqVersionRange.isInRange(capVersion) == false)
return false;
- OSGiMetaData metaData = bundleState.getOSGiMetaData();
+ OSGiMetaData metaData = bundleState.getMetaData();
PackageAttribute capParameters = exportPackage;
PackageAttribute reqParameters = packageRequirement.getPackageMetaData();
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/OSGiMetaData.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/OSGiMetaData.java 2009-12-19 04:03:09 UTC (rev 98016)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/OSGiMetaData.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -31,16 +31,16 @@
* OSGi specific manifest meta data.
*
* @author <a href="mailto:ales.justin@jboss.com">Ales Justin</a>
+ * @author Thomas.Diesler(a)jboss.com
*/
public interface OSGiMetaData extends ManifestMetaData
{
/**
- * Get the headers
+ * Get the headers in raw unlocalized format.
*
- * @param locale the locale to use
* @return the headers
*/
- Dictionary<String, String> getHeaders(String locale);
+ Dictionary<String, String> getHeaders();
/**
* Extension point to read custom manifest headers.
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java 2009-12-19 04:03:09 UTC (rev 98016)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -30,6 +30,7 @@
import static org.jboss.osgi.framework.metadata.internal.ValueCreatorUtil.STRING_LIST_VC;
import static org.jboss.osgi.framework.metadata.internal.ValueCreatorUtil.STRING_VC;
import static org.jboss.osgi.framework.metadata.internal.ValueCreatorUtil.URL_VC;
+import static org.osgi.framework.Constants.BUNDLE_ACTIVATIONPOLICY;
import static org.osgi.framework.Constants.BUNDLE_ACTIVATOR;
import static org.osgi.framework.Constants.BUNDLE_CATEGORY;
import static org.osgi.framework.Constants.BUNDLE_CLASSPATH;
@@ -69,6 +70,7 @@
import org.jboss.osgi.framework.metadata.internal.AbstractVersionRange.OSGiVersionToOSGiVersionComparator;
import org.jboss.osgi.framework.metadata.internal.AbstractVersionRange.OSGiVersionToStringComparator;
import org.jboss.osgi.framework.metadata.internal.AbstractVersionRange.OSGiVersionToVersionComparator;
+import org.jboss.osgi.framework.util.CaseInsensitiveDictionary;
import org.osgi.framework.Constants;
import org.osgi.framework.Version;
@@ -92,7 +94,7 @@
protected transient Map<String, Object> cachedAttributes = new ConcurrentHashMap<String, Object>();
protected transient ParameterizedAttribute parameters;
-
+
public AbstractOSGiMetaData()
{
}
@@ -103,14 +105,14 @@
}
@SuppressWarnings({ "unchecked", "rawtypes" })
- public Dictionary<String, String> getHeaders(String locale)
+ public Dictionary<String, String> getHeaders()
{
- // TODO localisation
- Map<Name, String> attributes = (Map) getManifest().getMainAttributes();
- Hashtable<String, String> result = new Hashtable<String, String>();
+ Map<Name, String> attributes = (Map)getManifest().getMainAttributes();
+ Dictionary<String, String> result = new Hashtable<String, String>();
for (Entry<Name, String> entry : attributes.entrySet())
result.put(entry.getKey().toString(), entry.getValue());
- return result;
+
+ return new CaseInsensitiveDictionary(result);
}
public String getHeader(String key)
@@ -120,7 +122,7 @@
public ActivationPolicyMetaData getBundleActivationPolicy()
{
- return get("Bundle-ActivationPolicy", ACTIVATION_POLICY_VC);
+ return get(BUNDLE_ACTIVATIONPOLICY, ACTIVATION_POLICY_VC);
}
public String getBundleActivator()
@@ -150,7 +152,7 @@
public int getBundleManifestVersion()
{
- return get(BUNDLE_MANIFESTVERSION, INTEGER_VC, 2);
+ return get(BUNDLE_MANIFESTVERSION, INTEGER_VC, 1);
}
public String getBundleName()
@@ -171,11 +173,11 @@
public String getBundleSymbolicName()
{
String symbolicName = null;
-
+
ParameterizedAttribute parameters = parseSymbolicName();
if (parameters != null)
symbolicName = parameters.getAttribute();
-
+
return symbolicName;
}
@@ -183,7 +185,7 @@
{
return parseSymbolicName();
}
-
+
public URL getBundleUpdateLocation()
{
return get(BUNDLE_UPDATELOCATION, URL_VC);
@@ -191,7 +193,7 @@
public String getBundleVersion()
{
- return get(BUNDLE_VERSION, STRING_VC , "0.0.0");
+ return get(BUNDLE_VERSION, STRING_VC, "0.0.0");
}
public List<PackageAttribute> getDynamicImports()
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverBundleImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverBundleImpl.java 2009-12-19 04:03:09 UTC (rev 98016)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolverBundleImpl.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -43,7 +43,7 @@
{
super(bundle);
- this.metaData = OSGiBundleState.assertBundleState(bundle).getOSGiMetaData();
+ this.metaData = OSGiBundleState.assertBundleState(bundle).getMetaData();
// Initialize exported packages
List<PackageAttribute> exportPackages = metaData.getExportPackages();
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java 2009-12-19 04:03:09 UTC (rev 98016)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/resolver/internal/basic/BasicResolverImpl.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -405,7 +405,7 @@
// The Require-Bundle header specifies that all exported packages from
// another bundle must be imported, effectively requiring the public interface
// of another bundle
- OSGiMetaData osgiMetaData = bundle.getOSGiMetaData();
+ OSGiMetaData osgiMetaData = bundle.getMetaData();
List<ParameterizedAttribute> requireBundles = osgiMetaData.getRequireBundles();
if (requireBundles != null)
{
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/CaseInsensitiveDictionary.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/CaseInsensitiveDictionary.java 2009-12-19 04:03:09 UTC (rev 98016)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/CaseInsensitiveDictionary.java 2009-12-19 11:35:39 UTC (rev 98017)
@@ -36,8 +36,11 @@
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
* @version $Revision: 1.1 $
*/
-public class CaseInsensitiveDictionary extends Dictionary<String, Object>
+@SuppressWarnings("rawtypes")
+public class CaseInsensitiveDictionary extends Hashtable
{
+ private static final long serialVersionUID = 5802491129524016545L;
+
/** The delegate dictionary */
private Dictionary<String, Object> delegate;
@@ -49,11 +52,12 @@
*
* @param delegate the delegate
*/
- public CaseInsensitiveDictionary(Dictionary<String, Object> delegate)
+ @SuppressWarnings("unchecked")
+ public CaseInsensitiveDictionary(Dictionary delegate)
{
if (delegate == null)
throw new IllegalArgumentException("Null delegaqte");
-
+
this.delegate = new Hashtable<String, Object>(delegate.size());
this.originalKeys = Collections.synchronizedSet(new HashSet<String>());
Enumeration<String> e = delegate.keys();
@@ -62,32 +66,32 @@
String key = e.nextElement();
if (get(key) != null)
throw new IllegalArgumentException("Properties contain duplicates with varying case for key=" + key + " : " + delegate);
-
+
this.delegate.put(key.toLowerCase(), delegate.get(key));
originalKeys.add(key);
}
}
-
+
public Enumeration<Object> elements()
{
return delegate.elements();
}
- @SuppressWarnings({ "unchecked", "rawtypes" })
+ @SuppressWarnings("unchecked")
public synchronized boolean equals(Object obj)
{
if (obj == this)
return true;
if (obj == null || obj instanceof Dictionary == false)
return false;
-
- Dictionary<String, Object> other = (Dictionary) obj;
-
+
+ Dictionary<String, Object> other = (Dictionary)obj;
+
if (size() != other.size())
return false;
if (isEmpty())
return true;
-
+
for (String key : originalKeys)
{
if (get(key).equals(other.get(key)))
@@ -99,7 +103,7 @@
public Object get(Object key)
{
if (key instanceof String)
- key = ((String) key).toLowerCase();
+ key = ((String)key).toLowerCase();
return delegate.get(key);
}
@@ -119,7 +123,7 @@
return Iterators.toEnumeration(originalKeys.iterator());
}
- public Object put(String key, Object value)
+ public Object put(Object key, Object value)
{
throw new UnsupportedOperationException("immutable");
}
14 years, 4 months
JBoss-OSGI SVN: r97998 - in projects/jboss-osgi/projects: runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading and 35 other directories.
by jboss-osgi-commits@lists.jboss.org
Author: thomas.diesler(a)jboss.com
Date: 2009-12-18 12:45:01 -0500 (Fri, 18 Dec 2009)
New Revision: 97998
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/OSGiMetaData.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/metadata/HeaderValuesTestCase.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/attributerequirebundleA/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/attributerequirebundlefails/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/bundleA/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/bundleclasspath/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/noreexportrequirebundleA/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/optionalrequirebundleA/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/optionalrequirebundlefails/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/reexportrequirebundleA/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/reexportrequirebundleB/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/simplerequirebundleA/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/simplerequirebundlefails/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/versionrequirebundleA/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/versionrequirebundlefails/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/entries/entries-simple/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/fail-on-start/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/simple-service/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle1/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle2/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle3/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/simple/simple-bundle1/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/simple/simple-bundle2/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/singleton/not-singleton/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/singleton/singleton1/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/singleton/singleton2/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/smoke/smoke-assembled/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/smoke/smoke-osgi-manifest/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/update/update-bundle1/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/update/update-bundle2/META-INF/MANIFEST.MF
projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
Log:
Initial support for R3 bundles
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2009-12-18 17:45:01 UTC (rev 97998)
@@ -50,7 +50,6 @@
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.FrameworkListener;
import org.osgi.framework.FrameworkUtil;
@@ -103,14 +102,22 @@
{
String symbolicName = getOSGiMetaData().getBundleSymbolicName();
if (symbolicName == null)
- throw new IllegalStateException("Cannot obtain " + Constants.BUNDLE_SYMBOLICNAME);
+ symbolicName = "anonymous-bundle" + getBundleId();
+
return symbolicName;
}
public Version getVersion()
{
- Version version = getOSGiMetaData().getBundleVersion();
- return version;
+ String versionstr = getOSGiMetaData().getBundleVersion();
+ try
+ {
+ return Version.parseVersion(versionstr);
+ }
+ catch (NumberFormatException ex)
+ {
+ return Version.emptyVersion;
+ }
}
public int getState()
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-12-18 17:45:01 UTC (rev 97998)
@@ -25,6 +25,8 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.AccessController;
@@ -53,6 +55,9 @@
import org.jboss.dependency.spi.ControllerState;
import org.jboss.dependency.spi.tracker.ContextTracker;
import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.IncompleteDeploymentException;
+import org.jboss.deployers.client.spi.IncompleteDeployments;
+import org.jboss.deployers.client.spi.MissingDependency;
import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.attachments.MutableAttachments;
import org.jboss.deployers.spi.deployer.DeploymentStage;
@@ -720,17 +725,76 @@
throw e;
}
}
+ catch (IncompleteDeploymentException ex)
+ {
+ String errorMessage = getIncompleteDeploymentInfo(dep, ex);
+ throw new BundleException(errorMessage);
+ }
catch (Exception ex)
{
- Throwable cause = ex;
- if (ex instanceof DeploymentException)
+ throw new BundleException("Error installing bundle from: " + dep, ex);
+ }
+ }
+
+ private String getIncompleteDeploymentInfo(Deployment dep, IncompleteDeploymentException ex)
+ {
+ IncompleteDeployments deployments = ex.getIncompleteDeployments();
+
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter printWriter = new PrintWriter(stringWriter);
+ printWriter.println("Error installing bundle from: " + dep);
+
+ // Contexts in error
+ Collection<Throwable> contextsError = deployments.getContextsInError().values();
+ if (contextsError.size() > 0)
+ {
+ printWriter.println("\nContext Errors:");
+ for (Throwable th : contextsError)
{
- cause = ex.getCause();
- if (cause instanceof BundleException)
- throw (BundleException)cause;
+ printWriter.println("\n");
+ th.printStackTrace(printWriter);
}
- throw new BundleException("Error installing bundle from: " + dep, (cause != null ? cause : ex));
}
+
+ // Deployments in error
+ Collection<Throwable> deploymentsInError = deployments.getDeploymentsInError().values();
+ if (deploymentsInError.size() > 0)
+ {
+ printWriter.println("\nDeployment Errors:");
+ for (Throwable th : deploymentsInError)
+ {
+ printWriter.println("\n");
+ th.printStackTrace(printWriter);
+ }
+ }
+
+ // Missing Dependencies
+ Collection<Set<MissingDependency>> missingDependencies = deployments.getContextsMissingDependencies().values();
+ if (missingDependencies.size() > 0)
+ {
+ printWriter.println("\nMissing Dependencies:");
+ for (Set<MissingDependency> missDeps : missingDependencies)
+ {
+ for (MissingDependency missDep : missDeps)
+ {
+ printWriter.println("\n " + missDep);
+ }
+ }
+ }
+
+ // Missing Deployers
+ Collection<String> missingDeployers = deployments.getDeploymentsMissingDeployer();
+ if (missingDeployers.size() > 0)
+ {
+ printWriter.println("\nMissing Deployers:");
+ for (String missDep : missingDeployers)
+ {
+ printWriter.println("\n " + missDep);
+ }
+ }
+
+ String errorMessage = stringWriter.toString();
+ return errorMessage;
}
/**
@@ -974,14 +1038,11 @@
if (metaData == null)
return;
- String symbolicName = metaData.getBundleSymbolicName();
- if (symbolicName == null)
- throw new IllegalStateException("No bundle symbolic name " + bundleState);
-
int manifestVersion = metaData.getBundleManifestVersion();
if (manifestVersion > 2)
throw new IllegalStateException("Unsupported manifest version " + manifestVersion + " for " + bundleState);
+ String symbolicName = bundleState.getSymbolicName();
for (AbstractBundleState bundle : getBundles())
{
OSGiMetaData other = bundle.getOSGiMetaData();
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java 2009-12-18 17:45:01 UTC (rev 97998)
@@ -26,6 +26,7 @@
import org.jboss.classloading.plugins.metadata.ModuleCapability;
import org.jboss.classloading.spi.dependency.Module;
import org.jboss.classloading.spi.metadata.Requirement;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.Parameter;
import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
@@ -45,25 +46,25 @@
/** The serialVersionUID */
private static final long serialVersionUID = 2366716668262831380L;
- /** The metadata */
- private OSGiMetaData metadata;
+ /** The bundle state */
+ private OSGiBundleState bundleState;
/**
* Create a new OSGiBundleCapability
*
- * @param metadata the osgi metadata
+ * @param bundleState the bundleState
* @return the capability
* @throws IllegalArgumentException for a null metadata
*/
- public static OSGiBundleCapability create(OSGiMetaData metadata)
+ public static OSGiBundleCapability create(OSGiBundleState bundleState)
{
- if (metadata == null)
- throw new IllegalArgumentException("Null metadata");
+ if (bundleState == null)
+ throw new IllegalArgumentException("Null bundleState");
- String name = metadata.getBundleSymbolicName();
- Version version = metadata.getBundleVersion();
+ String symbolicName = bundleState.getSymbolicName();
+ Version version = bundleState.getVersion();
- return new OSGiBundleCapability(name, version, metadata);
+ return new OSGiBundleCapability(symbolicName, version, bundleState);
}
/**
@@ -74,12 +75,12 @@
* @param metadata the metadata
* @throws IllegalArgumentException for a null name or requireBundle
*/
- public OSGiBundleCapability(String name, Version version, OSGiMetaData metadata)
+ public OSGiBundleCapability(String name, Version version, OSGiBundleState bundleState)
{
super(name, version);
- if (metadata == null)
- throw new IllegalArgumentException("Null metadata");
- this.metadata = metadata;
+ if (bundleState == null)
+ throw new IllegalArgumentException("Null bundleState");
+ this.bundleState = bundleState;
}
/**
@@ -89,7 +90,7 @@
*/
public OSGiMetaData getMetaData()
{
- return metadata;
+ return bundleState.getOSGiMetaData();
}
@Override
@@ -146,7 +147,7 @@
protected void toString(StringBuffer buffer)
{
super.toString(buffer);
- ParameterizedAttribute parameters = metadata.getBundleParameters();
+ ParameterizedAttribute parameters = getMetaData().getBundleParameters();
if (parameters != null)
{
Map<String, Parameter> params = parameters.getAttributes();
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoadingDeployer.java 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoadingDeployer.java 2009-12-18 17:45:01 UTC (rev 97998)
@@ -90,14 +90,14 @@
OSGiBundleManager bundleManager = bundleState.getBundleManager();
ClassLoadingMetaData classLoadingMetaData = new ClassLoadingMetaData();
- classLoadingMetaData.setName(osgiMetaData.getBundleSymbolicName());
- classLoadingMetaData.setVersion(osgiMetaData.getBundleVersion());
+ classLoadingMetaData.setName(bundleState.getSymbolicName());
+ classLoadingMetaData.setVersion(bundleState.getVersion());
classLoadingMetaData.setDomain(domain != null ? domain.getName() : null);
CapabilitiesMetaData capabilities = classLoadingMetaData.getCapabilities();
RequirementsMetaData requirements = classLoadingMetaData.getRequirements();
- OSGiBundleCapability capability = OSGiBundleCapability.create(osgiMetaData);
+ OSGiBundleCapability capability = OSGiBundleCapability.create(bundleState);
capabilities.addCapability(capability);
List<ParameterizedAttribute> requireBundles = osgiMetaData.getRequireBundles();
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java 2009-12-18 17:45:01 UTC (rev 97998)
@@ -22,7 +22,6 @@
package org.jboss.osgi.framework.deployers;
import java.util.jar.Manifest;
-import java.util.jar.Attributes.Name;
import org.jboss.deployers.vfs.spi.deployer.ManifestDeployer;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
@@ -30,35 +29,38 @@
import org.jboss.osgi.framework.metadata.internal.AbstractOSGiMetaData;
import org.jboss.osgi.spi.OSGiConstants;
import org.jboss.virtual.VirtualFile;
-import org.osgi.framework.Constants;
/**
* OSGiManifestParsingDeployer.<p>
*
- * This deployer attaches OSGiMetaData to the deployment if it is a real OSGi bundle.
+ * This deployer attaches OSGiMetaData to the deployment.
*
* @author <a href="adrian(a)jboss.com">Adrian Brock</a>
+ * @author Thomas.Diesler(a)jboss.com
* @version $Revision: 1.1 $
*/
public class OSGiManifestParsingDeployer extends ManifestDeployer<OSGiMetaData>
{
- /**
- * Create a new OSGiManifestParsingDeployer.
- */
public OSGiManifestParsingDeployer()
{
super(OSGiMetaData.class);
setTopLevelOnly(true);
}
-
+
@Override
protected OSGiMetaData createMetaData(Manifest manifest) throws Exception
{
- // To be a true OSGi bundle it must have a bundle symbolic name in the manfiest
- if (manifest.getMainAttributes().get(new Name(Constants.BUNDLE_SYMBOLICNAME)) == null)
- return null;
-
- return new AbstractOSGiMetaData(manifest);
+ AbstractOSGiMetaData metaData = new AbstractOSGiMetaData(manifest);
+
+ // At least one of these manifest headers must be there
+ // Note, in R3 and R4 there is no common mandatory header
+ String bundleName = metaData.getBundleName();
+ String bundleVersion = metaData.getBundleVersion();
+ String bundleSymbolicName = metaData.getBundleSymbolicName();
+ if (bundleName == null && bundleVersion == null && bundleSymbolicName == null)
+ metaData = null;
+
+ return metaData;
}
@Override
@@ -67,9 +69,11 @@
super.init(unit, metaData, file);
String symbolicName = metaData.getBundleSymbolicName();
- log.debug("Bundle-SymbolicName: " + symbolicName + " in " + file);
-
- // Add a marker that this is an OSGi deployment
- unit.addAttachment(OSGiConstants.KEY_BUNDLE_SYMBOLIC_NAME, symbolicName);
+ if (symbolicName != null)
+ {
+ // Add a marker that this is an R4 OSGi deployment
+ log.debug("Bundle-SymbolicName: " + symbolicName);
+ unit.addAttachment(OSGiConstants.KEY_BUNDLE_SYMBOLIC_NAME, symbolicName);
+ }
}
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/OSGiMetaData.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/OSGiMetaData.java 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/OSGiMetaData.java 2009-12-18 17:45:01 UTC (rev 97998)
@@ -26,7 +26,6 @@
import java.util.List;
import org.jboss.deployers.vfs.spi.deployer.ManifestMetaData;
-import org.osgi.framework.Version;
/**
* OSGi specific manifest meta data.
@@ -143,10 +142,12 @@
/**
* Get bundle's version.
- *
+ *
+ * Note, R3 does not define a specific syntax for Bundle-Version.
+ *
* @return version of this bundle
*/
- Version getBundleVersion();
+ String getBundleVersion();
/**
* Get dynamic imports.
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/metadata/internal/AbstractOSGiMetaData.java 2009-12-18 17:45:01 UTC (rev 97998)
@@ -30,7 +30,6 @@
import static org.jboss.osgi.framework.metadata.internal.ValueCreatorUtil.STRING_LIST_VC;
import static org.jboss.osgi.framework.metadata.internal.ValueCreatorUtil.STRING_VC;
import static org.jboss.osgi.framework.metadata.internal.ValueCreatorUtil.URL_VC;
-import static org.jboss.osgi.framework.metadata.internal.ValueCreatorUtil.VERSION_VC;
import static org.osgi.framework.Constants.BUNDLE_ACTIVATOR;
import static org.osgi.framework.Constants.BUNDLE_CATEGORY;
import static org.osgi.framework.Constants.BUNDLE_CLASSPATH;
@@ -190,9 +189,9 @@
return get(BUNDLE_UPDATELOCATION, URL_VC);
}
- public Version getBundleVersion()
+ public String getBundleVersion()
{
- return get(BUNDLE_VERSION, VERSION_VC , Version.emptyVersion);
+ return get(BUNDLE_VERSION, STRING_VC , "0.0.0");
}
public List<PackageAttribute> getDynamicImports()
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleUnitTestCase.java 2009-12-18 17:45:01 UTC (rev 97998)
@@ -242,6 +242,7 @@
Dictionary expected = new Hashtable();
expected.put(Constants.BUNDLE_NAME, "Simple1");
expected.put(Constants.BUNDLE_SYMBOLICNAME, "org.jboss.test.osgi.simple1");
+ expected.put(Constants.BUNDLE_MANIFESTVERSION, "2");
expected.put(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
expected.put(Attributes.Name.IMPLEMENTATION_TITLE.toString(), "JBoss OSGi tests");
expected.put(Attributes.Name.IMPLEMENTATION_VENDOR.toString(), "jboss.org");
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/metadata/HeaderValuesTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/metadata/HeaderValuesTestCase.java 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/java/org/jboss/test/osgi/bundle/metadata/HeaderValuesTestCase.java 2009-12-18 17:45:01 UTC (rev 97998)
@@ -41,7 +41,6 @@
import org.jboss.osgi.framework.metadata.internal.AbstractParameter;
import org.jboss.osgi.framework.metadata.internal.AbstractParameterizedAttribute;
import org.jboss.osgi.framework.metadata.internal.OSGiParameters;
-import org.osgi.framework.Version;
/**
* Test OSGi header values.
@@ -79,20 +78,16 @@
Manifest manifest = getManifest(createName("Simple"));
OSGiMetaData metaData = new AbstractOSGiMetaData(manifest);
- assertEquals(metaData.getBundleActivator(), "org.jboss.test.osgi.bundle.metadata.BundleActivator");
- List<String> classpath = Arrays.asList("test.jar", "mc.jar", "seam.jar");
- assertEquals(metaData.getBundleClassPath(), classpath);
- assertEquals(metaData.getBundleDescription(), "TestHeadersManifest");
- assertEquals(metaData.getBundleLocalization(), "OSGI-INF/l10n/bundle");
- assertEquals(metaData.getBundleManifestVersion(), 2);
- assertEquals(metaData.getBundleName(), "TestBundle");
- assertEquals(metaData.getBundleSymbolicName(), "UniqueName");
- URL url = new URL("file://test.jar");
- assertEquals(metaData.getBundleUpdateLocation(), url);
- Version version = new Version("1.2.3.GA");
- assertEquals(metaData.getBundleVersion(), version);
- List<String> env = Arrays.asList("ena", "dva", "tri");
- assertEquals(metaData.getRequiredExecutionEnvironment(), env);
+ assertEquals("org.jboss.test.osgi.bundle.metadata.BundleActivator", metaData.getBundleActivator());
+ assertEquals(Arrays.asList("test.jar", "mc.jar", "seam.jar"), metaData.getBundleClassPath());
+ assertEquals("TestHeadersManifest", metaData.getBundleDescription());
+ assertEquals("OSGI-INF/l10n/bundle", metaData.getBundleLocalization());
+ assertEquals(2, metaData.getBundleManifestVersion());
+ assertEquals("TestBundle", metaData.getBundleName());
+ assertEquals("UniqueName", metaData.getBundleSymbolicName());
+ assertEquals(new URL("file://test.jar"), metaData.getBundleUpdateLocation());
+ assertEquals("1.2.3.GA", metaData.getBundleVersion());
+ assertEquals(Arrays.asList("ena", "dva", "tri"), metaData.getRequiredExecutionEnvironment());
}
public void testJavaccManifest() throws Exception
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/attributerequirebundleA/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/attributerequirebundleA/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/attributerequirebundleA/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: BundleB
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
Require-Bundle: org.jboss.test.osgi.classloader.bundleA;test=x
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/attributerequirebundlefails/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/attributerequirebundlefails/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/attributerequirebundlefails/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: BundleB
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
Require-Bundle: org.jboss.test.osgi.classloader.bundleA;doesnotexist=true;test=y
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/bundleA/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/bundleA/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/bundleA/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,8 +1,5 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: BundleA
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleA;test=x
Bundle-Version: 1.0.0
Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0;test=x
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/bundleclasspath/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/bundleclasspath/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/bundleclasspath/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,3 +1,4 @@
+Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: bundle-classpath
Bundle-ClassPath: .,WEB-INF/classes
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/noreexportrequirebundleA/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/noreexportrequirebundleA/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/noreexportrequirebundleA/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,8 +1,5 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: BundleB
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
Require-Bundle: org.jboss.test.osgi.classloader.bundleA
Export-Package: org.jboss.test.osgi.classloader.support.b
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/optionalrequirebundleA/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/optionalrequirebundleA/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/optionalrequirebundleA/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: BundleB
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
Require-Bundle: org.jboss.test.osgi.classloader.bundleA;resolution:=optional
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/optionalrequirebundlefails/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/optionalrequirebundlefails/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/optionalrequirebundlefails/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: BundleB
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
Require-Bundle: doesnotexist;resolution:=optional
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/reexportrequirebundleA/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/reexportrequirebundleA/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/reexportrequirebundleA/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,8 +1,5 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: BundleB
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
Require-Bundle: org.jboss.test.osgi.classloader.bundleA;visibility:=reexport
Export-Package: org.jboss.test.osgi.classloader.support.b
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/reexportrequirebundleB/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/reexportrequirebundleB/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/reexportrequirebundleB/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: BundleC
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleC
Require-Bundle: org.jboss.test.osgi.classloader.bundleB
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/simplerequirebundleA/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/simplerequirebundleA/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/simplerequirebundleA/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: BundleB
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
Require-Bundle: org.jboss.test.osgi.classloader.bundleA
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/simplerequirebundlefails/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/simplerequirebundlefails/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/simplerequirebundlefails/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: BundleB
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
Require-Bundle: doesnotexist
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/versionrequirebundleA/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/versionrequirebundleA/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/versionrequirebundleA/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: BundleB
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
Require-Bundle: org.jboss.test.osgi.classloader.bundleA;bundle-version="[0.0.0,1.0.0]"
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/versionrequirebundlefails/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/versionrequirebundlefails/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/classloader/versionrequirebundlefails/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: BundleB
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
Require-Bundle: org.jboss.test.osgi.classloader.bundleA;bundle-version="[0.0.0,1.0.0)"
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/entries/entries-simple/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/entries/entries-simple/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/entries/entries-simple/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,6 +1,3 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: EntriesSimple
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.entries.simple
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/fail-on-start/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/fail-on-start/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/fail-on-start/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,3 +1,4 @@
+Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: lifecycle-failstart
Import-Package: org.jboss.test.osgi.bundle.support.b
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/simple-service/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/simple-service/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/lifecycle/simple-service/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,3 +1,4 @@
+Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: lifecycle-service
Export-Package: org.jboss.test.osgi.bundle.support.b
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle1/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle1/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle1/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: Service1
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.service1
Import-Package: org.jboss.test.osgi.service.support.a
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle2/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle2/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle2/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: Service2
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.service2
Export-Package: org.jboss.test.osgi.service.support.a
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle3/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle3/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle3/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: Service3
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.service3
Import-Package: org.jboss.test.osgi.service.support.a,org.jboss.test.osgi.service.support.c
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/service/service-bundle4/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: Service4
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.service4
Import-Package: org.jboss.test.osgi.service.support.a,org.jboss.test.osgi.service.support.c,org.jboss.test.osgi.service.support.d,org.osgi.framework
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/simple/simple-bundle1/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/simple/simple-bundle1/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/simple/simple-bundle1/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -2,5 +2,6 @@
Implementation-Title: JBoss OSGi tests
Implementation-Version: test
Implementation-Vendor: jboss.org
+Bundle-ManifestVersion: 2
Bundle-Name: Simple1
Bundle-SymbolicName: org.jboss.test.osgi.simple1
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/simple/simple-bundle2/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/simple/simple-bundle2/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/simple/simple-bundle2/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,6 +1,3 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: Simple2
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.simple2
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/singleton/not-singleton/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/singleton/not-singleton/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/singleton/not-singleton/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,7 +1,4 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: NotSingleton
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.singleton
Bundle-Version: 2.0.0
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/singleton/singleton1/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/singleton/singleton1/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/singleton/singleton1/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,6 +1,3 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: Singleton1
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.singleton;singleton:=true
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/singleton/singleton2/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/singleton/singleton2/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/singleton/singleton2/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,6 +1,3 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: Singleton2
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.singleton;singleton:=true
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/smoke/smoke-assembled/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/smoke/smoke-assembled/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/smoke/smoke-assembled/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,6 +1,3 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: SmokeAssmbled
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.smoke.assembled
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/smoke/smoke-osgi-manifest/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/smoke/smoke-osgi-manifest/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/smoke/smoke-osgi-manifest/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,6 +1,3 @@
Manifest-Version: 1.0
-Implementation-Title: JBoss OSGi tests
-Implementation-Version: test
-Implementation-Vendor: jboss.org
-Bundle-Name: Smoke
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.jboss.test.osgi.smoke
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/update/update-bundle1/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/update/update-bundle1/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/update/update-bundle1/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,4 +1,5 @@
Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: update-bundle1
Bundle-Version: 1.0.0
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/update/update-bundle2/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/update/update-bundle2/META-INF/MANIFEST.MF 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bundles/update/update-bundle2/META-INF/MANIFEST.MF 2009-12-18 17:45:01 UTC (rev 97998)
@@ -1,3 +1,4 @@
Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
Bundle-SymbolicName: update-bundle2
Bundle-Version: 1.0.1
Modified: projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java
===================================================================
--- projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-12-18 17:41:46 UTC (rev 97997)
+++ projects/jboss-osgi/projects/spi/trunk/src/main/java/org/jboss/osgi/spi/util/BundleInfo.java 2009-12-18 17:45:01 UTC (rev 97998)
@@ -54,7 +54,7 @@
private URL rootURL;
private String location;
private String symbolicName;
- private String version;
+ private String bundleVersion;
private transient VirtualFile rootFile;
private transient Manifest manifest;
@@ -67,7 +67,7 @@
URL url = getRealLocation(location);
if (url == null)
throw new IllegalArgumentException("Cannot obtain root url from: " + location);
-
+
return new BundleInfo(toVirtualFile(url), url.toExternalForm());
}
@@ -75,7 +75,7 @@
{
if (url == null)
throw new IllegalArgumentException("Null root url");
-
+
return new BundleInfo(toVirtualFile(url), url.toExternalForm());
}
@@ -100,9 +100,9 @@
// Derive the location from the root
if (location == null)
location = rootURL.toExternalForm();
-
+
this.location = location;
-
+
// Initialize the manifest
try
{
@@ -113,12 +113,58 @@
throw new BundleException("Cannot get manifest from: " + rootURL, ex);
}
+ // A bundle manifest must express the version of the OSGi manifest header
+ // syntax in the Bundle-ManifestVersion header. Bundles exploiting this version
+ // of the Framework specification (or later) must specify this header.
+ // The Framework version 1.3 (or later) bundle manifest version must be ’2’.
+ // Bundle manifests written to previous specifications’ manifest syntax are
+ // taken to have a bundle manifest version of '1', although there is no way to
+ // express this in such manifests.
+ String manifestVersion = getManifestHeader(Constants.BUNDLE_MANIFESTVERSION);
+ if (manifestVersion == null)
+ manifestVersion = "1";
+
symbolicName = getManifestHeader(Constants.BUNDLE_SYMBOLICNAME);
- if (symbolicName == null)
- throw new IllegalArgumentException("Cannot obtain Bundle-SymbolicName for: " + rootFile);
+ bundleVersion = getManifestHeader(Constants.BUNDLE_VERSION);
+
+ // R3 Framework
+ if (manifestVersion.equals("1"))
+ {
+ if (symbolicName != null)
+ throw new IllegalArgumentException("Invalid Bundle-ManifestVersion:=1 for " + symbolicName);
- version = getManifestHeader(Constants.BUNDLE_VERSION);
- version = Version.parseVersion(version).toString();
+ // Generate default symbolic name
+ String name = getManifestHeader(Constants.BUNDLE_NAME);
+ symbolicName = name.replace(' ', '-');
+
+ // Parse the Bundle-Version string
+ try
+ {
+ bundleVersion = Version.parseVersion(bundleVersion).toString();
+ }
+ catch (NumberFormatException ex)
+ {
+ // Install expected to succeed on invalid Bundle-Version
+ // https://www.osgi.org/members/bugzilla/show_bug.cgi?id=1503
+ bundleVersion = Version.emptyVersion.toString();
+ }
+ }
+
+ // R4 Framework
+ else if (manifestVersion.equals("2"))
+ {
+ if (symbolicName == null)
+ throw new IllegalArgumentException("Cannot obtain Bundle-SymbolicName for: " + rootFile);
+
+ // Parse the Bundle-Version string
+ bundleVersion = Version.parseVersion(bundleVersion).toString();
+ }
+
+ // Unsupported Bundle-ManifestVersion
+ else
+ {
+ throw new IllegalArgumentException("Unsupported Bundle-ManifestVersion: " + manifestVersion);
+ }
}
/**
@@ -146,7 +192,7 @@
{
if (rootFile == null)
rootFile = toVirtualFile(rootURL);
-
+
return rootFile;
}
@@ -171,10 +217,10 @@
*/
public Version getVersion()
{
- return Version.parseVersion(version);
+ return Version.parseVersion(bundleVersion);
}
- private Manifest getManifest()
+ private Manifest getManifest()
{
if (manifest == null)
{
@@ -229,7 +275,7 @@
// ignore
}
}
-
+
// Try to prefix the location with the test archive directory
if (url == null)
{
@@ -237,10 +283,10 @@
if (location.startsWith(prefix) == false && new File(prefix).exists())
return getRealLocation(prefix + File.separator + location);
}
-
+
return url;
}
-
+
private static URL toURL(VirtualFile file)
{
try
@@ -255,7 +301,7 @@
private String toEqualString()
{
- return "[" + symbolicName + "-" + version + ",url=" + rootURL + "]";
+ return "[" + symbolicName + "-" + bundleVersion + ",url=" + rootURL + "]";
}
@Override
14 years, 4 months