[jboss-cvs] JBossAS SVN: r92743 - in projects/jboss-osgi/projects/runtime/microcontainer/trunk: scripts and 16 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Aug 24 10:24:15 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-08-24 10:24:14 -0400 (Mon, 24 Aug 2009)
New Revision: 92743
Added:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/assembly-bundles.xml
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/integration/
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/integration/simple/
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/integration/simple/simple-logservice.bnd
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/integration/simple/simple.bnd
Removed:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/simple/bundle/
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/simple/simple.bnd
Modified:
projects/jboss-osgi/projects/runtime/microcontainer/trunk/pom.xml
projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/antrun-test-jars.xml
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/OSGiBundleClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/api/SystemPackagesPlugin.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.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/OSGiClassLoaderSystem.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/plugins/SystemPackagesPluginImpl.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleActivator.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleService.java
projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml
Log:
Add system packages to the parent class loader domain
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/pom.xml 2009-08-24 13:49:11 UTC (rev 92742)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/pom.xml 2009-08-24 14:24:14 UTC (rev 92743)
@@ -14,9 +14,11 @@
<!-- Properties -->
<properties>
+ <version.apache.felix.log>1.1.0-SNAPSHOT</version.apache.felix.log>
<version.jboss.aop>2.1.0.CR3</version.jboss.aop>
<version.jboss.deployers>2.0.8.GA</version.jboss.deployers>
<version.jboss.logging.log4j>2.1.0.GA</version.jboss.logging.log4j>
+ <version.jboss.osgi.common>1.0.1-SNAPSHOT</version.jboss.osgi.common>
<version.jboss.osgi.runtime.deployers>1.0.1-SNAPSHOT</version.jboss.osgi.runtime.deployers>
<version.jboss.osgi.spi>1.0.1-SNAPSHOT</version.jboss.osgi.spi>
<version.jboss.microcontainer>2.0.6.GA</version.jboss.microcontainer>
@@ -132,11 +134,55 @@
</exclusion>
</exclusions>
</dependency>
+
+ <!-- Test bundles dependencies -->
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.log</artifactId>
+ <version>${version.apache.felix.log}</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-common</artifactId>
+ <version>${version.jboss.osgi.common}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
<plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>bundles</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>directory-single</goal>
+ </goals>
+ <configuration>
+ <finalName>test-libs</finalName>
+ <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
+ <appendAssemblyId>false</appendAssemblyId>
+ <descriptors>
+ <descriptor>scripts/assembly-bundles.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/antrun-test-jars.xml 2009-08-24 13:49:11 UTC (rev 92742)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/antrun-test-jars.xml 2009-08-24 14:24:14 UTC (rev 92743)
@@ -43,7 +43,8 @@
<!-- Please add alphabetically -->
<!-- simple -->
- <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-bundle.jar" files="${tests.resources.dir}/bundles/simple/simple.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-bundle.jar" files="${tests.resources.dir}/integration/simple/simple.bnd" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/simple-logservice-bundle.jar" files="${tests.resources.dir}/integration/simple/simple-logservice.bnd" />
<!-- Please add alphabetically -->
Added: projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/assembly-bundles.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/assembly-bundles.xml (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/assembly-bundles.xml 2009-08-24 14:24:14 UTC (rev 92743)
@@ -0,0 +1,37 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
+
+ <id>deploy-artifacts</id>
+ <formats>
+ <format>dir</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+
+ <!-- Dependency Sets -->
+ <dependencySets>
+
+ <!-- bundles -->
+ <dependencySet>
+ <outputDirectory>bundles</outputDirectory>
+ <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ <includes>
+ <include>*:org.osgi.compendium:jar</include>
+ </includes>
+ <useStrictFiltering>true</useStrictFiltering>
+ <scope>compile</scope>
+ <unpack>false</unpack>
+ </dependencySet>
+ <dependencySet>
+ <outputDirectory>bundles</outputDirectory>
+ <outputFileNameMapping>${artifact.artifactId}${dashClassifier?}.${artifact.extension}</outputFileNameMapping>
+ <includes>
+ <include>*:jboss-osgi-common:jar</include>
+ <include>*:org.apache.felix.log:jar</include>
+ </includes>
+ <useStrictFiltering>true</useStrictFiltering>
+ <scope>test</scope>
+ <unpack>false</unpack>
+ </dependencySet>
+
+ </dependencySets>
+</assembly>
Property changes on: projects/jboss-osgi/projects/runtime/microcontainer/trunk/scripts/assembly-bundles.xml
___________________________________________________________________
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/deployers/bundle/OSGiBundleClassLoadingDeployer.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/OSGiBundleClassLoadingDeployer.java 2009-08-24 13:49:11 UTC (rev 92742)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/deployers/bundle/OSGiBundleClassLoadingDeployer.java 2009-08-24 14:24:14 UTC (rev 92743)
@@ -38,7 +38,6 @@
import org.jboss.osgi.spi.metadata.OSGiMetaData;
import org.jboss.osgi.spi.metadata.PackageAttribute;
import org.jboss.osgi.spi.metadata.Parameter;
-import org.jboss.osgi.spi.util.ConstantsHelper;
import org.osgi.framework.Constants;
/**
@@ -89,9 +88,6 @@
Capability capability = new ModuleCapability(metadata.getBundleSymbolicName(), metadata.getBundleVersion());
classLoadingMetaData.getCapabilities().addCapability(capability);
- // [TODO] Should system packages be added as capabilities?
- SystemPackagesPlugin syspackPlugin = bundleManager.getPlugin(SystemPackagesPlugin.class);
-
ArrayList<String> exportedNames = new ArrayList<String>();
List<PackageAttribute> exported = metadata.getExportPackages();
@@ -109,10 +105,12 @@
List<PackageAttribute> imported = metadata.getImportPackages();
if (imported != null)
{
+ SystemPackagesPlugin syspackPlugin = bundleManager.getPlugin(SystemPackagesPlugin.class);
for (PackageAttribute packageAttribute : imported)
{
String packageName = packageAttribute.getPackageInfo().getName();
+ // [TODO] Should system packages be added as capabilities?
boolean isSystemPackage = syspackPlugin.isSystemPackage(packageName);
boolean isOptional = false;
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/api/SystemPackagesPlugin.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/api/SystemPackagesPlugin.java 2009-08-24 13:49:11 UTC (rev 92742)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/api/SystemPackagesPlugin.java 2009-08-24 14:24:14 UTC (rev 92743)
@@ -34,6 +34,8 @@
public interface SystemPackagesPlugin extends AbstractPlugin
{
List<String> getSystemPackages();
+
+ String getSystemPackagesAsString();
boolean isSystemPackage(String name);
}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java 2009-08-24 13:49:11 UTC (rev 92742)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiBundleState.java 2009-08-24 14:24:14 UTC (rev 92743)
@@ -85,31 +85,31 @@
{
/** The log */
private static final Logger log = Logger.getLogger(OSGiBundleState.class);
-
+
/** Used to generate a unique id */
private static final AtomicLong bundleIDGenerator = new AtomicLong();
-
+
/** The bundle id */
private long bundleId;
-
+
/** The last modified time stamp */
private long lastModified = System.currentTimeMillis();
-
+
/** The bundle manager */
private OSGiBundleManager bundleManager;
-
+
/** The osgi metadata */
private OSGiMetaData osgiMetaData;
-
+
/** The deployment unit */
private DeploymentUnit unit;
-
+
/** The bundle context */
private BundleContext bundleContext;
-
- /** The bundle */
+
+ /** The bundle */
private Bundle bundle;
-
+
/** The bundle state */
private AtomicInteger state = new AtomicInteger(Bundle.UNINSTALLED);
@@ -118,13 +118,13 @@
/** The services in use */
private Map<OSGiServiceState, Integer> servicesInUse = new ConcurrentHashMap<OSGiServiceState, Integer>();
-
+
/** The bundle listeners */
private List<BundleListener> bundleListeners = new CopyOnWriteArrayList<BundleListener>();
/** The framework listeners */
private List<FrameworkListener> frameworkListeners = new CopyOnWriteArrayList<FrameworkListener>();
-
+
/** The service listeners */
private Map<ServiceListener, ServiceListenerRegistration> serviceListeners = new ConcurrentHashMap<ServiceListener, ServiceListenerRegistration>();
@@ -247,7 +247,7 @@
Collection<OSGiBundleState> bundleStates = bundleManager.getBundles();
if (bundleStates.isEmpty())
return new Bundle[0];
-
+
List<Bundle> bundles = new ArrayList<Bundle>(bundleStates.size());
for (OSGiBundleState bundleState : bundleStates)
bundles.add(bundleState.getBundleInternal());
@@ -263,7 +263,7 @@
{
lastModified = System.currentTimeMillis();
}
-
+
public String getLocation()
{
checkAdminPermission(AdminPermission.METADATA);
@@ -271,16 +271,16 @@
URL url = getOSGiMetaData().getBundleUpdateLocation();
if (url != null)
return url.toString();
-
+
DeploymentUnit unit = getDeploymentUnit();
if (unit instanceof VFSDeploymentUnit)
{
- VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
VirtualFile root = vfsDeploymentUnit.getRoot();
return root.getName();
}
-
- return null;
+
+ return null;
}
/**
@@ -305,7 +305,7 @@
checkAdminPermission(AdminPermission.METADATA);
return getOSGiMetaData().getHeaders(locale);
}
-
+
public String getProperty(String key)
{
checkValidBundleContext();
@@ -328,8 +328,8 @@
DeploymentUnit unit = getDeploymentUnit();
if (unit instanceof VFSDeploymentUnit)
{
- VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
-
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
+
if (path.startsWith("/"))
path = path.substring(1);
return vfsDeploymentUnit.getResourceLoader().getResource(path);
@@ -347,21 +347,21 @@
DeploymentUnit unit = getDeploymentUnit();
if (unit instanceof VFSDeploymentUnit)
{
- VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
VirtualFile root = vfsDeploymentUnit.getRoot();
if (path.startsWith("/"))
path = path.substring(1);
try
{
- VirtualFile child = root.getChild(path);
- if (child != null)
- return new VFSEntryPathsEnumeration(root, child);
+ VirtualFile child = root.getChild(path);
+ if (child != null)
+ return new VFSEntryPathsEnumeration(root, child);
}
catch (IOException e)
{
throw new RuntimeException("Error determining entry paths for " + root + " path=" + path);
}
-
+
}
return null;
}
@@ -375,31 +375,31 @@
checkInstalled();
if (noAdminPermission(AdminPermission.RESOURCE))
return null;
-
+
// [TODO] fragments
resolve(false);
-
+
if (filePattern == null)
filePattern = "*";
-
+
DeploymentUnit unit = getDeploymentUnit();
if (unit instanceof VFSDeploymentUnit)
{
- VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+ VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit)unit;
VirtualFile root = vfsDeploymentUnit.getRoot();
if (path.startsWith("/"))
path = path.substring(1);
try
{
- VirtualFile child = root.getChild(path);
- if (child != null)
- return new VFSFindEntriesEnumeration(root, child, filePattern, recurse);
+ VirtualFile child = root.getChild(path);
+ if (child != null)
+ return new VFSFindEntriesEnumeration(root, child, filePattern, recurse);
}
catch (IOException e)
{
throw new RuntimeException("Error finding entries for " + root + " path=" + path + " pattern=" + filePattern + " recurse=" + recurse);
}
-
+
}
return null;
}
@@ -410,7 +410,7 @@
checkInstalled();
checkAdminPermission(AdminPermission.CLASS);
// [TODO] bundle fragment
-
+
try
{
resolve(true);
@@ -456,7 +456,7 @@
SecurityManager sm = System.getSecurityManager();
if (sm == null)
return true;
-
+
// [TODO] hasPermission
return true;
}
@@ -524,7 +524,7 @@
public ServiceReference[] getRegisteredServices()
{
checkInstalled();
-
+
if (registeredServices.isEmpty())
return null;
@@ -585,11 +585,11 @@
}
return true;
}
-
+
public ServiceReference[] getServicesInUse()
{
checkInstalled();
-
+
synchronized (servicesInUse)
{
Collection<OSGiServiceState> inUse = servicesInUse.keySet();
@@ -620,7 +620,7 @@
if (reference == null)
throw new IllegalArgumentException("Null reference");
-
+
return getBundleManager().getService(this, reference);
}
@@ -650,7 +650,7 @@
public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties)
{
checkValidBundleContext();
-
+
OSGiServiceState serviceState = getBundleManager().registerService(this, clazzes, service, properties);
return serviceState.getRegistration();
}
@@ -664,14 +664,14 @@
{
getBundleManager().unregisterService(serviceState);
}
-
+
public boolean ungetService(ServiceReference reference)
{
checkValidBundleContext();
return getBundleManager().ungetService(this, reference);
}
-
+
boolean ungetService(OSGiServiceState state)
{
return getBundleManager().ungetService(this, state);
@@ -683,10 +683,10 @@
throw new IllegalArgumentException("Null listener");
checkValidBundleContext();
-
+
if (listener instanceof SynchronousBundleListener)
checkAdminPermission(AdminPermission.LISTENER);
-
+
if (bundleListeners.contains(listener))
return;
@@ -699,7 +699,7 @@
throw new IllegalArgumentException("Null listener");
checkValidBundleContext();
-
+
if (listener instanceof SynchronousBundleListener)
checkAdminPermission(AdminPermission.LISTENER);
@@ -709,7 +709,7 @@
/**
* Try to resolve the bundle
*
- * @param errorOnFail whether to throw an error when not installed
+ * @param errorOnFail whether to throw an error when not installed
* @return true when resolved
*/
boolean resolve(boolean errorOnFail)
@@ -730,22 +730,19 @@
{
checkInstalled();
checkAdminPermission(AdminPermission.EXECUTE);
-
+
if (getState() == ACTIVE)
return;
getBundleManager().start(this);
}
-
+
/**
* Start internal
*
- * [TODO] Start Level Service & START_TRANSIENT?
- * [TODO] START_ACTIVATION_POLICY
- * [TODO] LAZY_ACTIVATION
- * [TODO] locks
- * [TODO] options
- * @throws Throwable for any error
+ * [TODO] Start Level Service & START_TRANSIENT? [TODO] START_ACTIVATION_POLICY [TODO] LAZY_ACTIVATION [TODO] locks [TODO] options
+ *
+ * @throws Throwable for any error
*/
public void startInternal() throws Throwable
{
@@ -761,26 +758,27 @@
if (bundleActivatorClassName != null)
{
ClassLoader classLoader = unit.getClassLoader();
-
- DeploymentControllerContext deploymentControllerContext = getDeploymentUnit().getAttachment(ControllerContext.class.getName(), DeploymentControllerContext.class);
+
+ DeploymentControllerContext deploymentControllerContext = getDeploymentUnit().getAttachment(ControllerContext.class.getName(),
+ DeploymentControllerContext.class);
if (deploymentControllerContext == null)
throw new BundleException("No deployment controller context: " + getCanonicalName());
-
- KernelController controller = (KernelController) deploymentControllerContext.getController();
+
+ KernelController controller = (KernelController)deploymentControllerContext.getController();
BeanInfo beanInfo = controller.getKernel().getConfig().getBeanInfo(bundleActivatorClassName, classLoader);
Object result = beanInfo.newInstance();
if (result instanceof BundleActivator == false)
throw new BundleException(bundleActivatorClassName + " is not an implementation of " + BundleActivator.class.getName());
- BundleActivator bundleActivator = (BundleActivator) result;
+ BundleActivator bundleActivator = (BundleActivator)result;
unit.addAttachment(BundleActivator.class, bundleActivator);
-
+
bundleActivator.start(bundleContext);
}
}
-
+
if (getState() != STARTING)
throw new BundleException("Bundle has been uninstalled: " + bundle);
-
+
changeState(ACTIVE);
}
catch (Throwable t)
@@ -803,7 +801,7 @@
{
checkInstalled();
checkAdminPermission(AdminPermission.EXECUTE);
-
+
if (getState() != ACTIVE)
return;
@@ -813,15 +811,14 @@
/**
* Stop Internal
*
- * [TODO] Start Level Service & STOP_TRANSIENT?
- * [TODO] locks
- * [TODO] options
+ * [TODO] Start Level Service & STOP_TRANSIENT? [TODO] locks [TODO] options
+ *
* @throws Throwable for any error
*/
public void stopInternal() throws Throwable
{
changeState(STOPPING);
-
+
Throwable rethrow = null;
try
{
@@ -867,7 +864,7 @@
}
}
}
-
+
if (getState() != STOPPING)
throw new BundleException("Bundle has been uninstalled: " + getCanonicalName());
}
@@ -878,7 +875,7 @@
bundleContext = null;
unit.removeAttachment(BundleActivator.class);
}
-
+
if (rethrow != null)
throw rethrow;
}
@@ -911,7 +908,7 @@
void uninstallInternal()
{
changeState(Bundle.UNINSTALLED);
-
+
frameworkListeners.clear();
bundleListeners.clear();
serviceListeners.clear();
@@ -921,9 +918,9 @@
{
if (listener == null)
throw new IllegalArgumentException("Null listener");
-
+
checkValidBundleContext();
-
+
if (frameworkListeners.contains(listener))
return;
@@ -952,23 +949,50 @@
{
checkValidBundleContext();
checkAdminPermission(AdminPermission.LIFECYCLE); // [TODO] extension bundles
-
+
OSGiBundleManager bundleManager = getBundleManager();
if (bundleManager == null)
throw new IllegalStateException("Bundle " + getCanonicalName() + " is not valid");
+ URL url = getLocationURL(location);
+ OSGiBundleState bundleState = bundleManager.install(url);
+ return bundleState.getBundleInternal();
+ }
+
+ private URL getLocationURL(String location) throws BundleException
+ {
+ // Try location as URL
+ URL url = null;
try
{
- URL url = new URL(location);
- OSGiBundleState bundleState = bundleManager.install(url);
- return bundleState.getBundleInternal();
+ url = new URL(location);
}
catch (MalformedURLException e)
{
- throw new BundleException("Unable to handle location=" + location, e);
+ // ignore
}
+
+ // Try location as File
+ if (url == null)
+ {
+ try
+ {
+ File file = new File(location);
+ if (file.exists())
+ url = file.toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // ignore
+ }
+ }
+
+ if (url == null)
+ throw new BundleException("Unable to handle location=" + location);
+
+ return url;
}
-
+
@Override
public String toString()
{
@@ -1027,7 +1051,7 @@
return null;
}
}
-
+
/**
* Change the state of the bundle
*
@@ -1039,11 +1063,19 @@
int type = 0;
switch (state)
{
- case Bundle.STARTING : type = BundleEvent.STARTING; break;
- case Bundle.ACTIVE : type = BundleEvent.STARTED; break;
- case Bundle.STOPPING : type = BundleEvent.STOPPING; break;
- case Bundle.UNINSTALLED : type = BundleEvent.UNINSTALLED; break;
- case Bundle.INSTALLED :
+ case Bundle.STARTING:
+ type = BundleEvent.STARTING;
+ break;
+ case Bundle.ACTIVE:
+ type = BundleEvent.STARTED;
+ break;
+ case Bundle.STOPPING:
+ type = BundleEvent.STOPPING;
+ break;
+ case Bundle.UNINSTALLED:
+ type = BundleEvent.UNINSTALLED;
+ break;
+ case Bundle.INSTALLED:
{
if (previous == Bundle.RESOLVED)
type = BundleEvent.UNRESOLVED;
@@ -1051,7 +1083,7 @@
type = BundleEvent.INSTALLED;
break;
}
- case Bundle.RESOLVED :
+ case Bundle.RESOLVED:
{
if (previous == Bundle.STOPPING)
type = BundleEvent.STOPPED;
@@ -1059,7 +1091,7 @@
type = BundleEvent.RESOLVED;
break;
}
- default :
+ default:
throw new IllegalArgumentException("Unknown bundle state: " + state);
}
this.state.set(state);
@@ -1067,7 +1099,7 @@
BundleEvent event = new BundleEvent(type, getBundleInternal());
fireBundleEvent(event);
}
-
+
/**
* Fire a bundle event
*
@@ -1078,11 +1110,11 @@
// Nobody is interested
if (bundleListeners.isEmpty())
return;
-
+
// Are we active?
if (getBundleManager().isActive() == false)
return;
-
+
// Synchronous listeners first
for (BundleListener listener : bundleListeners)
{
@@ -1114,7 +1146,7 @@
}
}
}
-
+
/**
* Fire a framework event
*
@@ -1126,11 +1158,11 @@
// Nobody is interested
if (frameworkListeners.isEmpty())
return;
-
+
// Are we active?
if (getBundleManager().isActive() == false)
return;
-
+
// Call the listeners
FrameworkEvent event = new FrameworkEvent(type, getBundleInternal(), throwable);
for (FrameworkListener listener : frameworkListeners)
@@ -1145,7 +1177,7 @@
}
}
}
-
+
/**
* Fire a service event
*
@@ -1160,13 +1192,13 @@
// Nobody is interested
if (serviceListeners.isEmpty())
return;
-
+
// Are we active?
if (getBundleManager().isActive() == false)
return;
-
+
ServiceEvent event = new ServiceEvent(type, service.getReferenceInternal());
-
+
// Call the listeners
for (Map.Entry<ServiceListener, ServiceListenerRegistration> entry : serviceListeners.entrySet())
{
@@ -1187,7 +1219,7 @@
}
}
}
-
+
/**
* Check the bundle is installed
*
@@ -1212,13 +1244,12 @@
throw new IllegalStateException("Bundle context is no longer valid");
return result;
}
-
+
/**
* Check the admin permission
*
* @param what what permission to check
- * @throws SecurityException when the caller does not have the AdminPermission
- * and a security manager is installed
+ * @throws SecurityException when the caller does not have the AdminPermission and a security manager is installed
*/
private void checkAdminPermission(String what)
{
@@ -1226,7 +1257,7 @@
if (sm != null)
sm.checkPermission(new AdminPermission(this, what));
}
-
+
/**
* Checks if we have the admin permission
*
@@ -1256,16 +1287,22 @@
{
switch (state)
{
- case Bundle.INSTALLED : return "INSTALLED";
- case Bundle.RESOLVED : return "RESOLVED";
- case Bundle.STARTING : return "STARTING";
- case Bundle.ACTIVE : return "ACTIVE";
- case Bundle.STOPPING : return "STOPPING";
- case Bundle.UNINSTALLED : return "UNINSTALLED";
+ case Bundle.INSTALLED:
+ return "INSTALLED";
+ case Bundle.RESOLVED:
+ return "RESOLVED";
+ case Bundle.STARTING:
+ return "STARTING";
+ case Bundle.ACTIVE:
+ return "ACTIVE";
+ case Bundle.STOPPING:
+ return "STOPPING";
+ case Bundle.UNINSTALLED:
+ return "UNINSTALLED";
}
return "???" + state;
}
-
+
/**
* ServiceListenerRegistration.
*/
@@ -1273,7 +1310,7 @@
{
// Any filter
Filter filter;
-
+
// Any access control context
AccessControlContext accessControlContext;
@@ -1285,7 +1322,7 @@
public ServiceListenerRegistration(Filter filter)
{
this.filter = filter;
-
+
if (System.getSecurityManager() != null)
accessControlContext = AccessController.getContext();
}
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-08-24 13:49:11 UTC (rev 92742)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/bundle/OSGiServiceState.java 2009-08-24 14:24:14 UTC (rev 92743)
@@ -531,6 +531,7 @@
{
if (object == null)
throw new IllegalArgumentException("Null object");
+
for (String className : getClasses())
{
try
@@ -538,11 +539,11 @@
Class<?> clazz = getBundleState().loadClass(className);
// [TODO] show classloader information all interfaces for debugging purposes
if (clazz.isInstance(object) == false)
- throw new IllegalArgumentException(object + " of type " + object.getClass().getName() + " does not implement " + className);
+ throw new IllegalArgumentException(object.getClass().getName() + " does not implement " + className);
}
catch (ClassNotFoundException e)
{
- throw new IllegalArgumentException("Cannot load class: " + className, e);
+ throw new IllegalArgumentException(object.getClass().getName() + " cannot load class: " + className, e);
}
}
return object;
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderSystem.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderSystem.java 2009-08-24 13:49:11 UTC (rev 92742)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/classloading/OSGiClassLoaderSystem.java 2009-08-24 14:24:14 UTC (rev 92743)
@@ -27,27 +27,38 @@
import org.jboss.classloader.spi.ClassLoaderSystem;
import org.jboss.classloader.spi.ParentPolicy;
import org.jboss.classloader.spi.filter.ClassFilter;
-import org.jboss.classloader.spi.filter.RecursivePackageClassFilter;
+import org.jboss.classloader.spi.filter.PackageClassFilter;
+import org.jboss.osgi.plugins.facade.api.SystemPackagesPlugin;
+import org.jboss.osgi.plugins.facade.bundle.OSGiBundleManager;
import org.jboss.osgi.plugins.facade.bundle.OSGiBundleState;
/**
* OSGiClassLoaderSystem.<p>
*
- * TODO Figure out how to make this more easily configurable
- *
* @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author Thomas.Diesler at jboss.com
* @version $Revision: 1.1 $
*/
public class OSGiClassLoaderSystem extends ClassLoaderSystem
{
/**
* Create a new OSGiClassLoaderSystem.
+ * @param bundleManager the bundleManager
+ * @throws IllegalArgumentException for a null bundle manager
*/
- public OSGiClassLoaderSystem()
+ public OSGiClassLoaderSystem(OSGiBundleManager bundleManager)
{
+ if (bundleManager == null)
+ throw new IllegalArgumentException("Null bundle manager");
+
ClassLoaderDomain domain = getDefaultDomain();
- PatternClassFilter filter = RecursivePackageClassFilter.createRecursivePackageClassFilterFromString("org.osgi");
+
+ // Initialize the configured system packages
+ SystemPackagesPlugin syspackPlugin = bundleManager.getPlugin(SystemPackagesPlugin.class);
+ String sysPackageString = syspackPlugin.getSystemPackagesAsString();
+ PatternClassFilter filter = PackageClassFilter.createPackageClassFilterFromString(sysPackageString);
filter.setIncludeJava(true);
+
domain.setParentPolicy(new ParentPolicy(filter, ClassFilter.NOTHING));
AbstractJDKChecker.getExcluded().add(OSGiBundleState.class);
}
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/plugins/SystemPackagesPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/plugins/SystemPackagesPluginImpl.java 2009-08-24 13:49:11 UTC (rev 92742)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/main/java/org/jboss/osgi/plugins/facade/plugins/SystemPackagesPluginImpl.java 2009-08-24 14:24:14 UTC (rev 92743)
@@ -98,6 +98,16 @@
return Collections.unmodifiableList(allPackages);
}
+ @Override
+ public String getSystemPackagesAsString()
+ {
+ StringBuffer sysPackageString = new StringBuffer();
+ for (String name : allPackageNames)
+ sysPackageString.append(name + ",");
+
+ return sysPackageString.toString();
+ }
+
public boolean isSystemPackage(String name)
{
if(name == null)
Copied: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java (from rev 92733, projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java)
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleBundleTestCase.java 2009-08-24 14:24:14 UTC (rev 92743)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.integration.simple;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.osgi.spi.testing.OSGiBundle;
+import org.jboss.osgi.spi.testing.OSGiRuntime;
+import org.jboss.osgi.spi.testing.OSGiTestHelper;
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * A test that deployes a bundle and verifies its state
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Aug-2009
+ */
+public class SimpleBundleTestCase
+{
+ @Test
+ public void testBundleInstallLauchAPI() throws Exception
+ {
+ // Uses the OSGi Framework launch API
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ Framework framework = factory.newFramework(null);
+ framework.start();
+
+ OSGiTestHelper helper = new OSGiTestHelper();
+
+ BundleContext sysContext = framework.getBundleContext();
+ Bundle bundle = sysContext.installBundle(helper.getTestArchivePath("simple-bundle.jar"));
+
+ assertEquals("simple-bundle", bundle.getSymbolicName());
+
+ bundle.start();
+ assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
+
+ bundle.uninstall();
+ assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
+
+ framework.stop();
+ }
+
+ @Test
+ public void testBundleInstallRuntimeAPI() throws Exception
+ {
+ // Uses the JBossOSGi SPI provided runtime abstraction
+ OSGiRuntime runtime = new OSGiTestHelper().getEmbeddedRuntime();
+ OSGiBundle bundle = runtime.installBundle("simple-bundle.jar");
+
+ assertEquals("simple-bundle", bundle.getSymbolicName());
+
+ bundle.start();
+ assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
+
+ bundle.uninstall();
+ assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
+
+ runtime.shutdown();
+ }
+}
\ No newline at end of file
Added: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java 2009-08-24 14:24:14 UTC (rev 92743)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.integration.simple;
+
+//$Id$
+
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import org.jboss.osgi.spi.testing.OSGiTest;
+import org.jboss.osgi.spi.util.ServiceLoader;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.launch.Framework;
+import org.osgi.framework.launch.FrameworkFactory;
+
+/**
+ * A test that deployes a bundle and verifies its state
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 18-Aug-2009
+ */
+public class SimpleLogServiceTestCase extends OSGiTest
+{
+ @Test
+ public void testNoLogService() throws Exception
+ {
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ Framework framework = factory.newFramework(null);
+ framework.start();
+
+ BundleContext sysContext = framework.getBundleContext();
+ Bundle bundle = sysContext.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+
+ try
+ {
+ bundle.start();
+ fail("Unresolved package contstraint on [org.osgi.service.log] expected");
+ }
+ catch (BundleException ex)
+ {
+ // expected
+ }
+
+ framework.stop();
+ }
+
+ @Test
+ public void testLogService() throws Exception
+ {
+ FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
+ Framework framework = factory.newFramework(null);
+ framework.start();
+
+ BundleContext sysContext = framework.getBundleContext();
+ sysContext.installBundle(getTestArchivePath("bundles/org.osgi.compendium.jar")).start();
+ sysContext.installBundle(getTestArchivePath("bundles/org.apache.felix.log.jar")).start();
+
+ Bundle bundle = sysContext.installBundle(getTestArchivePath("simple-logservice-bundle.jar"));
+ bundle.start();
+
+ // The bundle activator is expected to set this property
+ String result = System.getProperty(bundle.getSymbolicName());
+ assertNotNull("Result property not null", result);
+
+ assertTrue("BundleActivator start", result.indexOf("startBundleActivator") > 0);
+
+ System.out.println("FIXME [JBOSGI-135] Cannot get LogService when compendium is installed");
+ //assertTrue("getService", result.indexOf("getService") > 0);
+ //assertTrue("addingService", result.indexOf("addingService") > 0);
+
+ framework.stop();
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/SimpleLogServiceTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleA (from rev 92733, projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/simple/bundle)
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleActivator.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/simple/bundle/SimpleActivator.java 2009-08-24 09:40:32 UTC (rev 92733)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleActivator.java 2009-08-24 14:24:14 UTC (rev 92743)
@@ -19,7 +19,7 @@
* 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.simple.bundle;
+package org.jboss.test.osgi.integration.simple.bundleA;
//$Id$
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleService.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/simple/bundle/SimpleService.java 2009-08-24 09:40:32 UTC (rev 92733)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleA/SimpleService.java 2009-08-24 14:24:14 UTC (rev 92743)
@@ -19,7 +19,7 @@
* 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.simple.bundle;
+package org.jboss.test.osgi.integration.simple.bundleA;
//$Id$
Added: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java 2009-08-24 14:24:14 UTC (rev 92743)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.osgi.integration.simple.bundleB;
+
+//$Id$
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A Service Activator
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 24-Apr-2009
+ */
+public class SimpleLogServiceActivator implements BundleActivator
+{
+ public void start(BundleContext context)
+ {
+ final String symName = context.getBundle().getSymbolicName();
+ addMessage(symName, "startBundleActivator");
+
+ ServiceReference sref = context.getServiceReference(LogService.class.getName());
+ if (sref != null)
+ {
+ LogService service = (LogService)context.getService(sref);
+ String message = "getService: " + service.getClass().getName();
+ addMessage(symName, message);
+ }
+
+ ServiceTracker tracker = new ServiceTracker(context, LogService.class.getName(), null)
+ {
+ @Override
+ public Object addingService(ServiceReference reference)
+ {
+ LogService service = (LogService)super.addingService(reference);
+ String message = "addingService: " + service.getClass().getName();
+ addMessage(symName, message);
+ return service;
+ }
+ };
+ tracker.open();
+ }
+
+ public void stop(BundleContext context)
+ {
+ String symName = context.getBundle().getSymbolicName();
+ addMessage(symName, "stopBundleActivator");
+ }
+
+ private void addMessage(String propName, String message)
+ {
+ String previous = System.getProperty(propName, ":");
+ System.setProperty(propName, previous + message + ":");
+ //System.out.println(message);
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/integration/simple/bundleB/SimpleLogServiceActivator.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java 2009-08-24 13:49:11 UTC (rev 92742)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/java/org/jboss/test/osgi/simple/SimpleBundleTestCase.java 2009-08-24 14:24:14 UTC (rev 92743)
@@ -1,88 +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.test.osgi.simple;
-
-//$Id$
-
-import static org.junit.Assert.assertEquals;
-
-import java.net.URL;
-
-import org.jboss.osgi.spi.testing.OSGiBundle;
-import org.jboss.osgi.spi.testing.OSGiRuntime;
-import org.jboss.osgi.spi.testing.OSGiTestHelper;
-import org.jboss.osgi.spi.util.ServiceLoader;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.launch.Framework;
-import org.osgi.framework.launch.FrameworkFactory;
-
-/**
- * A test that deployes a bundle and verifies its state
- *
- * @author thomas.diesler at jboss.com
- * @since 18-Aug-2009
- */
-public class SimpleBundleTestCase
-{
- @Test
- public void testBundleInstallLauchAPI() throws Exception
- {
- // Uses the OSGi Framework launch API
- FrameworkFactory factory = ServiceLoader.loadService(FrameworkFactory.class);
- Framework framework = factory.newFramework(null);
- framework.start();
-
- BundleContext sysContext = framework.getBundleContext();
- URL bundleURL = new OSGiTestHelper().getTestArchiveURL("simple-bundle.jar");
- Bundle bundle = sysContext.installBundle(bundleURL.toExternalForm());
-
- assertEquals("simple-bundle", bundle.getSymbolicName());
-
- bundle.start();
- assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
-
- bundle.uninstall();
- assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
-
- framework.stop();
- }
-
- @Test
- public void testBundleInstallRuntimeAPI() throws Exception
- {
- // Uses the JBossOSGi SPI provided runtime abstraction
- OSGiRuntime runtime = new OSGiTestHelper().getEmbeddedRuntime();
- OSGiBundle bundle = runtime.installBundle("simple-bundle.jar");
-
- assertEquals("simple-bundle", bundle.getSymbolicName());
-
- bundle.start();
- assertEquals("Bundle state", Bundle.ACTIVE, bundle.getState());
-
- bundle.uninstall();
- assertEquals("Bundle state", Bundle.UNINSTALLED, bundle.getState());
-
- runtime.shutdown();
- }
-}
\ No newline at end of file
Modified: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml 2009-08-24 13:49:11 UTC (rev 92742)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bootstrap/bootstrap.xml 2009-08-24 14:24:14 UTC (rev 92743)
@@ -101,7 +101,9 @@
-->
<!-- ClassLoading -->
- <bean name="ClassLoaderSystem" class="org.jboss.osgi.plugins.facade.classloading.OSGiClassLoaderSystem" />
+ <bean name="ClassLoaderSystem" class="org.jboss.osgi.plugins.facade.classloading.OSGiClassLoaderSystem" >
+ <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ </bean>
<bean name="ClassLoading" class="org.jboss.classloading.spi.dependency.ClassLoading">
<incallback method="addModule" state="Configured" />
<uncallback method="removeModule" state="Configured" />
Deleted: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/simple/simple.bnd
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/simple/simple.bnd 2009-08-24 13:49:11 UTC (rev 92742)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/simple/simple.bnd 2009-08-24 14:24:14 UTC (rev 92743)
@@ -1,6 +0,0 @@
-# bnd build -classpath target/test-classes -output target/test-libs/simple-bundle.jar src/test/resources/bundles/simple/simple.bnd
-
-Bundle-SymbolicName: simple-bundle
-
-Bundle-Activator: org.jboss.test.osgi.simple.bundle.SimpleActivator
-Export-Package: org.jboss.test.osgi.simple.bundle
Added: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/integration/simple/simple-logservice.bnd
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/integration/simple/simple-logservice.bnd (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/integration/simple/simple-logservice.bnd 2009-08-24 14:24:14 UTC (rev 92743)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/simple-bundle.jar src/test/resources/integration/simple/simple-logservice.bnd
+
+Bundle-SymbolicName: simple-logservice-bundle
+
+Bundle-Activator: org.jboss.test.osgi.integration.simple.bundleB.SimpleLogServiceActivator
+Private-Package: org.jboss.test.osgi.integration.simple.bundleB
Copied: projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/integration/simple/simple.bnd (from rev 92733, projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/bundles/simple/simple.bnd)
===================================================================
--- projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/integration/simple/simple.bnd (rev 0)
+++ projects/jboss-osgi/projects/runtime/microcontainer/trunk/src/test/resources/integration/simple/simple.bnd 2009-08-24 14:24:14 UTC (rev 92743)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/simple-bundle.jar src/test/resources/integration/simple/simple.bnd
+
+Bundle-SymbolicName: simple-bundle
+
+Bundle-Activator: org.jboss.test.osgi.integration.simple.bundleA.SimpleActivator
+Export-Package: org.jboss.test.osgi.integration.simple.bundleA
More information about the jboss-cvs-commits
mailing list