[jboss-osgi-commits] JBoss-OSGI SVN: r93457 - in projects/jboss-osgi/projects/runtime/microcontainer/trunk: src/main/java/org/jboss/osgi/plugins/deployers/bundle and 23 other directories.
jboss-osgi-commits at lists.jboss.org
jboss-osgi-commits at lists.jboss.org
Mon Sep 14 04:40:28 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-09-14 04:40:27 -0400 (Mon, 14 Sep 2009)
New Revision: 93457
Added:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderFactory.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderPolicy.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/MicrocontainerServiceImpl.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/classloader/selfimportpackageAB/
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/classloader/selfimportpackageAB/META-INF/
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/classloader/selfimportpackageAB/META-INF/MANIFEST.MF
Removed:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/MicrocontainerServiceImpl.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/bundle/metadata/MetaDataTestSuite.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleTestSuite.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/FilterTestSuite.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/ServiceTestSuite.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/smoke/SmokeTestSuite.java
Modified:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/pom.xml
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/OSGiDeployersWrapper.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/api/StartLevelServicePlugin.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiServiceState.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiBundleClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/plugins/AbstractServicePluginImpl.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/resolver/BundleResolver.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/bundle/metadata/VersionRangeTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleContextUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleEntriesUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/SystemBundleUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/ExportImportPackageUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/RequireBundleUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/AbstractFilterTest.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/BundleContextFilterUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/FrameworkUtilFilterUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/resolver/BundleResolverTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/GetServiceReferencesUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/GetUnGetServiceUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/RegisterServiceUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/ServiceReferenceUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/ServiceRegistrationUnitTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/smoke/test/OSGiSmokeTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/classloader/simpleimportpackageA/META-INF/MANIFEST.MF
Log:
[JBCL-115] Module adds invalid delegates
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/pom.xml 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/pom.xml 2009-09-14 08:40:27 UTC (rev 93457)
@@ -44,6 +44,7 @@
<version.jboss.logging.log4j>2.1.0.GA</version.jboss.logging.log4j>
<version.jboss.osgi.apache.xerces>2.9.1-SNAPSHOT</version.jboss.osgi.apache.xerces>
<version.jboss.osgi.common>1.0.1-SNAPSHOT</version.jboss.osgi.common>
+ <version.jboss.osgi.common-core>2.2.13-SNAPSHOT</version.jboss.osgi.common-core>
<version.jboss.osgi.hotdeploy>1.0.1-SNAPSHOT</version.jboss.osgi.hotdeploy>
<version.jboss.osgi.husky>1.0.0</version.jboss.osgi.husky>
<version.jboss.osgi.jaxb>2.1.10-SNAPSHOT</version.jboss.osgi.jaxb>
@@ -250,6 +251,12 @@
</dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-common-core</artifactId>
+ <version>${version.jboss.osgi.common-core}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-husky</artifactId>
<version>${version.jboss.osgi.husky}</version>
<scope>test</scope>
@@ -262,6 +269,12 @@
</dependency>
<dependency>
<groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-jmx</artifactId>
+ <version>${version.jboss.osgi.jmx}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
<artifactId>jboss-osgi-xml-binding</artifactId>
<version>${version.jboss.osgi.xml.binding}</version>
<scope>test</scope>
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/OSGiDeployersWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/OSGiDeployersWrapper.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/OSGiDeployersWrapper.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -83,7 +83,7 @@
{
if (packageAdmin == null)
{
- BundleContext sysContext = bundleManager.getSystemContext();
+ BundleContext sysContext = bundleManager.getBundleContext();
ServiceReference sref = sysContext.getServiceReference(PackageAdmin.class.getName());
if (sref == null)
throw new IllegalStateException("Cannot obtain PackageAdmin");
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/api/StartLevelServicePlugin.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/api/StartLevelServicePlugin.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/api/StartLevelServicePlugin.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -21,8 +21,6 @@
*/
package org.jboss.osgi.plugins.facade.api;
-//$Id: AbstractPlugin.java 92725 2009-08-24 06:19:18Z thomas.diesler at jboss.com $
-
import org.osgi.service.startlevel.StartLevel;
/**
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleManager.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -31,6 +31,7 @@
import java.util.Comparator;
import java.util.Dictionary;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -124,7 +125,7 @@
/** The kernel */
private Kernel kernel;
-
+
/** The main deployer */
private DeployerClient deployerClient;
@@ -138,7 +139,7 @@
private OSGiSystemState systemBundle;
/** The registered manager plugins */
- private Map<Class<?>, Plugin> plugins = new HashMap<Class<?>, Plugin>();
+ private Map<Class<?>, Plugin> plugins = new LinkedHashMap<Class<?>, Plugin>();
/** The frame work properties */
private Map<String, Object> properties = new HashMap<String, Object>();
@@ -218,7 +219,7 @@
{
return kernel;
}
-
+
/**
* Set the framework properties
*
@@ -263,9 +264,8 @@
}
/**
- * Set a property.
- * This is used at the frame work init state.
- *
+ * Set a property. This is used at the frame work init state.
+ *
* @param key the prperty key
* @param value the property value
*/
@@ -294,6 +294,7 @@
/**
* Get an optional plugin that is registered with the bundle manager.
+ *
* @param <T> the pluging type
* @param clazz the plugin type
* @return The plugin instance or null if the requested plugin class is not registered
@@ -405,7 +406,7 @@
OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
if (bundleState == null)
throw new IllegalStateException("Unable to determine bundle state for " + deployment.getName());
-
+
return bundleState;
}
catch (Exception e)
@@ -460,7 +461,7 @@
}
/**
- * Add a deployment
+ * Add a deployment
*
* @param unit the deployment unit
* @return the bundle state
@@ -474,7 +475,7 @@
OSGiMetaData osgiMetaData = unit.getAttachment(OSGiMetaData.class);
if (osgiMetaData == null)
throw new IllegalStateException("Cannot obtain OSGi metadata");
-
+
OSGiBundleState bundleState = new OSGiBundleState(osgiMetaData, unit);
addBundle(bundleState);
return bundleState;
@@ -484,6 +485,7 @@
* Generate a name for the deployment unit
*
* todo some better solution
+ *
* @param unit the deployment unit
* @return the name
*/
@@ -565,11 +567,11 @@
*
* @return the system bundle context
*/
- public BundleContext getSystemContext()
+ public BundleContext getBundleContext()
{
return systemBundle.getBundleContext();
}
-
+
/**
* Get a deployment
*
@@ -638,7 +640,7 @@
{
return Collections.unmodifiableList(bundles);
}
-
+
/**
* Get the bundles with the given state
*
@@ -667,13 +669,13 @@
int state = bundleState.getState();
if (state != Bundle.INSTALLED)
return true;
-
+
DeploymentUnit unit = bundleState.getDeploymentUnit();
ControllerContext context = unit.getAttachment(ControllerContext.class);
-
+
ControllerState requiredState = context.getRequiredState();
DeploymentStage requiredStage = unit.getRequiredStage();
-
+
try
{
deployerClient.change(unit.getName(), DeploymentStages.CLASSLOADER);
@@ -685,10 +687,10 @@
{
unit.setRequiredStage(requiredStage);
context.setRequiredState(requiredState);
-
+
if (errorOnFail)
throw new IllegalStateException("Error resolving bundle: " + bundleState, ex);
-
+
return false;
}
}
@@ -704,7 +706,7 @@
// Resolve all INSTALLED bundles through the PackageAdmin
PackageAdmin packageAdmin = getPlugin(PackageAdminServicePlugin.class);
packageAdmin.resolveBundles(null);
-
+
try
{
String name = bundleState.getDeploymentUnit().getName();
@@ -751,13 +753,17 @@
* @param checkAssignable whether to check isAssignable
* @return the services
*/
- Collection<OSGiServiceState> getServices(AbstractBundleState bundleState, String clazz, Filter filter, boolean checkAssignable)
+ Collection<OSGiServiceState> getServices(AbstractBundleState bundle, String clazz, Filter filter, boolean checkAssignable)
{
if (filter == null)
filter = NoFilter.INSTANCE;
if (registeredServices.isEmpty())
return null;
+
+ // Don't check assignabilty for the system bundle
+ if (bundle.getBundleId() == 0)
+ checkAssignable = false;
// review: optimise this, e.g. index by class
// Use a sorted set to order services according to spec
@@ -768,10 +774,10 @@
if (service.isUnregistered() == false && filter.match(service) && service.hasPermission())
{
// Check any passed class matches
- if (clazz == null || service.matchClass(bundleState, clazz))
+ if (clazz == null || service.matchClass(clazz))
{
// Check the assignability
- if (checkAssignable == false || service.isAssignable(bundleState))
+ if (checkAssignable == false || service.isAssignable(bundle))
result.add(service);
}
}
@@ -782,65 +788,80 @@
/**
* Get service reference
*
- * @param bundleState the referencing bundle
+ * @param bundle the referencing bundle
* @param clazz any class
* @return the reference
*/
- ServiceReference getServiceReference(AbstractBundleState bundleState, String clazz)
+ ServiceReference getServiceReference(AbstractBundleState bundle, String clazz)
{
- // Ignore isAssignable for the system context
- boolean checkAssignable = (bundleState.getBundleId() != 0);
-
- Collection<OSGiServiceState> services = getServices(bundleState, clazz, null, checkAssignable);
+ Collection<OSGiServiceState> services = getServices(bundle, clazz, null, true);
if (services == null || services.isEmpty())
return null;
-
- // [TODO] service ranking and service id
+
// If multiple such services exist, the service with the highest ranking (as specified in its SERVICE_RANKING property) is returned.
// If there is a tie in ranking, the service with the lowest service ID (as specified in its SERVICE_ID property);
- // that is, the service that was registered first is returned.
+ // that is, the service that was registered first is returned.
+
+ long bestId = 0;
+ int bestRanking = 0;
+ ServiceReference bestMatch = null;
+ for (OSGiServiceState service : services)
+ {
+ long id = service.getServiceId();
+ int ranking = service.getServiceRanking();
+ if (bestMatch == null || ranking > bestRanking || (ranking == bestRanking && id < bestId))
+ {
+ bestMatch = service.getReferenceInternal();
+ bestRanking = ranking;
+ bestId = id;
+ }
+ }
- OSGiServiceState service = services.iterator().next();
- return service.getReferenceInternal();
+ return bestMatch;
}
/**
* Get service references
*
- * @param bundleState the referencing bundle
+ * @param bundle the referencing bundle
* @param clazz any class
* @param filter any filter
* @param checkAssignable whether to check isAssignable
* @return the services
*/
- ServiceReference[] getServiceReferences(AbstractBundleState bundleState, String clazz, Filter filter, boolean checkAssignable)
+ ServiceReference[] getServiceReferences(AbstractBundleState bundle, String clazz, Filter filter, boolean checkAssignable)
{
- Collection<OSGiServiceState> services = getServices(bundleState, clazz, filter, checkAssignable);
+ Collection<OSGiServiceState> services = getServices(bundle, clazz, filter, checkAssignable);
if (services == null || services.isEmpty())
return null;
+
ServiceReference[] result = new ServiceReference[services.size()];
+
int i = 0;
for (OSGiServiceState service : services)
result[i++] = service.getReferenceInternal();
+
return result;
}
/**
* Get service references
*
- * @param bundleState the referencing bundle
+ * @param bundle the referencing bundle
* @param clazz any class
- * @param filter any filter
+ * @param filterStr any filter
+ * @param checkAssignable
* @param checkAssignable whether to check isAssignable
* @return the services
* @throws InvalidSyntaxException when the filter is invalid
*/
- ServiceReference[] getServiceReferences(AbstractBundleState bundleState, String clazz, String filter, boolean checkAssignable) throws InvalidSyntaxException
+ ServiceReference[] getServiceReferences(AbstractBundleState bundle, String clazz, String filterStr, boolean checkAssignable) throws InvalidSyntaxException
{
- Filter f = NoFilter.INSTANCE;
- if (filter != null)
- f = FrameworkUtil.createFilter(filter);
- return getServiceReferences(bundleState, clazz, f, checkAssignable);
+ Filter filter = NoFilter.INSTANCE;
+ if (filterStr != null)
+ filter = FrameworkUtil.createFilter(filterStr);
+
+ return getServiceReferences(bundle, clazz, filter, checkAssignable);
}
/**
@@ -941,7 +962,7 @@
// Log INFO about this implementation
log.info(getClass().getPackage().getImplementationTitle());
log.info(getClass().getPackage().getImplementationVersion());
-
+
int state = systemBundle.getState();
// This method does nothing if called when this Framework is in the STARTING, ACTIVE or STOPPING state
@@ -985,7 +1006,7 @@
servicePlugin.startService();
}
}
-
+
// All installed bundles must be started
AutoInstallPlugin autoInstall = getOptionalPlugin(AutoInstallPlugin.class);
if (autoInstall != null)
@@ -1039,7 +1060,7 @@
servicePlugin.stopService();
}
}
-
+
systemBundle.changeState(Bundle.RESOLVED);
}
@@ -1097,7 +1118,7 @@
/**
* Fire a framework error
- *
+ *
* @param bundleState the bundle state
* @param context the msg context
* @param t the throwable
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiServiceState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiServiceState.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiServiceState.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -62,7 +62,7 @@
/** The bundle that registered the service */
private AbstractBundleState bundleState;
-
+
/** The service reference */
private OSGiServiceReferenceWrapper serviceReference;
@@ -115,7 +115,7 @@
this.bundleState = bundleState;
this.clazzes = clazzes;
this.serviceOrFactory = service;
-
+
if (service instanceof ServiceFactory == false)
checkObjClass(service);
@@ -317,12 +317,13 @@
throw new IllegalArgumentException("Null bundle");
if (className == null)
throw new IllegalArgumentException("Null class name");
+
if (bundle instanceof OSGiBundleWrapper == false)
throw new IllegalArgumentException("Unknown bundle: " + bundle);
OSGiBundleWrapper wrapper = (OSGiBundleWrapper)bundle;
- AbstractBundleState other = wrapper.getBundleState();
- return isAssignableTo(other, className);
+ AbstractBundleState bundleState = wrapper.getBundleState();
+ return isAssignableTo(bundleState, className);
}
/**
@@ -343,22 +344,22 @@
if (isUnregistered())
return false;
+ Class<?> source = (Class<?>)bundleState.getSource(className);
+ if (source == null)
+ throw new IllegalStateException("Cannot load '" + className + "' from: " + bundleState);
+
Class<?> otherSource = (Class<?>)other.getSource(className);
if (otherSource == null)
- return false;
+ throw new IllegalStateException("Cannot load '" + className + "' from: " + other);
- Class<?> source = (Class<?>)bundleState.getSource(className);
- if (source == null)
- return false;
-
boolean equals = otherSource.equals(source);
- if (equals == false && otherSource.getName().equals(source.getName()))
+ if (equals == false)
{
ClassLoader otherLoader = otherSource.getClassLoader();
ClassLoader sourceLoader = source.getClassLoader();
- StringBuffer buffer = new StringBuffer("Cannot assign [" + className + "] comming from different exporters");
- buffer.append("\n ").append(sourceLoader.toString());
- buffer.append("\n ").append(otherLoader);
+ StringBuffer buffer = new StringBuffer("Cannot assign '" + className + "' comming from different exporters");
+ buffer.append("\n service: ").append(sourceLoader);
+ buffer.append("\n request: ").append(otherLoader);
log.warn(buffer.toString());
}
return equals;
@@ -367,12 +368,12 @@
/**
* Check the isAssignable
*
- * @param other the bundle state
+ * @param bundle the bundle state
* @return true when assignable
*/
- boolean isAssignable(AbstractBundleState other)
+ boolean isAssignable(AbstractBundleState bundle)
{
- if (other == bundleState)
+ if (bundle == bundleState)
return true;
if (isUnregistered())
@@ -380,7 +381,7 @@
for (String clazz : getClasses())
{
- if (isAssignableTo(other, clazz) == false)
+ if (isAssignableTo(bundle, clazz) == false)
return false;
}
return true;
@@ -389,11 +390,10 @@
/**
* Match the class
*
- * @param other the other bundle state
* @param className the class name
* @return true when the class name matches
*/
- boolean matchClass(AbstractBundleState other, String className)
+ boolean matchClass(String className)
{
if (clazzes == null || clazzes.length == 0)
return false;
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiBundleClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiBundleClassLoadingDeployer.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiBundleClassLoadingDeployer.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -32,6 +32,7 @@
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.plugins.facade.api.SystemPackagesPlugin;
import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
@@ -52,6 +53,7 @@
public class OSGiBundleClassLoadingDeployer extends AbstractSimpleRealDeployer<OSGiMetaData>
{
private ClassLoaderDomain domain;
+ private ClassLoaderFactory factory;
/**
* Create a new OSGiBundleClassLoadingDeployer.
@@ -70,6 +72,11 @@
this.domain = domain;
}
+ public void setFactory(ClassLoaderFactory factory)
+ {
+ this.factory = factory;
+ }
+
@Override
public void deploy(DeploymentUnit unit, OSGiMetaData osgiMetaData) throws DeploymentException
{
@@ -131,6 +138,10 @@
}
}
+ // Add the OSGi ClassLoaderFactory if configured
+ if (factory != null)
+ unit.addAttachment(ClassLoaderFactory.class, factory);
+
// [TODO] dynamic imports
unit.addAttachment(ClassLoadingMetaData.class, classLoadingMetaData);
Added: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderFactory.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderFactory.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderFactory.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -0,0 +1,93 @@
+/*
+* 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.plugins.facade.classloading;
+
+// $Id$
+
+import org.jboss.classloader.spi.ClassLoaderPolicy;
+import org.jboss.classloader.spi.ClassLoaderPolicyFactory;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloading.spi.dependency.Module;
+import org.jboss.deployers.structure.spi.ClassLoaderFactory;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
+
+/**
+ * OSGiClassLoaderFactory
+ *
+ * Creates the OSGiClassLoader
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 11-Sep-2209
+ */
+public class OSGiClassLoaderFactory implements ClassLoaderFactory
+{
+ /** The classloader system */
+ private ClassLoaderSystem system;
+
+ public void setSystem(ClassLoaderSystem system)
+ {
+ this.system = system;
+ }
+
+ public ClassLoader createClassLoader(final DeploymentUnit unit) throws Exception
+ {
+ if (unit instanceof VFSDeploymentUnit == false)
+ throw new IllegalStateException("DeploymentUnit is not an instance of " + VFSDeploymentUnit.class.getName() + " actual=" + unit);
+
+ Module module = unit.getAttachment(Module.class);
+ if (module instanceof VFSDeploymentClassLoaderPolicyModule == false)
+ throw new IllegalStateException("Module is not an instance of " + VFSDeploymentClassLoaderPolicyModule.class.getName() + " actual=" + module);
+
+ VFSDeploymentClassLoaderPolicyModule vfsModule = (VFSDeploymentClassLoaderPolicyModule)module;
+ vfsModule.setPolicyFactory(new ClassLoaderPolicyFactory()
+ {
+ public ClassLoaderPolicy createClassLoaderPolicy()
+ {
+ VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
+ OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
+ return new OSGiClassLoaderPolicy(bundleState, vfsUnit.getRoot());
+ }
+ });
+ return vfsModule.registerClassLoaderPolicy(system);
+ }
+
+ public void removeClassLoader(DeploymentUnit unit) throws Exception
+ {
+ Module module = unit.getAttachment(Module.class);
+ if (module == null)
+ return;
+
+ ClassLoader classLoader = unit.getClassLoader();
+ try
+ {
+ // Remove the classloader
+ system.unregisterClassLoader(classLoader);
+ }
+ finally
+ {
+ module.reset();
+ }
+ }
+}
Property changes on: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderPolicy.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderPolicy.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderPolicy.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -0,0 +1,64 @@
+/*
+* 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.plugins.facade.classloading;
+
+// $Id$
+
+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.plugins.facade.bundle.OSGiBundleState;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * OSGiClassLoaderPolicy
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 11-Sep-2209
+ */
+public class OSGiClassLoaderPolicy extends VFSClassLoaderPolicy
+{
+ public OSGiClassLoaderPolicy(OSGiBundleState bundleState, VirtualFile root)
+ {
+ super(new VirtualFile[] { root });
+ if (bundleState == null)
+ throw new IllegalArgumentException("Null bundleState");
+
+ DeploymentUnit unit = bundleState.getDeploymentUnit();
+ Module module = unit.getAttachment(Module.class);
+ if (module instanceof VFSDeploymentClassLoaderPolicyModule == false)
+ throw new IllegalStateException("Module is not an instance of " + VFSDeploymentClassLoaderPolicyModule.class.getName() + " actual=" + module);
+
+ VFSDeploymentClassLoaderPolicyModule vfsModule = (VFSDeploymentClassLoaderPolicyModule)module;
+ String[] packageNames = vfsModule.getPackageNames();
+ setExportedPackages(packageNames);
+ setIncluded(vfsModule.getIncluded());
+ setExcluded(vfsModule.getExcluded());
+ setExcludedExport(vfsModule.getExcludedExport());
+ setExportAll(vfsModule.getExportAll());
+ setImportAll(vfsModule.isImportAll());
+ setCacheable(vfsModule.isCacheable());
+ setBlackListable(vfsModule.isBlackListable());
+ setDelegates(vfsModule.getDelegates());
+ }
+}
Property changes on: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderPolicy.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiPackageCapability.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -147,9 +147,10 @@
if (bundleCapability == null)
return false;
- Module exportingModule = bundleCapability.getExportingModule();
- PackageCapability packageCapability = bundleCapability.getPackageCapability();
- return exportingModule == capModule && packageCapability == this;
+ Module otherCapModule = bundleCapability.getExportingModule();
+ PackageCapability otherCapability = bundleCapability.getPackageCapability();
+ boolean isMatch = (otherCapModule == capModule && otherCapability == this);
+ return isMatch;
}
@SuppressWarnings("deprecation")
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/plugins/AbstractServicePluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/plugins/AbstractServicePluginImpl.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/plugins/AbstractServicePluginImpl.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -42,6 +42,6 @@
public BundleContext getSystemContext()
{
- return bundleManager.getSystemContext();
+ return bundleManager.getBundleContext();
}
}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/MicrocontainerServiceImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/MicrocontainerServiceImpl.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/MicrocontainerServiceImpl.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -1,199 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.plugins.facade.service;
-
-//$Id$
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import javax.management.MBeanServer;
-import javax.management.StandardMBean;
-
-import org.jboss.dependency.plugins.AbstractController;
-import org.jboss.dependency.plugins.AbstractControllerContext;
-import org.jboss.dependency.plugins.AbstractControllerContextActions;
-import org.jboss.dependency.plugins.action.ControllerContextAction;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerContextActions;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.logging.Logger;
-import org.jboss.osgi.plugins.facade.api.MicrocontainerServicePlugin;
-import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
-import org.jboss.osgi.plugins.facade.plugins.AbstractServicePluginImpl;
-import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
-import org.jboss.osgi.spi.service.MicrocontainerService;
-import org.osgi.framework.Constants;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.ServiceRegistration;
-
-/**
- * An implementation of the {@link MicrocontainerService}.
- *
- * @author thomas.diesler at jboss.com
- * @since 31-Aug-2009
- */
-public class MicrocontainerServiceImpl extends AbstractServicePluginImpl implements MicrocontainerServicePlugin, MicrocontainerServiceMBean
-{
- /** The log */
- private static final Logger log = Logger.getLogger(MicrocontainerServiceImpl.class);
-
- private Kernel kernel;
- private ServiceRegistration registration;
-
- public MicrocontainerServiceImpl(OSGiBundleManager bundleManager)
- {
- super(bundleManager);
-
- this.kernel = bundleManager.getKernel();
- }
-
- public void startService()
- {
- installKernelBean(BEAN_SYSTEM_BUNDLE_CONTEXT, getSystemContext());
- registration = getSystemContext().registerService(MicrocontainerService.class.getName(), this, null);
-
- // Track the MBeanServer and register this service as an MBean
- try
- {
- String filter = "(" + Constants.OBJECTCLASS + "=" + MBeanServer.class.getName() + ")";
- getSystemContext().addServiceListener(new JMXServiceListener(this), filter);
- }
- catch (InvalidSyntaxException ex)
- {
- // ignore
- }
- }
-
- public void stopService()
- {
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
- }
-
- public Object getRegisteredBean(String beanName)
- {
- ControllerContext context = kernel.getController().getInstalledContext(beanName);
- return context != null ? context.getTarget() : null;
- }
-
- @SuppressWarnings("unchecked")
- public <T> T getRegisteredBean(Class<T> beanClass, String beanName)
- {
- Object target = getRegisteredBean(beanName);
- if (target == null | beanClass.isAssignableFrom(target.getClass()) == false)
- return null;
-
- return (T)target;
- }
-
- public List<String> getRegisteredBeans()
- {
- List<String> names = new ArrayList<String>();
-
- AbstractController controller = (AbstractController)kernel.getController();
- for (ControllerContext ctx : controller.getAllContexts())
- {
- if (ctx instanceof KernelControllerContext)
- names.add(ctx.getName().toString());
- }
-
- return names;
- }
-
- private void installKernelBean(String beanName, Object target)
- {
- KernelController controller = kernel.getController();
- ControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
- try
- {
- controller.install(new AbstractControllerContext(beanName, actions, null, target));
- }
- catch (Throwable th)
- {
- throw new IllegalStateException("Cannot install kernel bean: " + beanName, th);
- }
- }
-
- private void registerMBeans(MBeanServer server, MicrocontainerServiceMBean mbeanImpl)
- {
- try
- {
- installKernelBean(BEAN_MBEAN_SERVER, server);
- StandardMBean mbean = new StandardMBean(mbeanImpl, MicrocontainerServiceMBean.class);
- server.registerMBean(mbean, MBEAN_MICROCONTAINER_SERVICE);
- }
- catch (Exception ex)
- {
- throw new IllegalStateException("Cannot register MicrocontainerServiceMBean", ex);
- }
- }
-
- private void unregisterMBeans(MBeanServer server)
- {
- try
- {
- if (server.isRegistered(MBEAN_MICROCONTAINER_SERVICE))
- server.unregisterMBean(MBEAN_MICROCONTAINER_SERVICE);
- }
- catch (Exception ex)
- {
- log.warn("Cannot unregister MicrocontainerServiceMBean", ex);
- }
- }
-
- class JMXServiceListener implements ServiceListener
- {
- private MicrocontainerServiceMBean mbean;
-
- public JMXServiceListener(MicrocontainerServiceMBean mbean)
- {
- this.mbean = mbean;
- }
-
- public void serviceChanged(ServiceEvent event)
- {
- ServiceReference sref = event.getServiceReference();
- MBeanServer server = (MBeanServer)getSystemContext().getService(sref);
- int type = event.getType();
- switch (type)
- {
- case ServiceEvent.REGISTERED:
- registerMBeans(server, mbean);
- break;
- case ServiceEvent.UNREGISTERING:
- unregisterMBeans(server);
- break;
- }
- }
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/MicrocontainerServiceImpl.java (from rev 93370, projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/MicrocontainerServiceImpl.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/MicrocontainerServiceImpl.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/MicrocontainerServiceImpl.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -0,0 +1,199 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.plugins.facade.service;
+
+//$Id$
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.management.MBeanServer;
+import javax.management.StandardMBean;
+
+import org.jboss.dependency.plugins.AbstractController;
+import org.jboss.dependency.plugins.AbstractControllerContext;
+import org.jboss.dependency.plugins.AbstractControllerContextActions;
+import org.jboss.dependency.plugins.action.ControllerContextAction;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerContextActions;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.logging.Logger;
+import org.jboss.osgi.plugins.facade.api.MicrocontainerServicePlugin;
+import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
+import org.jboss.osgi.plugins.facade.plugins.AbstractServicePluginImpl;
+import org.jboss.osgi.spi.management.MicrocontainerServiceMBean;
+import org.jboss.osgi.spi.service.MicrocontainerService;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * An implementation of the {@link MicrocontainerService}.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 31-Aug-2009
+ */
+public class MicrocontainerServiceImpl extends AbstractServicePluginImpl implements MicrocontainerServicePlugin, MicrocontainerServiceMBean
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(MicrocontainerServiceImpl.class);
+
+ private Kernel kernel;
+ private ServiceRegistration registration;
+
+ public MicrocontainerServiceImpl(OSGiBundleManager bundleManager)
+ {
+ super(bundleManager);
+
+ this.kernel = bundleManager.getKernel();
+ }
+
+ public void startService()
+ {
+ installKernelBean(BEAN_SYSTEM_BUNDLE_CONTEXT, getSystemContext());
+ registration = getSystemContext().registerService(MicrocontainerService.class.getName(), this, null);
+
+ // Track the MBeanServer and register this service as an MBean
+ try
+ {
+ String filter = "(" + Constants.OBJECTCLASS + "=" + MBeanServer.class.getName() + ")";
+ getSystemContext().addServiceListener(new JMXServiceListener(this), filter);
+ }
+ catch (InvalidSyntaxException ex)
+ {
+ // ignore
+ }
+ }
+
+ public void stopService()
+ {
+ if (registration != null)
+ {
+ registration.unregister();
+ registration = null;
+ }
+ }
+
+ public Object getRegisteredBean(String beanName)
+ {
+ ControllerContext context = kernel.getController().getInstalledContext(beanName);
+ return context != null ? context.getTarget() : null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T> T getRegisteredBean(Class<T> beanClass, String beanName)
+ {
+ Object target = getRegisteredBean(beanName);
+ if (target == null | beanClass.isAssignableFrom(target.getClass()) == false)
+ return null;
+
+ return (T)target;
+ }
+
+ public List<String> getRegisteredBeans()
+ {
+ List<String> names = new ArrayList<String>();
+
+ AbstractController controller = (AbstractController)kernel.getController();
+ for (ControllerContext ctx : controller.getAllContexts())
+ {
+ if (ctx instanceof KernelControllerContext)
+ names.add(ctx.getName().toString());
+ }
+
+ return names;
+ }
+
+ private void installKernelBean(String beanName, Object target)
+ {
+ KernelController controller = kernel.getController();
+ ControllerContextActions actions = new AbstractControllerContextActions(new HashMap<ControllerState, ControllerContextAction>());
+ try
+ {
+ controller.install(new AbstractControllerContext(beanName, actions, null, target));
+ }
+ catch (Throwable th)
+ {
+ throw new IllegalStateException("Cannot install kernel bean: " + beanName, th);
+ }
+ }
+
+ private void registerMBeans(MBeanServer server, MicrocontainerServiceMBean mbeanImpl)
+ {
+ try
+ {
+ installKernelBean(BEAN_MBEAN_SERVER, server);
+ StandardMBean mbean = new StandardMBean(mbeanImpl, MicrocontainerServiceMBean.class);
+ server.registerMBean(mbean, MBEAN_MICROCONTAINER_SERVICE);
+ }
+ catch (Exception ex)
+ {
+ throw new IllegalStateException("Cannot register MicrocontainerServiceMBean", ex);
+ }
+ }
+
+ private void unregisterMBeans(MBeanServer server)
+ {
+ try
+ {
+ if (server.isRegistered(MBEAN_MICROCONTAINER_SERVICE))
+ server.unregisterMBean(MBEAN_MICROCONTAINER_SERVICE);
+ }
+ catch (Exception ex)
+ {
+ log.warn("Cannot unregister MicrocontainerServiceMBean", ex);
+ }
+ }
+
+ class JMXServiceListener implements ServiceListener
+ {
+ private MicrocontainerServiceMBean mbean;
+
+ public JMXServiceListener(MicrocontainerServiceMBean mbean)
+ {
+ this.mbean = mbean;
+ }
+
+ public void serviceChanged(ServiceEvent event)
+ {
+ ServiceReference sref = event.getServiceReference();
+ MBeanServer server = (MBeanServer)getSystemContext().getService(sref);
+ int type = event.getType();
+ switch (type)
+ {
+ case ServiceEvent.REGISTERED:
+ registerMBeans(server, mbean);
+ break;
+ case ServiceEvent.UNREGISTERING:
+ unregisterMBeans(server);
+ break;
+ }
+ }
+ }
+}
\ No newline at end of file
Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -1,281 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.plugins.facade.service;
-
-//$Id: StartLevelImpl.java 93118 2009-09-02 08:24:44Z thomas.diesler at jboss.com $
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.jboss.classloading.plugins.metadata.PackageCapability;
-import org.jboss.classloading.spi.dependency.RequirementDependencyItem;
-import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
-import org.jboss.classloading.spi.metadata.Capability;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.classloading.spi.metadata.Requirement;
-import org.jboss.dependency.spi.DependencyInfo;
-import org.jboss.dependency.spi.DependencyItem;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.logging.Logger;
-import org.jboss.osgi.plugins.facade.api.PackageAdminServicePlugin;
-import org.jboss.osgi.plugins.facade.bundle.AbstractBundleState;
-import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
-import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
-import org.jboss.osgi.plugins.facade.bundle.OSGiBundleWrapper;
-import org.jboss.osgi.plugins.facade.plugins.AbstractServicePluginImpl;
-import org.jboss.osgi.plugins.resolver.BundleResolver;
-import org.jboss.osgi.spi.NotImplementedException;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.framework.Version;
-import org.osgi.service.packageadmin.ExportedPackage;
-import org.osgi.service.packageadmin.PackageAdmin;
-import org.osgi.service.packageadmin.RequiredBundle;
-
-/**
- * An implementation of the {@link PackageAdmin}.
- *
- * [TODO] [JBOSGI-149] Fully implement PackageAdmin
- *
- * @author thomas.diesler at jboss.com
- * @since 03-Sep-2009
- */
-public class PackageAdminImpl extends AbstractServicePluginImpl implements PackageAdminServicePlugin
-{
- /** The log */
- private static final Logger log = Logger.getLogger(PackageAdminImpl.class);
-
- private ServiceRegistration registration;
-
- public PackageAdminImpl(OSGiBundleManager bundleManager)
- {
- super(bundleManager);
- }
-
- public void startService()
- {
- BundleContext sysContext = getSystemContext();
- registration = sysContext.registerService(PackageAdmin.class.getName(), this, null);
- }
-
- public void stopService()
- {
- if (registration != null)
- {
- registration.unregister();
- registration = null;
- }
- }
-
- @SuppressWarnings("unchecked")
- public Bundle getBundle(Class clazz)
- {
- throw new NotImplementedException();
- }
-
- public int getBundleType(Bundle bundle)
- {
- throw new NotImplementedException();
- }
-
- public Bundle[] getBundles(String symbolicName, String versionRange)
- {
- throw new NotImplementedException();
- }
-
- public ExportedPackage getExportedPackage(String name)
- {
- throw new NotImplementedException();
- }
-
- public ExportedPackage[] getExportedPackages(Bundle bundle)
- {
- OSGiBundleState bundleState = assertBundleState(bundle);
- DeploymentUnit unit = bundleState.getDeploymentUnit();
- ClassLoadingMetaData metaData = unit.getAttachment(ClassLoadingMetaData.class);
- if (metaData == null)
- throw new IllegalStateException("Cannot obtain ClassLoadingMetaData");
-
- List<ExportedPackage> exported = new ArrayList<ExportedPackage>();
- CapabilitiesMetaData capabilities = metaData.getCapabilities();
- for (Capability capability : capabilities.getCapabilities())
- {
- if (capability instanceof PackageCapability)
- {
- exported.add(new ExportedPackageImpl(bundleState, (PackageCapability)capability));
- }
- }
- if (exported.size() == 0)
- return null;
-
- ExportedPackage[] result = new ExportedPackage[exported.size()];
- exported.toArray(result);
-
- return result;
- }
-
- public ExportedPackage[] getExportedPackages(String name)
- {
- throw new NotImplementedException();
- }
-
- public Bundle[] getFragments(Bundle bundle)
- {
- throw new NotImplementedException();
- }
-
- public Bundle[] getHosts(Bundle bundle)
- {
- throw new NotImplementedException();
- }
-
- public RequiredBundle[] getRequiredBundles(String symbolicName)
- {
- throw new NotImplementedException();
- }
-
- public void refreshPackages(Bundle[] bundles)
- {
- log.warn("Ignore refreshPackages");
- }
-
- public boolean resolveBundles(Bundle[] bundleArr)
- {
- // Collect the bundles that are in state INSTALLED
- List<Bundle> unresolvedBundles = new ArrayList<Bundle>();
- if (bundleArr == null)
- {
- unresolvedBundles.addAll(bundleManager.getBundles(Bundle.INSTALLED));
- }
- else
- {
- for (Bundle bundle : bundleArr)
- {
- if (bundle.getState() == Bundle.INSTALLED)
- unresolvedBundles.add(bundle);
- }
- }
-
- if (unresolvedBundles.isEmpty())
- return true;
-
- BundleResolver bundleResolver = bundleManager.getBundleResolver();
- List<Bundle> resolvedBundles = bundleResolver.resolveBundles(unresolvedBundles);
- boolean allResolved = resolvedBundles.containsAll(unresolvedBundles);
-
- int resolved = 1;
- while (resolved > 0)
- {
- resolved = 0;
- Iterator<Bundle> it = resolvedBundles.iterator();
- while (it.hasNext())
- {
- OSGiBundleState bundleState = assertBundleState(it.next());
- if (bundleManager.resolve(bundleState, false))
- {
- it.remove();
- resolved++;
- }
- }
- }
-
- // Log unresolved bundles
- for (Bundle bundle : unresolvedBundles)
- {
- if (bundle.getState() == Bundle.INSTALLED)
- {
- OSGiBundleState bundleState = assertBundleState(bundle);
- StringBuffer message = new StringBuffer("Unresolved bundle: " + bundle);
- DeploymentUnit unit = bundleState.getDeploymentUnit();
- DependencyInfo dinfo = unit.getDependencyInfo();
- for (DependencyItem di : dinfo.getUnresolvedDependencies(null))
- {
- if (di instanceof RequirementDependencyItem)
- {
- RequirementDependencyItem reqitem = (RequirementDependencyItem)di;
- Requirement req = reqitem.getRequirement();
- message.append("\n " + req);
- }
- }
- log.debug(message);
- }
- }
-
- return allResolved && resolvedBundles.isEmpty();
- }
-
- private OSGiBundleState assertBundleState(Bundle bundle)
- {
- if (bundle instanceof OSGiBundleWrapper)
- bundle = ((OSGiBundleWrapper)bundle).getBundleState();
-
- if (bundle instanceof OSGiBundleState == false)
- throw new IllegalArgumentException("Cannot obtain bunde state from: " + bundle);
-
- return (OSGiBundleState)bundle;
- }
-
- private static class ExportedPackageImpl implements ExportedPackage
- {
- private Bundle bundle;
- private PackageCapability capability;
-
- public ExportedPackageImpl(AbstractBundleState bundle, PackageCapability capability)
- {
- this.bundle = bundle.getBundle();
- this.capability = capability;
- }
-
- public Bundle getExportingBundle()
- {
- return bundle;
- }
-
- public Bundle[] getImportingBundles()
- {
- throw new NotImplementedException();
- }
-
- public String getName()
- {
- return capability.getName();
- }
-
- @SuppressWarnings("deprecation")
- public String getSpecificationVersion()
- {
- throw new NotImplementedException();
- }
-
- public Version getVersion()
- {
- return Version.parseVersion(capability.getVersion().toString());
- }
-
- public boolean isRemovalPending()
- {
- throw new NotImplementedException();
- }
- }
-}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java (from rev 93374, projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/service/PackageAdminImpl.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -0,0 +1,260 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.plugins.facade.service;
+
+//$Id: StartLevelImpl.java 93118 2009-09-02 08:24:44Z thomas.diesler at jboss.com $
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.classloading.plugins.metadata.PackageCapability;
+import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
+import org.jboss.classloading.spi.metadata.Capability;
+import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.osgi.plugins.facade.api.PackageAdminServicePlugin;
+import org.jboss.osgi.plugins.facade.bundle.AbstractBundleState;
+import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
+import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
+import org.jboss.osgi.plugins.facade.bundle.OSGiBundleWrapper;
+import org.jboss.osgi.plugins.facade.plugins.AbstractServicePluginImpl;
+import org.jboss.osgi.plugins.resolver.BundleResolver;
+import org.jboss.osgi.spi.NotImplementedException;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.Version;
+import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.packageadmin.RequiredBundle;
+
+/**
+ * An implementation of the {@link PackageAdmin}.
+ *
+ * [TODO] [JBOSGI-149] Fully implement PackageAdmin
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 03-Sep-2009
+ */
+public class PackageAdminImpl extends AbstractServicePluginImpl implements PackageAdminServicePlugin
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(PackageAdminImpl.class);
+
+ private ServiceRegistration registration;
+
+ public PackageAdminImpl(OSGiBundleManager bundleManager)
+ {
+ super(bundleManager);
+ }
+
+ public void startService()
+ {
+ BundleContext sysContext = getSystemContext();
+ registration = sysContext.registerService(PackageAdmin.class.getName(), this, null);
+ }
+
+ public void stopService()
+ {
+ if (registration != null)
+ {
+ registration.unregister();
+ registration = null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Bundle getBundle(Class clazz)
+ {
+ throw new NotImplementedException();
+ }
+
+ public int getBundleType(Bundle bundle)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Bundle[] getBundles(String symbolicName, String versionRange)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ExportedPackage getExportedPackage(String name)
+ {
+ throw new NotImplementedException();
+ }
+
+ public ExportedPackage[] getExportedPackages(Bundle bundle)
+ {
+ OSGiBundleState bundleState = assertBundleState(bundle);
+ DeploymentUnit unit = bundleState.getDeploymentUnit();
+ ClassLoadingMetaData metaData = unit.getAttachment(ClassLoadingMetaData.class);
+ if (metaData == null)
+ throw new IllegalStateException("Cannot obtain ClassLoadingMetaData");
+
+ List<ExportedPackage> exported = new ArrayList<ExportedPackage>();
+ CapabilitiesMetaData capabilities = metaData.getCapabilities();
+ for (Capability capability : capabilities.getCapabilities())
+ {
+ if (capability instanceof PackageCapability)
+ {
+ exported.add(new ExportedPackageImpl(bundleState, (PackageCapability)capability));
+ }
+ }
+ if (exported.size() == 0)
+ return null;
+
+ ExportedPackage[] result = new ExportedPackage[exported.size()];
+ exported.toArray(result);
+
+ return result;
+ }
+
+ public ExportedPackage[] getExportedPackages(String name)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Bundle[] getFragments(Bundle bundle)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Bundle[] getHosts(Bundle bundle)
+ {
+ throw new NotImplementedException();
+ }
+
+ public RequiredBundle[] getRequiredBundles(String symbolicName)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void refreshPackages(Bundle[] bundles)
+ {
+ // [TODO] refreshPackages(Bundle[] bundles)
+ log.debug("Ignore refreshPackages");
+ }
+
+ public boolean resolveBundles(Bundle[] bundleArr)
+ {
+ // Collect the bundles that are in state INSTALLED
+ List<Bundle> unresolvedBundles = new ArrayList<Bundle>();
+ if (bundleArr == null)
+ {
+ unresolvedBundles.addAll(bundleManager.getBundles(Bundle.INSTALLED));
+ }
+ else
+ {
+ for (Bundle bundle : bundleArr)
+ {
+ if (bundle.getState() == Bundle.INSTALLED)
+ unresolvedBundles.add(bundle);
+ }
+ }
+
+ if (unresolvedBundles.isEmpty())
+ return true;
+
+ BundleResolver bundleResolver = bundleManager.getBundleResolver();
+ List<OSGiBundleState> resolvableBundles = bundleResolver.resolveBundles(unresolvedBundles);
+ boolean allResolved = resolvableBundles.containsAll(unresolvedBundles);
+
+ int resolved = 1;
+ while (resolved > 0)
+ {
+ resolved = 0;
+ Iterator<OSGiBundleState> it = resolvableBundles.iterator();
+ while (it.hasNext())
+ {
+ OSGiBundleState bundleState = assertBundleState(it.next());
+ if (bundleManager.resolve(bundleState, false))
+ {
+ it.remove();
+ resolved++;
+ }
+ }
+ }
+
+ // Sanity check, that the controller could actually also resolve these bundles
+ if (resolvableBundles.isEmpty() == false)
+ throw new IllegalStateException("Controller could not resolve: " + resolvableBundles);
+
+ return allResolved;
+ }
+
+ private OSGiBundleState assertBundleState(Bundle bundle)
+ {
+ if (bundle instanceof OSGiBundleWrapper)
+ bundle = ((OSGiBundleWrapper)bundle).getBundleState();
+
+ if (bundle instanceof OSGiBundleState == false)
+ throw new IllegalArgumentException("Cannot obtain bunde state from: " + bundle);
+
+ return (OSGiBundleState)bundle;
+ }
+
+ private static class ExportedPackageImpl implements ExportedPackage
+ {
+ private Bundle bundle;
+ private PackageCapability capability;
+
+ public ExportedPackageImpl(AbstractBundleState bundle, PackageCapability capability)
+ {
+ this.bundle = bundle.getBundle();
+ this.capability = capability;
+ }
+
+ public Bundle getExportingBundle()
+ {
+ return bundle;
+ }
+
+ public Bundle[] getImportingBundles()
+ {
+ throw new NotImplementedException();
+ }
+
+ public String getName()
+ {
+ return capability.getName();
+ }
+
+ @SuppressWarnings("deprecation")
+ public String getSpecificationVersion()
+ {
+ throw new NotImplementedException();
+ }
+
+ public Version getVersion()
+ {
+ return Version.parseVersion(capability.getVersion().toString());
+ }
+
+ public boolean isRemovalPending()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/resolver/BundleResolver.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/resolver/BundleResolver.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/resolver/BundleResolver.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -22,6 +22,7 @@
package org.jboss.osgi.plugins.resolver;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -71,92 +72,125 @@
/**
* Resolve the given list of bundles.
*
- * This is an iterative process that tries to wire BundleRequirements
- * to BundleCapabilities.
+ * This is an iterative process that tries to wire BundleRequirements to BundleCapabilities.
*
* @return The list of resolved bundles in the resolve order or an empty list
*/
- public List<Bundle> resolveBundles(List<Bundle> unresolvedBundles)
+ public List<OSGiBundleState> resolveBundles(List<Bundle> bundles)
{
- if (unresolvedBundles == null)
+ if (bundles == null)
throw new IllegalArgumentException("Null bundles");
+ // Normalize to OSGiBundleState instances
+ List<OSGiBundleState> unresolvedBundles = new ArrayList<OSGiBundleState>();
+ for (Bundle bundle : bundles)
+ {
+ unresolvedBundles.add(assertBundleState(bundle));
+ }
+
int resolved = 1;
int resolveRounds = 0;
- // Normalize the bundles to OSGiBundleState instances
- unresolvedBundles = new ArrayList<Bundle>(unresolvedBundles);
- for (int i = 0; i < unresolvedBundles.size(); i++)
- {
- Bundle bundle = unresolvedBundles.get(i);
- unresolvedBundles.set(i, assertBundleState(bundle));
- }
-
- List<Bundle> resolvedBundles = new ArrayList<Bundle>();
- unresolvedBundles = new ArrayList<Bundle>(unresolvedBundles);
+ List<OSGiBundleState> resolvedBundles = new ArrayList<OSGiBundleState>();
while (resolved > 0 && unresolvedBundles.isEmpty() == false)
{
resolveRounds++;
- log.info("#" + resolveRounds + " *****************************************************************");
- log.info("Unresolved bundles: " + unresolvedBundles);
+ log.debug("#" + resolveRounds + " *****************************************************************");
+ log.debug("Unresolved bundles: " + unresolvedBundles);
resolved = 0;
- Iterator<Bundle> it = unresolvedBundles.iterator();
+ Iterator<OSGiBundleState> it = unresolvedBundles.iterator();
while (it.hasNext())
{
- OSGiBundleState bundleState = (OSGiBundleState)it.next();
- log.info("Resolving: " + bundleState);
+ OSGiBundleState bundleState = it.next();
+ log.debug("Resolving: " + bundleState);
if (resolveBundle(bundleState))
{
- resolvedBundles.add(bundleState.getBundleInternal());
+ resolvedBundles.add(bundleState);
it.remove();
resolved++;
}
}
}
- log.info("END *****************************************************************");
-
+ log.debug("END *****************************************************************");
+
// Log the unresolved bundles
- if (unresolvedBundles.isEmpty() == false)
+ for (Bundle bundle : unresolvedBundles)
{
- for (Bundle bundle : unresolvedBundles)
+ StringBuffer message = new StringBuffer("Unresolved bundle: " + bundle);
+ message.append("\n Cannot find exporter for");
+ List<BundleRequirement> bundleRequirements = getBundleRequirements(bundle);
+ for (BundleRequirement requirement : bundleRequirements)
{
- StringBuffer message = new StringBuffer("Unresolved bundle: " + bundle);
- List<BundleRequirement> bundleRequirements = getBundleRequirements(bundle);
- for (BundleRequirement requirement : bundleRequirements)
+ PackageRequirement packreq = requirement.getPackageRequirement();
+ BundleCapability bestMatch = findBestMatch(allCapabilities, requirement);
+ if (bestMatch == null && packreq.isOptional() == false && packreq.isDynamic() == false)
{
- PackageRequirement packreq = requirement.getPackageRequirement();
- BundleCapability bestMatch = findBestMatch(allCapabilities, requirement);
- if (bestMatch == null && packreq.isOptional() == false && packreq.isDynamic() == false)
- {
- message.append("\n" + packreq);
- }
+ message.append("\n " + packreq.getName() + ";version=" + packreq.getVersionRange());
}
- log.info(message);
}
+ log.debug(message);
}
return resolvedBundles;
}
+ public void removeBundle(Bundle bundle)
+ {
+ OSGiBundleState bundleState = assertBundleState(bundle);
+ Iterator<BundleCapability> it = allCapabilities.iterator();
+ while (it.hasNext())
+ {
+ BundleCapability aux = it.next();
+ if (aux.getExportingBundle().equals(bundleState))
+ it.remove();
+ }
+ bundleCapabilitiesMap.remove(bundleState);
+ bundleRequirementsMap.remove(bundleState);
+ }
+
+ public BundleCapability getMatchingCapability(Module module, PackageRequirement packageRequirement)
+ {
+ String location = module.getContextName();
+ AbstractBundleState bundle = bundleManager.getBundleByLocation(location);
+ if (bundle == null)
+ return null;
+
+ List<BundleRequirement> requirements = bundleRequirementsMap.get(bundle);
+ if (requirements == null)
+ return null;
+
+ BundleCapability result = null;
+ for (BundleRequirement req : requirements)
+ {
+ if (req.getPackageRequirement() == packageRequirement)
+ {
+ result = req.getWire();
+ break;
+ }
+ }
+
+ return result;
+ }
+
private boolean resolveBundle(OSGiBundleState bundle)
{
List<BundleCapability> bundleCapabilities = getBundleCapabilities(bundle);
List<BundleRequirement> bundleRequirements = getBundleRequirements(bundle);
-
+
List<BundleCapability> futureCapabilities = new ArrayList<BundleCapability>(allCapabilities);
futureCapabilities.addAll(bundleCapabilities);
-
+
for (BundleRequirement requirement : bundleRequirements)
{
PackageRequirement packreq = requirement.getPackageRequirement();
-
+
BundleCapability bestMatch = findBestMatch(futureCapabilities, requirement);
if (bestMatch == null && packreq.isOptional() == false && packreq.isDynamic() == false)
return false;
-
+
requirement.setWire(bestMatch);
}
@@ -167,99 +201,91 @@
if (it.next().getWire() == null)
it.remove();
}
-
+
if (processRequiredBundle(bundle, bundleCapabilities, bundleRequirements) == false)
return false;
-
+
allCapabilities.addAll(bundleCapabilities);
bundleCapabilitiesMap.put(bundle, bundleCapabilities);
bundleRequirementsMap.put(bundle, bundleRequirements);
+
+ logResolvedBundleInfo(bundle, bundleCapabilities, bundleRequirements);
+
+ return true;
+ }
+
+ /**
+ * Logs information about a resolved bundle
+ */
+ private void logResolvedBundleInfo(OSGiBundleState bundle, List<BundleCapability> bundleCapabilities, List<BundleRequirement> bundleRequirements)
+ {
+ // Log the package wiring information
+ StringBuffer message = new StringBuffer("Resolved: " + bundle);
- // Get the max length of all packages
+ // Log the exports
int nameLengthMax = 0;
for (BundleCapability capability : bundleCapabilities)
{
PackageCapability packcap = capability.getPackageCapability();
- nameLengthMax = Math.max(nameLengthMax, packcap.getName().length());
+ String packNameVersion = packcap.getName() + ";version=" + packcap.getVersion();
+ nameLengthMax = Math.max(nameLengthMax, packNameVersion.length());
}
- for (BundleRequirement requirement : bundleRequirements)
- {
- PackageRequirement packreq = requirement.getPackageRequirement();
- nameLengthMax = Math.max(nameLengthMax, packreq.getName().length());
- }
-
- // Log the package wiring information
- StringBuffer message = new StringBuffer("Resolved: " + bundle);
if (bundleCapabilities.isEmpty() == false)
{
message.append("\n Exports");
+ List<String> lines = new ArrayList<String>();
for (BundleCapability capability : bundleCapabilities)
{
PackageCapability packcap = capability.getPackageCapability();
-
- String packageName = packcap.getName();
- message.append("\n " + packageName);
+ String packNameVersion = packcap.getName() + ";version=" + packcap.getVersion();
+ lines.add("\n " + packNameVersion);
}
+ Collections.sort(lines);
+ for (String line : lines)
+ message.append(line);
}
+
+ // Log the imports
+ nameLengthMax = 0;
+ for (BundleRequirement requirement : bundleRequirements)
+ {
+ PackageRequirement packreq = requirement.getPackageRequirement();
+ String packNameVersion = packreq.getName() + ";version=" + packreq.getVersionRange();
+ nameLengthMax = Math.max(nameLengthMax, packNameVersion.length());
+ }
if (bundleRequirements.isEmpty() == false)
{
message.append("\n Imports");
+ List<String> lines = new ArrayList<String>();
for (BundleRequirement requirement : bundleRequirements)
{
PackageRequirement packreq = requirement.getPackageRequirement();
-
- String packageName = packreq.getName();
- message.append("\n " + packageName + " <== ");
- for (int i = 0; i < (nameLengthMax - packageName.length()); i++)
- message.append(" ");
-
+ String packNameVersion = packreq.getName() + ";version=" + packreq.getVersionRange();
+ StringBuffer line = new StringBuffer("\n " + packNameVersion);
+ for (int i = 0; i < (nameLengthMax - packNameVersion.length()); i++)
+ line.append(" ");
+
BundleCapability wire = requirement.getWire();
- message.append(wire != null ? wire.getExportingBundle() : "null");
+ if (wire == null)
+ {
+ line.append(" <= null");
+ }
+ else
+ {
+ Bundle wireBundle = wire.getExportingBundle();
+ PackageCapability wireCap = wire.getPackageCapability();
+ packNameVersion = wireCap.getName() + ";version=" + wireCap.getVersion();
+ line.append(" <= " + wireBundle + " " + packNameVersion);
+ }
+ lines.add(line.toString());
}
+ Collections.sort(lines);
+ for (String line : lines)
+ message.append(line);
}
- log.info(message);
-
- return true;
+ log.debug(message);
}
- public void removeBundle(Bundle bundle)
- {
- OSGiBundleState bundleState = assertBundleState(bundle);
- Iterator<BundleCapability> it = allCapabilities.iterator();
- while (it.hasNext())
- {
- BundleCapability aux = it.next();
- if (aux.getExportingBundle().equals(bundleState))
- it.remove();
- }
- bundleCapabilitiesMap.remove(bundleState);
- bundleRequirementsMap.remove(bundleState);
- }
-
- public BundleCapability getMatchingCapability(Module module, PackageRequirement packageRequirement)
- {
- String location = module.getContextName();
- AbstractBundleState bundle = bundleManager.getBundleByLocation(location);
- if (bundle == null)
- return null;
-
- List<BundleRequirement> requirements = bundleRequirementsMap.get(bundle);
- if (requirements == null)
- return null;
-
- BundleCapability result = null;
- for (BundleRequirement req : requirements)
- {
- if (req.getPackageRequirement() == packageRequirement)
- {
- result = req.getWire();
- break;
- }
- }
-
- return result;
- }
-
private BundleCapability findBestMatch(List<BundleCapability> capabilities, BundleRequirement requirement)
{
BundleCapability result = null;
@@ -290,7 +316,7 @@
OSGiBundleState bundleState = assertBundleState(bundle);
DeploymentUnit unit = bundleState.getDeploymentUnit();
ClassLoadingMetaData metadata = unit.getAttachment(ClassLoadingMetaData.class);
-
+
List<Capability> capabilities = metadata.getCapabilities().getCapabilities();
if (capabilities != null)
{
@@ -305,7 +331,7 @@
}
return result;
}
-
+
/**
* Get the set of bundle requirements
*/
@@ -316,7 +342,7 @@
OSGiBundleState bundleState = assertBundleState(bundle);
DeploymentUnit unit = bundleState.getDeploymentUnit();
ClassLoadingMetaData classloadingMetaData = unit.getAttachment(ClassLoadingMetaData.class);
-
+
List<Requirement> requirements = classloadingMetaData.getRequirements().getRequirements();
if (requirements != null)
{
@@ -329,7 +355,7 @@
}
}
}
-
+
return result;
}
@@ -347,32 +373,32 @@
String requiredBundleName = attr.getAttribute();
if (requiredBundleName == null)
throw new IllegalStateException("Cannot obtain value for: " + Constants.REQUIRE_BUNDLE);
-
+
String visibility = Constants.VISIBILITY_PRIVATE;
Parameter param = attr.getParameter(Constants.VISIBILITY_DIRECTIVE);
if (param != null)
visibility = (String)param.getValue();
-
+
String resolution = Constants.RESOLUTION_MANDATORY;
param = attr.getParameter(Constants.RESOLUTION_DIRECTIVE);
if (param != null)
resolution = (String)param.getValue();
-
+
// [TODO] bundle-version
//String bundleVersion = null;
//param = attr.getParameter(Constants.BUNDLE_VERSION_ATTRIBUTE);
//if (param != null)
// bundleVersion = (String)param.getValue();
-
+
if (Constants.RESOLUTION_MANDATORY.equals(resolution))
{
Bundle requiredBundle = getRequiredBundle(requiredBundleName);
if (requiredBundle == null)
{
- log.info("Cannot find " + resolution + " required bundle: " + requiredBundleName);
+ log.debug("Cannot find " + resolution + " required bundle: " + requiredBundleName);
return false;
}
-
+
List<BundleCapability> otherCapabilities = bundleCapabilitiesMap.get(requiredBundle);
for (BundleCapability otherCapability : otherCapabilities)
{
@@ -380,12 +406,12 @@
String packageName = otherPackage.getName();
Object version = otherPackage.getVersion();
VersionRange versionRange = new VersionRange(version, true, version, true);
-
+
OSGiPackageRequirement newPackageRequirement = new OSGiPackageRequirement(packageName, versionRange, null);
BundleRequirement newBundleRequirement = new BundleRequirement(bundle, newPackageRequirement);
newBundleRequirement.setWire(otherCapability);
bundleRequirements.add(newBundleRequirement);
-
+
if (Constants.VISIBILITY_REEXPORT.equals(visibility))
{
BundleCapability newBundleCapability = new BundleCapability(bundle, otherPackage);
@@ -399,7 +425,7 @@
}
}
}
-
+
return true;
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/bundle/metadata/HeaderValuesTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -56,11 +56,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(HeaderValuesTestCase.class);
- }
-
public void testSerializable() throws Exception
{
Manifest manifest = getManifest(createName(null));
Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/bundle/metadata/MetaDataTestSuite.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/bundle/metadata/MetaDataTestSuite.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/bundle/metadata/MetaDataTestSuite.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -1,49 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.test.bundle.metadata;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-/**
- * MetaData Test Suite.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public class MetaDataTestSuite extends TestSuite
-{
- public static void main(String[] args)
- {
- TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite("MetaData Tests");
-
- suite.addTest(HeaderValuesTestCase.suite());
- suite.addTest(VersionRangeTestCase.suite());
-
- return suite;
- }
-}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/bundle/metadata/VersionRangeTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/bundle/metadata/VersionRangeTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/bundle/metadata/VersionRangeTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -26,11 +26,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(VersionRangeTestCase.class);
- }
-
public void testRangeSpecRE() throws Exception
{
String rangeSpec = "1.0.0";
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/OSGiTestDelegate.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -56,7 +56,7 @@
static
{
- // FIXME the vfs is not initialising itself properly
+ //FIXME the vfs is not initialising itself properly
VFS.init();
try
{
@@ -214,7 +214,8 @@
*/
public void uninstall(Bundle bundle) throws Exception
{
- getBundleManager().uninstall(bundle);
+ if (bundle.getState() != Bundle.UNINSTALLED)
+ getBundleManager().uninstall(bundle);
}
protected DeploymentUnit getDeploymentUnit(Bundle bundle)
Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleTestSuite.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleTestSuite.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/BundleTestSuite.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -1,57 +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.test.osgi.bundle;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-import org.jboss.test.osgi.bundle.test.BundleContextUnitTestCase;
-import org.jboss.test.osgi.bundle.test.BundleEntriesUnitTestCase;
-import org.jboss.test.osgi.bundle.test.BundleUnitTestCase;
-import org.jboss.test.osgi.bundle.test.SystemBundleUnitTestCase;
-
-/**
- * BundleTestSuite.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class BundleTestSuite extends TestSuite
-{
- public static void main(String[] args)
- {
- TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite("Bundle Tests");
-
- suite.addTest(BundleUnitTestCase.suite());
- suite.addTest(BundleEntriesUnitTestCase.suite());
- suite.addTest(BundleContextUnitTestCase.suite());
- suite.addTest(SystemBundleUnitTestCase.suite());
-
- return suite;
- }
-}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleContextUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleContextUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleContextUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -54,11 +54,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(BundleContextUnitTestCase.class);
- }
-
public void testGetBundle() throws Exception
{
Bundle bundle1 = addBundle("/bundles/simple/", "simple-bundle1");
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleEntriesUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleEntriesUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleEntriesUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -48,11 +48,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(BundleEntriesUnitTestCase.class);
- }
-
public void testEntriesNotInstalled() throws Exception
{
Bundle bundle = addBundle("/bundles/entries/", "entries-simple");
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/BundleUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -47,11 +47,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(BundleUnitTestCase.class);
- }
-
public void testBundleId() throws Exception
{
long id1 = -1;
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/SystemBundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/SystemBundleUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/bundle/test/SystemBundleUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -50,11 +50,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(SystemBundleUnitTestCase.class);
- }
-
public static void deployBundles(OSGiTestDelegate delegate) throws Exception
{
Bundle bundle = delegate.addBundle("/bundles/simple/", "simple-bundle1");
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/ExportImportPackageUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/ExportImportPackageUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/ExportImportPackageUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -21,19 +21,17 @@
*/
package org.jboss.test.osgi.classloader.test;
-import junit.framework.Test;
-
import org.jboss.deployers.client.spi.IncompleteDeploymentException;
import org.jboss.test.osgi.OSGiTestCase;
import org.jboss.test.osgi.classloader.support.a.A;
import org.jboss.test.osgi.classloader.support.b.B;
-import org.junit.Ignore;
import org.osgi.framework.Bundle;
/**
* ExportImportUnitTestCase.
*
- * TODO test security TODO test mandatory attributes
+ * TODO test security
+ * TODO test mandatory attributes
* TODO test include/exclude
* TODO test uses
*
@@ -50,12 +48,23 @@
public void testSimpleImportPackage() throws Exception
{
+ //Bundle-Name: BundleA
+ //Bundle-Version: 1.0.0
+ //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleA;test=x
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0;test=x
Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
+
try
{
bundle1.start();
assertLoadClass(bundle1, A.class);
+
+ //Bundle-Name: BundleB
+ //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
+ //Export-Package: org.jboss.test.osgi.classloader.support.b
+ //Import-Package: org.jboss.test.osgi.classloader.support.a
Bundle bundle2 = assembleBundle("simpleimportpackageA", "/bundles/classloader/simpleimportpackageA", B.class);
+
try
{
bundle2.start();
@@ -77,12 +86,21 @@
public void testSimpleImportPackageFails() throws Exception
{
+ //Bundle-Name: BundleA
+ //Bundle-Version: 1.0.0
+ //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleA;test=x
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0;test=x
Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
try
{
bundle1.start();
assertLoadClass(bundle1, A.class);
+
+ //Bundle-Name: BundleB
+ //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
+ //Import-Package: doesnotexist
Bundle bundle2 = assembleBundle("simpleimportpackagefails", "/bundles/classloader/simpleimportpackagefails", B.class);
+
try
{
bundle2.start();
@@ -103,6 +121,62 @@
}
}
+ public void testSelfImportPackage() throws Exception
+ {
+ //Bundle-Name: BundleB
+ //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
+ //Export-Package: org.jboss.test.osgi.classloader.support.b
+ //Import-Package: org.jboss.test.osgi.classloader.support.a
+ Bundle bundleB = assembleBundle("BundleB", "/bundles/classloader/simpleimportpackageA", B.class);
+
+ try
+ {
+ assertEquals("Bundle INSTALLED", Bundle.INSTALLED, bundleB.getState());
+
+ try
+ {
+ bundleB.start();
+ fail("Expected to fail due to unresolved import");
+ }
+ catch (Exception e)
+ {
+ // expected
+ }
+
+ //Bundle-Name: BundleA
+ //Bundle-Version: 1.0.0
+ //Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleA
+ //Export-Package: org.jboss.test.osgi.classloader.support.a, org.jboss.test.osgi.classloader.support.b
+ //Import-Package: org.jboss.test.osgi.classloader.support.a, org.jboss.test.osgi.classloader.support.b
+ Bundle bundleA = assembleBundle("BundleA", "/bundles/classloader/selfimportpackageAB", A.class, B.class);
+
+ try
+ {
+ bundleB.start();
+ assertEquals("Bundle ACTIVE", Bundle.ACTIVE, bundleB.getState());
+
+ // BundleA is expected to resolve when BundleB gets started
+ assertEquals("Bundle RESOLVED", Bundle.RESOLVED, bundleA.getState());
+ assertLoadClass(bundleA, A.class, bundleA);
+ assertLoadClass(bundleA, B.class, bundleA);
+
+ // BundleB imports A from BundleA
+ assertLoadClass(bundleB, A.class, bundleA);
+
+ // BundleB does not import B
+ assertLoadClass(bundleB, B.class, bundleB);
+ }
+ finally
+ {
+ uninstall(bundleA);
+ }
+ }
+ finally
+ {
+ uninstall(bundleB);
+ }
+ }
+
public void testVersionImportPackage() throws Exception
{
Bundle bundle1 = assembleBundle("bundleA", "/bundles/classloader/bundleA", A.class);
@@ -240,7 +314,7 @@
try
{
bundle2.start();
- System.out.println(" FIXME [JBOSGI-153] Cannot parse Import-Package parameters");
+ System.out.println("FIXME [JBOSGI-153] Cannot parse Import-Package parameters");
//assertLoadClass(bundle2, A.class, bundle1);
assertLoadClass(bundle2, B.class, bundle2);
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/RequireBundleUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/RequireBundleUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/classloader/test/RequireBundleUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -132,9 +132,9 @@
bundle2.start();
fail("Should not be here!");
}
- catch (Throwable t)
+ catch (RuntimeException rte)
{
- checkDeepThrowable(IncompleteDeploymentException.class, t);
+ // expected
}
finally
{
@@ -229,10 +229,8 @@
try
{
- System.out.println(" FIXME assertLoadClass(bundle3, A.class, bundle1)");
- //assertLoadClass(bundle3, A.class, bundle1);
- System.out.println(" FIXME assertLoadClass(bundle3, B.class, bundle2)");
- //assertLoadClass(bundle3, B.class, bundle2);
+ assertLoadClass(bundle3, A.class, bundle1);
+ assertLoadClass(bundle3, B.class, bundle2);
}
finally
{
@@ -323,9 +321,9 @@
bundle2.start();
fail("Should not be here!");
}
- catch (Throwable t)
+ catch (RuntimeException rte)
{
- checkDeepThrowable(IncompleteDeploymentException.class, t);
+ // expected
}
finally
{
Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/FilterTestSuite.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/FilterTestSuite.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/FilterTestSuite.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -1,53 +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.test.osgi.filter;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-import org.jboss.test.osgi.filter.test.BundleContextFilterUnitTestCase;
-import org.jboss.test.osgi.filter.test.FrameworkUtilFilterUnitTestCase;
-
-/**
- * BundleTestSuite.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class FilterTestSuite extends TestSuite
-{
- public static void main(String[] args)
- {
- TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite("Filter Tests");
-
- suite.addTest(FrameworkUtilFilterUnitTestCase.suite());
- suite.addTest(BundleContextFilterUnitTestCase.suite());
-
- return suite;
- }
-}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/AbstractFilterTest.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/AbstractFilterTest.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/AbstractFilterTest.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -85,7 +85,7 @@
assertInvalid("(<=b)");
assertInvalid("(>=b)");
assertInvalid("(~=b)");
- System.out.println(" FIXME [JBOSGI-129] - Invalid (*=b)");
+ System.out.println("FIXME [JBOSGI-129] - Invalid (*=b)");
assertNoMatch("(*=b)", properties);
assertInvalid("(a=\\)");
@@ -94,7 +94,7 @@
assertMatch("(a =b)", properties);
assertMatch("(c= d)", properties);
assertMatch("(e=f )", properties);
- System.out.println(" FIXME [JBOSGI-129] - NoMatch (a=)");
+ System.out.println("FIXME [JBOSGI-129] - NoMatch (a=)");
assertInvalid("(a=)");
assertNoMatch("(a=c)", properties);
assertNoMatch("(x=c)", properties);
@@ -123,16 +123,16 @@
assertMatch("(a<=2)", properties);
assertMatch("( a<=2)", properties);
assertMatch("(a <=2)", properties);
- System.out.println(" FIXME [JBOSGI-129] - NoMatch (a<= 2)");
+ System.out.println("FIXME [JBOSGI-129] - NoMatch (a<= 2)");
assertMatch("(a<= 2)", properties);
- System.out.println(" FIXME [JBOSGI-129] - NoMatch (a<=2 )");
+ System.out.println("FIXME [JBOSGI-129] - NoMatch (a<=2 )");
assertMatch("(a<=2 )", properties);
assertNoMatch("(a<=0)", properties);
assertNoMatch("( a<=0)", properties);
assertNoMatch("(a <=0)", properties);
assertNoMatch("(a<= 0)", properties);
assertNoMatch("(a<=0 )", properties);
- System.out.println(" FIXME [JBOSGI-129] - NoMatch (a<= )");
+ System.out.println("FIXME [JBOSGI-129] - NoMatch (a<= )");
try
{
assertNoMatch("(a<= )", properties);
@@ -165,16 +165,16 @@
assertMatch("(a>=0)", properties);
assertMatch("( a>=0)", properties);
assertMatch("(a >=0)", properties);
- System.out.println(" FIXME [JBOSGI-129] - NoMatch (a>= 0)");
+ System.out.println("FIXME [JBOSGI-129] - NoMatch (a>= 0)");
assertMatch("(a>= 0)", properties);
- System.out.println(" FIXME [JBOSGI-129] - NoMatch (a>=0 )");
+ System.out.println("FIXME [JBOSGI-129] - NoMatch (a>=0 )");
assertMatch("(a>=0 )", properties);
assertNoMatch("(a>=2)", properties);
assertNoMatch("( a>=2)", properties);
assertNoMatch("(a >=2)", properties);
assertNoMatch("(a>= 2)", properties);
assertNoMatch("(a>=2 )", properties);
- System.out.println(" FIXME [JBOSGI-129] - NoMatch (a>= )");
+ System.out.println("FIXME [JBOSGI-129] - NoMatch (a>= )");
try
{
assertNoMatch("(a>= )", properties);
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/BundleContextFilterUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/BundleContextFilterUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/BundleContextFilterUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -47,11 +47,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(BundleContextFilterUnitTestCase.class);
- }
-
public static void deployBundles(OSGiTestDelegate delegate) throws Exception
{
Bundle bundle = delegate.addBundle("/bundles/simple/", "simple-bundle1");
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/FrameworkUtilFilterUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/FrameworkUtilFilterUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/filter/test/FrameworkUtilFilterUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -21,8 +21,6 @@
*/
package org.jboss.test.osgi.filter.test;
-import junit.framework.Test;
-
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
@@ -39,11 +37,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(FrameworkUtilFilterUnitTestCase.class);
- }
-
protected void assertFilterCaseSensitive(String filter, PropertyBuilder properties, boolean expected) throws Exception
{
assertFilter(createFilter(filter), properties, expected, true);
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/resolver/BundleResolverTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/resolver/BundleResolverTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/resolver/BundleResolverTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -23,12 +23,14 @@
// $Id: FrameworkLaunchTestCase.java 92733 2009-08-24 09:40:32Z thomas.diesler at jboss.com $
+import static org.junit.Assert.*;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
import org.jboss.osgi.plugins.resolver.BundleResolver;
import org.jboss.osgi.spi.testing.OSGiTest;
import org.jboss.osgi.spi.util.ServiceLoader;
@@ -80,8 +82,8 @@
}
BundleResolver bundleResolver = new BundleResolver(null);
- List<Bundle> resolved = bundleResolver.resolveBundles(unresolved);
- assertTrue("All bundles resolved", resolved.containsAll(unresolved));
+ List<OSGiBundleState> resolved = bundleResolver.resolveBundles(unresolved);
+ assertEquals("All bundles resolved", unresolved.size(), resolved.size());
framework.stop();
}
Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/ServiceTestSuite.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/ServiceTestSuite.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/ServiceTestSuite.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -1,59 +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.test.osgi.service;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-import org.jboss.test.osgi.service.test.GetServiceReferencesUnitTestCase;
-import org.jboss.test.osgi.service.test.GetUnGetServiceUnitTestCase;
-import org.jboss.test.osgi.service.test.RegisterServiceUnitTestCase;
-import org.jboss.test.osgi.service.test.ServiceReferenceUnitTestCase;
-import org.jboss.test.osgi.service.test.ServiceRegistrationUnitTestCase;
-
-/**
- * ServiceTestSuite.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class ServiceTestSuite extends TestSuite
-{
- public static void main(String[] args)
- {
- TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite("Service Tests");
-
- suite.addTest(RegisterServiceUnitTestCase.suite());
- suite.addTest(ServiceRegistrationUnitTestCase.suite());
- suite.addTest(ServiceReferenceUnitTestCase.suite());
- suite.addTest(GetServiceReferencesUnitTestCase.suite());
- suite.addTest(GetUnGetServiceUnitTestCase.suite());
-
- return suite;
- }
-}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/GetServiceReferencesUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/GetServiceReferencesUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/GetServiceReferencesUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -50,11 +50,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(GetServiceReferencesUnitTestCase.class);
- }
-
public void testGetServiceReferences() throws Exception
{
Bundle bundle1 = assembleBundle("simple1", "/bundles/simple/simple-bundle1", A.class);
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/GetUnGetServiceUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/GetUnGetServiceUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/GetUnGetServiceUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -46,11 +46,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(GetUnGetServiceUnitTestCase.class);
- }
-
public void testGetUnServiceErrors() throws Exception
{
String OBJCLASS = BundleContext.class.getName();
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/RegisterServiceUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/RegisterServiceUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/RegisterServiceUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -50,11 +50,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(RegisterServiceUnitTestCase.class);
- }
-
public void testRegisterServiceErrors() throws Exception
{
String OBJCLASS = BundleContext.class.getName();
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/ServiceReferenceUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/ServiceReferenceUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/ServiceReferenceUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -28,8 +28,6 @@
import java.util.Set;
import java.util.TreeSet;
-import junit.framework.Test;
-
import org.jboss.test.osgi.OSGiTestCase;
import org.jboss.test.osgi.service.support.a.A;
import org.osgi.framework.Bundle;
@@ -52,11 +50,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(ServiceReferenceUnitTestCase.class);
- }
-
public void testGetProperty() throws Exception
{
ServiceReference reference = null;
@@ -451,44 +444,50 @@
public void testIsAssignableTo() throws Exception
{
- Bundle bundle = assembleBundle("service2", "/bundles/service/service-bundle2", A.class);
+ //Bundle-Name: Service2
+ //Bundle-SymbolicName: org.jboss.test.osgi.service2
+ //Export-Package: org.jboss.test.osgi.service.support.a
+ Bundle bundle2 = assembleBundle("service2", "/bundles/service/service-bundle2", A.class);
+
try
{
- bundle.start();
- BundleContext bundleContext = bundle.getBundleContext();
- assertNotNull(bundleContext);
+ bundle2.start();
+ BundleContext bundleContext2 = bundle2.getBundleContext();
+ assertNotNull(bundleContext2);
- Bundle bundle2 = assembleBundle("service1", "/bundles/service/service-bundle1");
+ //Bundle-Name: Service1
+ //Bundle-SymbolicName: org.jboss.test.osgi.service1
+ //Import-Package: org.jboss.test.osgi.service.support.a
+ Bundle bundle1 = assembleBundle("service1", "/bundles/service/service-bundle1");
+
try
{
- ServiceRegistration registration = bundleContext.registerService(BundleContext.class.getName(), bundleContext, null);
+ ServiceRegistration registration = bundleContext2.registerService(BundleContext.class.getName(), bundleContext2, null);
assertNotNull(registration);
ServiceReference reference = registration.getReference();
assertNotNull(reference);
- assertTrue(reference.isAssignableTo(bundle, A.class.getName()));
- assertTrue(reference.isAssignableTo(bundle, String.class.getName()));
- System.out.println("FIXME assertTrue(reference.isAssignableTo(bundle2, A.class.getName()))");
- //assertTrue(reference.isAssignableTo(bundle2, A.class.getName()));
- System.out.println("FIXME assertTrue(reference.isAssignableTo(bundle2, String.class.getName()))");
- //assertTrue(reference.isAssignableTo(bundle2, String.class.getName()));
+ assertTrue(reference.isAssignableTo(bundle2, A.class.getName()));
+ assertTrue(reference.isAssignableTo(bundle2, String.class.getName()));
+ assertTrue(reference.isAssignableTo(bundle1, A.class.getName()));
+ assertTrue(reference.isAssignableTo(bundle1, String.class.getName()));
registration.unregister();
- assertTrue(reference.isAssignableTo(bundle, A.class.getName()));
- assertTrue(reference.isAssignableTo(bundle, String.class.getName()));
- assertFalse(reference.isAssignableTo(bundle2, A.class.getName()));
- assertFalse(reference.isAssignableTo(bundle2, String.class.getName())); // review ???
+ assertTrue(reference.isAssignableTo(bundle2, A.class.getName()));
+ assertTrue(reference.isAssignableTo(bundle2, String.class.getName()));
+ assertFalse(reference.isAssignableTo(bundle1, A.class.getName()));
+ assertFalse(reference.isAssignableTo(bundle1, String.class.getName())); // review ???
}
finally
{
- uninstall(bundle2);
+ uninstall(bundle1);
}
}
finally
{
- uninstall(bundle);
+ uninstall(bundle2);
}
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/ServiceRegistrationUnitTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/ServiceRegistrationUnitTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/service/test/ServiceRegistrationUnitTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -47,11 +47,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(ServiceRegistrationUnitTestCase.class);
- }
-
public void testGetReference() throws Exception
{
Bundle bundle = addBundle("/bundles/simple/", "simple-bundle1");
Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/smoke/SmokeTestSuite.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/smoke/SmokeTestSuite.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/smoke/SmokeTestSuite.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -1,51 +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.test.osgi.smoke;
-
-import org.jboss.test.osgi.smoke.test.OSGiSmokeTestCase;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-/**
- * SmokeTestSuite.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class SmokeTestSuite extends TestSuite
-{
- public static void main(String[] args)
- {
- TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite("Smoke Tests");
-
- suite.addTest(OSGiSmokeTestCase.suite());
-
- return suite;
- }
-}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/smoke/test/OSGiSmokeTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/smoke/test/OSGiSmokeTestCase.java 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/smoke/test/OSGiSmokeTestCase.java 2009-09-14 08:40:27 UTC (rev 93457)
@@ -45,11 +45,6 @@
super(name);
}
- public static Test suite()
- {
- return suite(OSGiSmokeTestCase.class);
- }
-
public void testNoManifest() throws Exception
{
// [TODO] discuss no manifest
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml 2009-09-14 08:40:27 UTC (rev 93457)
@@ -143,8 +143,12 @@
<property name="classLoaderSystem"><inject bean="OSGiClassLoaderSystem"/></property>
<property name="bundleManager"><inject bean="OSGiBundleManager" /></property>
</bean>
+ <bean name="OSGiClassLoaderFactory" class="org.jboss.osgi.plugins.facade.classloading.OSGiClassLoaderFactory" >
+ <property name="system"><inject bean="OSGiClassLoaderSystem"/></property>
+ </bean>
<bean name="OSGiBundleClassLoadingDeployer" class="org.jboss.osgi.plugins.facade.classloading.OSGiBundleClassLoadingDeployer">
<property name="domain"><inject bean="OSGiClassLoaderDomain"/></property>
+ <property name="factory"><inject bean="OSGiClassLoaderFactory"/></property>
</bean>
<bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
Added: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/classloader/selfimportpackageAB/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/classloader/selfimportpackageAB/META-INF/MANIFEST.MF (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/classloader/selfimportpackageAB/META-INF/MANIFEST.MF 2009-09-14 08:40:27 UTC (rev 93457)
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Implementation-Title: JBoss OSGi tests
+Implementation-Version: test
+Implementation-Vendor: jboss.org
+Bundle-Name: BundleA
+Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleA;test=x
+Bundle-Version: 1.0.0
+Export-Package: org.jboss.test.osgi.classloader.support.a,org.jboss.test.osgi.classloader.support.b
+Import-Package: org.jboss.test.osgi.classloader.support.a,org.jboss.test.osgi.classloader.support.b
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/classloader/simpleimportpackageA/META-INF/MANIFEST.MF
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/classloader/simpleimportpackageA/META-INF/MANIFEST.MF 2009-09-14 08:32:54 UTC (rev 93456)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/classloader/simpleimportpackageA/META-INF/MANIFEST.MF 2009-09-14 08:40:27 UTC (rev 93457)
@@ -4,4 +4,5 @@
Implementation-Vendor: jboss.org
Bundle-Name: BundleB
Bundle-SymbolicName: org.jboss.test.osgi.classloader.bundleB
+Export-Package: org.jboss.test.osgi.classloader.support.b
Import-Package: org.jboss.test.osgi.classloader.support.a
More information about the jboss-osgi-commits
mailing list