[jboss-cvs] JBossAS SVN: r95194 - in projects/jboss-osgi: projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 20 14:43:37 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-20 14:43:36 -0400 (Tue, 20 Oct 2009)
New Revision: 95194
Modified:
projects/jboss-osgi/projects/runtime/felix/trunk/
projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
projects/jboss-osgi/trunk/pom.xml
projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml
Log:
Resurect Felix BundleContextWrapper
Property changes on: projects/jboss-osgi/projects/runtime/felix/trunk
___________________________________________________________________
Name: svn:mergeinfo
-
Modified: projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java 2009-10-20 18:08:11 UTC (rev 95193)
+++ projects/jboss-osgi/projects/runtime/felix/trunk/src/main/java/org/jboss/osgi/felix/FelixBundleContextWrapper.java 2009-10-20 18:43:36 UTC (rev 95194)
@@ -23,13 +23,24 @@
//$Id$
+import java.net.MalformedURLException;
+import java.net.URL;
+
import org.jboss.logging.Logger;
+import org.jboss.osgi.deployment.deployer.DeployerService;
import org.jboss.osgi.spi.framework.BundleContextWrapper;
+import org.jboss.osgi.spi.util.BundleInfo;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
/**
* The FelixBundleContextWrapper wrapps the BundleContext provided by the Felix implemenation.
*
+ * It provides additional functionality on bundle install.
+ *
* @author thomas.diesler at jboss.com
* @since 15-Oct-2009
*/
@@ -42,4 +53,59 @@
{
super(context);
}
+
+ @Override
+ public Bundle installBundle(String location) throws BundleException
+ {
+ URL url;
+ try
+ {
+ url = new URL(location);
+ }
+ catch (MalformedURLException ex)
+ {
+ throw new IllegalArgumentException("Invalid bundle location: " + location);
+ }
+
+ BundleInfo info = BundleInfo.createBundleInfo(url);
+ String symbolicName = info.getSymbolicName();
+ Version version = Version.parseVersion(info.getVersion());
+
+ Bundle bundle;
+
+ ServiceReference sref = context.getServiceReference(DeployerService.class.getName());
+ if (sref != null)
+ {
+ DeployerService service = (DeployerService)context.getService(sref);
+ service.deploy(url);
+ bundle = getBundle(symbolicName, version, true);
+ }
+ else
+ {
+ bundle = context.installBundle(location);
+ }
+
+ return bundle;
+ }
+
+ private Bundle getBundle(String symbolicName, Version version, boolean mustExist)
+ {
+ Bundle bundle = null;
+ for (Bundle aux : getBundles())
+ {
+ if (aux.getSymbolicName().equals(symbolicName))
+ {
+ if (version == null || version.equals(aux.getVersion()))
+ {
+ bundle = aux;
+ break;
+ }
+ }
+ }
+
+ if (bundle == null && mustExist == true)
+ throw new IllegalStateException("Cannot obtain bundle: " + symbolicName + "-" + version);
+
+ return bundle;
+ }
}
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/pom.xml 2009-10-20 18:08:11 UTC (rev 95193)
+++ projects/jboss-osgi/trunk/pom.xml 2009-10-20 18:43:36 UTC (rev 95194)
@@ -257,6 +257,20 @@
</dependencies>
</dependencyManagement>
+ <!-- Dependencies -->
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-log4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
<!-- Repositories -->
<repositories>
<repository>
Modified: projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml 2009-10-20 18:08:11 UTC (rev 95193)
+++ projects/jboss-osgi/trunk/reactor/blueprint/testsuite/pom.xml 2009-10-20 18:43:36 UTC (rev 95194)
@@ -236,11 +236,6 @@
<artifactId>jboss-osgi-framework</artifactId>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <scope>provided</scope>
- </dependency>
</dependencies>
<build>
<plugins>
@@ -280,11 +275,6 @@
<artifactId>jboss-osgi-framework</artifactId>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <scope>provided</scope>
- </dependency>
</dependencies>
<build>
<plugins>
More information about the jboss-cvs-commits
mailing list