Author: thomas.diesler(a)jboss.com
Date: 2010-03-03 09:45:40 -0500 (Wed, 03 Mar 2010)
New Revision: 101775
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/pom.xml
Removed:
projects/jboss-osgi/projects/runtime/framework/trunk/core/scripts/
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/etc/
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderDomain.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderSystem.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/vfs/
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/main/
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/scripts/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/etc/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/bundle/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleRequirement.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoading.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiCoreClassFilter.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiModule.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageRequirement.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleActivatorDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateCreateDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateInstallDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateResolveDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiContextTrackerDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployerTempWorkaround.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiNativeCodeMetaDataDeployer.java
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/launch/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/metadata/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/packageadmin/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/plugins/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/resolver/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/service/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/util/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/vfs/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/resources/
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/test/
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/core/.classpath
projects/jboss-osgi/projects/runtime/framework/trunk/core/.project
projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/.classpath
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/.classpath
Log:
Remove all dependencies on jboss-vfs from framework-core
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/.classpath
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/.classpath 2010-03-03
14:09:33 UTC (rev 101774)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/.classpath 2010-03-03
14:45:40 UTC (rev 101775)
@@ -2,8 +2,6 @@
<classpath>
<classpathentry kind="src" output="target/classes"
path="src/main/java"/>
<classpathentry excluding="**" kind="src"
output="target/classes" path="src/main/resources"/>
- <classpathentry kind="src" output="target/test-classes"
path="src/test/java"/>
- <classpathentry excluding="**" kind="src"
output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con"
path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/.project
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/.project 2010-03-03 14:09:33
UTC (rev 101774)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/.project 2010-03-03 14:45:40
UTC (rev 101775)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>jboss-osgi-framework</name>
+ <name>jboss-osgi-framework-core</name>
<comment></comment>
<projects>
</projects>
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml 2010-03-03 14:09:33
UTC (rev 101774)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml 2010-03-03 14:45:40
UTC (rev 101775)
@@ -18,7 +18,7 @@
<name>JBossOSGi Framework - Core</name>
<groupId>org.jboss.osgi.framework</groupId>
- <artifactId>jboss-osgi-framework</artifactId>
+ <artifactId>jboss-osgi-framework-core</artifactId>
<packaging>bundle</packaging>
<parent>
@@ -48,6 +48,12 @@
<dependency>
<groupId>org.jboss.cl</groupId>
<artifactId>jboss-classloading-vfs</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.deployers</groupId>
@@ -68,6 +74,12 @@
<dependency>
<groupId>org.jboss.deployers</groupId>
<artifactId>jboss-deployers-impl</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.deployers</groupId>
@@ -76,10 +88,22 @@
<dependency>
<groupId>org.jboss.deployers</groupId>
<artifactId>jboss-deployers-vfs-spi</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.deployers</groupId>
<artifactId>jboss-deployers-vfs</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.jboss.deployers</groupId>
@@ -132,199 +156,11 @@
<artifactId>org.osgi.compendium</artifactId>
</dependency>
- <!-- Test bundles dependencies -->
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.configadmin</artifactId>
- <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.apache.felix</groupId>
- <artifactId>org.apache.felix.log</artifactId>
- <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.apache.felix</groupId>
- <artifactId>org.apache.felix.metatype</artifactId>
- <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-apache-xerces</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-common</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-common-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-husky</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-jaxb</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.jmx</groupId>
- <artifactId>jboss-osgi-jmx</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.jndi</groupId>
- <artifactId>jboss-osgi-jndi</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-reflect</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-xml-binding</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-jetty-bundle</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!-- Test Dependencies -->
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-testing</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.vfs</groupId>
- <artifactId>jboss-osgi-vfs21</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <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>
- <execution>
- <id>all</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>scripts/assembly-all.xml</descriptor>
- </descriptors>
- <archive>
-
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
- </archive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>build-test-jars</id>
- <phase>test-compile</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <property name="maven.runtime.classpath"
refid="maven.runtime.classpath" />
- <property name="tests.output.dir"
value="${project.build.directory}" />
- <ant antfile="scripts/antrun-test-jars.xml" />
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-idea-plugin</artifactId>
- <configuration>
- <downloadSources>true</downloadSources>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
@@ -344,33 +180,6 @@
</instructions>
</configuration>
</plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <argLine>-Xmx512m</argLine>
- <systemProperties>
- <property>
- <name>log4j.output.dir</name>
- <value>${project.build.directory}</value>
- </property>
- <property>
- <name>org.jboss.osgi.framework.launch.bootstrapPath</name>
- <value>bootstrap/jboss-osgi-bootstrap.xml</value>
- </property>
- <property>
- <name>org.jboss.osgi.husky.Invoker</name>
- <value>org.jboss.osgi.husky.internal.AbstractInvoker</value>
- </property>
- <property>
- <name>test.archive.directory</name>
- <value>${project.build.directory}/test-libs</value>
- </property>
- </systemProperties>
- <excludes>
- <!-- excludes listed here need to have a jira issue associated
<exclude>org/jboss/test/osgi/service/ServiceMixUnitTestCase.class</exclude>
-->
- </excludes>
- </configuration>
- </plugin>
</plugins>
</build>
</project>
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java 2010-03-03
14:09:33 UTC (rev 101774)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/AbstractDeployedBundleState.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -34,9 +34,9 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.osgi.deployment.deployer.Deployment;
+import org.jboss.osgi.framework.deployers.AbstractDeployment;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.plugins.PackageAdminPlugin;
-import org.jboss.osgi.vfs.AbstractVFS;
import org.jboss.osgi.vfs.VirtualFile;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
@@ -83,7 +83,7 @@
// The framework is expected to preserve the location passed into
installBundle(String)
Deployment dep = unit.getAttachment(Deployment.class);
location = (dep != null ? dep.getLocation() : unit.getName());
- rootFile = (dep != null ? dep.getRoot() :
AbstractVFS.adapt(((VFSDeploymentUnit)unit).getRoot()));
+ rootFile = (dep != null ? dep.getRoot() : AbstractDeployment.getRoot(unit));
bundleId = bundleIDGenerator.incrementAndGet();
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-03-03
14:09:33 UTC (rev 101774)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -55,12 +55,11 @@
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
import org.jboss.kernel.Kernel;
import org.jboss.logging.Logger;
import org.jboss.osgi.deployment.deployer.Deployment;
import org.jboss.osgi.deployment.deployer.DeploymentFactory;
+import org.jboss.osgi.framework.deployers.AbstractDeployment;
import org.jboss.osgi.framework.deployers.OSGiBundleActivatorDeployer;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
@@ -532,8 +531,7 @@
// Create the deployment and deploy it
try
{
- org.jboss.virtual.VirtualFile root =
(org.jboss.virtual.VirtualFile)AbstractVFS.adapt(dep.getRoot());
- VFSDeployment deployment =
VFSDeploymentFactory.getInstance().createVFSDeployment(root);
+ org.jboss.deployers.client.spi.Deployment deployment =
AbstractDeployment.createDeployment(dep.getRoot());
MutableAttachments att =
(MutableAttachments)deployment.getPredeterminedManagedObjects();
att.addAttachment(Deployment.class, dep);
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java 2010-03-03
14:09:33 UTC (rev 101774)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleClassLoader.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,47 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-// $Id: OSGiClassLoaderFactory.java 95177 2009-10-20 15:14:31Z thomas.diesler(a)jboss.com
$
-
-import org.jboss.classloader.spi.ClassLoaderPolicy;
-import org.jboss.classloader.spi.base.BaseClassLoader;
-
-/**
- * An OSGi bundle class loader.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 19-Dec-2009
- */
-public class OSGiBundleClassLoader extends BaseClassLoader
-{
- @SuppressWarnings("unused")
- private OSGiClassLoaderPolicy osgiPolicy;
-
- public OSGiBundleClassLoader(ClassLoaderPolicy policy)
- {
- super(policy);
-
- if (policy instanceof OSGiClassLoaderPolicy)
- osgiPolicy = (OSGiClassLoaderPolicy)policy;
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderDomain.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderDomain.java 2010-03-03
14:09:33 UTC (rev 101774)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderDomain.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,130 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-// $Id: $
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.classloader.plugins.filter.CombiningClassFilter;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderPolicy;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloader.spi.ParentPolicy;
-import org.jboss.classloader.spi.base.BaseClassLoader;
-import org.jboss.classloader.spi.filter.ClassFilter;
-import org.jboss.classloader.spi.filter.ClassFilterUtils;
-import org.jboss.classloader.spi.filter.PackageClassFilter;
-import org.jboss.classloader.spi.filter.RecursivePackageClassFilter;
-import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.plugins.SystemPackagesPlugin;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * OSGiClassLoaderDomain.<p>
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 03-Sep-2009
- */
-public class OSGiClassLoaderDomain extends ClassLoaderDomain
-{
- private ClassLoaderSystem classLoaderSystem;
- private OSGiBundleManager bundleManager;
- private List<URL> classPath = new ArrayList<URL>();
-
- /**
- * Create a new OSGiClassLoaderDomain.
- * @param domainName the domain name
- * @throws IllegalArgumentException for a null bundle manager
- */
- public OSGiClassLoaderDomain(String domainName)
- {
- super(domainName);
- }
-
- public void setClassLoaderSystem(ClassLoaderSystem classLoaderSystem)
- {
- this.classLoaderSystem = classLoaderSystem;
- }
-
- public void setBundleManager(OSGiBundleManager bundleManager)
- {
- this.bundleManager = bundleManager;
- }
-
- public void setClassPath(List<URL> classPath)
- {
- this.classPath = classPath;
- }
-
- @Override
- protected Class<?> loadClass(BaseClassLoader classLoader, String name, boolean
allExports) throws ClassNotFoundException
- {
- return super.loadClass(classLoader, name, allExports);
- }
-
- public void start() throws IOException
- {
- if (classLoaderSystem == null)
- throw new IllegalArgumentException("Null classLoaderSystem");
- if (bundleManager == null)
- throw new IllegalArgumentException("Null bundleManager");
- if (classPath == null)
- throw new IllegalArgumentException("Null classPath");
-
- // Register the domain with the ClassLoaderSystem
- classLoaderSystem.registerDomain(this);
-
- // Initialize the configured system packages
- ClassFilter systemFilter =
PackageClassFilter.createPackageClassFilterFromString(getSystemPackagesAsString());
- ClassFilter javaFilter =
RecursivePackageClassFilter.createRecursivePackageClassFilter("java");
- ClassFilter filter = CombiningClassFilter.create(javaFilter,
OSGiCoreClassFilter.INSTANCE, systemFilter);
-
- // Setup the domain's parent policy
- setParentPolicy(new ParentPolicy(filter, ClassFilterUtils.NOTHING));
-
- // Initialize the configured policy roots
- VirtualFile[] roots = new VirtualFile[classPath.size()];
- for (int i = 0; i < classPath.size(); i++)
- roots[i] = VFS.createNewRoot(classPath.get(i));
-
- // Create and register the ClassLoaderPolicy
- ClassLoaderPolicy systemPolicy = new
VFSClassLoaderPolicy("OSGiSystemPolicy", roots);
- classLoaderSystem.registerClassLoaderPolicy(getName(), systemPolicy);
- }
-
- private String getSystemPackagesAsString()
- {
- SystemPackagesPlugin syspackPlugin =
bundleManager.getPlugin(SystemPackagesPlugin.class);
- List<String> sysPackages = syspackPlugin.getSystemPackages(false);
- StringBuffer sysPackageString = new StringBuffer();
- for (String name : sysPackages)
- sysPackageString.append(name + ",");
-
- return sysPackageString.toString();
- }
-}
\ No newline at end of file
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2010-03-03
14:09:33 UTC (rev 101774)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderFactory.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,108 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-// $Id$
-
-import java.util.List;
-
-import org.jboss.classloader.spi.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.framework.bundle.AbstractBundleState;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * OSGiClassLoaderFactory
- *
- * Creates the OSGiClassLoader
- *
- * @author Thomas.Diesler(a)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("Not an instance of VFSDeploymentUnit:
" + unit);
-
- Module module = unit.getAttachment(Module.class);
- if (module instanceof VFSDeploymentClassLoaderPolicyModule == false)
- throw new IllegalStateException("Not an instance of
VFSDeploymentClassLoaderPolicyModule: " + module);
-
- VFSDeploymentClassLoaderPolicyModule vfsModule =
(VFSDeploymentClassLoaderPolicyModule)module;
- vfsModule.setPolicyFactory(new ClassLoaderPolicyFactory()
- {
- public ClassLoaderPolicy createClassLoaderPolicy()
- {
- VFSDeploymentUnit vfsUnit = (VFSDeploymentUnit)unit;
- AbstractBundleState bundleState =
unit.getAttachment(AbstractBundleState.class);
- VirtualFile[] roots = getClassLoaderPolicyRoots(bundleState, vfsUnit);
- ClassLoaderPolicy policy = new OSGiClassLoaderPolicy(bundleState, roots);
- unit.addAttachment(ClassLoaderPolicy.class, policy);
- return policy;
- }
-
- private VirtualFile[] getClassLoaderPolicyRoots(AbstractBundleState bundleState,
VFSDeploymentUnit vfsUnit)
- {
- // The classpath is initialised by the bundle structure deployer
- List<VirtualFile> classPaths = vfsUnit.getClassPath();
- VirtualFile[] policyRoots = new VirtualFile[classPaths.size()];
- classPaths.toArray(policyRoots);
- return policyRoots;
- }
- });
- 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();
- }
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-03-03
14:09:33 UTC (rev 101774)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderPolicy.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,278 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-// $Id$
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.classloader.spi.NativeLibraryProvider;
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.classloading.spi.vfs.policy.VFSClassLoaderPolicy;
-import org.jboss.classloading.spi.vfs.policy.VirtualFileInfo;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.metadata.NativeLibrary;
-import org.jboss.osgi.framework.metadata.NativeLibraryMetaData;
-import org.jboss.osgi.framework.plugins.BundleStoragePlugin;
-import org.jboss.osgi.vfs.AbstractVFS;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * The ClassLoaderPolicy for OSGi bundles.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 11-Sep-2009
- */
-public class OSGiClassLoaderPolicy extends VFSClassLoaderPolicy
-{
- /** The associated bundle state */
- private AbstractBundleState bundleState;
- /** The fragment roots */
- private List<VirtualFile> fragments;
-
- public OSGiClassLoaderPolicy(AbstractBundleState bundleState, VirtualFile[] roots)
- {
- super(roots);
-
- if (bundleState == null)
- throw new IllegalArgumentException("Null bundleState");
- this.bundleState = bundleState;
-
- if (bundleState instanceof AbstractDeployedBundleState)
- {
- AbstractDeployedBundleState depBundleState =
(AbstractDeployedBundleState)bundleState;
- DeploymentUnit unit = depBundleState.getDeploymentUnit();
- Module module = unit.getAttachment(Module.class);
- if (module instanceof OSGiModule == false)
- throw new IllegalStateException("Not an instance of OSGiModule: " +
module);
-
- OSGiModule osgiModule = (OSGiModule)module;
- String[] packageNames = osgiModule.getPackageNames();
- setExportedPackages(packageNames);
- setIncluded(osgiModule.getIncluded());
- setExcluded(osgiModule.getExcluded());
- setExcludedExport(osgiModule.getExcludedExport());
- setExportAll(osgiModule.getExportAll());
- setImportAll(osgiModule.isImportAll());
- setCacheable(osgiModule.isCacheable());
- setBlackListable(osgiModule.isBlackListable());
- setDelegates(osgiModule.getDelegates());
-
- // Bundle-NativeCode handling
- processNativeLibraryMetaData(depBundleState);
- }
- }
-
-
- @Override
- public String getName()
- {
- return bundleState.getCanonicalName();
- }
-
- /**
- * Processes the NativeLibraryMetaData that is part of the OSGiClassLoadingMetaData
- * and adds the NativeLibraryProviders to the ClassLoaderPolicy
- */
- private void processNativeLibraryMetaData(AbstractBundleState absBundleState)
- {
- if (absBundleState instanceof OSGiBundleState == false)
- return;
-
- OSGiBundleState bundleState = (OSGiBundleState)absBundleState;
- DeploymentUnit unit = bundleState.getDeploymentUnit();
- ClassLoadingMetaData clMetaData = unit.getAttachment(ClassLoadingMetaData.class);
- if (clMetaData instanceof OSGiClassLoadingMetaData == false)
- return;
-
- OSGiClassLoadingMetaData classLoadingMetaData =
(OSGiClassLoadingMetaData)clMetaData;
- NativeLibraryMetaData libMetaData = classLoadingMetaData.getNativeLibraries();
- if (libMetaData == null || libMetaData.getNativeLibraries() == null)
- return;
-
- // Add the native library mappings to the OSGiClassLoaderPolicy
- for (NativeLibrary library : libMetaData.getNativeLibraries())
- {
- String libpath = library.getLibraryPath();
- String libfile = new File(libpath).getName();
- String libname = libfile.substring(0, libfile.lastIndexOf('.'));
-
- // Add the library provider to the policy
- NativeLibraryProvider libProvider = new OSGiNativeLibraryProvider(bundleState,
libname, libpath);
- addNativeLibrary(libProvider);
-
- // [TODO] why does the TCK use 'Native' to mean 'libNative' ?
- if (libname.startsWith("lib"))
- {
- libname = libname.substring(3);
- libProvider = new OSGiNativeLibraryProvider(bundleState, libname, libpath);
- addNativeLibrary(libProvider);
- }
- }
- }
-
- /**
- * Attach a new fragment root to the policy.
- * @param fragRoot The fragment root file
- */
- public void attachFragment(VirtualFile fragRoot)
- {
- if (fragRoot == null)
- throw new IllegalArgumentException("Null fragment file");
-
- if (fragments == null)
- fragments = new CopyOnWriteArrayList<VirtualFile>();
-
- fragments.add(fragRoot);
- }
-
- /**
- * Detach a fragment root from the policy.
- * @param fragRoot The fragment root file
- * @return true if the fragment could be detached
- */
- public boolean detachFragment(VirtualFile fragRoot)
- {
- if (fragRoot == null)
- throw new IllegalArgumentException("Null fragment file");
-
- if (fragments == null)
- return false;
-
- return fragments.remove(fragRoot);
- }
-
- /**
- * Get the array of attached fragment root files.
- * @return The array of attached fragment root files or null.
- */
- public VirtualFile[] getFragmentRoots()
- {
- if (fragments == null)
- return null;
-
- VirtualFile[] retarr = new VirtualFile[fragments.size()];
- fragments.toArray(retarr);
- return retarr;
- }
-
- @Override
- protected VirtualFileInfo findVirtualFileInfo(String path)
- {
- VirtualFileInfo result = super.findVirtualFileInfo(path);
- if (result == null && fragments != null)
- {
- for (VirtualFile root : fragments)
- {
- try
- {
- VirtualFile file = root.getChild(path);
- if (file != null)
- {
- result = new VirtualFileInfo(file, root);
- return result;
- }
- }
- catch (Exception ignored)
- {
- }
- }
- }
- return result;
- }
-
- /**
- * An implementation of NativeLibraryProvider that provides the native library file
- * location from the bundle that contains the library.
- */
- static class OSGiNativeLibraryProvider implements NativeLibraryProvider
- {
- private OSGiBundleState bundleState;
- private String libpath;
- private String libname;
- private File libraryFile;
-
- OSGiNativeLibraryProvider(OSGiBundleState bundleState, String libname, String
libpath)
- {
- this.bundleState = bundleState;
- this.libpath = libpath;
- this.libname = libname;
-
- // If a native code library in a selected native code clause cannot be found
- // within the bundle then the bundle must fail to resolve
- URL entryURL = bundleState.getEntry(libpath);
- if (entryURL == null)
- throw new IllegalStateException("Cannot find native library: " +
libpath);
- }
-
- public String getLibraryName()
- {
- return libname;
- }
-
- public String getLibraryPath()
- {
- return libpath;
- }
-
- public File getLibraryLocation() throws IOException
- {
- if (libraryFile == null)
- {
- // Get the virtual file for entry for the library
- VirtualFile fileSource =
(VirtualFile)AbstractVFS.adapt(bundleState.getRoot().getChild(libpath));
-
- // Create a unique local file location
- libraryFile = getUniqueLibraryFile(bundleState, libpath);
- libraryFile.deleteOnExit();
-
- // Copy the native library to the bundle storage area
- FileOutputStream fos = new FileOutputStream(libraryFile);
- VFSUtils.copyStream(fileSource.openStream(), fos);
- fos.close();
- }
- return libraryFile;
- }
-
- private File getUniqueLibraryFile(final OSGiBundleState bundleState, final String
libpath)
- {
- OSGiBundleManager bundleManager = bundleState.getBundleManager();
- String timestamp = new
SimpleDateFormat("-yyyyMMdd-HHmmssSSS").format(new
Date(bundleState.getLastModified()));
- String uniquePath = new
StringBuffer(libpath).insert(libpath.lastIndexOf("."), timestamp).toString();
- BundleStoragePlugin plugin =
bundleManager.getPlugin(BundleStoragePlugin.class);
- return plugin.getDataFile(bundleState, uniquePath);
- }
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderSystem.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderSystem.java 2010-03-03
14:09:33 UTC (rev 101774)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoaderSystem.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,73 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-
-import org.jboss.classloader.plugins.filter.CombiningClassFilter;
-import org.jboss.classloader.plugins.jdk.AbstractJDKChecker;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderPolicy;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloader.spi.ParentPolicy;
-import org.jboss.classloader.spi.base.BaseClassLoader;
-import org.jboss.classloader.spi.filter.ClassFilter;
-import org.jboss.classloader.spi.filter.ClassFilterUtils;
-import org.jboss.classloader.spi.filter.RecursivePackageClassFilter;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-
-/**
- * The OSGi ClassLoaderSystem.
- *
- * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
- * @author Thomas.Diesler(a)jboss.com
- * @version $Revision: 1.1 $
- */
-public class OSGiClassLoaderSystem extends ClassLoaderSystem
-{
- /**
- * Create a new OSGiClassLoaderSystem.
- */
- public OSGiClassLoaderSystem()
- {
- ClassLoaderDomain domain = getDefaultDomain();
-
- ClassFilter javaFilter =
RecursivePackageClassFilter.createRecursivePackageClassFilter("java");
- ClassFilter filter = CombiningClassFilter.create(javaFilter,
OSGiCoreClassFilter.INSTANCE);
- domain.setParentPolicy(new ParentPolicy(filter, ClassFilterUtils.NOTHING));
-
- AbstractJDKChecker.getExcluded().add(AbstractBundleState.class);
- AbstractJDKChecker.getExcluded().add(OSGiBundleState.class);
- }
-
- @Override
- protected ClassLoaderDomain createDomain(String name)
- {
- return new OSGiClassLoaderDomain(name);
- }
-
- @Override
- protected BaseClassLoader createClassLoader(ClassLoaderPolicy policy)
- {
- return new OSGiBundleClassLoader(policy);
- }
-}
\ No newline at end of file
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java 2010-03-03
14:09:33 UTC (rev 101774)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentAttachmentDeployer.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,102 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-// $Id$
-
-import org.jboss.classloader.spi.ClassLoaderPolicy;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-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.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.bundle.OSGiFragmentState;
-import org.jboss.osgi.framework.classloading.OSGiClassLoaderPolicy;
-import org.jboss.osgi.vfs.AbstractVFS;
-import org.jboss.virtual.VirtualFile;
-import org.osgi.framework.Bundle;
-
-/**
- * A deployer, that handles OSGi fragment attachments.
- *
- * Fragments are bundles that can be attached to one or more host bundles by the
- * Framework. Attaching is done as part of resolving: the Framework appends
- * the relevant definitions of the fragment bundles to the host’s definitions
- * before the host is resolved.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 08-Jan-2010
- */
-public class OSGiFragmentAttachmentDeployer extends
AbstractSimpleRealDeployer<ClassLoadingMetaData>
-{
- // The relative order at which the fragments get attached
- static final int RELATIVE_ORDER = 100;
-
- public OSGiFragmentAttachmentDeployer()
- {
- super(ClassLoadingMetaData.class);
- setStage(DeploymentStages.CLASSLOADER);
- setRelativeOrder(RELATIVE_ORDER);
- setTopLevelOnly(true);
- }
-
- @Override
- public void deploy(DeploymentUnit unit, ClassLoadingMetaData classLoadingMetaData)
throws DeploymentException
- {
- // Return if this is not a real bundle (i.e. a fragment)
- AbstractBundleState absBundleState =
unit.getAttachment(AbstractBundleState.class);
- if (absBundleState == null)
- return;
-
- OSGiBundleManager bundleManager = absBundleState.getBundleManager();
-
- // Iterate over all installed fragments and attach to host when appropriate
- if (absBundleState.isFragment() == false)
- {
- OSGiBundleState hostState = (OSGiBundleState)absBundleState;
- for (AbstractBundleState auxBundle :
bundleManager.getBundles(Bundle.INSTALLED))
- {
- if (auxBundle.isFragment())
- {
- OSGiFragmentState auxState = (OSGiFragmentState)auxBundle;
- if (hostState.isFragmentAttachable(auxState))
- {
- hostState.attachFragment(auxState);
- }
- }
- }
- }
-
- // Add the fragment's DelegateLoader to the host's ClassLoaderPolicy
- if (absBundleState.isFragment() == true)
- {
- OSGiFragmentState fragState = (OSGiFragmentState)absBundleState;
- OSGiBundleState hostState = fragState.getFragmentHost();
- DeploymentUnit hostUnit = hostState.getDeploymentUnit();
- OSGiClassLoaderPolicy hostPolicy =
(OSGiClassLoaderPolicy)hostUnit.getAttachment(ClassLoaderPolicy.class);
- hostPolicy.attachFragment((VirtualFile)AbstractVFS.adapt(fragState.getRoot()));
- }
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java 2010-03-03
14:09:33 UTC (rev 101774)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiManifestParsingDeployer.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,75 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-import java.util.jar.Manifest;
-
-import org.jboss.deployers.vfs.spi.deployer.ManifestDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.framework.metadata.internal.AbstractOSGiMetaData;
-import org.jboss.osgi.spi.OSGiConstants;
-import org.jboss.osgi.spi.util.BundleInfo;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * OSGiManifestParsingDeployer.<p>
- *
- * This deployer attaches OSGiMetaData to the deployment.
- *
- * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
- * @author Thomas.Diesler(a)jboss.com
- * @version $Revision: 1.1 $
- */
-public class OSGiManifestParsingDeployer extends ManifestDeployer<OSGiMetaData>
-{
- public OSGiManifestParsingDeployer()
- {
- super(OSGiMetaData.class);
- setTopLevelOnly(true);
- }
-
- @Override
- protected OSGiMetaData createMetaData(Manifest manifest) throws Exception
- {
- int manifestVersion = BundleInfo.getBundleManifestVersion(manifest);
- if (manifestVersion < 0 || manifestVersion > 2)
- return null;
-
- AbstractOSGiMetaData osgiMetaData = new AbstractOSGiMetaData(manifest);
- return osgiMetaData;
- }
-
- @Override
- protected void init(VFSDeploymentUnit unit, OSGiMetaData osgiMetaData, VirtualFile
file) throws Exception
- {
- super.init(unit, osgiMetaData, file);
-
- String symbolicName = osgiMetaData.getBundleSymbolicName();
- if (symbolicName != null)
- {
- // Add a marker that this is an R4 OSGi deployment
- log.debug("Bundle-SymbolicName: " + symbolicName);
- unit.addAttachment(OSGiConstants.KEY_BUNDLE_SYMBOLIC_NAME, symbolicName);
- }
- }
-}
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java 2010-03-03
14:09:33 UTC (rev 101774)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/plugins/internal/SystemPackagesPluginImpl.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -92,8 +92,6 @@
allPackages.add("org.jboss.osgi.deployment.interceptor");
allPackages.add("org.jboss.osgi.microcontainer");
- allPackages.add("org.jboss.virtual");
-
String[] corePackages = OSGiCoreClassFilter.getCorePackages();
allPackageNames.addAll(Arrays.asList(corePackages));
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java 2010-03-03
14:09:33 UTC (rev 101774)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/service/internal/LifecycleInterceptorServiceImpl.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -23,7 +23,7 @@
//$Id$
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.logging.Logger;
import org.jboss.osgi.deployment.interceptor.AbstractLifecycleInterceptorService;
import org.jboss.osgi.deployment.interceptor.InvocationContext;
@@ -34,7 +34,6 @@
import org.jboss.osgi.framework.plugins.LifecycleInterceptorServicePlugin;
import org.jboss.osgi.framework.plugins.internal.AbstractServicePlugin;
import org.jboss.osgi.framework.util.DeploymentUnitAttachments;
-import org.jboss.osgi.vfs.AbstractVFS;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
@@ -71,13 +70,13 @@
if (bundleState == null)
throw new IllegalStateException("Cannot obtain bundleState for:
" + bundle);
- VFSDeploymentUnit unit = (VFSDeploymentUnit)bundleState.getDeploymentUnit();
+ DeploymentUnit unit = bundleState.getDeploymentUnit();
InvocationContext inv = unit.getAttachment(InvocationContext.class);
if (inv == null)
{
BundleContext context =
bundleState.getBundleManager().getSystemContext();
DeploymentUnitAttachments att = new DeploymentUnitAttachments(unit);
- inv = new InvocationContextImpl(context, bundle,
AbstractVFS.adapt(unit.getRoot()), att);
+ inv = new InvocationContextImpl(context, bundle, bundleState.getRoot(),
att);
unit.addAttachment(InvocationContext.class, inv);
}
return inv;
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-03 14:09:33 UTC
(rev 101774)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/pom.xml 2010-03-03 14:45:40 UTC
(rev 101775)
@@ -69,6 +69,8 @@
<modules>
<module>core</module>
<module>metadata</module>
+ <module>vfs21</module>
+ <module>testsuite</module>
</modules>
<!-- Dependency Management -->
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/testsuite (from rev 101768,
projects/jboss-osgi/projects/runtime/framework/trunk/core)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/.classpath
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/.classpath 2010-03-03
10:22:49 UTC (rev 101768)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/.classpath 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" output="target/classes"
path="src/main/java"/>
- <classpathentry excluding="**" kind="src"
output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes"
path="src/test/java"/>
<classpathentry excluding="**" kind="src"
output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con"
path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml 2010-03-03 10:22:49
UTC (rev 101768)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/pom.xml 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,371 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ====================================================================== -->
-<!-- -->
-<!-- JBoss, the OpenSource J2EE webOS -->
-<!-- -->
-<!-- Distributable under LGPL license. -->
-<!-- See terms of license at
http://www.gnu.org. -->
-<!-- -->
-<!-- ====================================================================== -->
-
-<!-- $Id$ -->
-
-<!-- Set these VM properties in your IDE debugger
-Dlog4j.output.dir=${workspace_loc:jboss-osgi-framework/target}
-Dlog4j.configuration=log4j-console.xml -->
-
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <name>JBossOSGi Framework - Core</name>
- <groupId>org.jboss.osgi.framework</groupId>
- <artifactId>jboss-osgi-framework</artifactId>
- <packaging>bundle</packaging>
-
- <parent>
- <groupId>org.jboss.osgi.framework</groupId>
- <artifactId>jboss-osgi-framework-parent</artifactId>
- <version>1.0.0.Alpha4-SNAPSHOT</version>
- </parent>
-
- <dependencies>
- <dependency>
- <groupId>org.jboss.osgi.framework</groupId>
- <artifactId>jboss-osgi-framework-metadata</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>biz.aQute</groupId>
- <artifactId>bnd</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.cl</groupId>
- <artifactId>jboss-classloader</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.cl</groupId>
- <artifactId>jboss-classloading</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.cl</groupId>
- <artifactId>jboss-classloading-vfs</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-client-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-core-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-structure-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-vfs-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-vfs</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-jmx</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.kernel</groupId>
- <artifactId>jboss-kernel</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.kernel</groupId>
- <artifactId>jboss-jmx-aop-mc-int</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.kernel</groupId>
- <artifactId>jboss-jmx-mc-int</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.kernel</groupId>
- <artifactId>jboss-dependency</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-mdr</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.runtime</groupId>
- <artifactId>jboss-osgi-deployers</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.runtime</groupId>
- <artifactId>jboss-osgi-deployment</artifactId>
- </dependency>
-
- <!-- OSGi Dependencies -->
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
-
- <!-- Test bundles dependencies -->
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.configadmin</artifactId>
- <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.apache.felix</groupId>
- <artifactId>org.apache.felix.log</artifactId>
- <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.apache.felix</groupId>
- <artifactId>org.apache.felix.metatype</artifactId>
- <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-apache-xerces</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-common</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-common-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-husky</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-jaxb</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.jmx</groupId>
- <artifactId>jboss-osgi-jmx</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.jndi</groupId>
- <artifactId>jboss-osgi-jndi</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-reflect</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-xml-binding</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-jetty-bundle</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!-- Test Dependencies -->
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-testing</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <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>
- <execution>
- <id>all</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>scripts/assembly-all.xml</descriptor>
- </descriptors>
- <archive>
-
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
- </archive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>build-test-jars</id>
- <phase>test-compile</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <property name="maven.runtime.classpath"
refid="maven.runtime.classpath" />
- <property name="tests.output.dir"
value="${project.build.directory}" />
- <ant antfile="scripts/antrun-test-jars.xml" />
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-idea-plugin</artifactId>
- <configuration>
- <downloadSources>true</downloadSources>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
-
<Bundle-SymbolicName>org.jboss.osgi.framework</Bundle-SymbolicName>
- <Bundle-Name>JBossOSGi Framework</Bundle-Name>
- <Bundle-Version>${version}</Bundle-Version>
- <Export-Package>
- org.osgi.framework;version="1.5",
- org.osgi.framework.launch;version="1.0",
- org.osgi.framework.hooks.service;version="1.0",
- org.osgi.service.packageadmin;version="1.2",
- org.osgi.service.startlevel;version="1.1",
- org.osgi.util.tracker;version="1.4"
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <argLine>-Xmx512m</argLine>
- <systemProperties>
- <property>
- <name>log4j.output.dir</name>
- <value>${project.build.directory}</value>
- </property>
- <property>
- <name>org.jboss.osgi.framework.launch.bootstrapPath</name>
- <value>bootstrap/jboss-osgi-bootstrap.xml</value>
- </property>
- <property>
- <name>org.jboss.osgi.husky.Invoker</name>
- <value>org.jboss.osgi.husky.internal.AbstractInvoker</value>
- </property>
- <property>
- <name>test.archive.directory</name>
- <value>${project.build.directory}/test-libs</value>
- </property>
- </systemProperties>
- <excludes>
- <!-- excludes listed here need to have a jira issue associated
<exclude>org/jboss/test/osgi/service/ServiceMixUnitTestCase.class</exclude>
-->
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/pom.xml (from rev
101772, projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/pom.xml
(rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/pom.xml 2010-03-03
14:45:40 UTC (rev 101775)
@@ -0,0 +1,277 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!-- -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at
http://www.gnu.org. -->
+<!-- -->
+<!-- ====================================================================== -->
+
+<!-- $Id$ -->
+
+<!-- Set these VM properties in your IDE debugger
-Dlog4j.output.dir=${workspace_loc:jboss-osgi-framework/target}
-Dlog4j.configuration=log4j-console.xml -->
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>JBossOSGi Framework - Testsuite</name>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-testsuite</artifactId>
+ <packaging>jar</packaging>
+
+ <parent>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-parent</artifactId>
+ <version>1.0.0.Alpha4-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-core</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-metadata</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-vfs21</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>biz.aQute</groupId>
+ <artifactId>bnd</artifactId>
+ </dependency>
+
+ <!-- Test bundles dependencies -->
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.configadmin</artifactId>
+ <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.apache.felix</groupId>
+ <artifactId>org.apache.felix.log</artifactId>
+ <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.apache.felix</groupId>
+ <artifactId>org.apache.felix.metatype</artifactId>
+ <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-apache-xerces</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-common</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-common-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-husky</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-jaxb</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.jmx</groupId>
+ <artifactId>jboss-osgi-jmx</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.jndi</groupId>
+ <artifactId>jboss-osgi-jndi</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-reflect</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.bundles</groupId>
+ <artifactId>jboss-osgi-xml-binding</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.web</groupId>
+ <artifactId>pax-web-jetty-bundle</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- Test Dependencies -->
+ <dependency>
+ <groupId>org.jboss.test</groupId>
+ <artifactId>jboss-test</artifactId>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi</groupId>
+ <artifactId>jboss-osgi-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.osgi.vfs</groupId>
+ <artifactId>jboss-osgi-vfs21</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <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>
+ <id>build-test-jars</id>
+ <phase>test-compile</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <tasks>
+ <property name="maven.runtime.classpath"
refid="maven.runtime.classpath" />
+ <property name="tests.output.dir"
value="${project.build.directory}" />
+ <ant antfile="scripts/antrun-test-jars.xml" />
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-idea-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+
<Bundle-SymbolicName>org.jboss.osgi.framework</Bundle-SymbolicName>
+ <Bundle-Name>JBossOSGi Framework</Bundle-Name>
+ <Bundle-Version>${version}</Bundle-Version>
+ <Export-Package>
+ org.osgi.framework;version="1.5",
+ org.osgi.framework.launch;version="1.0",
+ org.osgi.framework.hooks.service;version="1.0",
+ org.osgi.service.packageadmin;version="1.2",
+ org.osgi.service.startlevel;version="1.1",
+ org.osgi.util.tracker;version="1.4"
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Xmx512m</argLine>
+ <systemProperties>
+ <property>
+ <name>log4j.output.dir</name>
+ <value>${project.build.directory}</value>
+ </property>
+ <property>
+ <name>org.jboss.osgi.framework.launch.bootstrapPath</name>
+ <value>bootstrap/jboss-osgi-bootstrap.xml</value>
+ </property>
+ <property>
+ <name>org.jboss.osgi.husky.Invoker</name>
+ <value>org.jboss.osgi.husky.internal.AbstractInvoker</value>
+ </property>
+ <property>
+ <name>test.archive.directory</name>
+ <value>${project.build.directory}/test-libs</value>
+ </property>
+ </systemProperties>
+ <excludes>
+ <!-- excludes listed here need to have a jira issue associated
<exclude>org/jboss/test/osgi/service/ServiceMixUnitTestCase.class</exclude>
-->
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTest.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/FrameworkTest.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTest.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,647 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.classloader.plugins.ClassLoaderUtils;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.spi.util.ConstantsHelper;
-import org.jboss.test.kernel.junit.MicrocontainerTest;
-import org.jboss.virtual.AssembledDirectory;
-import org.jboss.virtual.VirtualFile;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleEvent;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.FrameworkListener;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.SynchronousBundleListener;
-
-/**
- * OSGiTestCase - Parent Test Case for OSGi tests.
- *
- * @author <a href="baileyje(a)gmail.com">John Bailey</a>
- * @version $Revision: 87848 $
- */
-public abstract class FrameworkTest extends MicrocontainerTest implements
FrameworkListener, SynchronousBundleListener, ServiceListener
-{
- private final List<FrameworkEvent> frameworkEvents = new
CopyOnWriteArrayList<FrameworkEvent>();
- private final List<BundleEvent> bundleEvents = new
CopyOnWriteArrayList<BundleEvent>();
- private final List<ServiceEvent> serviceEvents = new
CopyOnWriteArrayList<ServiceEvent>();
-
- /**
- * Create a new OSGiTestCase.
- *
- * @param name the test name
- */
- public FrameworkTest(String name)
- {
- super(name);
- }
-
- public static FrameworkTestDelegate getDelegate(Class<?> clazz) throws
Exception
- {
- return new FrameworkTestDelegate(clazz);
- }
-
- /**
- * Get OSGiTestDelegate
- */
- protected FrameworkTestDelegate getDelegate()
- {
- return (FrameworkTestDelegate)super.getDelegate();
- }
-
- /**
- * Get BundleManager from Delegate
- *
- * @return The BundleManager
- */
- protected OSGiBundleManager getBundleManager()
- {
- return getDelegate().getBundleManager();
- }
-
- /**
- * Get the system bundle
- *
- * @return the system bundle
- */
- protected Bundle getSystemBundle()
- {
- return getBundleManager().getBundleById(0).getBundleInternal();
- }
-
- /**
- * Add the base bundles
- *
- * @param expected the collection to add to
- */
- protected void addBaseBundles(Collection<Bundle> expected)
- {
- expected.add(getSystemBundle());
- }
-
- /**
- * Create a bundle
- *
- * @param root the location of the location to deploy
- * @param child the child to deploy
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- protected Bundle addBundle(String root, String child) throws Exception
- {
- return getDelegate().addBundle(root, child);
- }
-
- /**
- * Create a bundle
- *
- * @param file the virtual file
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- protected Bundle addBundle(VirtualFile file) throws Exception
- {
- return getDelegate().addBundle(file);
- }
-
- /**
- * Create a bundle
- *
- * @param root the location of the location to deploy
- * @param child the child to deploy
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- protected Bundle deployBundle(String root, String child) throws Exception
- {
- return getDelegate().deployBundle(root, child);
- }
-
- /**
- * Create a bundle
- *
- * @param file the virtual file
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- protected Bundle deployBundle(VirtualFile file) throws Exception
- {
- return getDelegate().deployBundle(file);
- }
-
- protected Bundle installBundle(String location) throws BundleException
- {
- return getBundleManager().installBundle(location, null).getBundleInternal();
- }
-
- protected Bundle installBundle(String location, InputStream instream) throws
BundleException
- {
- return getBundleManager().installBundle(location, instream).getBundleInternal();
- }
-
- protected Bundle installBundle(VirtualFile bundleFile) throws BundleException
- {
- return getBundleManager().installBundle(bundleFile).getBundleInternal();
- }
-
- /**
- * Remove a bundle
- *
- * @param bundle the bundle to remove
- * @throws Exception for any error
- */
- protected void uninstall(Bundle bundle) throws Exception
- {
- getDelegate().uninstall(bundle);
- }
-
- protected DeploymentUnit getDeploymentUnit(Bundle bundle)
- {
- return getDelegate().getDeploymentUnit(bundle);
- }
-
- protected VirtualFile assembleBundle(String name, String resources, Class<?>...
packages) throws Exception
- {
- return getDelegate().assembleBundle(name, new String[] { resources }, packages);
- }
-
- protected VirtualFile assembleBundle(String name, String[] resourcePaths,
Class<?>... packages) throws Exception
- {
- return getDelegate().assembleBundle(name, resourcePaths, packages);
- }
-
- protected Bundle deployBundle(String name, Class<?>... packages) throws
Exception
- {
- return getDelegate().deployBundle(name, null, (String[]) null, packages);
- }
-
- protected Bundle deployBundle(String name, String resourcePath, Class<?>...
packages) throws Exception
- {
- return getDelegate().deployBundle(name, null, resourcePath, packages);
- }
-
- protected Bundle deployBundle(String name, String[] resourcePaths, Class<?>...
packages) throws Exception
- {
- return getDelegate().deployBundle(name, null, resourcePaths, packages);
- }
-
- protected Bundle deployBundle(String name, OSGiMetaData metaData, Class<?>...
packages) throws Exception
- {
- return getDelegate().deployBundle(name, metaData, (String[]) null, packages);
- }
-
- protected Bundle deployBundle(String name, OSGiMetaData metaData, String resourcePath,
Class<?>... packages) throws Exception
- {
- return getDelegate().deployBundle(name, metaData, resourcePath, packages);
- }
-
- protected Bundle deployBundle(String name, OSGiMetaData metaData, String[]
resourcePaths, Class<?>... packages) throws Exception
- {
- return getDelegate().deployBundle(name, metaData, resourcePaths, packages);
- }
-
- protected AssembledDirectory createAssembledDirectory(String name) throws Exception
- {
- return getDelegate().createAssembledDirectory(name, "");
- }
-
- protected AssembledDirectory createAssembledDirectory(String name, String rootName)
throws Exception
- {
- return getDelegate().createAssembledDirectory(name, rootName);
- }
-
- protected void addPackage(AssembledDirectory dir, Class<?> reference) throws
Exception
- {
- getDelegate().addPackage(dir, reference);
- }
-
- protected void addPath(final AssembledDirectory dir, String path, String name) throws
Exception
- {
- getDelegate().addPath(dir, path, name);
- }
-
- protected void assertBundleState(int expState, int wasState)
- {
- String expstr = ConstantsHelper.bundleState(expState);
- String wasstr = ConstantsHelper.bundleState(wasState);
- assertEquals("Bundle " + expstr, expstr, wasstr);
- }
-
- protected void assertClassEquality(Class<?> expected, Class<?> actual)
- {
- assertTrue("Should be the same " +
ClassLoaderUtils.classToString(expected) + " and " +
ClassLoaderUtils.classToString(actual), expected == actual);
- }
-
- protected void assertNoClassEquality(Class<?> expected, Class<?> actual)
- {
- assertTrue("Should NOT be the same " +
ClassLoaderUtils.classToString(expected) + " and " +
ClassLoaderUtils.classToString(actual), expected != actual);
- }
-
- protected void assertClassLoader(Class<?> clazz, Bundle expected)
- {
- if (expected == null)
- return;
- ClassLoader cl = clazz.getClassLoader();
- ClassLoader bundleClassLoader = getBundleClassLoader(expected);
- boolean result = bundleClassLoader.equals(cl);
- assertTrue(ClassLoaderUtils.classToString(clazz) + " should have expected
classloader=" + expected, result);
- }
-
- protected ClassLoader getBundleClassLoader(Bundle expected)
- {
- return getDeploymentUnit(expected).getClassLoader();
- }
-
- protected Class<?> assertLoadClass(Bundle start, Class<?> reference)
throws Exception
- {
- return assertLoadClass(start, reference, start);
- }
-
- protected Class<?> assertLoadClass(Bundle start, Class<?> reference,
Bundle expected) throws Exception
- {
- return assertLoadClass(start, reference, expected, false);
- }
-
- protected Class<?> assertLoadClass(Bundle start, Class<?> reference,
Bundle expected, boolean isReference) throws Exception
- {
- Class<?> result = assertLoadClass(reference.getName(), start, expected);
- if (isReference)
- assertClassEquality(reference, result);
- else
- assertNoClassEquality(reference, result);
- return result;
- }
-
- protected Class<?> assertLoadClass(String name, Bundle bundle, Bundle expected)
- {
- Class<?> result = null;
- try
- {
- result = bundle.loadClass(name);
- getLog().debug("Got class: " + ClassLoaderUtils.classToString(result)
+ " for " + name + " from " + bundle);
- }
- catch (ClassNotFoundException e)
- {
- failure("Did not expect CNFE for " + name + " from " +
bundle, e);
- }
- assertClassLoader(result, expected);
- return result;
- }
-
- protected void assertLoadClassFail(Bundle start, Class<?> reference)
- {
- assertLoadClassFail(start, reference.getName());
- }
-
- protected void assertLoadClassFail(Bundle start, String name)
- {
- try
- {
- start.loadClass(name);
- fail("Should not be here!");
- }
- catch (Exception expected)
- {
- checkThrowable(ClassNotFoundException.class, expected);
- }
- }
-
- protected URL getBundleResource(Bundle bundle, String path)
- {
- return getDelegate().getBundleResource(bundle, path);
- }
-
- protected Enumeration<URL> getBundleResources(Bundle bundle, String path) throws
Exception
- {
- return getDelegate().getBundleResources(bundle, path);
- }
-
- protected void assertNoAllReferences(BundleContext bundleContext, String clazz) throws
Exception
- {
- assertNoAllReferences(bundleContext, clazz, null);
- }
-
- protected void assertNoAllReferences(BundleContext bundleContext, String clazz, String
filter) throws Exception
- {
- ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz + " filter=" + filter);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz +
" filter=" + filter);
- assertNull("Expected no references for clazz=" + clazz + "
filter=" + filter, actual);
- }
-
- protected void assertAllReferences(BundleContext bundleContext, String clazz,
ServiceReference... expected) throws Exception
- {
- assertAllReferences(bundleContext, clazz, null, expected);
- }
-
- protected void assertAllReferences(BundleContext bundleContext, String clazz, String
filter, ServiceReference... expected) throws Exception
- {
- ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz + " filter=" + filter);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz +
" filter=" + filter);
- assertEquals(bundleContext + " with clazz=" + clazz + "
filter=" + filter, expected, actual);
- }
-
- protected void assertNoReferences(BundleContext bundleContext, String clazz) throws
Exception
- {
- assertNoReferences(bundleContext, clazz, null);
- }
-
- protected void assertNoReferences(BundleContext bundleContext, String clazz, String
filter) throws Exception
- {
- ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz + " filter=" + filter);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz +
" filter=" + filter);
- assertNull("Expected no references for clazz=" + clazz + "
filter=" + filter, actual);
- }
-
- protected void assertReferences(BundleContext bundleContext, String clazz,
ServiceReference... expected) throws Exception
- {
- assertReferences(bundleContext, clazz, null, expected);
- }
-
- protected void assertReferences(BundleContext bundleContext, String clazz, String
filter, ServiceReference... expected) throws Exception
- {
- ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz + " filter=" + filter);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz +
" filter=" + filter);
- assertEquals(bundleContext + " with clazz=" + clazz + "
filter=" + filter, expected, actual);
- }
-
- protected void assertNoGetReference(BundleContext bundleContext, String clazz) throws
Exception
- {
- ServiceReference actual = bundleContext.getServiceReference(clazz);
- if (actual != null)
- getLog().debug(bundleContext + " got " + actual + " for
clazz=" + clazz);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz);
- assertNull("Expected no references for clazz=" + clazz, actual);
- }
-
- protected void assertGetReference(BundleContext bundleContext, String clazz,
ServiceReference expected) throws Exception
- {
- ServiceReference actual = bundleContext.getServiceReference(clazz);
- if (actual != null)
- getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz);
- else
- getLog().debug(bundleContext + " got nothing for clazz=" + clazz);
- assertEquals(bundleContext + " with clazz=" + clazz, expected, actual);
- }
-
- protected void assertUsingBundles(ServiceReference reference, Bundle... bundles)
- {
- Set<Bundle> actual = new HashSet<Bundle>();
- Bundle[] users = reference.getUsingBundles();
- if (users != null)
- actual.addAll(Arrays.asList(users));
-
- Set<Bundle> expected = new HashSet<Bundle>();
- expected.addAll(Arrays.asList(bundles));
-
- getLog().debug(reference + " users=" + actual);
-
- // switch - check expected on actual, since actual might be proxy
- assertEquals(actual, expected);
- }
-
- protected void assertBundle(Bundle b1, Bundle b2)
- {
- assertNotNull(b1);
- assertNotNull(b2);
- assertEquals(b1.getBundleId(), b2.getBundleId());
- }
-
- protected void assertObjectClass(String expected, ServiceReference reference)
- {
- assertObjectClass(new String[] { expected }, reference);
- }
-
- protected void assertObjectClass(String[] expected, ServiceReference reference)
- {
- Object actual = reference.getProperty(Constants.OBJECTCLASS);
- if (actual == null)
- fail("no object class???");
- if (actual instanceof String[] == false)
- fail(actual + " is not a string array??? " +
actual.getClass().getName());
- assertEquals(expected, (String[])actual);
- }
-
- public void frameworkEvent(FrameworkEvent event)
- {
- synchronized (frameworkEvents)
- {
- getLog().debug("FrameworkEvent type=" +
ConstantsHelper.frameworkEvent(event.getType()) + " for " + event);
- frameworkEvents.add(event);
- frameworkEvents.notifyAll();
- }
- }
-
- protected void assertNoFrameworkEvent() throws Exception
- {
- getLog().debug("frameworkEvents=" + frameworkEvents);
- assertEquals(0, frameworkEvents.size());
- }
-
- protected void assertFrameworkEvent(int type) throws Exception
- {
- assertFrameworkEvent(type, getSystemBundle(), null);
- }
-
- protected void assertFrameworkEvent(int type, Class<? extends Throwable>
expectedThrowable) throws Exception
- {
- assertFrameworkEvent(type, getSystemBundle(), expectedThrowable);
- }
-
- protected void assertFrameworkEvent(int type, Bundle bundle, Class<? extends
Throwable> expectedThrowable) throws Exception
- {
- waitForEvent(frameworkEvents, type);
- getLog().debug("frameworkEvents=" + frameworkEvents);
- int size = frameworkEvents.size();
- assertTrue("" + size, size > 0);
- FrameworkEvent event = frameworkEvents.remove(0);
- assertEquals(ConstantsHelper.frameworkEvent(type),
ConstantsHelper.frameworkEvent(event.getType()));
- Throwable t = event.getThrowable();
- if (expectedThrowable == null)
- {
- if (t != null)
- {
- getLog().error("Unexpected error in Framework event: ", t);
- fail("Unexpected throwable: " + t);
- }
- }
- else
- {
- checkThrowable(BundleException.class, t);
- checkDeepThrowable(expectedThrowable, t);
- }
- assertEquals(bundle, event.getSource());
- assertEquals(bundle, event.getBundle());
- }
-
- public void bundleChanged(BundleEvent event)
- {
- synchronized (bundleEvents)
- {
- getLog().debug("BundleChanged type=" +
ConstantsHelper.bundleEvent(event.getType()) + " for " + event);
- bundleEvents.add(event);
- bundleEvents.notifyAll();
- }
- }
-
- protected void assertNoBundleEvent() throws Exception
- {
- getLog().debug("bundleEvents=" + bundleEvents);
- assertEquals(0, bundleEvents.size());
- }
-
- protected void assertBundleEvent(int type, Bundle bundle) throws Exception
- {
- waitForEvent(bundleEvents, type);
-
- getLog().debug("bundleEvents=" + bundleEvents);
- int size = bundleEvents.size();
- assertTrue("" + size, size > 0);
-
- if (bundle instanceof AbstractBundleState)
- bundle = ((AbstractBundleState)bundle).getBundle();
-
- BundleEvent foundEvent = null;
- for(int i=0; i < bundleEvents.size(); i++)
- {
- BundleEvent aux = bundleEvents.get(i);
- if (type == aux.getType())
- {
- if (bundle.equals(aux.getSource()) &&
bundle.equals(aux.getBundle()))
- {
- bundleEvents.remove(aux);
- foundEvent = aux;
- break;
- }
- }
- }
-
- if (foundEvent == null)
- fail("Cannot find event " + ConstantsHelper.bundleEvent(type) + "
from " + bundle);
- }
-
- public void serviceChanged(ServiceEvent event)
- {
- synchronized (serviceEvents)
- {
- getLog().debug("ServiceChanged type=" +
ConstantsHelper.serviceEvent(event.getType()) + " for " + event);
- serviceEvents.add(event);
- serviceEvents.notifyAll();
- }
- }
-
- protected void assertNoServiceEvent() throws Exception
- {
- getLog().debug("serviceEvents=" + serviceEvents);
- assertEquals(0, serviceEvents.size());
- }
-
- protected void assertServiceEvent(int type, ServiceReference reference) throws
Exception
- {
- waitForEvent(serviceEvents, type);
- getLog().debug("serviceEvents=" + serviceEvents);
- int size = serviceEvents.size();
- assertTrue("" + size, size > 0);
- ServiceEvent event = serviceEvents.remove(0);
- assertEquals(ConstantsHelper.serviceEvent(type),
ConstantsHelper.serviceEvent(event.getType()));
- assertEquals(reference, event.getSource());
- assertEquals(reference, event.getServiceReference());
- }
-
- @SuppressWarnings("rawtypes")
- private void waitForEvent(List events, int type) throws InterruptedException
- {
- // Timeout for event delivery: 3 sec
- int timeout = 30;
-
- boolean eventFound = false;
- while (eventFound == false && 0 < timeout)
- {
- synchronized (events)
- {
- events.wait(100);
- for (Object aux : events)
- {
- if (aux instanceof BundleEvent)
- {
- BundleEvent event = (BundleEvent)aux;
- if (type == event.getType())
- {
- eventFound = true;
- break;
- }
- }
- else if (aux instanceof ServiceEvent)
- {
- ServiceEvent event = (ServiceEvent)aux;
- if (type == event.getType())
- {
- eventFound = true;
- break;
- }
- }
- else if (aux instanceof FrameworkEvent)
- {
- FrameworkEvent event = (FrameworkEvent)aux;
- if (type == event.getType())
- {
- eventFound = true;
- break;
- }
- }
- }
- }
- timeout--;
- }
- }
-}
Copied:
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTest.java
(from rev 101772,
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/FrameworkTest.java)
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTest.java
(rev 0)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTest.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -0,0 +1,648 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.jboss.classloader.plugins.ClassLoaderUtils;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.spi.util.ConstantsHelper;
+import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+import org.jboss.virtual.AssembledDirectory;
+import org.jboss.virtual.VirtualFile;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.SynchronousBundleListener;
+
+/**
+ * OSGiTestCase - Parent Test Case for OSGi tests.
+ *
+ * @author <a href="baileyje(a)gmail.com">John Bailey</a>
+ * @version $Revision: 87848 $
+ */
+public abstract class FrameworkTest extends MicrocontainerTest implements
FrameworkListener, SynchronousBundleListener, ServiceListener
+{
+ private final List<FrameworkEvent> frameworkEvents = new
CopyOnWriteArrayList<FrameworkEvent>();
+ private final List<BundleEvent> bundleEvents = new
CopyOnWriteArrayList<BundleEvent>();
+ private final List<ServiceEvent> serviceEvents = new
CopyOnWriteArrayList<ServiceEvent>();
+
+ /**
+ * Create a new OSGiTestCase.
+ *
+ * @param name the test name
+ */
+ public FrameworkTest(String name)
+ {
+ super(name);
+ }
+
+ public static FrameworkTestDelegate getDelegate(Class<?> clazz) throws
Exception
+ {
+ return new FrameworkTestDelegate(clazz);
+ }
+
+ /**
+ * Get OSGiTestDelegate
+ */
+ protected FrameworkTestDelegate getDelegate()
+ {
+ return (FrameworkTestDelegate)super.getDelegate();
+ }
+
+ /**
+ * Get BundleManager from Delegate
+ *
+ * @return The BundleManager
+ */
+ protected OSGiBundleManager getBundleManager()
+ {
+ return getDelegate().getBundleManager();
+ }
+
+ /**
+ * Get the system bundle
+ *
+ * @return the system bundle
+ */
+ protected Bundle getSystemBundle()
+ {
+ return getBundleManager().getBundleById(0).getBundleInternal();
+ }
+
+ /**
+ * Add the base bundles
+ *
+ * @param expected the collection to add to
+ */
+ protected void addBaseBundles(Collection<Bundle> expected)
+ {
+ expected.add(getSystemBundle());
+ }
+
+ /**
+ * Create a bundle
+ *
+ * @param root the location of the location to deploy
+ * @param child the child to deploy
+ * @return Bundle for the deployment
+ * @throws Exception for any error
+ */
+ protected Bundle addBundle(String root, String child) throws Exception
+ {
+ return getDelegate().addBundle(root, child);
+ }
+
+ /**
+ * Create a bundle
+ *
+ * @param file the virtual file
+ * @return Bundle for the deployment
+ * @throws Exception for any error
+ */
+ protected Bundle addBundle(VirtualFile file) throws Exception
+ {
+ return getDelegate().addBundle(file);
+ }
+
+ /**
+ * Create a bundle
+ *
+ * @param root the location of the location to deploy
+ * @param child the child to deploy
+ * @return Bundle for the deployment
+ * @throws Exception for any error
+ */
+ protected Bundle deployBundle(String root, String child) throws Exception
+ {
+ return getDelegate().deployBundle(root, child);
+ }
+
+ /**
+ * Create a bundle
+ *
+ * @param file the virtual file
+ * @return Bundle for the deployment
+ * @throws Exception for any error
+ */
+ protected Bundle deployBundle(VirtualFile file) throws Exception
+ {
+ return getDelegate().deployBundle(file);
+ }
+
+ protected Bundle installBundle(String location) throws BundleException
+ {
+ return getBundleManager().installBundle(location, null).getBundleInternal();
+ }
+
+ protected Bundle installBundle(String location, InputStream instream) throws
BundleException
+ {
+ return getBundleManager().installBundle(location, instream).getBundleInternal();
+ }
+
+ protected Bundle installBundle(VirtualFile bundleFile) throws BundleException
+ {
+ return
getBundleManager().installBundle(AbstractVFS.adapt(bundleFile)).getBundleInternal();
+ }
+
+ /**
+ * Remove a bundle
+ *
+ * @param bundle the bundle to remove
+ * @throws Exception for any error
+ */
+ protected void uninstall(Bundle bundle) throws Exception
+ {
+ getDelegate().uninstall(bundle);
+ }
+
+ protected DeploymentUnit getDeploymentUnit(Bundle bundle)
+ {
+ return getDelegate().getDeploymentUnit(bundle);
+ }
+
+ protected VirtualFile assembleBundle(String name, String resources, Class<?>...
packages) throws Exception
+ {
+ return getDelegate().assembleBundle(name, new String[] { resources }, packages);
+ }
+
+ protected VirtualFile assembleBundle(String name, String[] resourcePaths,
Class<?>... packages) throws Exception
+ {
+ return getDelegate().assembleBundle(name, resourcePaths, packages);
+ }
+
+ protected Bundle deployBundle(String name, Class<?>... packages) throws
Exception
+ {
+ return getDelegate().deployBundle(name, null, (String[]) null, packages);
+ }
+
+ protected Bundle deployBundle(String name, String resourcePath, Class<?>...
packages) throws Exception
+ {
+ return getDelegate().deployBundle(name, null, resourcePath, packages);
+ }
+
+ protected Bundle deployBundle(String name, String[] resourcePaths, Class<?>...
packages) throws Exception
+ {
+ return getDelegate().deployBundle(name, null, resourcePaths, packages);
+ }
+
+ protected Bundle deployBundle(String name, OSGiMetaData metaData, Class<?>...
packages) throws Exception
+ {
+ return getDelegate().deployBundle(name, metaData, (String[]) null, packages);
+ }
+
+ protected Bundle deployBundle(String name, OSGiMetaData metaData, String resourcePath,
Class<?>... packages) throws Exception
+ {
+ return getDelegate().deployBundle(name, metaData, resourcePath, packages);
+ }
+
+ protected Bundle deployBundle(String name, OSGiMetaData metaData, String[]
resourcePaths, Class<?>... packages) throws Exception
+ {
+ return getDelegate().deployBundle(name, metaData, resourcePaths, packages);
+ }
+
+ protected AssembledDirectory createAssembledDirectory(String name) throws Exception
+ {
+ return getDelegate().createAssembledDirectory(name, "");
+ }
+
+ protected AssembledDirectory createAssembledDirectory(String name, String rootName)
throws Exception
+ {
+ return getDelegate().createAssembledDirectory(name, rootName);
+ }
+
+ protected void addPackage(AssembledDirectory dir, Class<?> reference) throws
Exception
+ {
+ getDelegate().addPackage(dir, reference);
+ }
+
+ protected void addPath(final AssembledDirectory dir, String path, String name) throws
Exception
+ {
+ getDelegate().addPath(dir, path, name);
+ }
+
+ protected void assertBundleState(int expState, int wasState)
+ {
+ String expstr = ConstantsHelper.bundleState(expState);
+ String wasstr = ConstantsHelper.bundleState(wasState);
+ assertEquals("Bundle " + expstr, expstr, wasstr);
+ }
+
+ protected void assertClassEquality(Class<?> expected, Class<?> actual)
+ {
+ assertTrue("Should be the same " +
ClassLoaderUtils.classToString(expected) + " and " +
ClassLoaderUtils.classToString(actual), expected == actual);
+ }
+
+ protected void assertNoClassEquality(Class<?> expected, Class<?> actual)
+ {
+ assertTrue("Should NOT be the same " +
ClassLoaderUtils.classToString(expected) + " and " +
ClassLoaderUtils.classToString(actual), expected != actual);
+ }
+
+ protected void assertClassLoader(Class<?> clazz, Bundle expected)
+ {
+ if (expected == null)
+ return;
+ ClassLoader cl = clazz.getClassLoader();
+ ClassLoader bundleClassLoader = getBundleClassLoader(expected);
+ boolean result = bundleClassLoader.equals(cl);
+ assertTrue(ClassLoaderUtils.classToString(clazz) + " should have expected
classloader=" + expected, result);
+ }
+
+ protected ClassLoader getBundleClassLoader(Bundle expected)
+ {
+ return getDeploymentUnit(expected).getClassLoader();
+ }
+
+ protected Class<?> assertLoadClass(Bundle start, Class<?> reference)
throws Exception
+ {
+ return assertLoadClass(start, reference, start);
+ }
+
+ protected Class<?> assertLoadClass(Bundle start, Class<?> reference,
Bundle expected) throws Exception
+ {
+ return assertLoadClass(start, reference, expected, false);
+ }
+
+ protected Class<?> assertLoadClass(Bundle start, Class<?> reference,
Bundle expected, boolean isReference) throws Exception
+ {
+ Class<?> result = assertLoadClass(reference.getName(), start, expected);
+ if (isReference)
+ assertClassEquality(reference, result);
+ else
+ assertNoClassEquality(reference, result);
+ return result;
+ }
+
+ protected Class<?> assertLoadClass(String name, Bundle bundle, Bundle expected)
+ {
+ Class<?> result = null;
+ try
+ {
+ result = bundle.loadClass(name);
+ getLog().debug("Got class: " + ClassLoaderUtils.classToString(result)
+ " for " + name + " from " + bundle);
+ }
+ catch (ClassNotFoundException e)
+ {
+ failure("Did not expect CNFE for " + name + " from " +
bundle, e);
+ }
+ assertClassLoader(result, expected);
+ return result;
+ }
+
+ protected void assertLoadClassFail(Bundle start, Class<?> reference)
+ {
+ assertLoadClassFail(start, reference.getName());
+ }
+
+ protected void assertLoadClassFail(Bundle start, String name)
+ {
+ try
+ {
+ start.loadClass(name);
+ fail("Should not be here!");
+ }
+ catch (Exception expected)
+ {
+ checkThrowable(ClassNotFoundException.class, expected);
+ }
+ }
+
+ protected URL getBundleResource(Bundle bundle, String path)
+ {
+ return getDelegate().getBundleResource(bundle, path);
+ }
+
+ protected Enumeration<URL> getBundleResources(Bundle bundle, String path) throws
Exception
+ {
+ return getDelegate().getBundleResources(bundle, path);
+ }
+
+ protected void assertNoAllReferences(BundleContext bundleContext, String clazz) throws
Exception
+ {
+ assertNoAllReferences(bundleContext, clazz, null);
+ }
+
+ protected void assertNoAllReferences(BundleContext bundleContext, String clazz, String
filter) throws Exception
+ {
+ ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
+ if (actual != null)
+ getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz + " filter=" + filter);
+ else
+ getLog().debug(bundleContext + " got nothing for clazz=" + clazz +
" filter=" + filter);
+ assertNull("Expected no references for clazz=" + clazz + "
filter=" + filter, actual);
+ }
+
+ protected void assertAllReferences(BundleContext bundleContext, String clazz,
ServiceReference... expected) throws Exception
+ {
+ assertAllReferences(bundleContext, clazz, null, expected);
+ }
+
+ protected void assertAllReferences(BundleContext bundleContext, String clazz, String
filter, ServiceReference... expected) throws Exception
+ {
+ ServiceReference[] actual = bundleContext.getAllServiceReferences(clazz, filter);
+ if (actual != null)
+ getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz + " filter=" + filter);
+ else
+ getLog().debug(bundleContext + " got nothing for clazz=" + clazz +
" filter=" + filter);
+ assertEquals(bundleContext + " with clazz=" + clazz + "
filter=" + filter, expected, actual);
+ }
+
+ protected void assertNoReferences(BundleContext bundleContext, String clazz) throws
Exception
+ {
+ assertNoReferences(bundleContext, clazz, null);
+ }
+
+ protected void assertNoReferences(BundleContext bundleContext, String clazz, String
filter) throws Exception
+ {
+ ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
+ if (actual != null)
+ getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz + " filter=" + filter);
+ else
+ getLog().debug(bundleContext + " got nothing for clazz=" + clazz +
" filter=" + filter);
+ assertNull("Expected no references for clazz=" + clazz + "
filter=" + filter, actual);
+ }
+
+ protected void assertReferences(BundleContext bundleContext, String clazz,
ServiceReference... expected) throws Exception
+ {
+ assertReferences(bundleContext, clazz, null, expected);
+ }
+
+ protected void assertReferences(BundleContext bundleContext, String clazz, String
filter, ServiceReference... expected) throws Exception
+ {
+ ServiceReference[] actual = bundleContext.getServiceReferences(clazz, filter);
+ if (actual != null)
+ getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz + " filter=" + filter);
+ else
+ getLog().debug(bundleContext + " got nothing for clazz=" + clazz +
" filter=" + filter);
+ assertEquals(bundleContext + " with clazz=" + clazz + "
filter=" + filter, expected, actual);
+ }
+
+ protected void assertNoGetReference(BundleContext bundleContext, String clazz) throws
Exception
+ {
+ ServiceReference actual = bundleContext.getServiceReference(clazz);
+ if (actual != null)
+ getLog().debug(bundleContext + " got " + actual + " for
clazz=" + clazz);
+ else
+ getLog().debug(bundleContext + " got nothing for clazz=" + clazz);
+ assertNull("Expected no references for clazz=" + clazz, actual);
+ }
+
+ protected void assertGetReference(BundleContext bundleContext, String clazz,
ServiceReference expected) throws Exception
+ {
+ ServiceReference actual = bundleContext.getServiceReference(clazz);
+ if (actual != null)
+ getLog().debug(bundleContext + " got " + Arrays.asList(actual) +
" for clazz=" + clazz);
+ else
+ getLog().debug(bundleContext + " got nothing for clazz=" + clazz);
+ assertEquals(bundleContext + " with clazz=" + clazz, expected, actual);
+ }
+
+ protected void assertUsingBundles(ServiceReference reference, Bundle... bundles)
+ {
+ Set<Bundle> actual = new HashSet<Bundle>();
+ Bundle[] users = reference.getUsingBundles();
+ if (users != null)
+ actual.addAll(Arrays.asList(users));
+
+ Set<Bundle> expected = new HashSet<Bundle>();
+ expected.addAll(Arrays.asList(bundles));
+
+ getLog().debug(reference + " users=" + actual);
+
+ // switch - check expected on actual, since actual might be proxy
+ assertEquals(actual, expected);
+ }
+
+ protected void assertBundle(Bundle b1, Bundle b2)
+ {
+ assertNotNull(b1);
+ assertNotNull(b2);
+ assertEquals(b1.getBundleId(), b2.getBundleId());
+ }
+
+ protected void assertObjectClass(String expected, ServiceReference reference)
+ {
+ assertObjectClass(new String[] { expected }, reference);
+ }
+
+ protected void assertObjectClass(String[] expected, ServiceReference reference)
+ {
+ Object actual = reference.getProperty(Constants.OBJECTCLASS);
+ if (actual == null)
+ fail("no object class???");
+ if (actual instanceof String[] == false)
+ fail(actual + " is not a string array??? " +
actual.getClass().getName());
+ assertEquals(expected, (String[])actual);
+ }
+
+ public void frameworkEvent(FrameworkEvent event)
+ {
+ synchronized (frameworkEvents)
+ {
+ getLog().debug("FrameworkEvent type=" +
ConstantsHelper.frameworkEvent(event.getType()) + " for " + event);
+ frameworkEvents.add(event);
+ frameworkEvents.notifyAll();
+ }
+ }
+
+ protected void assertNoFrameworkEvent() throws Exception
+ {
+ getLog().debug("frameworkEvents=" + frameworkEvents);
+ assertEquals(0, frameworkEvents.size());
+ }
+
+ protected void assertFrameworkEvent(int type) throws Exception
+ {
+ assertFrameworkEvent(type, getSystemBundle(), null);
+ }
+
+ protected void assertFrameworkEvent(int type, Class<? extends Throwable>
expectedThrowable) throws Exception
+ {
+ assertFrameworkEvent(type, getSystemBundle(), expectedThrowable);
+ }
+
+ protected void assertFrameworkEvent(int type, Bundle bundle, Class<? extends
Throwable> expectedThrowable) throws Exception
+ {
+ waitForEvent(frameworkEvents, type);
+ getLog().debug("frameworkEvents=" + frameworkEvents);
+ int size = frameworkEvents.size();
+ assertTrue("" + size, size > 0);
+ FrameworkEvent event = frameworkEvents.remove(0);
+ assertEquals(ConstantsHelper.frameworkEvent(type),
ConstantsHelper.frameworkEvent(event.getType()));
+ Throwable t = event.getThrowable();
+ if (expectedThrowable == null)
+ {
+ if (t != null)
+ {
+ getLog().error("Unexpected error in Framework event: ", t);
+ fail("Unexpected throwable: " + t);
+ }
+ }
+ else
+ {
+ checkThrowable(BundleException.class, t);
+ checkDeepThrowable(expectedThrowable, t);
+ }
+ assertEquals(bundle, event.getSource());
+ assertEquals(bundle, event.getBundle());
+ }
+
+ public void bundleChanged(BundleEvent event)
+ {
+ synchronized (bundleEvents)
+ {
+ getLog().debug("BundleChanged type=" +
ConstantsHelper.bundleEvent(event.getType()) + " for " + event);
+ bundleEvents.add(event);
+ bundleEvents.notifyAll();
+ }
+ }
+
+ protected void assertNoBundleEvent() throws Exception
+ {
+ getLog().debug("bundleEvents=" + bundleEvents);
+ assertEquals(0, bundleEvents.size());
+ }
+
+ protected void assertBundleEvent(int type, Bundle bundle) throws Exception
+ {
+ waitForEvent(bundleEvents, type);
+
+ getLog().debug("bundleEvents=" + bundleEvents);
+ int size = bundleEvents.size();
+ assertTrue("" + size, size > 0);
+
+ if (bundle instanceof AbstractBundleState)
+ bundle = ((AbstractBundleState)bundle).getBundle();
+
+ BundleEvent foundEvent = null;
+ for(int i=0; i < bundleEvents.size(); i++)
+ {
+ BundleEvent aux = bundleEvents.get(i);
+ if (type == aux.getType())
+ {
+ if (bundle.equals(aux.getSource()) &&
bundle.equals(aux.getBundle()))
+ {
+ bundleEvents.remove(aux);
+ foundEvent = aux;
+ break;
+ }
+ }
+ }
+
+ if (foundEvent == null)
+ fail("Cannot find event " + ConstantsHelper.bundleEvent(type) + "
from " + bundle);
+ }
+
+ public void serviceChanged(ServiceEvent event)
+ {
+ synchronized (serviceEvents)
+ {
+ getLog().debug("ServiceChanged type=" +
ConstantsHelper.serviceEvent(event.getType()) + " for " + event);
+ serviceEvents.add(event);
+ serviceEvents.notifyAll();
+ }
+ }
+
+ protected void assertNoServiceEvent() throws Exception
+ {
+ getLog().debug("serviceEvents=" + serviceEvents);
+ assertEquals(0, serviceEvents.size());
+ }
+
+ protected void assertServiceEvent(int type, ServiceReference reference) throws
Exception
+ {
+ waitForEvent(serviceEvents, type);
+ getLog().debug("serviceEvents=" + serviceEvents);
+ int size = serviceEvents.size();
+ assertTrue("" + size, size > 0);
+ ServiceEvent event = serviceEvents.remove(0);
+ assertEquals(ConstantsHelper.serviceEvent(type),
ConstantsHelper.serviceEvent(event.getType()));
+ assertEquals(reference, event.getSource());
+ assertEquals(reference, event.getServiceReference());
+ }
+
+ @SuppressWarnings("rawtypes")
+ private void waitForEvent(List events, int type) throws InterruptedException
+ {
+ // Timeout for event delivery: 3 sec
+ int timeout = 30;
+
+ boolean eventFound = false;
+ while (eventFound == false && 0 < timeout)
+ {
+ synchronized (events)
+ {
+ events.wait(100);
+ for (Object aux : events)
+ {
+ if (aux instanceof BundleEvent)
+ {
+ BundleEvent event = (BundleEvent)aux;
+ if (type == event.getType())
+ {
+ eventFound = true;
+ break;
+ }
+ }
+ else if (aux instanceof ServiceEvent)
+ {
+ ServiceEvent event = (ServiceEvent)aux;
+ if (type == event.getType())
+ {
+ eventFound = true;
+ break;
+ }
+ }
+ else if (aux instanceof FrameworkEvent)
+ {
+ FrameworkEvent event = (FrameworkEvent)aux;
+ if (type == event.getType())
+ {
+ eventFound = true;
+ break;
+ }
+ }
+ }
+ }
+ timeout--;
+ }
+ }
+}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,380 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, 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 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 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;
-
-// $Id: $
-
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Enumeration;
-
-import junit.framework.AssertionFailedError;
-
-import org.jboss.classloader.plugins.ClassLoaderUtils;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.deployers.client.spi.DeployerClient;
-import org.jboss.deployers.client.spi.Deployment;
-import org.jboss.deployers.spi.attachments.MutableAttachments;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
-import org.jboss.deployers.vfs.spi.client.VFSDeployment;
-import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
-import org.jboss.virtual.AssembledDirectory;
-import org.jboss.virtual.VFS;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.plugins.context.jar.JarUtils;
-import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-
-/**
- * A OSGiTestDelegate
- *
- * @author <a href="baileyje(a)gmail.com">John Bailey</a>
- * @author Thomas.Diesler(a)jboss.com
- */
-public class FrameworkTestDelegate extends MicrocontainerTestDelegate
-{
- private OSGiBundleManager bundleManager;
-
- /**
- * Create a new OSGiTestDelegate.
- * @param clazz test class
- * @throws Exception for any error
- */
- FrameworkTestDelegate(Class<?> clazz) throws Exception
- {
- super(clazz);
- }
-
- /**
- * Deploys the jboss-osgi-bootstrap.xml bean descriptor to setup OSGi deployers
- */
- protected void deploy() throws Exception
- {
- String common = "/bootstrap/jboss-osgi-bootstrap.xml";
- URL url = getClass().getResource(common);
- if (url == null)
- throw new IllegalStateException(common + " not found");
- deploy(url);
- try
- {
- super.deploy();
- deployBundles();
- }
- catch (Throwable t)
- {
- undeploy();
- if (t instanceof Exception)
- throw (Exception)t;
- if (t instanceof Error)
- throw (Error)t;
- throw new RuntimeException("Error during deploy", t);
- }
- }
-
- protected void undeploy()
- {
- undeployBundles();
- super.undeploy();
- }
-
- @SuppressWarnings("unchecked")
- protected void deployBundles() throws Exception
- {
- try
- {
- Method method = clazz.getMethod("deployBundles",
FrameworkTestDelegate.class);
- log.debug("Deploying Bundles...");
- method.invoke(null, this);
- }
- catch (NoSuchMethodException e)
- {
- log.debug("No deployBundles() in " + clazz.getName());
- }
- }
-
- protected void undeployBundles()
- {
- OSGiBundleManager bundleManager = getBundleManager();
- Collection<AbstractBundleState> bundles = bundleManager.getBundles();
- for (AbstractBundleState aux : bundles)
- {
- try
- {
- if (aux.getBundleId() != 0)
- {
- AbstractDeployedBundleState bundleState =
(AbstractDeployedBundleState)aux;
- bundleManager.uninstallBundle(bundleState);
- }
- }
- catch (Throwable t)
- {
- getLog().warn("Error undeploying bundle: " + aux, t);
- }
- }
- }
-
- public OSGiBundleManager getBundleManager()
- {
- if (bundleManager == null)
- {
- bundleManager = getBean("OSGiBundleManager",
ControllerState.INSTALLED, OSGiBundleManager.class);
- try
- {
- if (bundleManager.isFrameworkActive() == false)
- bundleManager.startFramework();
- }
- catch (BundleException ex)
- {
- throw new IllegalStateException("Cannot start bundle manager",
ex);
- }
- }
- return bundleManager;
- }
-
- public DeployerClient getDeployerClient()
- {
- return getBundleManager().getDeployerClient();
- }
-
- /**
- * Create a bundle
- *
- * @param root the location to deploy
- * @param child the child to deploy
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- public Bundle addBundle(String root, String child) throws Exception
- {
- URL resourceRoot = getClass().getResource(root);
- if (resourceRoot == null)
- throw new AssertionFailedError("Resource not found: " + root);
- URL childResource = new URL(resourceRoot, child);
- AbstractBundleState bundleState = getBundleManager().installBundle(childResource);
- return bundleState.getBundleInternal();
- }
-
- /**
- * Create a bundle
- *
- * @param file the virtual file
- * @return Bundle for the deployment
- * @throws Exception for any error
- */
- public Bundle addBundle(VirtualFile file) throws Exception
- {
- AbstractBundleState bundleState = getBundleManager().installBundle(file);
- return bundleState.getBundleInternal();
- }
-
- /**
- * Remove a bundle
- *
- * @param bundle the bundle to remove
- * @throws Exception for any error
- */
- public void uninstall(Bundle bundle) throws Exception
- {
- if (bundle.getState() != Bundle.UNINSTALLED)
- {
- AbstractDeployedBundleState bundleState =
OSGiBundleState.assertBundleState(bundle);
- getBundleManager().uninstallBundle(bundleState);
- }
- }
-
- public DeploymentUnit getDeploymentUnit(Bundle bundle)
- {
- DeploymentUnit deploymentUnit =
getBundleManager().getDeployment(bundle.getBundleId());
- if (deploymentUnit == null)
- throw new AssertionFailedError("Bundle not installed: " + bundle);
- return deploymentUnit;
- }
-
- public VirtualFile assembleBundle(String name, String resources, Class<?>...
packages) throws Exception
- {
- return assembleBundle(name, new String[] { resources }, packages);
- }
-
- public VirtualFile assembleBundle(String name, String[] resourcePaths,
Class<?>... packages) throws Exception
- {
- AssembledDirectory assembledDirectory = createAssembledDirectory(name,
"", resourcePaths, packages);
- return assembledDirectory;
- }
-
- public Bundle deployBundle(String name, OSGiMetaData metaData, String resourcePath,
Class<?>... packages) throws Exception
- {
- AssembledDirectory assembledDirectory = createAssembledDirectory(name,
"", new String[] { resourcePath }, packages);
- return deployBundle(assembledDirectory, metaData);
- }
-
- public Bundle deployBundle(String name, OSGiMetaData metaData, String[] resourcePaths,
Class<?>... packages) throws Exception
- {
- AssembledDirectory assembledDirectory = createAssembledDirectory(name,
"", resourcePaths, packages);
- return deployBundle(assembledDirectory, metaData);
- }
-
- public Bundle deployBundle(VirtualFile virtualFile, OSGiMetaData metaData) throws
Exception
- {
- Deployment deployment = createDeployment(virtualFile, metaData);
- return deployBundle(deployment);
- }
-
- public Bundle deployBundle(String root, String child) throws Exception
- {
- URL resourceRoot = getClass().getResource(root);
- if (resourceRoot == null)
- throw new AssertionFailedError("Resource not found: " + root);
- URL childResource = new URL(resourceRoot, child);
- return deployBundle(childResource);
- }
-
- public Bundle deployBundle(URL url) throws Exception
- {
- // Get the root file
- VirtualFile root;
- try
- {
- root = VFS.getRoot(url);
- }
- catch (IOException e)
- {
- throw new BundleException("Invalid url=" + url, e);
- }
-
- return deployBundle(root);
- }
-
- public Bundle deployBundle(VirtualFile file) throws Exception
- {
- return deployBundle(file, null);
- }
-
- public Bundle deployBundle(Deployment deployment) throws Exception
- {
- DeployerClient deployerClient = getDeployerClient();
- MainDeployerStructure deployerStructure = (MainDeployerStructure) deployerClient;
- deployerClient.deploy(deployment);
- try
- {
- DeploymentUnit unit =
deployerStructure.getDeploymentUnit(deployment.getName());
- AbstractBundleState bundleState =
unit.getAttachment(AbstractBundleState.class);
- if (bundleState == null)
- throw new IllegalStateException("Unable to determine bundle state for
" + deployment.getName());
-
- return bundleState.getBundleInternal();
- }
- catch (Exception e)
- {
- deployerClient.undeploy(deployment);
- throw e;
- }
- }
-
- public Deployment createDeployment(VirtualFile virtualFile) throws Exception
- {
- return createDeployment(virtualFile, null);
- }
-
- public Deployment createDeployment(VirtualFile virtualFile, OSGiMetaData metaData)
throws Exception
- {
- return createDeployment(virtualFile, metaData, OSGiMetaData.class);
- }
-
- @SuppressWarnings({"unchecked"})
- public <T> Deployment createDeployment(VirtualFile virtualFile, T metaData,
Class<T> expectedType) throws Exception
- {
- VFSDeployment deployment =
VFSDeploymentFactory.getInstance().createVFSDeployment(virtualFile);
- if (metaData != null)
- {
- if (expectedType == null)
- expectedType = (Class<T>)metaData.getClass();
-
- MutableAttachments att =
(MutableAttachments)deployment.getPredeterminedManagedObjects();
- att.addAttachment(expectedType, metaData);
- }
- return deployment;
- }
-
- public AssembledDirectory createAssembledDirectory(String name, String rootName,
String[] resourcePaths, Class<?>... packages) throws Exception
- {
- AssembledDirectory assembledDirectory = createAssembledDirectory(name, rootName);
- if (resourcePaths != null)
- {
- for (String path : resourcePaths)
- addPath(assembledDirectory, path, "");
- }
- if (packages != null)
- {
- for (Class<?> reference : packages)
- addPackage(assembledDirectory, reference);
- }
- return assembledDirectory;
- }
-
- public AssembledDirectory createAssembledDirectory(String name) throws Exception
- {
- return createAssembledDirectory(name, "");
- }
-
- public AssembledDirectory createAssembledDirectory(String name, String rootName)
throws Exception
- {
- return AssembledDirectory.createAssembledDirectory(name, rootName);
- }
-
- public void addPackage(AssembledDirectory dir, Class<?> reference) throws
Exception
- {
- String packagePath = ClassLoaderUtils.packageNameToPath(reference.getName());
- dir.addResources(reference, new String[] { packagePath + "/*.class" },
new String[0]);
- }
-
- public void addPath(final AssembledDirectory dir, String path, String name) throws
Exception
- {
- URL url = getClass().getResource(path);
- if (url == null)
- throw new AssertionFailedError(path + " not found");
-
- VirtualFile file = VFS.getVirtualFile(url, name);
- // TODO - remove this filter after new VFS relase
- SuffixesExcludeFilter noJars = new SuffixesExcludeFilter(JarUtils.getSuffixes());
- dir.addPath(file, noJars);
- }
-
- public URL getBundleResource(Bundle bundle, String path)
- {
- return getDeploymentUnit(bundle).getResourceLoader().getResource(path);
- }
-
- public Enumeration<URL> getBundleResources(Bundle bundle, String path) throws
Exception
- {
- return getDeploymentUnit(bundle).getResourceLoader().getResources(path);
- }
-}
Copied:
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
(from rev 101772,
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java)
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java
(rev 0)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/FrameworkTestDelegate.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -0,0 +1,380 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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 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 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;
+
+// $Id: $
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Enumeration;
+
+import junit.framework.AssertionFailedError;
+
+import org.jboss.classloader.plugins.ClassLoaderUtils;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployers.client.spi.DeployerClient;
+import org.jboss.deployers.client.spi.Deployment;
+import org.jboss.deployers.spi.attachments.MutableAttachments;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
+import org.jboss.deployers.vfs.spi.client.VFSDeployment;
+import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
+import org.jboss.osgi.framework.bundle.OSGiBundleManager;
+import org.jboss.osgi.framework.bundle.OSGiBundleState;
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.vfs.AbstractVFS;
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+import org.jboss.virtual.AssembledDirectory;
+import org.jboss.virtual.VFS;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
+import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+
+/**
+ * A OSGiTestDelegate
+ *
+ * @author <a href="baileyje(a)gmail.com">John Bailey</a>
+ * @author Thomas.Diesler(a)jboss.com
+ */
+public class FrameworkTestDelegate extends MicrocontainerTestDelegate
+{
+ private OSGiBundleManager bundleManager;
+
+ /**
+ * Create a new OSGiTestDelegate.
+ * @param clazz test class
+ * @throws Exception for any error
+ */
+ FrameworkTestDelegate(Class<?> clazz) throws Exception
+ {
+ super(clazz);
+ }
+
+ /**
+ * Deploys the jboss-osgi-bootstrap.xml bean descriptor to setup OSGi deployers
+ */
+ protected void deploy() throws Exception
+ {
+ String common = "/bootstrap/jboss-osgi-bootstrap.xml";
+ URL url = getClass().getResource(common);
+ if (url == null)
+ throw new IllegalStateException(common + " not found");
+ deploy(url);
+ try
+ {
+ super.deploy();
+ deployBundles();
+ }
+ catch (Throwable t)
+ {
+ undeploy();
+ if (t instanceof Exception)
+ throw (Exception)t;
+ if (t instanceof Error)
+ throw (Error)t;
+ throw new RuntimeException("Error during deploy", t);
+ }
+ }
+
+ protected void undeploy()
+ {
+ undeployBundles();
+ super.undeploy();
+ }
+
+ protected void deployBundles() throws Exception
+ {
+ try
+ {
+ Method method = clazz.getMethod("deployBundles",
FrameworkTestDelegate.class);
+ log.debug("Deploying Bundles...");
+ method.invoke(null, this);
+ }
+ catch (NoSuchMethodException e)
+ {
+ log.debug("No deployBundles() in " + clazz.getName());
+ }
+ }
+
+ protected void undeployBundles()
+ {
+ OSGiBundleManager bundleManager = getBundleManager();
+ Collection<AbstractBundleState> bundles = bundleManager.getBundles();
+ for (AbstractBundleState aux : bundles)
+ {
+ try
+ {
+ if (aux.getBundleId() != 0)
+ {
+ AbstractDeployedBundleState bundleState =
(AbstractDeployedBundleState)aux;
+ bundleManager.uninstallBundle(bundleState);
+ }
+ }
+ catch (Throwable t)
+ {
+ getLog().warn("Error undeploying bundle: " + aux, t);
+ }
+ }
+ }
+
+ public OSGiBundleManager getBundleManager()
+ {
+ if (bundleManager == null)
+ {
+ bundleManager = getBean("OSGiBundleManager",
ControllerState.INSTALLED, OSGiBundleManager.class);
+ try
+ {
+ if (bundleManager.isFrameworkActive() == false)
+ bundleManager.startFramework();
+ }
+ catch (BundleException ex)
+ {
+ throw new IllegalStateException("Cannot start bundle manager",
ex);
+ }
+ }
+ return bundleManager;
+ }
+
+ public DeployerClient getDeployerClient()
+ {
+ return getBundleManager().getDeployerClient();
+ }
+
+ /**
+ * Create a bundle
+ *
+ * @param root the location to deploy
+ * @param child the child to deploy
+ * @return Bundle for the deployment
+ * @throws Exception for any error
+ */
+ public Bundle addBundle(String root, String child) throws Exception
+ {
+ URL resourceRoot = getClass().getResource(root);
+ if (resourceRoot == null)
+ throw new AssertionFailedError("Resource not found: " + root);
+ URL childResource = new URL(resourceRoot, child);
+ AbstractBundleState bundleState = getBundleManager().installBundle(childResource);
+ return bundleState.getBundleInternal();
+ }
+
+ /**
+ * Create a bundle
+ *
+ * @param file the virtual file
+ * @return Bundle for the deployment
+ * @throws Exception for any error
+ */
+ public Bundle addBundle(VirtualFile file) throws Exception
+ {
+ AbstractBundleState bundleState =
getBundleManager().installBundle(AbstractVFS.adapt(file));
+ return bundleState.getBundleInternal();
+ }
+
+ /**
+ * Remove a bundle
+ *
+ * @param bundle the bundle to remove
+ * @throws Exception for any error
+ */
+ public void uninstall(Bundle bundle) throws Exception
+ {
+ if (bundle.getState() != Bundle.UNINSTALLED)
+ {
+ AbstractDeployedBundleState bundleState =
OSGiBundleState.assertBundleState(bundle);
+ getBundleManager().uninstallBundle(bundleState);
+ }
+ }
+
+ public DeploymentUnit getDeploymentUnit(Bundle bundle)
+ {
+ DeploymentUnit deploymentUnit =
getBundleManager().getDeployment(bundle.getBundleId());
+ if (deploymentUnit == null)
+ throw new AssertionFailedError("Bundle not installed: " + bundle);
+ return deploymentUnit;
+ }
+
+ public VirtualFile assembleBundle(String name, String resources, Class<?>...
packages) throws Exception
+ {
+ return assembleBundle(name, new String[] { resources }, packages);
+ }
+
+ public VirtualFile assembleBundle(String name, String[] resourcePaths,
Class<?>... packages) throws Exception
+ {
+ AssembledDirectory assembledDirectory = createAssembledDirectory(name,
"", resourcePaths, packages);
+ return assembledDirectory;
+ }
+
+ public Bundle deployBundle(String name, OSGiMetaData metaData, String resourcePath,
Class<?>... packages) throws Exception
+ {
+ AssembledDirectory assembledDirectory = createAssembledDirectory(name,
"", new String[] { resourcePath }, packages);
+ return deployBundle(assembledDirectory, metaData);
+ }
+
+ public Bundle deployBundle(String name, OSGiMetaData metaData, String[] resourcePaths,
Class<?>... packages) throws Exception
+ {
+ AssembledDirectory assembledDirectory = createAssembledDirectory(name,
"", resourcePaths, packages);
+ return deployBundle(assembledDirectory, metaData);
+ }
+
+ public Bundle deployBundle(VirtualFile virtualFile, OSGiMetaData metaData) throws
Exception
+ {
+ Deployment deployment = createDeployment(virtualFile, metaData);
+ return deployBundle(deployment);
+ }
+
+ public Bundle deployBundle(String root, String child) throws Exception
+ {
+ URL resourceRoot = getClass().getResource(root);
+ if (resourceRoot == null)
+ throw new AssertionFailedError("Resource not found: " + root);
+ URL childResource = new URL(resourceRoot, child);
+ return deployBundle(childResource);
+ }
+
+ public Bundle deployBundle(URL url) throws Exception
+ {
+ // Get the root file
+ VirtualFile root;
+ try
+ {
+ root = VFS.getRoot(url);
+ }
+ catch (IOException e)
+ {
+ throw new BundleException("Invalid url=" + url, e);
+ }
+
+ return deployBundle(root);
+ }
+
+ public Bundle deployBundle(VirtualFile file) throws Exception
+ {
+ return deployBundle(file, null);
+ }
+
+ public Bundle deployBundle(Deployment deployment) throws Exception
+ {
+ DeployerClient deployerClient = getDeployerClient();
+ MainDeployerStructure deployerStructure = (MainDeployerStructure) deployerClient;
+ deployerClient.deploy(deployment);
+ try
+ {
+ DeploymentUnit unit =
deployerStructure.getDeploymentUnit(deployment.getName());
+ AbstractBundleState bundleState =
unit.getAttachment(AbstractBundleState.class);
+ if (bundleState == null)
+ throw new IllegalStateException("Unable to determine bundle state for
" + deployment.getName());
+
+ return bundleState.getBundleInternal();
+ }
+ catch (Exception e)
+ {
+ deployerClient.undeploy(deployment);
+ throw e;
+ }
+ }
+
+ public Deployment createDeployment(VirtualFile virtualFile) throws Exception
+ {
+ return createDeployment(virtualFile, null);
+ }
+
+ public Deployment createDeployment(VirtualFile virtualFile, OSGiMetaData metaData)
throws Exception
+ {
+ return createDeployment(virtualFile, metaData, OSGiMetaData.class);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public <T> Deployment createDeployment(VirtualFile virtualFile, T metaData,
Class<T> expectedType) throws Exception
+ {
+ VFSDeployment deployment =
VFSDeploymentFactory.getInstance().createVFSDeployment(virtualFile);
+ if (metaData != null)
+ {
+ if (expectedType == null)
+ expectedType = (Class<T>)metaData.getClass();
+
+ MutableAttachments att =
(MutableAttachments)deployment.getPredeterminedManagedObjects();
+ att.addAttachment(expectedType, metaData);
+ }
+ return deployment;
+ }
+
+ public AssembledDirectory createAssembledDirectory(String name, String rootName,
String[] resourcePaths, Class<?>... packages) throws Exception
+ {
+ AssembledDirectory assembledDirectory = createAssembledDirectory(name, rootName);
+ if (resourcePaths != null)
+ {
+ for (String path : resourcePaths)
+ addPath(assembledDirectory, path, "");
+ }
+ if (packages != null)
+ {
+ for (Class<?> reference : packages)
+ addPackage(assembledDirectory, reference);
+ }
+ return assembledDirectory;
+ }
+
+ public AssembledDirectory createAssembledDirectory(String name) throws Exception
+ {
+ return createAssembledDirectory(name, "");
+ }
+
+ public AssembledDirectory createAssembledDirectory(String name, String rootName)
throws Exception
+ {
+ return AssembledDirectory.createAssembledDirectory(name, rootName);
+ }
+
+ public void addPackage(AssembledDirectory dir, Class<?> reference) throws
Exception
+ {
+ String packagePath = ClassLoaderUtils.packageNameToPath(reference.getName());
+ dir.addResources(reference, new String[] { packagePath + "/*.class" },
new String[0]);
+ }
+
+ public void addPath(final AssembledDirectory dir, String path, String name) throws
Exception
+ {
+ URL url = getClass().getResource(path);
+ if (url == null)
+ throw new AssertionFailedError(path + " not found");
+
+ VirtualFile file = VFS.getVirtualFile(url, name);
+ // TODO - remove this filter after new VFS relase
+ SuffixesExcludeFilter noJars = new SuffixesExcludeFilter(JarUtils.getSuffixes());
+ dir.addPath(file, noJars);
+ }
+
+ public URL getBundleResource(Bundle bundle, String path)
+ {
+ return getDeploymentUnit(bundle).getResourceLoader().getResource(path);
+ }
+
+ public Enumeration<URL> getBundleResources(Bundle bundle, String path) throws
Exception
+ {
+ return getDeploymentUnit(bundle).getResourceLoader().getResources(path);
+ }
+}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,1240 +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.resolver;
-
-// $Id$
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.jboss.test.osgi.classloader.support.a.A;
-import org.jboss.virtual.VirtualFile;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * An abstract resolver test.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 09-Nov-2009
- */
-public abstract class AbstractImportExportTest extends AbstractResolverTest
-{
- @Test
- public void testSimpleImport() throws Exception
- {
- // Bundle-SymbolicName: simpleimport
- // Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleB, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testSimpleImportPackageFails() throws Exception
- {
- // Bundle-SymbolicName: simpleimport
- // Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertFalse("Not all resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
-
- // Verify that the class load
- assertLoadFails(bundleA, A.class);
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testExplicitBundleResolve() throws Exception
- {
- // Bundle-SymbolicName: simpleimport
- // Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Only resolve BundleB
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(new Bundle[] { bundleB });
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class can be loaded
- assertLoaderBundle(bundleB, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testSelfImportPackage() throws Exception
- {
- // Bundle-SymbolicName: selfimport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- // Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/selfimport", A.class);
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleA, bundleA, A.class);
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testVersionImportPackage() throws Exception
- {
- //Bundle-SymbolicName: packageimportversion
- //Import-Package:
org.jboss.test.osgi.classloader.support.a;version="[0.0.0,1.0.0]"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportversion");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- //Bundle-SymbolicName: packageexportversion100
- //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion100", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleB, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testVersionImportPackageFails() throws Exception
- {
- //Bundle-SymbolicName: packageimportversionfails
- //Import-Package:
org.jboss.test.osgi.classloader.support.a;version="[3.0,4.0)"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportversionfails");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- //Bundle-SymbolicName: packageexportversion100
- //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion100", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertFalse("Not all resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoadFails(bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testOptionalImportPackage() throws Exception
- {
- //Bundle-SymbolicName: packageimportoptional
- //Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportoptional");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
-
- // Verify that the class load
- assertLoadFails(bundleA, A.class);
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testOptionalImportPackageWired() throws Exception
- {
- //Bundle-SymbolicName: packageimportoptional
- //Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportoptional");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleB, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testOptionalImportPackageNotWired() throws Exception
- {
- //Bundle-SymbolicName: packageimportoptional
- //Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportoptional");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class cannot be loaded from bundleA
- // because the wire could not be established when bundleA was resolved
- assertLoadFails(bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testBundleNameImportPackage() throws Exception
- {
- //Bundle-SymbolicName: bundlenameimport
- //Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=simpleexport
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/bundlenameimport");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- //Bundle-SymbolicName: simpleexport
- //Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleB, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testBundleNameImportPackageFails() throws Exception
- {
- //Bundle-SymbolicName: bundlenameimport
- //Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=simpleexport
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/bundlenameimport");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- //Bundle-SymbolicName: sigleton;singleton:=true
- //Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/singleton", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertFalse("Not all resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoadFails(bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testBundleVersionImportPackage() throws Exception
- {
- //Bundle-SymbolicName: bundleversionimport
- //Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-version="[0.0.0,1.0.0)"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/bundleversionimport");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleB, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testBundleVersionImportPackageFails() throws Exception
- {
- //Bundle-SymbolicName: bundleversionimportfails
- //Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-version="[1.0.0,2.0.0)"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/bundleversionimportfails");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertFalse("Not all resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoadFails(bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- // [TODO] require bundle visibility
- public void testRequireBundle() throws Exception
- {
- //Bundle-SymbolicName: requirebundle
- //Require-Bundle: simpleexport
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundle");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleB, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testRequireBundleFails() throws Exception
- {
- //Bundle-SymbolicName: requirebundle
- //Require-Bundle: simpleexport
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundle");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertFalse("Not all resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
-
- // Verify that the class load
- assertLoadFails(bundleA, A.class);
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testRequireBundleOptional() throws Exception
- {
- //Bundle-SymbolicName: requirebundleoptional
- //Require-Bundle: simpleexport;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleoptional");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testRequireBundleVersion() throws Exception
- {
- //Bundle-SymbolicName: requirebundleversion
- //Require-Bundle: simpleexport;bundle-version="[0.0.0,1.0.0]"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleversion");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleB, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testRequireBundleVersionFails() throws Exception
- {
- //Bundle-SymbolicName: versionrequirebundlefails
- //Require-Bundle: simpleexport;bundle-version="[1.0.0,2.0.0)"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleversionfails");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertFalse("Not all resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoadFails(bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPreferredExporterResolved() throws Exception
- {
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
-
- // Bundle-SymbolicName: simpleexportother
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexportother", A.class);
-
- // Bundle-SymbolicName: simpleimport
- // Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
-
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
-
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- Bundle bundleC = framework.installBundle(fileC);
- try
- {
- allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
- assertEquals("BundleC RESOLVED", Bundle.RESOLVED,
bundleC.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleA, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- assertLoaderBundle(bundleA, bundleC, A.class);
- }
- finally
- {
- bundleC.uninstall();
- }
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPreferredExporterResolvedReverse() throws Exception
- {
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
-
- // Bundle-SymbolicName: simpleexportother
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexportother", A.class);
-
- // Bundle-SymbolicName: simpleimport
- // Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
-
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- Bundle bundleC = framework.installBundle(fileC);
- try
- {
- allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleC RESOLVED", Bundle.RESOLVED,
bundleC.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleA, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- assertLoaderBundle(bundleB, bundleC, A.class);
- }
- finally
- {
- bundleC.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
- finally
- {
- bundleB.uninstall();
- }
- }
-
- @Test
- public void testPreferredExporterHigherVersion() throws Exception
- {
- //Bundle-SymbolicName: packageexportversion100
- //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportversion100", A.class);
-
- //Bundle-SymbolicName: packageexportversion200
- //Export-Package: org.jboss.test.osgi.classloader.support.a;version=2.0.0
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion200", A.class);
-
- // Bundle-SymbolicName: simpleimport
- // Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
-
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- Bundle bundleC = framework.installBundle(fileC);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
- assertEquals("BundleC RESOLVED", Bundle.RESOLVED,
bundleC.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleA, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- assertLoaderBundle(bundleB, bundleC, A.class);
- }
- finally
- {
- bundleC.uninstall();
- }
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPreferredExporterHigherVersionReverse() throws Exception
- {
- //Bundle-SymbolicName: packageexportversion200
- //Export-Package: org.jboss.test.osgi.classloader.support.a;version=2.0.0
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportversion200", A.class);
-
- //Bundle-SymbolicName: packageexportversion100
- //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion100", A.class);
-
- // Bundle-SymbolicName: simpleimport
- // Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
-
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- Bundle bundleC = framework.installBundle(fileC);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
- assertEquals("BundleC RESOLVED", Bundle.RESOLVED,
bundleC.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleA, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- assertLoaderBundle(bundleA, bundleC, A.class);
- }
- finally
- {
- bundleC.uninstall();
- }
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPreferredExporterLowerId() throws Exception
- {
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
-
- // Bundle-SymbolicName: simpleexportother
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexportother", A.class);
-
- // Bundle-SymbolicName: simpleimport
- // Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
-
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- Bundle bundleC = framework.installBundle(fileC);
- try
- {
- allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleC RESOLVED", Bundle.RESOLVED,
bundleC.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleA, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- assertLoaderBundle(bundleA, bundleC, A.class);
- }
- finally
- {
- bundleC.uninstall();
- }
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPreferredExporterLowerIdReverse() throws Exception
- {
- // Bundle-SymbolicName: simpleexportother
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexportother", A.class);
-
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
-
- // Bundle-SymbolicName: simpleimport
- // Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
-
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- Bundle bundleC = framework.installBundle(fileC);
- try
- {
- allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleC RESOLVED", Bundle.RESOLVED,
bundleC.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleA, bundleA, A.class);
- assertLoaderBundle(bundleB, bundleB, A.class);
- assertLoaderBundle(bundleA, bundleC, A.class);
- }
- finally
- {
- bundleC.uninstall();
- }
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPackageAttribute() throws Exception
- {
- //Bundle-SymbolicName: packageexportattribute
- //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattribute", A.class);
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- //Bundle-SymbolicName: simpleimport
- //Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleimport");
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleA, bundleA, A.class);
- assertLoaderBundle(bundleA, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
-
- //Bundle-SymbolicName: packageimportattribute
- //Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
- fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattribute");
- bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleA, bundleA, A.class);
- assertLoaderBundle(bundleA, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPackageAttributeFails() throws Exception
- {
- //Bundle-SymbolicName: packageexportattribute
- //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattribute", A.class);
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- //Bundle-SymbolicName: packageimportattributefails
- //Import-Package: org.jboss.test.osgi.classloader.support.a;test=y
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattributefails");
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertFalse("Not all resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB INSTALLED", Bundle.INSTALLED,
bundleB.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleA, bundleA, A.class);
- assertLoadFails(bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPackageAttributeMandatory() throws Exception
- {
- //Bundle-SymbolicName: packageexportattributemandatory
- //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattributemandatory", A.class);
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- //Bundle-SymbolicName: packageimportattribute
- //Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattribute");
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleA, bundleA, A.class);
- assertLoaderBundle(bundleA, bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPackageAttributeMandatoryFails() throws Exception
- {
- //Bundle-SymbolicName: packageexportattributemandatory
- //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattributemandatory", A.class);
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- //Bundle-SymbolicName: simpleimport
- //Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleimport");
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertFalse("Not all resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- assertEquals("BundleB INSTALLED", Bundle.INSTALLED,
bundleB.getState());
-
- // Verify that the class load
- assertLoaderBundle(bundleA, bundleA, A.class);
- assertLoadFails(bundleB, A.class);
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testSystemPackageImport() throws Exception
- {
- //Bundle-SymbolicName: systempackageimport
- //Import-Package: org.osgi.framework;version=1.4
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/systempackageimport");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- // Resolve the installed bundles
- PackageAdmin packageAdmin = getPackageAdmin();
- boolean allResolved = packageAdmin.resolveBundles(null);
- assertTrue("All resolved", allResolved);
-
- // Verify bundle states
- assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-}
\ No newline at end of file
Copied:
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
(from rev 101772,
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java)
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
(rev 0)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -0,0 +1,1240 @@
+/*
+ * 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.resolver;
+
+// $Id$
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.jboss.osgi.vfs.VirtualFile;
+import org.jboss.test.osgi.classloader.support.a.A;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * An abstract resolver test.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 09-Nov-2009
+ */
+public abstract class AbstractImportExportTest extends AbstractResolverTest
+{
+ @Test
+ public void testSimpleImport() throws Exception
+ {
+ // Bundle-SymbolicName: simpleimport
+ // Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleB, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testSimpleImportPackageFails() throws Exception
+ {
+ // Bundle-SymbolicName: simpleimport
+ // Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertFalse("Not all resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
+
+ // Verify that the class load
+ assertLoadFails(bundleA, A.class);
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testExplicitBundleResolve() throws Exception
+ {
+ // Bundle-SymbolicName: simpleimport
+ // Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Only resolve BundleB
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(new Bundle[] { bundleB });
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class can be loaded
+ assertLoaderBundle(bundleB, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testSelfImportPackage() throws Exception
+ {
+ // Bundle-SymbolicName: selfimport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ // Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/selfimport", A.class);
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleA, bundleA, A.class);
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testVersionImportPackage() throws Exception
+ {
+ //Bundle-SymbolicName: packageimportversion
+ //Import-Package:
org.jboss.test.osgi.classloader.support.a;version="[0.0.0,1.0.0]"
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportversion");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ //Bundle-SymbolicName: packageexportversion100
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion100", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleB, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testVersionImportPackageFails() throws Exception
+ {
+ //Bundle-SymbolicName: packageimportversionfails
+ //Import-Package:
org.jboss.test.osgi.classloader.support.a;version="[3.0,4.0)"
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportversionfails");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ //Bundle-SymbolicName: packageexportversion100
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion100", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertFalse("Not all resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoadFails(bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testOptionalImportPackage() throws Exception
+ {
+ //Bundle-SymbolicName: packageimportoptional
+ //Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportoptional");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+
+ // Verify that the class load
+ assertLoadFails(bundleA, A.class);
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testOptionalImportPackageWired() throws Exception
+ {
+ //Bundle-SymbolicName: packageimportoptional
+ //Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportoptional");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleB, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testOptionalImportPackageNotWired() throws Exception
+ {
+ //Bundle-SymbolicName: packageimportoptional
+ //Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportoptional");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class cannot be loaded from bundleA
+ // because the wire could not be established when bundleA was resolved
+ assertLoadFails(bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testBundleNameImportPackage() throws Exception
+ {
+ //Bundle-SymbolicName: bundlenameimport
+ //Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=simpleexport
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/bundlenameimport");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ //Bundle-SymbolicName: simpleexport
+ //Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleB, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testBundleNameImportPackageFails() throws Exception
+ {
+ //Bundle-SymbolicName: bundlenameimport
+ //Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=simpleexport
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/bundlenameimport");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ //Bundle-SymbolicName: sigleton;singleton:=true
+ //Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/singleton", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertFalse("Not all resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoadFails(bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testBundleVersionImportPackage() throws Exception
+ {
+ //Bundle-SymbolicName: bundleversionimport
+ //Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-version="[0.0.0,1.0.0)"
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/bundleversionimport");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleB, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testBundleVersionImportPackageFails() throws Exception
+ {
+ //Bundle-SymbolicName: bundleversionimportfails
+ //Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-version="[1.0.0,2.0.0)"
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/bundleversionimportfails");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertFalse("Not all resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoadFails(bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ // [TODO] require bundle visibility
+ public void testRequireBundle() throws Exception
+ {
+ //Bundle-SymbolicName: requirebundle
+ //Require-Bundle: simpleexport
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundle");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleB, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testRequireBundleFails() throws Exception
+ {
+ //Bundle-SymbolicName: requirebundle
+ //Require-Bundle: simpleexport
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundle");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertFalse("Not all resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
+
+ // Verify that the class load
+ assertLoadFails(bundleA, A.class);
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testRequireBundleOptional() throws Exception
+ {
+ //Bundle-SymbolicName: requirebundleoptional
+ //Require-Bundle: simpleexport;resolution:=optional
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleoptional");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testRequireBundleVersion() throws Exception
+ {
+ //Bundle-SymbolicName: requirebundleversion
+ //Require-Bundle: simpleexport;bundle-version="[0.0.0,1.0.0]"
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleversion");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleB, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testRequireBundleVersionFails() throws Exception
+ {
+ //Bundle-SymbolicName: versionrequirebundlefails
+ //Require-Bundle: simpleexport;bundle-version="[1.0.0,2.0.0)"
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleversionfails");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertFalse("Not all resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA INSTALLED", Bundle.INSTALLED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoadFails(bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPreferredExporterResolved() throws Exception
+ {
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
+
+ // Bundle-SymbolicName: simpleexportother
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexportother", A.class);
+
+ // Bundle-SymbolicName: simpleimport
+ // Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
+
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ Bundle bundleC = framework.installBundle(fileC);
+ try
+ {
+ allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+ assertEquals("BundleC RESOLVED", Bundle.RESOLVED,
bundleC.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleA, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ assertLoaderBundle(bundleA, bundleC, A.class);
+ }
+ finally
+ {
+ bundleC.uninstall();
+ }
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPreferredExporterResolvedReverse() throws Exception
+ {
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
+
+ // Bundle-SymbolicName: simpleexportother
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexportother", A.class);
+
+ // Bundle-SymbolicName: simpleimport
+ // Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
+
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ Bundle bundleC = framework.installBundle(fileC);
+ try
+ {
+ allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleC RESOLVED", Bundle.RESOLVED,
bundleC.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleA, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ assertLoaderBundle(bundleB, bundleC, A.class);
+ }
+ finally
+ {
+ bundleC.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+
+ @Test
+ public void testPreferredExporterHigherVersion() throws Exception
+ {
+ //Bundle-SymbolicName: packageexportversion100
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportversion100", A.class);
+
+ //Bundle-SymbolicName: packageexportversion200
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;version=2.0.0
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion200", A.class);
+
+ // Bundle-SymbolicName: simpleimport
+ // Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
+
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ Bundle bundleC = framework.installBundle(fileC);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+ assertEquals("BundleC RESOLVED", Bundle.RESOLVED,
bundleC.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleA, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ assertLoaderBundle(bundleB, bundleC, A.class);
+ }
+ finally
+ {
+ bundleC.uninstall();
+ }
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPreferredExporterHigherVersionReverse() throws Exception
+ {
+ //Bundle-SymbolicName: packageexportversion200
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;version=2.0.0
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportversion200", A.class);
+
+ //Bundle-SymbolicName: packageexportversion100
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion100", A.class);
+
+ // Bundle-SymbolicName: simpleimport
+ // Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
+
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ Bundle bundleC = framework.installBundle(fileC);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+ assertEquals("BundleC RESOLVED", Bundle.RESOLVED,
bundleC.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleA, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ assertLoaderBundle(bundleA, bundleC, A.class);
+ }
+ finally
+ {
+ bundleC.uninstall();
+ }
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPreferredExporterLowerId() throws Exception
+ {
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
+
+ // Bundle-SymbolicName: simpleexportother
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexportother", A.class);
+
+ // Bundle-SymbolicName: simpleimport
+ // Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
+
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ Bundle bundleC = framework.installBundle(fileC);
+ try
+ {
+ allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleC RESOLVED", Bundle.RESOLVED,
bundleC.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleA, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ assertLoaderBundle(bundleA, bundleC, A.class);
+ }
+ finally
+ {
+ bundleC.uninstall();
+ }
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPreferredExporterLowerIdReverse() throws Exception
+ {
+ // Bundle-SymbolicName: simpleexportother
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexportother", A.class);
+
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
+
+ // Bundle-SymbolicName: simpleimport
+ // Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileC = assembleBundle("bundleC",
"/bundles/resolver/simpleimport");
+
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ Bundle bundleC = framework.installBundle(fileC);
+ try
+ {
+ allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleC RESOLVED", Bundle.RESOLVED,
bundleC.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleA, bundleA, A.class);
+ assertLoaderBundle(bundleB, bundleB, A.class);
+ assertLoaderBundle(bundleA, bundleC, A.class);
+ }
+ finally
+ {
+ bundleC.uninstall();
+ }
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPackageAttribute() throws Exception
+ {
+ //Bundle-SymbolicName: packageexportattribute
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattribute", A.class);
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ //Bundle-SymbolicName: simpleimport
+ //Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleimport");
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleA, bundleA, A.class);
+ assertLoaderBundle(bundleA, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+
+ //Bundle-SymbolicName: packageimportattribute
+ //Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
+ fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattribute");
+ bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleA, bundleA, A.class);
+ assertLoaderBundle(bundleA, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPackageAttributeFails() throws Exception
+ {
+ //Bundle-SymbolicName: packageexportattribute
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattribute", A.class);
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ //Bundle-SymbolicName: packageimportattributefails
+ //Import-Package: org.jboss.test.osgi.classloader.support.a;test=y
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattributefails");
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertFalse("Not all resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB INSTALLED", Bundle.INSTALLED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleA, bundleA, A.class);
+ assertLoadFails(bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPackageAttributeMandatory() throws Exception
+ {
+ //Bundle-SymbolicName: packageexportattributemandatory
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattributemandatory", A.class);
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ //Bundle-SymbolicName: packageimportattribute
+ //Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattribute");
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB RESOLVED", Bundle.RESOLVED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleA, bundleA, A.class);
+ assertLoaderBundle(bundleA, bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPackageAttributeMandatoryFails() throws Exception
+ {
+ //Bundle-SymbolicName: packageexportattributemandatory
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattributemandatory", A.class);
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ //Bundle-SymbolicName: simpleimport
+ //Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleimport");
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertFalse("Not all resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ assertEquals("BundleB INSTALLED", Bundle.INSTALLED,
bundleB.getState());
+
+ // Verify that the class load
+ assertLoaderBundle(bundleA, bundleA, A.class);
+ assertLoadFails(bundleB, A.class);
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testSystemPackageImport() throws Exception
+ {
+ //Bundle-SymbolicName: systempackageimport
+ //Import-Package: org.osgi.framework;version=1.4
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/systempackageimport");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ // Resolve the installed bundles
+ PackageAdmin packageAdmin = getPackageAdmin();
+ boolean allResolved = packageAdmin.resolveBundles(null);
+ assertTrue("All resolved", allResolved);
+
+ // Verify bundle states
+ assertEquals("BundleA RESOLVED", Bundle.RESOLVED,
bundleA.getState());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+}
\ No newline at end of file
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,450 +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.resolver;
-
-// $Id$
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-import java.util.Set;
-
-import org.jboss.osgi.framework.resolver.ExportPackage;
-import org.jboss.osgi.framework.resolver.ImportPackage;
-import org.jboss.osgi.framework.resolver.RequiredBundle;
-import org.jboss.osgi.framework.resolver.Resolver;
-import org.jboss.osgi.framework.resolver.ResolverBundle;
-import org.jboss.test.osgi.classloader.support.a.A;
-import org.jboss.virtual.VirtualFile;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Version;
-
-/**
- * Test {@link Resolver} metadata.
- *
- * @author thomas.diesler(a)jboss.com
- * @since 09-Nov-2009
- */
-public class ResolverMetadataTest extends AbstractResolverTest
-{
- @Test
- public void testSimpleExport() throws Exception
- {
- Resolver resolver = getTestResolver();
- if (resolver == null)
- return;
-
- // Bundle-SymbolicName: simpleexport
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- assertEquals(1, resolver.getBundles().size());
-
- ResolverBundle resBundleA = resolver.getBundle(bundleA.getSymbolicName(),
null);
- assertNotNull("Resolvable not null", resBundleA);
-
- resBundleA = resolver.getBundle(bundleA.getSymbolicName(),
bundleA.getVersion());
- assertNotNull("Resolvable not null", resBundleA);
-
- resBundleA = resolver.getBundle(bundleA);
- assertNotNull("Resolvable not null", resBundleA);
-
- assertNotNull(resBundleA.getBundle());
- assertEquals("simpleexport", resBundleA.getSymbolicName());
- assertEquals(Version.emptyVersion, resBundleA.getVersion());
-
- List<ExportPackage> exportPackages = resBundleA.getExportPackages();
- assertNotNull("ExportPackages not null", exportPackages);
- assertEquals(1, exportPackages.size());
-
- ExportPackage exportPackage =
resBundleA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
- assertNotNull("ExportPackage not null", exportPackage);
- assertEquals("org.jboss.test.osgi.classloader.support.a",
exportPackage.getName());
-
- assertEquals(Version.emptyVersion, exportPackage.getVersion());
- assertEquals(0, exportPackage.getUses().size());
- assertEquals(0, exportPackage.getMandatory().size());
- assertNull("Null includes", exportPackage.getIncludes());
- assertNull("Null excludes", exportPackage.getExcludes());
-
- List<ImportPackage> importPackages = resBundleA.getImportPackages();
- assertNotNull("ImportPackages not null", importPackages);
- assertEquals(0, importPackages.size());
-
- assertFalse("No sigleton", resBundleA.isSingleton());
- assertFalse("Not resolved", resBundleA.isResolved());
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testSimpleImport() throws Exception
- {
- Resolver resolver = getTestResolver();
- if (resolver == null)
- return;
-
- // Bundle-SymbolicName: simpleimport
- // Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- ResolverBundle resBundleA = resolver.getBundle(bundleA);
-
- List<ImportPackage> importPackages = resBundleA.getImportPackages();
- assertNotNull("ImportPackages not null", importPackages);
- assertEquals(1, importPackages.size());
-
- ImportPackage importPackage =
resBundleA.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- assertNotNull("ImportPackage not null", importPackage);
- assertEquals("org.jboss.test.osgi.classloader.support.a",
importPackage.getName());
-
- assertEquals("[0.0.0,?)", importPackage.getVersion().toString());
- assertNull("Null bundle-symbolic-name",
importPackage.getBundleSymbolicName());
- assertNull("Null bundle-version", importPackage.getBundleVersion());
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testSingleton() throws Exception
- {
- Resolver resolver = getTestResolver();
- if (resolver == null)
- return;
-
- // Bundle-SymbolicName: singleton;singleton:=true
- // Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/singleton", A.class);
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- ResolverBundle resBundleA = resolver.getBundle(bundleA);
- assertTrue("Sigleton", resBundleA.isSingleton());
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testRequireBundle() throws Exception
- {
- Resolver resolver = getTestResolver();
- if (resolver == null)
- return;
-
- //Bundle-SymbolicName: requirebundle
- //Require-Bundle: simpleexport
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundle");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- ResolverBundle resBundleA = resolver.getBundle(bundleA);
- List<RequiredBundle> requiredBundles = resBundleA.getRequiredBundles();
- assertEquals("RequiredBundles not null", 1, requiredBundles.size());
- RequiredBundle reqBundle = requiredBundles.get(0);
- assertEquals("simpleexport", reqBundle.getSymbolicName());
- assertNull("Null version", reqBundle.getVersion());
- assertFalse("Not optional", reqBundle.isOptional());
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testRequireBundleOptional() throws Exception
- {
- Resolver resolver = getTestResolver();
- if (resolver == null)
- return;
-
- //Bundle-SymbolicName: requirebundle
- //Require-Bundle: simpleexport;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleoptional");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- ResolverBundle resBundleA = resolver.getBundle(bundleA);
- List<RequiredBundle> requiredBundles = resBundleA.getRequiredBundles();
- assertEquals("RequiredBundles not null", 1, requiredBundles.size());
- RequiredBundle reqBundle = requiredBundles.get(0);
- assertEquals("simpleexport", reqBundle.getSymbolicName());
- assertNull("Null version", reqBundle.getVersion());
- assertTrue("Resolution optional", reqBundle.isOptional());
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testRequireBundleVersion() throws Exception
- {
- Resolver resolver = getTestResolver();
- if (resolver == null)
- return;
-
- //Bundle-SymbolicName: requirebundle
- //Require-Bundle: simpleexport;bundle-version="[0.0.0,1.0.0]"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleversion");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- ResolverBundle resBundleA = resolver.getBundle(bundleA);
- List<RequiredBundle> requiredBundles = resBundleA.getRequiredBundles();
- assertEquals("RequiredBundles not null", 1, requiredBundles.size());
- RequiredBundle reqBundle = requiredBundles.get(0);
- assertEquals("simpleexport", reqBundle.getSymbolicName());
- assertNotNull("Version not null", reqBundle.getVersion());
- assertFalse("Not optional", reqBundle.isOptional());
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPackageAttribute() throws Exception
- {
- Resolver resolver = getTestResolver();
- if (resolver == null)
- return;
-
- //Bundle-SymbolicName: packageexportattribute
- //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattribute");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- ResolverBundle resBundleA = resolver.getBundle(bundleA);
- ExportPackage exportPackage =
resBundleA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
- Set<String> exportAttributes = exportPackage.getAttributes();
- assertTrue("Contains attr",
exportAttributes.contains("test"));
- assertEquals("x", exportPackage.getAttribute("test"));
-
- //Bundle-SymbolicName: simpleimport
- //Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleimport");
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- ResolverBundle resBundleB = resolver.getBundle(bundleB);
- ImportPackage importPackage =
resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- assertTrue("Attribute match",
exportPackage.matchAttributes(importPackage));
- }
- finally
- {
- bundleB.uninstall();
- }
-
- //Bundle-SymbolicName: packageimportattribute
- //Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
- fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattribute");
- bundleB = framework.installBundle(fileB);
- try
- {
- ResolverBundle resBundleB = resolver.getBundle(bundleB);
- ImportPackage importPackage =
resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- Set<String> importAttributes = importPackage.getAttributes();
- assertTrue("Contains attr",
importAttributes.contains("test"));
- assertEquals("x", importPackage.getAttribute("test"));
- assertTrue("Attribute match",
exportPackage.matchAttributes(importPackage));
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPackageAttributeFails() throws Exception
- {
- Resolver resolver = getTestResolver();
- if (resolver == null)
- return;
-
- //Bundle-SymbolicName: packageexportattribute
- //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattribute");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- ResolverBundle resBundleA = resolver.getBundle(bundleA);
- ExportPackage exportPackage =
resBundleA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
- Set<String> attributes = exportPackage.getAttributes();
- assertTrue("Contains attr", attributes.contains("test"));
- assertEquals("x", exportPackage.getAttribute("test"));
-
- //Bundle-SymbolicName: packageimportattributefails
- //Import-Package: org.jboss.test.osgi.classloader.support.a;test=y
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattributefails");
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- ResolverBundle resBundleB = resolver.getBundle(bundleB);
- ImportPackage importPackage =
resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- Set<String> importAttributes = importPackage.getAttributes();
- assertTrue("Contains attr",
importAttributes.contains("test"));
- assertEquals("y", importPackage.getAttribute("test"));
- assertFalse("Attribute no match",
exportPackage.matchAttributes(importPackage));
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPackageAttributeMandatory() throws Exception
- {
- Resolver resolver = getTestResolver();
- if (resolver == null)
- return;
-
- //Bundle-SymbolicName: packageexportattributemandatory
- //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattributemandatory");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- ResolverBundle resBundleA = resolver.getBundle(bundleA);
- ExportPackage exportPackage =
resBundleA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
- Set<String> attributes = exportPackage.getAttributes();
- assertTrue("Contains test", attributes.contains("test"));
- assertEquals("x", exportPackage.getAttribute("test"));
- Set<String> mandatory = exportPackage.getMandatory();
- assertTrue("Contains test", mandatory.contains("test"));
-
- //Bundle-SymbolicName: packageimportattribute
- //Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattribute");
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- ResolverBundle resBundleB = resolver.getBundle(bundleB);
- ImportPackage importPackage =
resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- Set<String> importAttributes = importPackage.getAttributes();
- assertTrue("Contains attr",
importAttributes.contains("test"));
- assertEquals("x", importPackage.getAttribute("test"));
- assertTrue("Attribute match",
exportPackage.matchAttributes(importPackage));
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-
- @Test
- public void testPackageAttributeMandatoryFails() throws Exception
- {
- Resolver resolver = getTestResolver();
- if (resolver == null)
- return;
-
- //Bundle-SymbolicName: packageexportattributemandatory
- //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattributemandatory");
- Bundle bundleA = framework.installBundle(fileA);
- try
- {
- ResolverBundle resBundleA = resolver.getBundle(bundleA);
- ExportPackage exportPackage =
resBundleA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
- Set<String> attributes = exportPackage.getAttributes();
- assertTrue("Contains test", attributes.contains("test"));
- assertEquals("x", exportPackage.getAttribute("test"));
- Set<String> mandatory = exportPackage.getMandatory();
- assertTrue("Contains test", mandatory.contains("test"));
-
- //Bundle-SymbolicName: simpleimport
- //Import-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleimport");
- Bundle bundleB = framework.installBundle(fileB);
- try
- {
- ResolverBundle resBundleB = resolver.getBundle(bundleB);
- ImportPackage importPackage =
resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- assertFalse("Attribute no match",
exportPackage.matchAttributes(importPackage));
- }
- finally
- {
- bundleB.uninstall();
- }
-
- //Bundle-SymbolicName: packageimportattributefails
- //Import-Package: org.jboss.test.osgi.classloader.support.a;test=y
- fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattributefails");
- bundleB = framework.installBundle(fileB);
- try
- {
- ResolverBundle resBundleB = resolver.getBundle(bundleB);
- ImportPackage importPackage =
resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
- Set<String> importAttributes = importPackage.getAttributes();
- assertTrue("Contains attr",
importAttributes.contains("test"));
- assertEquals("y", importPackage.getAttribute("test"));
- assertFalse("Attribute no match",
exportPackage.matchAttributes(importPackage));
- }
- finally
- {
- bundleB.uninstall();
- }
- }
- finally
- {
- bundleA.uninstall();
- }
- }
-}
\ No newline at end of file
Copied:
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
(from rev 101772,
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java)
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java
(rev 0)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/testsuite/src/test/java/org/jboss/test/osgi/resolver/ResolverMetadataTest.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -0,0 +1,450 @@
+/*
+ * 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.resolver;
+
+// $Id$
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.osgi.framework.resolver.ExportPackage;
+import org.jboss.osgi.framework.resolver.ImportPackage;
+import org.jboss.osgi.framework.resolver.RequiredBundle;
+import org.jboss.osgi.framework.resolver.Resolver;
+import org.jboss.osgi.framework.resolver.ResolverBundle;
+import org.jboss.osgi.vfs.VirtualFile;
+import org.jboss.test.osgi.classloader.support.a.A;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Version;
+
+/**
+ * Test {@link Resolver} metadata.
+ *
+ * @author thomas.diesler(a)jboss.com
+ * @since 09-Nov-2009
+ */
+public class ResolverMetadataTest extends AbstractResolverTest
+{
+ @Test
+ public void testSimpleExport() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ if (resolver == null)
+ return;
+
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ assertEquals(1, resolver.getBundles().size());
+
+ ResolverBundle resBundleA = resolver.getBundle(bundleA.getSymbolicName(),
null);
+ assertNotNull("Resolvable not null", resBundleA);
+
+ resBundleA = resolver.getBundle(bundleA.getSymbolicName(),
bundleA.getVersion());
+ assertNotNull("Resolvable not null", resBundleA);
+
+ resBundleA = resolver.getBundle(bundleA);
+ assertNotNull("Resolvable not null", resBundleA);
+
+ assertNotNull(resBundleA.getBundle());
+ assertEquals("simpleexport", resBundleA.getSymbolicName());
+ assertEquals(Version.emptyVersion, resBundleA.getVersion());
+
+ List<ExportPackage> exportPackages = resBundleA.getExportPackages();
+ assertNotNull("ExportPackages not null", exportPackages);
+ assertEquals(1, exportPackages.size());
+
+ ExportPackage exportPackage =
resBundleA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
+ assertNotNull("ExportPackage not null", exportPackage);
+ assertEquals("org.jboss.test.osgi.classloader.support.a",
exportPackage.getName());
+
+ assertEquals(Version.emptyVersion, exportPackage.getVersion());
+ assertEquals(0, exportPackage.getUses().size());
+ assertEquals(0, exportPackage.getMandatory().size());
+ assertNull("Null includes", exportPackage.getIncludes());
+ assertNull("Null excludes", exportPackage.getExcludes());
+
+ List<ImportPackage> importPackages = resBundleA.getImportPackages();
+ assertNotNull("ImportPackages not null", importPackages);
+ assertEquals(0, importPackages.size());
+
+ assertFalse("No sigleton", resBundleA.isSingleton());
+ assertFalse("Not resolved", resBundleA.isResolved());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testSimpleImport() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ if (resolver == null)
+ return;
+
+ // Bundle-SymbolicName: simpleimport
+ // Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleimport");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ ResolverBundle resBundleA = resolver.getBundle(bundleA);
+
+ List<ImportPackage> importPackages = resBundleA.getImportPackages();
+ assertNotNull("ImportPackages not null", importPackages);
+ assertEquals(1, importPackages.size());
+
+ ImportPackage importPackage =
resBundleA.getImportPackage("org.jboss.test.osgi.classloader.support.a");
+ assertNotNull("ImportPackage not null", importPackage);
+ assertEquals("org.jboss.test.osgi.classloader.support.a",
importPackage.getName());
+
+ assertEquals("[0.0.0,?)", importPackage.getVersion().toString());
+ assertNull("Null bundle-symbolic-name",
importPackage.getBundleSymbolicName());
+ assertNull("Null bundle-version", importPackage.getBundleVersion());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testSingleton() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ if (resolver == null)
+ return;
+
+ // Bundle-SymbolicName: singleton;singleton:=true
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/singleton", A.class);
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ ResolverBundle resBundleA = resolver.getBundle(bundleA);
+ assertTrue("Sigleton", resBundleA.isSingleton());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testRequireBundle() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ if (resolver == null)
+ return;
+
+ //Bundle-SymbolicName: requirebundle
+ //Require-Bundle: simpleexport
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundle");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ ResolverBundle resBundleA = resolver.getBundle(bundleA);
+ List<RequiredBundle> requiredBundles = resBundleA.getRequiredBundles();
+ assertEquals("RequiredBundles not null", 1, requiredBundles.size());
+ RequiredBundle reqBundle = requiredBundles.get(0);
+ assertEquals("simpleexport", reqBundle.getSymbolicName());
+ assertNull("Null version", reqBundle.getVersion());
+ assertFalse("Not optional", reqBundle.isOptional());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testRequireBundleOptional() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ if (resolver == null)
+ return;
+
+ //Bundle-SymbolicName: requirebundle
+ //Require-Bundle: simpleexport;resolution:=optional
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleoptional");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ ResolverBundle resBundleA = resolver.getBundle(bundleA);
+ List<RequiredBundle> requiredBundles = resBundleA.getRequiredBundles();
+ assertEquals("RequiredBundles not null", 1, requiredBundles.size());
+ RequiredBundle reqBundle = requiredBundles.get(0);
+ assertEquals("simpleexport", reqBundle.getSymbolicName());
+ assertNull("Null version", reqBundle.getVersion());
+ assertTrue("Resolution optional", reqBundle.isOptional());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testRequireBundleVersion() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ if (resolver == null)
+ return;
+
+ //Bundle-SymbolicName: requirebundle
+ //Require-Bundle: simpleexport;bundle-version="[0.0.0,1.0.0]"
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/requirebundleversion");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ ResolverBundle resBundleA = resolver.getBundle(bundleA);
+ List<RequiredBundle> requiredBundles = resBundleA.getRequiredBundles();
+ assertEquals("RequiredBundles not null", 1, requiredBundles.size());
+ RequiredBundle reqBundle = requiredBundles.get(0);
+ assertEquals("simpleexport", reqBundle.getSymbolicName());
+ assertNotNull("Version not null", reqBundle.getVersion());
+ assertFalse("Not optional", reqBundle.isOptional());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPackageAttribute() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ if (resolver == null)
+ return;
+
+ //Bundle-SymbolicName: packageexportattribute
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattribute");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ ResolverBundle resBundleA = resolver.getBundle(bundleA);
+ ExportPackage exportPackage =
resBundleA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
+ Set<String> exportAttributes = exportPackage.getAttributes();
+ assertTrue("Contains attr",
exportAttributes.contains("test"));
+ assertEquals("x", exportPackage.getAttribute("test"));
+
+ //Bundle-SymbolicName: simpleimport
+ //Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleimport");
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ ResolverBundle resBundleB = resolver.getBundle(bundleB);
+ ImportPackage importPackage =
resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
+ assertTrue("Attribute match",
exportPackage.matchAttributes(importPackage));
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+
+ //Bundle-SymbolicName: packageimportattribute
+ //Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
+ fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattribute");
+ bundleB = framework.installBundle(fileB);
+ try
+ {
+ ResolverBundle resBundleB = resolver.getBundle(bundleB);
+ ImportPackage importPackage =
resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
+ Set<String> importAttributes = importPackage.getAttributes();
+ assertTrue("Contains attr",
importAttributes.contains("test"));
+ assertEquals("x", importPackage.getAttribute("test"));
+ assertTrue("Attribute match",
exportPackage.matchAttributes(importPackage));
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPackageAttributeFails() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ if (resolver == null)
+ return;
+
+ //Bundle-SymbolicName: packageexportattribute
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattribute");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ ResolverBundle resBundleA = resolver.getBundle(bundleA);
+ ExportPackage exportPackage =
resBundleA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
+ Set<String> attributes = exportPackage.getAttributes();
+ assertTrue("Contains attr", attributes.contains("test"));
+ assertEquals("x", exportPackage.getAttribute("test"));
+
+ //Bundle-SymbolicName: packageimportattributefails
+ //Import-Package: org.jboss.test.osgi.classloader.support.a;test=y
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattributefails");
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ ResolverBundle resBundleB = resolver.getBundle(bundleB);
+ ImportPackage importPackage =
resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
+ Set<String> importAttributes = importPackage.getAttributes();
+ assertTrue("Contains attr",
importAttributes.contains("test"));
+ assertEquals("y", importPackage.getAttribute("test"));
+ assertFalse("Attribute no match",
exportPackage.matchAttributes(importPackage));
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPackageAttributeMandatory() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ if (resolver == null)
+ return;
+
+ //Bundle-SymbolicName: packageexportattributemandatory
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattributemandatory");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ ResolverBundle resBundleA = resolver.getBundle(bundleA);
+ ExportPackage exportPackage =
resBundleA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
+ Set<String> attributes = exportPackage.getAttributes();
+ assertTrue("Contains test", attributes.contains("test"));
+ assertEquals("x", exportPackage.getAttribute("test"));
+ Set<String> mandatory = exportPackage.getMandatory();
+ assertTrue("Contains test", mandatory.contains("test"));
+
+ //Bundle-SymbolicName: packageimportattribute
+ //Import-Package: org.jboss.test.osgi.classloader.support.a;test=x
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattribute");
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ ResolverBundle resBundleB = resolver.getBundle(bundleB);
+ ImportPackage importPackage =
resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
+ Set<String> importAttributes = importPackage.getAttributes();
+ assertTrue("Contains attr",
importAttributes.contains("test"));
+ assertEquals("x", importPackage.getAttribute("test"));
+ assertTrue("Attribute match",
exportPackage.matchAttributes(importPackage));
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testPackageAttributeMandatoryFails() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ if (resolver == null)
+ return;
+
+ //Bundle-SymbolicName: packageexportattributemandatory
+ //Export-Package: org.jboss.test.osgi.classloader.support.a;test=x;mandatory:=test
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageexportattributemandatory");
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ ResolverBundle resBundleA = resolver.getBundle(bundleA);
+ ExportPackage exportPackage =
resBundleA.getExportPackage("org.jboss.test.osgi.classloader.support.a");
+ Set<String> attributes = exportPackage.getAttributes();
+ assertTrue("Contains test", attributes.contains("test"));
+ assertEquals("x", exportPackage.getAttribute("test"));
+ Set<String> mandatory = exportPackage.getMandatory();
+ assertTrue("Contains test", mandatory.contains("test"));
+
+ //Bundle-SymbolicName: simpleimport
+ //Import-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleimport");
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ ResolverBundle resBundleB = resolver.getBundle(bundleB);
+ ImportPackage importPackage =
resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
+ assertFalse("Attribute no match",
exportPackage.matchAttributes(importPackage));
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+
+ //Bundle-SymbolicName: packageimportattributefails
+ //Import-Package: org.jboss.test.osgi.classloader.support.a;test=y
+ fileB = assembleBundle("bundleB",
"/bundles/resolver/packageimportattributefails");
+ bundleB = framework.installBundle(fileB);
+ try
+ {
+ ResolverBundle resBundleB = resolver.getBundle(bundleB);
+ ImportPackage importPackage =
resBundleB.getImportPackage("org.jboss.test.osgi.classloader.support.a");
+ Set<String> importAttributes = importPackage.getAttributes();
+ assertTrue("Contains attr",
importAttributes.contains("test"));
+ assertEquals("y", importPackage.getAttribute("test"));
+ assertFalse("Attribute no match",
exportPackage.matchAttributes(importPackage));
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+}
\ No newline at end of file
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/vfs21 (from rev 101768,
projects/jboss-osgi/projects/runtime/framework/trunk/core)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/.classpath
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/.classpath 2010-03-03
10:22:49 UTC (rev 101768)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/.classpath 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" output="target/classes"
path="src/main/java"/>
- <classpathentry excluding="**" kind="src"
output="target/classes" path="src/main/resources"/>
- <classpathentry kind="src" output="target/test-classes"
path="src/test/java"/>
- <classpathentry excluding="**" kind="src"
output="target/test-classes" path="src/test/resources"/>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con"
path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Deleted: projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/pom.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml 2010-03-03 10:22:49
UTC (rev 101768)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/pom.xml 2010-03-03 14:45:40
UTC (rev 101775)
@@ -1,371 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!-- ====================================================================== -->
-<!-- -->
-<!-- JBoss, the OpenSource J2EE webOS -->
-<!-- -->
-<!-- Distributable under LGPL license. -->
-<!-- See terms of license at
http://www.gnu.org. -->
-<!-- -->
-<!-- ====================================================================== -->
-
-<!-- $Id$ -->
-
-<!-- Set these VM properties in your IDE debugger
-Dlog4j.output.dir=${workspace_loc:jboss-osgi-framework/target}
-Dlog4j.configuration=log4j-console.xml -->
-
-<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <name>JBossOSGi Framework - Core</name>
- <groupId>org.jboss.osgi.framework</groupId>
- <artifactId>jboss-osgi-framework</artifactId>
- <packaging>bundle</packaging>
-
- <parent>
- <groupId>org.jboss.osgi.framework</groupId>
- <artifactId>jboss-osgi-framework-parent</artifactId>
- <version>1.0.0.Alpha4-SNAPSHOT</version>
- </parent>
-
- <dependencies>
- <dependency>
- <groupId>org.jboss.osgi.framework</groupId>
- <artifactId>jboss-osgi-framework-metadata</artifactId>
- <version>${version}</version>
- </dependency>
- <dependency>
- <groupId>biz.aQute</groupId>
- <artifactId>bnd</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.cl</groupId>
- <artifactId>jboss-classloader</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.cl</groupId>
- <artifactId>jboss-classloading</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.cl</groupId>
- <artifactId>jboss-classloading-vfs</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-client-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-core-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-impl</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-structure-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-vfs-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-vfs</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.deployers</groupId>
- <artifactId>jboss-deployers-jmx</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.kernel</groupId>
- <artifactId>jboss-kernel</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.kernel</groupId>
- <artifactId>jboss-jmx-aop-mc-int</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.kernel</groupId>
- <artifactId>jboss-jmx-mc-int</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.kernel</groupId>
- <artifactId>jboss-dependency</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-mdr</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-spi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.runtime</groupId>
- <artifactId>jboss-osgi-deployers</artifactId>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.runtime</groupId>
- <artifactId>jboss-osgi-deployment</artifactId>
- </dependency>
-
- <!-- OSGi Dependencies -->
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
-
- <!-- Test bundles dependencies -->
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.configadmin</artifactId>
- <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.apache.felix</groupId>
- <artifactId>org.apache.felix.log</artifactId>
- <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.apache.felix</groupId>
- <artifactId>org.apache.felix.metatype</artifactId>
- <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-apache-xerces</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-common</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-common-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-husky</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-jaxb</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.jmx</groupId>
- <artifactId>jboss-osgi-jmx</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.jndi</groupId>
- <artifactId>jboss-osgi-jndi</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-reflect</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi.bundles</groupId>
- <artifactId>jboss-osgi-xml-binding</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.web</groupId>
- <artifactId>pax-web-jetty-bundle</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!-- Test Dependencies -->
- <dependency>
- <groupId>org.jboss.test</groupId>
- <artifactId>jboss-test</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.jboss</groupId>
- <artifactId>jboss-common-core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-spi</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.jboss.osgi</groupId>
- <artifactId>jboss-osgi-testing</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <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>
- <execution>
- <id>all</id>
- <phase>package</phase>
- <goals>
- <goal>single</goal>
- </goals>
- <configuration>
- <descriptors>
- <descriptor>scripts/assembly-all.xml</descriptor>
- </descriptors>
- <archive>
-
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
- </archive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>build-test-jars</id>
- <phase>test-compile</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <tasks>
- <property name="maven.runtime.classpath"
refid="maven.runtime.classpath" />
- <property name="tests.output.dir"
value="${project.build.directory}" />
- <ant antfile="scripts/antrun-test-jars.xml" />
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-idea-plugin</artifactId>
- <configuration>
- <downloadSources>true</downloadSources>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
-
<Bundle-SymbolicName>org.jboss.osgi.framework</Bundle-SymbolicName>
- <Bundle-Name>JBossOSGi Framework</Bundle-Name>
- <Bundle-Version>${version}</Bundle-Version>
- <Export-Package>
- org.osgi.framework;version="1.5",
- org.osgi.framework.launch;version="1.0",
- org.osgi.framework.hooks.service;version="1.0",
- org.osgi.service.packageadmin;version="1.2",
- org.osgi.service.startlevel;version="1.1",
- org.osgi.util.tracker;version="1.4"
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <argLine>-Xmx512m</argLine>
- <systemProperties>
- <property>
- <name>log4j.output.dir</name>
- <value>${project.build.directory}</value>
- </property>
- <property>
- <name>org.jboss.osgi.framework.launch.bootstrapPath</name>
- <value>bootstrap/jboss-osgi-bootstrap.xml</value>
- </property>
- <property>
- <name>org.jboss.osgi.husky.Invoker</name>
- <value>org.jboss.osgi.husky.internal.AbstractInvoker</value>
- </property>
- <property>
- <name>test.archive.directory</name>
- <value>${project.build.directory}/test-libs</value>
- </property>
- </systemProperties>
- <excludes>
- <!-- excludes listed here need to have a jira issue associated
<exclude>org/jboss/test/osgi/service/ServiceMixUnitTestCase.class</exclude>
-->
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
Copied: projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/pom.xml (from rev
101772, projects/jboss-osgi/projects/runtime/framework/trunk/core/pom.xml)
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/pom.xml
(rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/pom.xml 2010-03-03 14:45:40
UTC (rev 101775)
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!-- -->
+<!-- JBoss, the OpenSource J2EE webOS -->
+<!-- -->
+<!-- Distributable under LGPL license. -->
+<!-- See terms of license at
http://www.gnu.org. -->
+<!-- -->
+<!-- ====================================================================== -->
+
+<!-- $Id$ -->
+
+<!-- Set these VM properties in your IDE debugger
-Dlog4j.output.dir=${workspace_loc:jboss-osgi-framework/target}
-Dlog4j.configuration=log4j-console.xml -->
+
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>JBossOSGi Framework - VFS21</name>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-vfs21</artifactId>
+ <packaging>jar</packaging>
+
+ <parent>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework-parent</artifactId>
+ <version>1.0.0.Alpha4-SNAPSHOT</version>
+ </parent>
+
+ <!-- Properties -->
+ <properties>
+ <version.jboss.vfs>2.1.3.SP1</version.jboss.vfs>
+ </properties>
+
+ <!-- Dependencies -->
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.osgi.framework</groupId>
+ <artifactId>jboss-osgi-framework</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-vfs</artifactId>
+ <version>${version.jboss.vfs}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ </plugins>
+ </build>
+</project>
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleCapability.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,160 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-import java.util.Map;
-
-import org.jboss.classloading.plugins.metadata.ModuleCapability;
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.classloading.spi.metadata.Requirement;
-import org.jboss.classloading.spi.version.VersionRange;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.framework.metadata.Parameter;
-import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
-
-/**
- * OSGiBundleCapability.
- *
- * todo BundlePermission/PROVIDE
- * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
- * @author Thomas.Diesler(a)jboss.com
- * @version $Revision: 1.1 $
- */
-public class OSGiBundleCapability extends ModuleCapability
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 2366716668262831380L;
-
- /** The bundle state */
- private AbstractBundleState bundleState;
-
- /**
- * Create a new OSGiBundleCapability
- *
- * @param bundleState the bundleState
- * @return the capability
- * @throws IllegalArgumentException for a null metadata
- */
- public static OSGiBundleCapability create(AbstractBundleState bundleState)
- {
- if (bundleState == null)
- throw new IllegalArgumentException("Null bundleState");
-
- String symbolicName = bundleState.getSymbolicName();
- Version version = bundleState.getVersion();
-
- return new OSGiBundleCapability(symbolicName, version, bundleState);
- }
-
- /**
- * Create a new OSGiBundleCapability.
- *
- * @param name the name
- * @param version the version pass null of the default version
- * @param metadata the metadata
- * @throws IllegalArgumentException for a null name or requireBundle
- */
- public OSGiBundleCapability(String name, Version version, AbstractBundleState
bundleState)
- {
- super(name, version);
- if (bundleState == null)
- throw new IllegalArgumentException("Null bundleState");
- this.bundleState = bundleState;
- }
-
- /**
- * Get the metadata.
- *
- * @return the metadata.
- */
- public OSGiMetaData getMetaData()
- {
- return bundleState.getOSGiMetaData();
- }
-
- @Override
- public boolean resolves(Module reqModule, Requirement requirement)
- {
- if (super.resolves(reqModule, requirement) == false)
- return false;
- if (requirement instanceof OSGiBundleRequirement == false)
- return true;
-
- // Review its not clear to me from the spec whether attribute matching
- // beyond the version should work for require-bundle?
- Version ourVersion = Version.parseVersion(getMetaData().getBundleVersion());
- OSGiBundleRequirement bundleRequirement = (OSGiBundleRequirement)requirement;
- VersionRange requiredRange = bundleRequirement.getVersionRange();
- if (requiredRange.isInRange(ourVersion) == false)
- return false;
-
- ParameterizedAttribute ourParameters = getMetaData().getBundleParameters();
- if (ourParameters == null)
- return false;
-
- Map<String, Parameter> params = bundleRequirement.getAttributes();
- if (params != null && params.isEmpty() == false)
- {
- for (String name : params.keySet())
- {
- if (Constants.BUNDLE_VERSION_ATTRIBUTE.equals(name))
- continue;
-
- String reqValue = (String)params.get(name).getValue();
- String ourValue = ourParameters.getAttributeValue(name, String.class);
- if (reqValue.equals(ourValue) == false)
- return false;
- }
- }
-
- return true;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- return true;
- if (obj == null || obj instanceof OSGiBundleCapability == false)
- return false;
- if (super.equals(obj) == false)
- return false;
- OSGiBundleCapability other = (OSGiBundleCapability)obj;
- return getMetaData().equals(other.getMetaData());
- }
-
- @Override
- protected void toString(StringBuffer buffer)
- {
- super.toString(buffer);
- ParameterizedAttribute parameters = getMetaData().getBundleParameters();
- if (parameters != null)
- {
- Map<String, Parameter> params = parameters.getAttributes();
- if (params != null && params.isEmpty() == false)
- buffer.append(" attributes=").append(params);
- }
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleRequirement.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleRequirement.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiBundleRequirement.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,143 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.classloading.plugins.metadata.ModuleRequirement;
-import org.jboss.classloading.spi.version.VersionRange;
-import org.jboss.osgi.framework.metadata.Parameter;
-import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
-import org.jboss.osgi.framework.metadata.internal.AbstractVersionRange;
-import org.osgi.framework.Constants;
-
-/**
- * OSGiBundleRequirement.
- *
- * todo BundlePermission/REQUIRE
- * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
- * @author Thomas.Diesler(a)jboss.com
- * @version $Revision: 1.1 $
- */
-public class OSGiBundleRequirement extends ModuleRequirement
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 4264597072894634275L;
-
- private String visibility;
- private String resolution;
- private Map<String, Parameter> attributes;
-
- /**
- * Create a new OSGiBundleRequirement.
- *
- * @param requireBundle the require bundle metadata
- * @return the requirement
- * @throws IllegalArgumentException for a null requireBundle
- */
- public static OSGiBundleRequirement create(ParameterizedAttribute requireBundle)
- {
- if (requireBundle == null)
- throw new IllegalArgumentException("Null require bundle");
-
- String name = requireBundle.getAttribute();
-
- AbstractVersionRange range = null;
- String version =
requireBundle.getAttributeValue(Constants.BUNDLE_VERSION_ATTRIBUTE, String.class);
- if (version != null)
- range = (AbstractVersionRange)AbstractVersionRange.valueOf(version);
-
- String visibility = requireBundle.getDirectiveValue(Constants.VISIBILITY_DIRECTIVE,
String.class);
- String resolution = requireBundle.getDirectiveValue(Constants.RESOLUTION_DIRECTIVE,
String.class);
- Map<String, Parameter> attributes = requireBundle.getAttributes();
-
- return new OSGiBundleRequirement(name, range, visibility, resolution, attributes);
- }
-
- /**
- * Create a new bundle requirement.
- *
- * @param name the symbolic name of the required bundle
- * @param versionRange the version range of the required bundle
- */
- public static OSGiBundleRequirement create(String name, VersionRange versionRange)
- {
- return new OSGiBundleRequirement(name, versionRange, Constants.VISIBILITY_PRIVATE,
Constants.RESOLUTION_MANDATORY, null);
- }
-
- /**
- * Create a new OSGiBundleRequirement.
- */
- private OSGiBundleRequirement(String name, VersionRange versionRange, String
visDirective, String resDirective, Map<String, Parameter> attrMap)
- {
- super(name, versionRange);
-
- attributes = attrMap;
- if (attributes == null)
- attributes = new HashMap<String, Parameter>();
-
- visibility = visDirective;
- if (visibility == null)
- visibility = Constants.VISIBILITY_PRIVATE;
-
- resolution = resDirective;
- if (resolution == null)
- resolution = Constants.RESOLUTION_MANDATORY;
-
- if (Constants.VISIBILITY_REEXPORT.equals(visibility))
- setReExport(true);
-
- if (Constants.RESOLUTION_OPTIONAL.equals(resolution))
- setOptional(true);
- }
-
- public Map<String, Parameter> getAttributes()
- {
- return Collections.unmodifiableMap(attributes);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- return true;
- if (obj == null || obj instanceof OSGiBundleRequirement == false)
- return false;
- if (super.equals(obj) == false)
- return false;
-
- return true;
- }
-
- @Override
- protected void toString(StringBuffer buffer)
- {
- super.toString(buffer);
- if (attributes.containsKey(Constants.VISIBILITY_DIRECTIVE) == false)
- buffer.append(Constants.VISIBILITY_DIRECTIVE + ":=" + visibility);
- if (attributes.containsKey(Constants.RESOLUTION_DIRECTIVE) == false)
- buffer.append(Constants.RESOLUTION_DIRECTIVE + ":=" + resolution);
- buffer.append(attributes);
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoading.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoading.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoading.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,37 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-// $Id$
-
-import org.jboss.classloading.spi.dependency.ClassLoading;
-
-/**
- * The ClassLoading for OSGi bundles.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 05-Jan-2010
- */
-public class OSGiClassLoading extends ClassLoading
-{
-
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiClassLoadingMetaData.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,146 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-// $Id$
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.osgi.framework.metadata.NativeLibraryMetaData;
-import org.osgi.framework.Version;
-
-/**
- * An extension of {@link ClassLoadingMetaData} that captures OSGi specific
- * classloading metadata.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 08-Jan-2010
- */
-public class OSGiClassLoadingMetaData extends ClassLoadingMetaData
-{
- private static final long serialVersionUID = 1L;
-
- // The optional fragment host
- private FragmentHostMetaData fragmentHost;
-
- // The list of attached fragment classloading metadata
- private List<OSGiClassLoadingMetaData> attachedFragments = new
ArrayList<OSGiClassLoadingMetaData>();
-
- // The native code libraries
- private NativeLibraryMetaData libraries = new NativeLibraryMetaData();
-
- public FragmentHostMetaData getFragmentHost()
- {
- return fragmentHost;
- }
-
- public void setFragmentHost(FragmentHostMetaData fragmentHost)
- {
- this.fragmentHost = fragmentHost;
- }
-
- public List<OSGiClassLoadingMetaData> getAttachedClassLoadingMetaData()
- {
- return Collections.unmodifiableList(attachedFragments);
- }
-
- public void attachClassLoadingMetaData(OSGiClassLoadingMetaData fragment)
- {
- if (fragment == null)
- throw new IllegalArgumentException("Null fragment");
- if (fragment.getFragmentHost() == null)
- throw new IllegalArgumentException("Not a fragment: " + fragment);
- if (getFragmentHost() != null)
- throw new IllegalArgumentException("Cannot attach a fragment to a fragment:
" + fragment);
-
- attachedFragments.add(fragment);
- }
-
- /**
- * Get the native libraries.
- *
- * @return the native libraries.
- */
- public NativeLibraryMetaData getNativeLibraries()
- {
- return libraries;
- }
-
- /**
- * Set the native libraries.
- *
- * @param nativeLibraries libraries the native libraries.
- * @throws IllegalArgumentException for null native libraries
- */
- public void setNativeLibraries(NativeLibraryMetaData nativeLibraries)
- {
- if (nativeLibraries == null)
- throw new IllegalArgumentException("Null libraries");
- this.libraries = nativeLibraries;
- }
-
- /**
- * Fragment-Host metadata.
- */
- public static class FragmentHostMetaData
- {
- private String symbolicName;
- private Version bundleVersion;
- private String extension;
-
- public FragmentHostMetaData(String symbolicName)
- {
- if (symbolicName == null)
- throw new IllegalArgumentException("Null symbolicName");
-
- this.symbolicName = symbolicName;
- }
-
- public String getSymbolicName()
- {
- return symbolicName;
- }
-
- public Version getBundleVersion()
- {
- return bundleVersion;
- }
-
- public String getExtension()
- {
- return extension;
- }
-
- public void setExtension(String extension)
- {
- this.extension = extension;
- }
-
- public void setBundleVersion(Version bundleVersion)
- {
- this.bundleVersion = bundleVersion;
- }
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiCoreClassFilter.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiCoreClassFilter.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiCoreClassFilter.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,72 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-// $Id: $
-
-import org.jboss.classloader.spi.filter.PackageClassFilter;
-
-/**
- * A class filter for OSGi Core packages.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 02-Feb-2010
- */
-public final class OSGiCoreClassFilter extends PackageClassFilter
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 5679852972501066041L;
-
- /** The singleton instance */
- public static OSGiCoreClassFilter INSTANCE = new OSGiCoreClassFilter();
-
- private OSGiCoreClassFilter()
- {
- super(getCorePackages());
- }
-
- public static String[] getCorePackages()
- {
- return new String[] {
- "org.osgi.framework",
- "org.osgi.framework.hooks",
- "org.osgi.framework.hooks.service",
- "org.osgi.framework.launch",
- "org.osgi.service.condpermadmin",
- "org.osgi.service.packageadmin",
- "org.osgi.service.permissionadmin",
- "org.osgi.service.startlevel",
- "org.osgi.service.url"
- };
- }
-
- public String toString()
- {
- return "OSGI_CORE";
- }
-
- @Override
- public void setIncludeJava(boolean includeJava)
- {
- throw new UnsupportedOperationException("Cannot modify OSGi Core
Filter");
- }
-}
\ No newline at end of file
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiModule.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiModule.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiModule.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,44 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule;
-
-/**
- * The {@link Module} that represents and OSGi bundle deployment.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @version $Revision$
- */
-public class OSGiModule extends VFSDeploymentClassLoaderPolicyModule
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 1L;
-
- public OSGiModule(DeploymentUnit unit, ClassLoadingMetaData metaData)
- {
- super(unit);
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageCapability.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,295 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.jboss.classloading.plugins.metadata.PackageCapability;
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.classloading.spi.metadata.Requirement;
-import org.jboss.classloading.spi.version.VersionRange;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.framework.metadata.PackageAttribute;
-import org.jboss.osgi.framework.metadata.Parameter;
-import org.jboss.osgi.framework.metadata.internal.AbstractVersionRange;
-import org.jboss.osgi.framework.plugins.ResolverPlugin;
-import org.jboss.osgi.framework.resolver.Resolver;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
-
-/**
- * OSGiPackageCapability.
- *
- * todo PackagePermission/EXPORT todo uses todo include/exclude
- *
- * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
- * @author Thomas.Diesler(a)jboss.com
- * @version $Revision: 1.1 $
- */
-public class OSGiPackageCapability extends PackageCapability
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 3940667616588052822L;
-
- /** The bundle state */
- private AbstractBundleState bundleState;
-
- /** The export package */
- private PackageAttribute exportPackage;
-
- /** The mandatory attributes */
- private String[] mandatoryAttributes;
-
- /**
- * Create a new OSGiPackageCapability.
- *
- * @param bundleState the bundle state
- * @param exportPackage the export package metadata
- * @return the capability
- * @throws IllegalArgumentException for null metadata
- */
- @SuppressWarnings("deprecation")
- public static OSGiPackageCapability create(AbstractBundleState bundleState,
PackageAttribute exportPackage)
- {
- if (bundleState == null)
- throw new IllegalArgumentException("Null bundle");
-
- String name = exportPackage.getAttribute();
- String versionString = exportPackage.getAttributeValue(Constants.VERSION_ATTRIBUTE,
String.class);
-
- String oldVersionString =
exportPackage.getAttributeValue(Constants.PACKAGE_SPECIFICATION_VERSION, String.class);
- if (oldVersionString != null)
- {
- if (versionString != null && versionString.equals(oldVersionString) ==
false)
- throw new IllegalStateException(Constants.VERSION_ATTRIBUTE + " of
" + versionString + " does not match " +
Constants.PACKAGE_SPECIFICATION_VERSION
- + " of " + oldVersionString);
- if (versionString == null)
- versionString = oldVersionString;
- }
-
- Version version = null;
- if (versionString != null)
- {
- // Handle version strings with quotes
- if (versionString.startsWith("\"") &&
versionString.endsWith("\""))
- versionString = versionString.substring(1, versionString.length() - 1);
-
- version = Version.parseVersion(versionString);
- }
-
- OSGiPackageCapability capability = new OSGiPackageCapability(bundleState, name,
version, exportPackage);
- capability.setSplitPackagePolicy(SplitPackagePolicy.First);
-
- return capability;
- }
-
- private OSGiPackageCapability(AbstractBundleState bundleState, String name, Version
version, PackageAttribute exportPackage)
- {
- super(name, version);
- this.bundleState = bundleState;
- this.exportPackage = exportPackage;
-
- String mandatory = exportPackage.getDirectiveValue(Constants.MANDATORY_DIRECTIVE,
String.class);
- if (mandatory != null)
- {
- StringTokenizer tokens = new StringTokenizer(mandatory, ",");
- mandatoryAttributes = new String[tokens.countTokens()];
- int i = 0;
- while (tokens.hasMoreTokens())
- mandatoryAttributes[i++] = tokens.nextToken();
- }
-
- if (exportPackage.getAttribute(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE) != null)
- throw new IllegalStateException("You cannot specify " +
Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE + " on an Export-Package");
- if (exportPackage.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE) != null)
- throw new IllegalStateException("You cannot specify " +
Constants.BUNDLE_VERSION_ATTRIBUTE + " on an Export-Package");
- }
-
- @Override
- public boolean resolves(Module reqModule, Requirement requirement)
- {
- if (super.resolves(reqModule, requirement) == false)
- return false;
- if (requirement instanceof OSGiPackageRequirement == false)
- return true;
-
- OSGiPackageRequirement osgiPackageRequirement =
(OSGiPackageRequirement)requirement;
- if (matchPackageAttributes(osgiPackageRequirement) == false)
- return false;
-
- OSGiBundleManager bundleManager = bundleState.getBundleManager();
- Resolver bundleResolver = bundleManager.getOptionalPlugin(ResolverPlugin.class);
- if (bundleResolver != null)
- {
- // Get the bundle associated with the requirement
- String reqLocation = reqModule.getContextName();
- AbstractBundleState reqBundle = bundleManager.getBundleByLocation(reqLocation);
- if (reqBundle == null)
- throw new IllegalStateException("Cannot get bundle for: " +
reqLocation);
-
- // Get the exporter for this requirement
- if (reqBundle instanceof OSGiBundleState)
- {
- String packageName = osgiPackageRequirement.getName();
- return bundleResolver.match(reqBundle, bundleState, packageName);
- }
- }
-
- return true;
- }
-
- /**
- * Get the Module associated with this capability
- *
- * @return the module
- */
- public Module getModule()
- {
- Module module = null;
- if (bundleState instanceof AbstractDeployedBundleState)
- {
- AbstractDeployedBundleState depBundle =
(AbstractDeployedBundleState)bundleState;
- DeploymentUnit unit = depBundle.getDeploymentUnit();
- module = unit.getAttachment(Module.class);
- if (module == null)
- throw new IllegalStateException("Cannot obtain module from: " +
bundleState);
- }
- return module;
- }
-
- @SuppressWarnings("deprecation")
- public boolean matchPackageAttributes(OSGiPackageRequirement packageRequirement)
- {
- String capPackageName = getName();
- String reqPackageName = packageRequirement.getName();
- if (capPackageName.equals(reqPackageName) == false)
- return false;
-
- VersionRange reqVersionRange = packageRequirement.getVersionRange();
- Object capVersion = getVersion();
- if (reqVersionRange.isInRange(capVersion) == false)
- return false;
-
- OSGiMetaData osgiMetaData = bundleState.getOSGiMetaData();
- PackageAttribute capParameters = exportPackage;
- PackageAttribute reqParameters = packageRequirement.getPackageMetaData();
-
- boolean validMatch = true;
-
- // Check all the manadatory attributes are present
- if (validMatch == true && mandatoryAttributes != null)
- {
- for (String mand : mandatoryAttributes)
- {
- Parameter reqAttributeValue = reqParameters.getAttribute(mand);
- if (reqParameters == null || reqAttributeValue == null)
- {
- validMatch = false;
- break;
- }
- }
- }
-
- if (validMatch == true && reqParameters != null)
- {
- Map<String, Parameter> params = reqParameters.getAttributes();
- if (params != null && params.isEmpty() == false)
- {
- for (String name : params.keySet())
- {
- String otherValue = reqParameters.getAttributeValue(name, String.class);
- String ourValue = capParameters.getAttributeValue(name, String.class);
-
- if (Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE.equals(name))
- {
- if (otherValue.equals(osgiMetaData.getBundleSymbolicName()) == false)
- validMatch = false;
- }
- else if (Constants.BUNDLE_VERSION_ATTRIBUTE.equals(name))
- {
- VersionRange range =
(VersionRange)AbstractVersionRange.valueOf(otherValue);
- if (range.isInRange(osgiMetaData.getBundleVersion()) == false)
- validMatch = false;
- }
- else if (Constants.PACKAGE_SPECIFICATION_VERSION.equals(name) ||
Constants.VERSION_ATTRIBUTE.equals(name))
- {
- continue;
- }
- else
- {
- if (ourValue == null || ourValue.equals(otherValue) == false)
- validMatch = false;
- }
-
- if (validMatch == false)
- break;
- }
- }
- }
-
- return validMatch;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- return true;
- if (obj == null || obj instanceof OSGiPackageCapability == false)
- return false;
- if (super.equals(obj) == false)
- return false;
-
- return true;
- }
-
- private String shortString;
-
- public String toShortString()
- {
- if (shortString == null)
- {
- StringBuffer buffer = new StringBuffer(bundleState.getCanonicalName() +
"[" + getName());
- Map<String, Parameter> attributes = exportPackage.getAttributes();
- Map<String, Parameter> directives = exportPackage.getDirectives();
- for (Map.Entry<String, Parameter> entry : directives.entrySet())
- buffer.append(";" + entry.getKey() + ":=" +
entry.getValue().getValue());
- for (Map.Entry<String, Parameter> entry : attributes.entrySet())
- buffer.append(";" + entry.getKey() + "=" +
entry.getValue().getValue());
- buffer.append("]");
- shortString = buffer.toString();
- }
- return shortString;
- }
-
- @Override
- protected void toString(StringBuffer buffer)
- {
- buffer.append(toShortString());
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageRequirement.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageRequirement.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/classloading/OSGiPackageRequirement.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,182 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.classloading;
-
-import java.util.Map;
-
-import org.jboss.classloading.plugins.metadata.PackageRequirement;
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.classloading.spi.version.VersionRange;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
-import org.jboss.osgi.framework.metadata.PackageAttribute;
-import org.jboss.osgi.framework.metadata.Parameter;
-import org.jboss.osgi.framework.metadata.internal.AbstractVersionRange;
-import org.osgi.framework.Constants;
-
-/**
- * OSGiPackageRequirement.
- *
- * todo PackagePermission/IMPORT
- * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
- * @author Thomas.Diesler(a)jboss.com
- * @version $Revision: 1.1 $
- */
-public class OSGiPackageRequirement extends PackageRequirement
-{
- /** The serialVersionUID */
- private static final long serialVersionUID = 5109907232396093061L;
-
- /** The bundle state */
- private AbstractBundleState bundleState;
-
- /** The attributes */
- private PackageAttribute requirePackage;
-
- /**
- * Create a new OSGiPackageRequirement.
- *
- * @param bundleState the bundle state
- * @param requirePackage the require package metadata
- * @return the requirement
- * @throws IllegalArgumentException for a null requirePackage
- */
- @SuppressWarnings("deprecation")
- public static OSGiPackageRequirement create(AbstractBundleState bundleState,
PackageAttribute requirePackage)
- {
- if (bundleState == null)
- throw new IllegalArgumentException("Null bundle");
- if (requirePackage == null)
- throw new IllegalArgumentException("Null require package");
-
- String name = requirePackage.getAttribute();
-
- AbstractVersionRange range = null;
- String versionString =
requirePackage.getAttributeValue(Constants.VERSION_ATTRIBUTE, String.class);
- if (versionString != null)
- {
- range = (AbstractVersionRange)AbstractVersionRange.valueOf(versionString);
- String oldVersionString =
requirePackage.getAttributeValue(Constants.PACKAGE_SPECIFICATION_VERSION, String.class);
- if (oldVersionString != null && oldVersionString.equals(versionString)
== false)
- throw new IllegalStateException(Constants.VERSION_ATTRIBUTE + " of
" + versionString + " does not match " +
Constants.PACKAGE_SPECIFICATION_VERSION
- + " of " + oldVersionString);
- }
- else
- {
- versionString =
requirePackage.getAttributeValue(Constants.PACKAGE_SPECIFICATION_VERSION, String.class);
- if (versionString != null)
- range = (AbstractVersionRange)AbstractVersionRange.valueOf(versionString);
- }
-
- return new OSGiPackageRequirement(bundleState, name, range, requirePackage);
- }
-
- /**
- * Create a new OSGiPackageRequirement.
- *
- * @param bundleState the bundleState
- * @param name the name
- * @param versionRange the version range - pass null for all versions
- * @param requirePackage the require package metadata
- * @throws IllegalArgumentException for a null name or requirePackage
- */
- public OSGiPackageRequirement(AbstractBundleState bundleState, String name,
VersionRange versionRange, PackageAttribute requirePackage)
- {
- super(name, versionRange);
- this.bundleState = bundleState;
-
- if (requirePackage != null)
- {
- this.requirePackage = requirePackage;
- String resolution =
requirePackage.getDirectiveValue(Constants.RESOLUTION_DIRECTIVE, String.class);
- if (Constants.RESOLUTION_OPTIONAL.equals(resolution))
- setOptional(true);
- }
- }
-
- /**
- * Get the requirePackage metadata.
- *
- * @return the requirePackage.
- */
- public PackageAttribute getPackageMetaData()
- {
- return requirePackage;
- }
-
- /**
- * Get the Module associated with this requirement
- *
- * @return the module
- */
- public Module getModule()
- {
- Module module = null;
- if (bundleState instanceof AbstractDeployedBundleState)
- {
- AbstractDeployedBundleState depBundle =
(AbstractDeployedBundleState)bundleState;
- DeploymentUnit unit = depBundle.getDeploymentUnit();
- module = unit.getAttachment(Module.class);
- if (module == null)
- throw new IllegalStateException("Cannot obtain module from: " +
bundleState);
- }
- return module;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- return true;
- if (obj == null || obj instanceof OSGiPackageRequirement == false)
- return false;
- if (super.equals(obj) == false)
- return false;
-
- return true;
- }
-
- private String shortString;
- public String toShortString()
- {
- if (shortString == null)
- {
- StringBuffer buffer = new StringBuffer(bundleState.getCanonicalName() +
"[" + getName());
- Map<String, Parameter> attributes = requirePackage.getAttributes();
- Map<String, Parameter> directives = requirePackage.getDirectives();
- for (Map.Entry<String, Parameter> entry : directives.entrySet())
- buffer.append(";" + entry.getKey() + ":=" +
entry.getValue().getValue());
- for (Map.Entry<String, Parameter> entry : attributes.entrySet())
- buffer.append(";" + entry.getKey() + "=" +
entry.getValue().getValue());
- buffer.append("]");
- shortString = buffer.toString();
- }
- return shortString;
- }
-
- @Override
- protected void toString(StringBuffer buffer)
- {
- buffer.append(toShortString());
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/AbstractOSGiClassLoadingDeployer.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,152 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-// $Id$
-
-import java.util.List;
-
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloading.spi.metadata.CapabilitiesMetaData;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.classloading.spi.metadata.RequirementsMetaData;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.ClassLoaderFactory;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.classloading.OSGiBundleCapability;
-import org.jboss.osgi.framework.classloading.OSGiBundleRequirement;
-import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
-import org.jboss.osgi.framework.classloading.OSGiPackageCapability;
-import org.jboss.osgi.framework.classloading.OSGiPackageRequirement;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.framework.metadata.PackageAttribute;
-import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
-import org.jboss.osgi.framework.plugins.SystemPackagesPlugin;
-
-/**
- * An abstract OSGi classloading deployer, that maps {@link OSGiMetaData} into {@link
ClassLoadingMetaData}.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 07-Jan-2010
- */
-public class AbstractOSGiClassLoadingDeployer extends
AbstractSimpleRealDeployer<OSGiMetaData>
-{
- private ClassLoaderDomain domain;
- private ClassLoaderFactory factory;
-
- public AbstractOSGiClassLoadingDeployer()
- {
- super(OSGiMetaData.class);
- addInput(AbstractBundleState.class);
- setOutput(ClassLoadingMetaData.class);
- setStage(DeploymentStages.POST_PARSE);
- setTopLevelOnly(true);
- }
-
- public void setDomain(ClassLoaderDomain domain)
- {
- this.domain = domain;
- }
-
- public void setFactory(ClassLoaderFactory factory)
- {
- this.factory = factory;
- }
-
- @Override
- public void deploy(DeploymentUnit unit, OSGiMetaData osgiMetaData) throws
DeploymentException
- {
- if (unit.isAttachmentPresent(ClassLoadingMetaData.class))
- return;
-
- AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
- if (bundleState == null)
- throw new IllegalStateException("No bundle state");
-
- OSGiBundleManager bundleManager = bundleState.getBundleManager();
-
- OSGiClassLoadingMetaData classLoadingMetaData = new OSGiClassLoadingMetaData();
- classLoadingMetaData.setName(bundleState.getSymbolicName());
- classLoadingMetaData.setVersion(bundleState.getVersion());
- classLoadingMetaData.setDomain(domain != null ? domain.getName() : null);
-
- CapabilitiesMetaData capabilities = classLoadingMetaData.getCapabilities();
- RequirementsMetaData requirements = classLoadingMetaData.getRequirements();
-
- OSGiBundleCapability bundleCapability = OSGiBundleCapability.create(bundleState);
- capabilities.addCapability(bundleCapability);
-
- // Required Bundles
- List<ParameterizedAttribute> requireBundles =
osgiMetaData.getRequireBundles();
- if (requireBundles != null && requireBundles.isEmpty() == false)
- {
- for (ParameterizedAttribute requireBundle : requireBundles)
- {
- OSGiBundleRequirement requirement =
OSGiBundleRequirement.create(requireBundle);
- requirements.addRequirement(requirement);
- }
- }
-
- // Export Packages
- List<PackageAttribute> exported = osgiMetaData.getExportPackages();
- if (exported != null && exported.isEmpty() == false)
- {
- for (PackageAttribute packageAttribute : exported)
- {
- OSGiPackageCapability packageCapability =
OSGiPackageCapability.create(bundleState, packageAttribute);
- capabilities.addCapability(packageCapability);
- }
- }
-
- // Import Packages
- List<PackageAttribute> imported = osgiMetaData.getImportPackages();
- if (imported != null && imported.isEmpty() == false)
- {
- SystemPackagesPlugin syspackPlugin =
bundleManager.getPlugin(SystemPackagesPlugin.class);
- for (PackageAttribute packageAttribute : imported)
- {
- String packageName = packageAttribute.getAttribute();
-
- // [TODO] Should system packages be added as capabilities?
- boolean isSystemPackage = syspackPlugin.isSystemPackage(packageName);
- if (isSystemPackage == false)
- {
- OSGiPackageRequirement requirement =
OSGiPackageRequirement.create(bundleState, packageAttribute);
- requirements.addRequirement(requirement);
- }
- }
- }
-
- unit.addAttachment(ClassLoadingMetaData.class, classLoadingMetaData);
-
- // AnnotationMetaDataDeployer.ANNOTATION_META_DATA_COMPLETE
- unit.addAttachment("org.jboss.deployment.annotation.metadata.complete",
Boolean.TRUE);
-
- // Add the OSGi ClassLoaderFactory if configured
- if (factory != null)
- unit.addAttachment(ClassLoaderFactory.class, factory);
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleActivatorDeployer.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleActivatorDeployer.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleActivatorDeployer.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,76 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.osgi.framework.BundleException;
-
-/**
- * OSGiBundleActivatorDeployer.
- *
- * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
- * @author Thomas.Diesler(a)jboss.com
- * @version $Revision: 1.1 $
- */
-public class OSGiBundleActivatorDeployer extends
AbstractSimpleRealDeployer<OSGiBundleState>
-{
- public OSGiBundleActivatorDeployer()
- {
- super(OSGiBundleState.class);
- setTopLevelOnly(true);
- }
-
- @Override
- public void deploy(DeploymentUnit unit, OSGiBundleState bundleState) throws
DeploymentException
- {
- try
- {
- bundleState.startInternal();
- }
- catch (BundleException ex)
- {
- // We do not rethrow this exception to the deployer framework.
- // An exception during Bundle.start() is regarded as a normal deployment
condition and handeled internally by the OSGi layer.
- // The OSGiBundleManager picks up this BundleException and rethrows it if
available.
- unit.addAttachment(BundleException.class, ex);
- }
- }
-
- @Override
- public void undeploy(DeploymentUnit unit, OSGiBundleState bundleState)
- {
- try
- {
- bundleState.stopInternal();
- }
- catch (BundleException ex)
- {
- // We do not rethrow this exception to the deployer framework.
- // An exception during Bundle.start() is regarded as a normal deployment
condition and handeled internally by the OSGi layer.
- // The OSGiBundleManager picks up this BundleException and rethrows it if
available.
- unit.addAttachment(BundleException.class, ex);
- }
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleClassLoadingDeployer.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -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.osgi.framework.deployers;
-
-// $Id: $
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-
-/**
- * An OSGi classloading deployer, that maps osgi metadata into classloading metadata
- * for non-fragment bundles.
- *
- * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
- * @author Thomas.Diesler(a)jboss.com
- * @version $Revision: 1.1 $
- */
-public class OSGiBundleClassLoadingDeployer extends AbstractOSGiClassLoadingDeployer
-{
- @Override
- public void deploy(DeploymentUnit unit, OSGiMetaData osgiMetaData) throws
DeploymentException
- {
- super.deploy(unit, osgiMetaData);
-
- // Return if this is not a real bundle (i.e. a fragment)
- AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
- if (bundleState.isFragment())
- return;
-
- // nothing special to do
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateCreateDeployer.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateCreateDeployer.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateCreateDeployer.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,66 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-
-/**
- * A deployer that creates the bundle state through the bundle manager.
- *
- * The bundle is not yet INSTALLED.
- *
- * @author <a href="adrian(a)jboss.com">Adrian Brock</a>
- * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
- * @author Thomas.Diesler(a)jboss.com
- */
-public class OSGiBundleStateCreateDeployer extends AbstractRealDeployer
-{
- /** The bundle manager */
- protected OSGiBundleManager bundleManager;
-
- public OSGiBundleStateCreateDeployer(OSGiBundleManager bundleManager)
- {
- if (bundleManager == null)
- throw new IllegalArgumentException("Null bundle manager");
- this.bundleManager = bundleManager;
-
- setInput(OSGiMetaData.class);
- setOutput(AbstractBundleState.class);
- setStage(DeploymentStages.POST_PARSE);
- setTopLevelOnly(true);
- }
-
- @Override
- public void internalDeploy(DeploymentUnit unit) throws DeploymentException
- {
- unit.setRequiredStage(DeploymentStages.DESCRIBE);
-
- // Create the bundle state
- bundleManager.addDeployment(unit);
- }
-}
\ No newline at end of file
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateInstallDeployer.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateInstallDeployer.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateInstallDeployer.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,65 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-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.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-
-/**
- * A deployer that adds the bundle state to the bundle manager.
- *
- * This causes the bundle to get INSTALLED.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 19-Feb-2010
- */
-public class OSGiBundleStateInstallDeployer extends
AbstractSimpleRealDeployer<AbstractBundleState>
-{
- public OSGiBundleStateInstallDeployer()
- {
- super(AbstractBundleState.class);
- addInput(ClassLoadingMetaData.class);
- setStage(DeploymentStages.POST_PARSE);
- setTopLevelOnly(true);
- }
-
- @Override
- public void deploy(DeploymentUnit unit, AbstractBundleState bundleState) throws
DeploymentException
- {
- // Add the bundle to the manager when it is metadata complete
- OSGiBundleManager bundleManager = bundleState.getBundleManager();
- bundleManager.addBundle(bundleState);
- }
-
- @Override
- public void undeploy(DeploymentUnit unit, AbstractBundleState bundleState)
- {
- // Remove the bundle from the manager
- OSGiBundleManager bundleManager = bundleState.getBundleManager();
- bundleManager.removeBundle(bundleState);
- }
-}
\ No newline at end of file
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateResolveDeployer.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateResolveDeployer.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiBundleStateResolveDeployer.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -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.osgi.framework.deployers;
-
-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.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.bundle.OSGiFragmentState;
-import org.osgi.framework.Bundle;
-
-/**
- * A deployer that sets the bundle state to RESOLVED when the ClassLoader becomes
available.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 24-Feb-2010
- */
-public class OSGiBundleStateResolveDeployer extends
AbstractSimpleRealDeployer<OSGiBundleState>
-{
- // The relative order at which to change the bindle state to RESOLVED
- static final int RELATIVE_ORDER = 200;
-
- public OSGiBundleStateResolveDeployer()
- {
- super(OSGiBundleState.class);
- setStage(DeploymentStages.CLASSLOADER);
- setRelativeOrder(RELATIVE_ORDER);
- setTopLevelOnly(true);
- }
-
- @Override
- public void deploy(DeploymentUnit unit, OSGiBundleState bundleState) throws
DeploymentException
- {
- // Change the bundle state to RESOLVED
- bundleState.changeState(Bundle.RESOLVED);
- for (OSGiFragmentState fragment : bundleState.getAttachedFragments())
- fragment.changeState(Bundle.RESOLVED);
- }
-}
\ No newline at end of file
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiContextTrackerDeployer.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiContextTrackerDeployer.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiContextTrackerDeployer.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,55 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-import org.jboss.dependency.spi.tracker.ContextTracker;
-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.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-
-/**
- * Add context tracker to deployment.
- *
- * @author <a href="ales.justin(a)jboss.org">Ales Justin</a>
- */
-public class OSGiContextTrackerDeployer extends
AbstractSimpleRealDeployer<OSGiBundleState>
-{
- public OSGiContextTrackerDeployer()
- {
- super(OSGiBundleState.class);
- setStage(DeploymentStages.POST_PARSE);
- }
-
- public void deploy(DeploymentUnit unit, OSGiBundleState deployment) throws
DeploymentException
- {
- // add it to metadata so other non-osgi pieces can use it
- unit.getMutableMetaData().addMetaData(deployment, ContextTracker.class);
- }
-
- @Override
- public void undeploy(DeploymentUnit unit, OSGiBundleState deployment)
- {
- unit.getMutableMetaData().removeMetaData(ContextTracker.class);
- }
-}
\ No newline at end of file
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiDeployersWrapper.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,211 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.jboss.deployers.client.spi.main.MainDeployer;
-import org.jboss.deployers.plugins.main.MainDeployerImpl;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.Deployers;
-import org.jboss.deployers.spi.deployer.DeploymentStage;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.structure.spi.DeploymentContext;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedObject;
-import org.jboss.osgi.deployment.deployer.Deployment;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-/**
- * A Deployers implementation that wraps the deployers that are associated with the
MainDeployer.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 04-Sep-2009
- */
-public class OSGiDeployersWrapper implements Deployers
-{
- /** The log */
- private static final Logger log = Logger.getLogger(OSGiDeployersWrapper.class);
-
- private MainDeployer mainDeployer;
- private Deployers deployers;
- private OSGiBundleManager bundleManager;
- private PackageAdmin packageAdmin;
-
- /** The list of unresolved bundles */
- private List<OSGiBundleState> unresolvedBundles = new
CopyOnWriteArrayList<OSGiBundleState>();
-
- public OSGiDeployersWrapper(MainDeployer mainDeployer, OSGiBundleManager
bundleManager)
- {
- if (bundleManager == null)
- throw new IllegalArgumentException("Null bundleManager");
- if (mainDeployer instanceof MainDeployerImpl == false)
- throw new IllegalStateException("Cannot instrument: " +
mainDeployer);
-
- this.mainDeployer = mainDeployer;
- this.bundleManager = bundleManager;
-
- // Swap the deployers implementation
- MainDeployerImpl mainDeployerImpl = (MainDeployerImpl)mainDeployer;
- this.deployers = mainDeployerImpl.getDeployers();
- mainDeployerImpl.setDeployers(this);
- }
-
- private PackageAdmin getPackageAdmin()
- {
- if (packageAdmin == null)
- {
- BundleContext sysContext = bundleManager.getSystemContext();
- ServiceReference sref =
sysContext.getServiceReference(PackageAdmin.class.getName());
- if (sref == null)
- throw new IllegalStateException("Cannot obtain PackageAdmin");
-
- packageAdmin = (PackageAdmin)sysContext.getService(sref);
- }
- return packageAdmin;
- }
-
- public void process(List<DeploymentContext> deploy,
List<DeploymentContext> undeploy)
- {
- // Delegate to the original deployers
- deployers.process(deploy, undeploy);
-
- // OSGi bundles resolve phase
- afterDeployersProcess(deploy, undeploy);
- }
-
- private void afterDeployersProcess(List<DeploymentContext> deploy,
List<DeploymentContext> undeploy)
- {
- // Process undeploy contexts
- if (undeploy != null)
- {
- for (DeploymentContext context : undeploy)
- {
- DeploymentUnit unit = context.getDeploymentUnit();
- AbstractBundleState bundle = unit.getAttachment(AbstractBundleState.class);
- if (bundle != null)
- {
- unresolvedBundles.remove(bundle);
- }
- }
- }
-
- // Process deploy contexts
- if (deploy != null)
- {
- // Collect unresolved bundles
- for (DeploymentContext context : deploy)
- {
- DeploymentUnit unit = context.getDeploymentUnit();
- AbstractBundleState bundle = unit.getAttachment(AbstractBundleState.class);
- if (bundle == null || bundle.isFragment())
- continue;
-
- Deployment dep = unit.getAttachment(Deployment.class);
- boolean autoStart = (dep != null ? dep.isAutoStart() : true);
-
- if (autoStart == true && bundle.getState() == Bundle.INSTALLED)
- {
- unresolvedBundles.add(0, (OSGiBundleState)bundle);
- }
- }
-
- // Try to resolve all unresolved bundles
- if (unresolvedBundles.isEmpty() == false)
- {
- OSGiBundleState[] unresolved = new
OSGiBundleState[unresolvedBundles.size()];
- unresolvedBundles.toArray(unresolved);
-
- // Use PackageAdmin to resolve the bundles
- getPackageAdmin().resolveBundles(unresolved);
-
- for (AbstractDeployedBundleState aux : unresolved)
- {
- if (aux.getState() != Bundle.RESOLVED)
- log.info("Unresolved: " + aux);
-
- if (aux.getState() == Bundle.RESOLVED)
- {
- unresolvedBundles.remove(aux);
-
- try
- {
- // When resolved progress to INSTALLED
- String name = aux.getDeploymentUnit().getName();
- mainDeployer.change(name, DeploymentStages.INSTALLED);
- }
- catch (DeploymentException ex)
- {
- log.error(ex);
- }
- }
- }
- }
- }
- }
-
- public void change(DeploymentContext context, DeploymentStage stage) throws
DeploymentException
- {
- deployers.change(context, stage);
- }
-
- public void checkComplete(DeploymentContext... contexts) throws DeploymentException
- {
- deployers.checkComplete(contexts);
- }
-
- public void checkComplete(Collection<DeploymentContext> errors,
Collection<org.jboss.deployers.client.spi.Deployment> missingDeployer) throws
DeploymentException
- {
- deployers.checkComplete(errors, missingDeployer);
- }
-
- public void checkStructureComplete(DeploymentContext... contexts) throws
DeploymentException
- {
- deployers.checkStructureComplete(contexts);
- }
-
- public DeploymentStage getDeploymentStage(DeploymentContext context) throws
DeploymentException
- {
- return deployers.getDeploymentStage(context);
- }
-
- public Map<String, ManagedObject> getManagedObjects(DeploymentContext context)
throws DeploymentException
- {
- return deployers.getManagedObjects(context);
- }
-
- public void shutdown()
- {
- deployers.shutdown();
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiFragmentClassLoadingDeployer.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,80 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-// $Id$
-
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
-import
org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData.FragmentHostMetaData;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.framework.metadata.Parameter;
-import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
-
-/**
- * An OSGi classloading deployer, that maps osgi metadata into classloading metadata
- * for fragment bundles.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 07-Jan-2010
- */
-public class OSGiFragmentClassLoadingDeployer extends AbstractOSGiClassLoadingDeployer
-{
- @Override
- public void deploy(DeploymentUnit unit, OSGiMetaData osgiMetaData) throws
DeploymentException
- {
- super.deploy(unit, osgiMetaData);
-
- // Return if this is not a bundle fragment
- AbstractBundleState bundleState = unit.getAttachment(AbstractBundleState.class);
- if (bundleState.isFragment() == false)
- return;
-
- OSGiClassLoadingMetaData classLoadingMetaData =
(OSGiClassLoadingMetaData)unit.getAttachment(ClassLoadingMetaData.class);
-
- // Initialize the Fragment-Host
- ParameterizedAttribute hostAttr = osgiMetaData.getFragmentHost();
- FragmentHostMetaData fragmentHost = new
FragmentHostMetaData(hostAttr.getAttribute());
- classLoadingMetaData.setFragmentHost(fragmentHost);
-
- Parameter bundleVersionAttr =
hostAttr.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
- if (bundleVersionAttr != null)
- fragmentHost.setBundleVersion((Version)bundleVersionAttr.getValue());
-
- Parameter extensionDirective =
hostAttr.getDirective(Constants.EXTENSION_DIRECTIVE);
- if (extensionDirective != null)
- fragmentHost.setExtension((String)extensionDirective.getValue());
-
- // TODO Modify the CL metadata of the host such that eventually the CL policy
- // contains a DelegateLoader for the attached fragment
-
- // Adding the fragment as an OSGiBundleRequirement to the host does not work
because
- // those requirements end up as DependencyItems already during the INSTALL phase.
- // Remember to do equivalent code in OSGiBundleClassLoadingDeployer
- // in case the fragment gets installed before the host.
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployer.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployer.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployer.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,66 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer;
-import org.jboss.osgi.framework.classloading.OSGiModule;
-
-/**
- * The OSGiModuleDeployer creates the {@link OSGiModule}.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @version $Revision$
- */
-public class OSGiModuleDeployer extends VFSClassLoaderDescribeDeployer
-{
- /* [TODO] We don't need to overwrite deploy if the base class can handle an
already attached Module
- public void deploy(DeploymentUnit unit, ClassLoadingMetaData metaData) throws
DeploymentException
- {
- // If there is no module attached proceed as normal
- Module module = unit.getAttachment(Module.class);
- if (module == null)
- {
- super.deploy(unit, metaData);
- return;
- }
-
- // If there is already a module attached and this is an OSGi deployment
- // remove the old module and create a new OSGiModule
- if (metaData instanceof OSGiClassLoadingMetaData)
- {
- ClassLoading classLoading = getClassLoading();
- classLoading.removeModule(module);
- unit.removeAttachment(Module.class);
- super.deploy(unit, metaData);
- }
- }
- */
-
- @Override
- protected ClassLoaderPolicyModule createModule(DeploymentUnit unit,
ClassLoadingMetaData metaData)
- {
- return new OSGiModule(unit, metaData);
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployerTempWorkaround.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployerTempWorkaround.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiModuleDeployerTempWorkaround.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,70 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-import org.jboss.classloading.spi.dependency.ClassLoading;
-import org.jboss.classloading.spi.dependency.Module;
-import org.jboss.classloading.spi.dependency.policy.ClassLoaderPolicyModule;
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.plugins.classloader.VFSClassLoaderDescribeDeployer;
-import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
-import org.jboss.osgi.framework.classloading.OSGiModule;
-
-/**
- * [TODO] Remove this deployer when the VFSClassLoaderDescribeDeployer
- * suports an already attached Module.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @version $Revision: 100143 $
- */
-public class OSGiModuleDeployerTempWorkaround extends VFSClassLoaderDescribeDeployer
-{
- public OSGiModuleDeployerTempWorkaround()
- {
- // Make sure we come after the ClassLoaderDescribeDeployer
- setInput(Module.class);
- }
-
- @Override
- public void deploy(DeploymentUnit unit, ClassLoadingMetaData metaData) throws
DeploymentException
- {
- // If there is already a module attached and this is an OSGi deployment
- // remove the old module and create a new OSGiModule
- if (metaData instanceof OSGiClassLoadingMetaData)
- {
- Module module = unit.removeAttachment(Module.class);
- ClassLoading classLoading = getClassLoading();
- classLoading.removeModule(module);
- unit.removeAttachment(Module.class);
- super.deploy(unit, metaData);
- }
- }
-
- @Override
- protected ClassLoaderPolicyModule createModule(DeploymentUnit unit,
ClassLoadingMetaData metaData)
- {
- OSGiModule module = new OSGiModule(unit, metaData);
- return module;
- }
-}
Deleted:
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiNativeCodeMetaDataDeployer.java
===================================================================
---
projects/jboss-osgi/projects/runtime/framework/trunk/core/src/main/java/org/jboss/osgi/framework/deployers/OSGiNativeCodeMetaDataDeployer.java 2010-03-03
10:22:49 UTC (rev 101768)
+++
projects/jboss-osgi/projects/runtime/framework/trunk/vfs21/src/main/java/org/jboss/osgi/framework/deployers/OSGiNativeCodeMetaDataDeployer.java 2010-03-03
14:45:40 UTC (rev 101775)
@@ -1,264 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, Red Hat Middleware LLC, and individual contributors
-* as indicated by the @author tags. See the copyright.txt file in the
-* distribution for a full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
-*/
-package org.jboss.osgi.framework.deployers;
-
-// $Id$
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.osgi.framework.bundle.AbstractBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleManager;
-import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
-import org.jboss.osgi.framework.metadata.NativeLibrary;
-import org.jboss.osgi.framework.metadata.NativeLibraryMetaData;
-import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.framework.metadata.Parameter;
-import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
-import org.osgi.framework.Constants;
-
-/**
- * A deployer that takes care of loading native code libraries.
- *
- * @author Thomas.Diesler(a)jboss.com
- * @since 19-Dec-2009
- */
-public class OSGiNativeCodeMetaDataDeployer extends AbstractRealDeployer
-{
- /** Maps an alias to an OSGi processor name */
- private static Map<String, String> processorAlias = new HashMap<String,
String>();
- static
- {
- processorAlias.put("pentium", "x86");
- processorAlias.put("i386", "x86");
- processorAlias.put("i486", "x86");
- processorAlias.put("i586", "x86");
- processorAlias.put("i686", "x86");
- processorAlias.put("amd64", "x86-64");
- processorAlias.put("em64t", "x86-64");
- processorAlias.put("x86_64", "x86-64");
- }
-
- /** Maps an alias to an OSGi osname */
- private static Map<String, String> osAlias = new HashMap<String,
String>();
- static
- {
- osAlias.put("SymbianOS", "Epoc32");
- osAlias.put("hp-ux", "HPUX");
- osAlias.put("Mac OS", "MacOS");
- osAlias.put("Mac OS X", "MacOSX");
- osAlias.put("OS/2", "OS2");
- osAlias.put("procnto", "QNX");
- osAlias.put("Win95", "Windows95");
- osAlias.put("Windows 95", "Windows95");
- osAlias.put("Win32", "Windows95");
- osAlias.put("Win98", "Windows98");
- osAlias.put("Windows 98", "Windows98");
- osAlias.put("Win32", "Windows98");
- osAlias.put("WinNT", "WindowsNT");
- osAlias.put("Windows NT", "WindowsNT");
- osAlias.put("Win32", "WindowsNT");
- osAlias.put("WinCE", "WindowsCE");
- osAlias.put("Windows CE", "WindowsCE");
- osAlias.put("Win2000", "Windows2000");
- osAlias.put("Windows 2000", "Windows2000");
- osAlias.put("Win32", "Windows2000");
- osAlias.put("Win2003", "Windows2003");
- osAlias.put("Windows 2003", "Windows2003");
- osAlias.put("Win32", "Windows2003");
- osAlias.put("Windows Server 2003", "Windows2003");
- osAlias.put("WinXP", "WindowsXP");
- osAlias.put("Windows XP", "WindowsXP");
- osAlias.put("Win32", "WindowsXP");
- osAlias.put("WinVista", "WindowsVista");
- osAlias.put("Windows Vista", "WindowsVista");
- osAlias.put("Win32", "WindowsVista");
- osAlias.put("Windows 7", "Windows7");
- }
-
- public OSGiNativeCodeMetaDataDeployer()
- {
- setInput(ClassLoadingMetaData.class);
- setStage(DeploymentStages.POST_PARSE);
- setTopLevelOnly(true);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- protected void internalDeploy(DeploymentUnit unit) throws DeploymentException
- {
- AbstractBundleState absBundleState =
unit.getAttachment(AbstractBundleState.class);
- if ((absBundleState instanceof OSGiBundleState) == false)
- return;
-
- OSGiClassLoadingMetaData classLoadingMetaData =
(OSGiClassLoadingMetaData)unit.getAttachment(ClassLoadingMetaData.class);
- if (classLoadingMetaData == null)
- throw new IllegalStateException("No ClassLoadingMetaData");
-
- OSGiBundleState bundleState = (OSGiBundleState)absBundleState;
- OSGiBundleManager bundleManager = bundleState.getBundleManager();
- OSGiMetaData osgiMetaData = bundleState.getOSGiMetaData();
- List<ParameterizedAttribute> nativeCodeParams =
osgiMetaData.getBundleNativeCode();
- if (nativeCodeParams == null)
- return;
-
- // Find the matching parameters
- List<ParameterizedAttribute> matchedParams = new
ArrayList<ParameterizedAttribute>();
- for (ParameterizedAttribute param : nativeCodeParams)
- {
- if (matchParameter(bundleManager, param))
- matchedParams.add(param);
- }
-
- // If no native clauses were selected in step 1, this algorithm is terminated
- // and a BundleException is thrown if the optional clause is not present
- if (matchedParams.size() == 0)
- {
- // [TODO] optional
- throw new DeploymentException("No native clauses selected from: " +
nativeCodeParams);
- }
-
- // The selected clauses are now sorted in the following priority order:
- // * osversion: floor of the osversion range in descending order, osversion not
specified
- // * language: language specified, language not specified
- // * Position in the Bundle-NativeCode manifest header: lexical left to right
- if (matchedParams.size() > 1)
- {
- // [TODO] selected clauses are now sorted
- }
-
- NativeLibraryMetaData nativeLibraries = classLoadingMetaData.getNativeLibraries();
- for (ParameterizedAttribute param : matchedParams)
- {
- Parameter osnameParam = param.getAttribute(Constants.BUNDLE_NATIVECODE_OSNAME);
- Parameter procParam =
param.getAttribute(Constants.BUNDLE_NATIVECODE_PROCESSOR);
- //Parameter osversionParam =
param.getAttribute(Constants.BUNDLE_NATIVECODE_OSVERSION);
-
- List<String> osNames;
- if (osnameParam.isCollection())
- osNames = (List<String>)osnameParam.getValue();
- else
- osNames = Collections.singletonList((String)osnameParam.getValue());
-
- String libpath = param.getAttribute();
- String libsource = bundleState.getCanonicalName();
-
- NativeLibrary library = new NativeLibrary(osNames, libpath, libsource);
-
- // Processors
- if (procParam != null)
- {
- List<String> processors;
- if (procParam.isCollection())
- processors = (List<String>)procParam.getValue();
- else
- processors = Collections.singletonList((String)procParam.getValue());
-
- library.setProcessors(processors);
- }
-
- // [TODO] osVersions, languages, selectionFilter, optional
- // library.setOsVersions(osVersions);
- // library.setLanguages(languages);
- // library.setSelectionFilter(selectionFilter);
- // library.setOptional(optional);
-
- nativeLibraries.addNativeLibrary(library);
- }
- }
-
- @SuppressWarnings("unchecked")
- private boolean matchParameter(OSGiBundleManager bundleManager, ParameterizedAttribute
param)
- {
- String fwOSName = bundleManager.getProperty(Constants.FRAMEWORK_OS_NAME);
- String fwProcessor = bundleManager.getProperty(Constants.FRAMEWORK_PROCESSOR);
- //String fwOSVersion = bundleManager.getProperty(Constants.FRAMEWORK_OS_VERSION);
-
- // Only select the native code clauses for which the following expressions all
evaluate to true
- // * osname ~= [org.osgi.framework.os.name]
- // * processor ~= [org.osgi.framework.processor]
- // * osversion range includes [org.osgi.framework.os.version] or osversion is not
specified
- // * language ~= [org.osgi.framework.language] or language is not specified
- // * selection-filter evaluates to true when using the values of the system
properties or selection-filter is not specified
-
- Parameter osnameParam = param.getAttribute(Constants.BUNDLE_NATIVECODE_OSNAME);
- Parameter procParam = param.getAttribute(Constants.BUNDLE_NATIVECODE_PROCESSOR);
- //Parameter osversionParam =
param.getAttribute(Constants.BUNDLE_NATIVECODE_OSVERSION);
-
- boolean match = (osnameParam != null);
-
- // osname ~= [org.osgi.framework.os.name]
- if (match == true && osnameParam != null)
- {
- List<String> osNames;
- if (osnameParam.isCollection())
- osNames = (List<String>)osnameParam.getValue();
- else
- osNames = Collections.singletonList((String)osnameParam.getValue());
-
- boolean osmatch = false;
- for (String osname : osNames)
- {
- osmatch = (osname.equalsIgnoreCase(fwOSName) ||
osname.equalsIgnoreCase(osAlias.get(fwOSName)));
- if (osmatch == true)
- break;
- }
-
- match &= osmatch;
- }
-
- // processor ~= [org.osgi.framework.processor]
- match &= (procParam != null);
- if (match && procParam != null)
- {
- List<String> processors;
- if (procParam.isCollection())
- processors = (List<String>)procParam.getValue();
- else
- processors = Collections.singletonList((String)procParam.getValue());
-
- boolean procmatch = false;
- for (String proc : processors)
- {
- procmatch = (proc.equals(fwProcessor) ||
proc.equals(processorAlias.get(fwProcessor)));
- if (procmatch == true)
- break;
- }
-
- match &= procmatch;
- }
-
- // [TODO] osversion range includes [org.osgi.framework.os.version] or osversion is
not specified
- // [TODO] language ~= [org.osgi.framework.language] or language is not specified
- // [TODO] selection-filter evaluates to true when using the values of the system
properties or selection-filter is not specified
- return match;
- }
-}