Author: thomas.diesler(a)jboss.com
Date: 2009-11-17 13:15:51 -0500 (Tue, 17 Nov 2009)
New Revision: 96465
Added:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageexportversion/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportoptional/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportversion/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportversionfails/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleexportsecond/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleexportsecond/META-INF/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleexportsecond/META-INF/MANIFEST.MF
Removed:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/bundlenameexport/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/optionalimportpackage/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/versionexportpackage/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/versionimportpackage/
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/versionimportpackagefails/
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/WireCandidate.java
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/resolver-rules.drl
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/bundlenameimport/META-INF/MANIFEST.MF
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageexportversion/META-INF/MANIFEST.MF
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportoptional/META-INF/MANIFEST.MF
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportversion/META-INF/MANIFEST.MF
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportversionfails/META-INF/MANIFEST.MF
Log:
Support Require-Bundle. Use wire preferrence to already resolved bundle
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java 2009-11-17
17:54:23 UTC (rev 96464)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ExportPackageImpl.java 2009-11-17
18:15:51 UTC (rev 96465)
@@ -106,8 +106,14 @@
importers.remove(importer);
}
+ public String toShortString()
+ {
+ ResolvableImpl owner = (ResolvableImpl)getOwner();
+ return owner.toShortString() + super.toShortString();
+ }
+
public String toString()
{
- return "ExportPackage" + toShortString();
+ return "ExportPackage[" + toShortString() + "]";
}
}
\ No newline at end of file
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java 2009-11-17
17:54:23 UTC (rev 96464)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ImportPackageImpl.java 2009-11-17
18:15:51 UTC (rev 96465)
@@ -87,8 +87,14 @@
}
+ public String toShortString()
+ {
+ ResolvableImpl owner = (ResolvableImpl)getOwner();
+ return owner.toShortString() + super.toShortString();
+ }
+
public String toString()
{
- return "ImportPackage" + toShortString();
+ return "ImportPackage[" + toShortString() + "]";
}
}
\ No newline at end of file
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java 2009-11-17
17:54:23 UTC (rev 96464)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/ResolvableImpl.java 2009-11-17
18:15:51 UTC (rev 96465)
@@ -162,9 +162,14 @@
return metaData.isSingleton();
}
+ public String toShortString()
+ {
+ return getSymbolicName() + "-" + getVersion();
+ }
+
@Override
public String toString()
{
- return "Resolvable[" + getSymbolicName() + "-" + getVersion() +
"]";
+ return "Resolvable[" + toShortString() + "]";
}
}
\ No newline at end of file
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/WireCandidate.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/WireCandidate.java 2009-11-17
17:54:23 UTC (rev 96464)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/resolver/internal/drools/WireCandidate.java 2009-11-17
18:15:51 UTC (rev 96465)
@@ -23,7 +23,6 @@
import org.jboss.osgi.framework.resolver.ExportPackage;
import org.jboss.osgi.framework.resolver.ImportPackage;
-import org.jboss.osgi.framework.resolver.Resolvable;
import org.jboss.osgi.framework.resolver.internal.ExportPackageImpl;
import org.jboss.osgi.framework.resolver.internal.ImportPackageImpl;
@@ -61,11 +60,7 @@
@Override
public String toString()
{
- Resolvable impOwner = importPackage.getOwner();
- String importer = impOwner.getSymbolicName() + "-" +
impOwner.getVersion() + importPackage.toShortString();
- Resolvable expOwner = exportPackage.getOwner();
- String exporter = expOwner.getSymbolicName() + "-" +
expOwner.getVersion() + exportPackage.toShortString();
- return "WireCandidate[" + importer + "] --> [" + exporter +
"]";
+ return "WireCandidate[" + importPackage.toShortString() + " -->
" + exportPackage.toShortString() + "]";
}
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java 2009-11-17
17:54:23 UTC (rev 96464)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/java/org/jboss/test/osgi/resolver/AbstractImportExportTest.java 2009-11-17
18:15:51 UTC (rev 96465)
@@ -211,15 +211,15 @@
Resolver resolver = getTestResolver();
assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
- //Bundle-SymbolicName: versionimportpackage
+ //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/versionimportpackage");
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportversion");
Bundle bundleA = framework.installBundle(fileA);
try
{
- //Bundle-SymbolicName: versionexportpackage
+ //Bundle-SymbolicName: packageexportversion
//Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/versionexportpackage", A.class);
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -259,15 +259,15 @@
Resolver resolver = getTestResolver();
assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
- //Bundle-SymbolicName: versionimportpackagefails
+ //Bundle-SymbolicName: packageimportversionfails
//Import-Package:
org.jboss.test.osgi.classloader.support.a;version="[3.0,4.0)"
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/versionimportpackagefails");
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportversionfails");
Bundle bundleA = framework.installBundle(fileA);
try
{
- //Bundle-SymbolicName: versionexportpackage
+ //Bundle-SymbolicName: packageexportversion
//Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/versionexportpackage", A.class);
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/packageexportversion", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -307,9 +307,9 @@
Resolver resolver = getTestResolver();
assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
- //Bundle-SymbolicName: optionalimportpackage
+ //Bundle-SymbolicName: packageimportoptional
//Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/optionalimportpackage");
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportoptional");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -338,9 +338,9 @@
Resolver resolver = getTestResolver();
assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
- //Bundle-SymbolicName: optionalimportpackage
+ //Bundle-SymbolicName: packageimportoptional
//Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/optionalimportpackage");
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportoptional");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -386,9 +386,9 @@
Resolver resolver = getTestResolver();
assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
- //Bundle-SymbolicName: optionalimportpackage
+ //Bundle-SymbolicName: packageimportoptional
//Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
- VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/optionalimportpackage");
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/packageimportoptional");
Bundle bundleA = framework.installBundle(fileA);
try
{
@@ -438,14 +438,14 @@
assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
//Bundle-SymbolicName: bundlenameimport
- //Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=bundlenameexport
+ //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: bundlenameexport
+ //Bundle-SymbolicName: simpleexport
//Export-Package: org.jboss.test.osgi.classloader.support.a
- VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/bundlenameexport", A.class);
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexport", A.class);
Bundle bundleB = framework.installBundle(fileB);
try
{
@@ -486,14 +486,14 @@
assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
//Bundle-SymbolicName: bundlenameimport
- //Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=bundlenameexport
+ //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-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
{
@@ -694,12 +694,289 @@
}
}
+ @Test
+ public void testRequireBundleOptional() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
+
+ //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
+ resolver.resolve(null);
+
+ // Verify resolvable for bundleA
+ Resolvable resolvableA = resolver.getBundle(bundleA);
+ assertTrue("BundleA resolved", resolvableA.isResolved());
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testRequireBundleVersion() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
+
+ //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
+ resolver.resolve(null);
+
+ // Verify resolvable for bundleA
+ Resolvable resolvableA = resolver.getBundle(bundleA);
+ assertTrue("BundleA resolved", resolvableA.isResolved());
+
+ // Verify resolvable for bundleB
+ Resolvable resolvableB = resolver.getBundle(bundleB);
+ assertTrue("BundleB resolved", resolvableB.isResolved());
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testRequireBundleVersionFails() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
+
+ //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
+ resolver.resolve(null);
+
+ // Verify resolvable for bundleA
+ Resolvable resolvableA = resolver.getBundle(bundleA);
+ assertFalse("BundleA not resolved", resolvableA.isResolved());
+
+ // Verify resolvable for bundleB
+ Resolvable resolvableB = resolver.getBundle(bundleB);
+ assertTrue("BundleB resolved", resolvableB.isResolved());
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testResolvedExporterPreferred() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
+
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
+
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexportsecond", 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
+ resolver.resolve(null);
+
+ // Verify resolvable for bundleA
+ Resolvable resolvableA = resolver.getBundle(bundleA);
+ assertTrue("BundleA resolved", resolvableA.isResolved());
+
+ Bundle bundleB = framework.installBundle(fileB);
+ try
+ {
+ Bundle bundleC = framework.installBundle(fileC);
+ try
+ {
+ // Resolve the installed bundles
+ resolver.resolve(null);
+
+ // Verify resolvable for bundleB
+ Resolvable resolvableB = resolver.getBundle(bundleB);
+ assertTrue("BundleB resolved", resolvableB.isResolved());
+
+ // Verify resolvable for bundleC
+ Resolvable resolvableC = resolver.getBundle(bundleC);
+ assertTrue("BundleC resolved", resolvableC.isResolved());
+
+ // Verify that bundleC is wired to bundleA
+ ExportPackage exporter = resolver.getExporter(bundleC,
A.class.getPackage().getName());
+ assertNotNull("Exporter not null", exporter);
+ assertEquals("Wired to bundleA", bundleA.getSymbolicName(),
exporter.getOwner().getSymbolicName());
+ }
+ finally
+ {
+ bundleC.uninstall();
+ }
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
+ public void testResolvedExporterPreferredReverse() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
+
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileA = assembleBundle("bundleA",
"/bundles/resolver/simpleexport", A.class);
+
+ // Bundle-SymbolicName: simpleexport
+ // Export-Package: org.jboss.test.osgi.classloader.support.a
+ VirtualFile fileB = assembleBundle("bundleB",
"/bundles/resolver/simpleexportsecond", 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
+ resolver.resolve(null);
+
+ // Verify resolvable for bundleA
+ Resolvable resolvableB = resolver.getBundle(bundleB);
+ assertTrue("BundleB resolved", resolvableB.isResolved());
+
+ Bundle bundleA = framework.installBundle(fileA);
+ try
+ {
+ Bundle bundleC = framework.installBundle(fileC);
+ try
+ {
+ // Resolve the installed bundles
+ resolver.resolve(null);
+
+ // Verify resolvable for bundleA
+ Resolvable resolvableA = resolver.getBundle(bundleA);
+ assertTrue("BundleA resolved", resolvableA.isResolved());
+
+ // Verify resolvable for bundleC
+ Resolvable resolvableC = resolver.getBundle(bundleC);
+ assertTrue("BundleC resolved", resolvableC.isResolved());
+
+ // Verify that bundleC is wired to bundleB
+ ExportPackage exporter = resolver.getExporter(bundleC,
A.class.getPackage().getName());
+ assertNotNull("Exporter not null", exporter);
+ assertEquals("Wired to bundleB", bundleB.getSymbolicName(),
exporter.getOwner().getSymbolicName());
+ }
+ finally
+ {
+ bundleC.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+
@Ignore
+ public void testLogger() throws Exception
+ {
+ Resolver resolver = getTestResolver();
+ assertEquals("No bundles in resolver", 0, resolver.getBundles().size());
+
+ String pathA = getTestArchivePath("bundles/org.osgi.compendium.jar");
+ Bundle bundleA = framework.getBundleContext().installBundle(pathA);
+ try
+ {
+ // Resolve the compendium
+ resolver.resolve(null);
+
+ String pathB =
getTestArchivePath("bundles/org.apache.felix.log.jar");
+ Bundle bundleB = framework.getBundleContext().installBundle(pathB);
+ try
+ {
+ // Resolve the logging bundle
+ resolver.resolve(null);
+
+ // Verify resolvable for bundleA
+ Resolvable resolvableA = resolver.getBundle(bundleA);
+ assertTrue("BundleA resolved", resolvableA.isResolved());
+
+ // Verify resolvable for bundleB
+ Resolvable resolvableB = resolver.getBundle(bundleB);
+ assertTrue("BundleB resolved", resolvableB.isResolved());
+
+ }
+ finally
+ {
+ bundleB.uninstall();
+ }
+ }
+ finally
+ {
+ bundleA.uninstall();
+ }
+ }
+
+ @Test
public void testAttributeImportPackage() throws Exception
{
}
- @Ignore
+ @Test
public void testAttributeImportPackageFails() throws Exception
{
}
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/resolver-rules.drl
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/resolver-rules.drl 2009-11-17
17:54:23 UTC (rev 96464)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/resolver-rules.drl 2009-11-17
18:15:51 UTC (rev 96465)
@@ -158,17 +158,32 @@
/**************************************************************************************************
* A rule that sets the provider for a RequiredBundle if there is a match
*/
-rule "Set RequiredBundle provider on match"
+rule "RequiredBundle match on bundle-symbolic-name only"
salience 100
when
$provider : Resolvable( )
- $reqbundle : RequiredBundle( symbolicName == $provider.symbolicName, provider == null
)
+ $reqbundle : RequiredBundle( symbolicName == $provider.symbolicName, version == null,
provider == null )
then
log("RequiredBundle match " + $reqbundle + " --> " +
$provider);
modify ( $reqbundle ) { setProvider( $provider ) };
end
/**************************************************************************************************
+* A rule that sets the provider for a RequiredBundle if there is a match on
+* bundle-symbolic-name and bundle-version
+*/
+rule "RequiredBundle match on bundle-symbolic-name and bundle-version"
+salience 100
+when
+ $provider : Resolvable( )
+ $reqbundle : RequiredBundle( symbolicName == $provider.symbolicName, version != null,
provider == null )
+ eval( inRange( $reqbundle.getVersion(), $provider.getVersion()))
+then
+ log("RequiredBundle match " + $reqbundle + " --> " +
$provider);
+ modify ( $reqbundle ) { setProvider( $provider ) };
+end
+
+/**************************************************************************************************
* A rule that applies the WireCandidate if there is only one
* possible WireCandidate left that refers to an ImportPackage.
*/
@@ -180,17 +195,34 @@
not( WireCandidate( this != $wc, importPackage == $import ) )
then
log("Use " + $wc);
+ modify ( $import ) { setExporter( $wc.getExportPackage() ) };
+ retract ( $wc );
+end
+
+/**************************************************************************************************
+* A rule that applies the WireCandidate if there is an already
+* resolved exporter.
+*/
+rule "Use WireCandidate to resolved exporter"
+when
+ $importer : Resolvable( resolved == false )
+ $import : ImportPackage( owner == $importer, exporter == null )
+ $exporter : Resolvable( resolved == true )
+ $export : ExportPackage( owner == $exporter )
+ $wc : WireCandidate( importPackage == $import, exportPackage == $export )
+then
+ log("Use resolved exporter " + $wc);
modify ( $wc.getImportPackage() ) { setExporter( $wc.getExportPackage() ) };
retract ( $wc );
end
/**************************************************************************************************
-* A rule that marls the Resolvable as resolved if there
+* A rule that marks the Resolvable as resolved if there
* is no more ImportPackage that is not wired to an ExportPackage.
*/
rule "Mark resolved"
when
- $owner : Resolvable( resolved == false )
+ $owner : Resolvable( state != Bundle.UNINSTALLED, resolved == false )
not( ImportPackage( owner == $owner, optional == false, exporter == null ))
not( RequiredBundle( owner == $owner, optional == false, provider == null ))
then
@@ -254,7 +286,7 @@
$owner : Resolvable( state == Bundle.UNINSTALLED )
$reqbundle : RequiredBundle( owner == $owner )
then
- log("Unistall " + $reqbundle);
+ log("Uninstall " + $reqbundle);
retract ( $reqbundle );
end
@@ -264,7 +296,7 @@
rule "Report unresolved import"
salience -1000
when
- $import : ImportPackage( exporter == null )
+ $import : ImportPackage( exporter == null, optional == false )
then
log("Unresolved " + $import );
end
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/bundlenameimport/META-INF/MANIFEST.MF
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/bundlenameimport/META-INF/MANIFEST.MF 2009-11-17
17:54:23 UTC (rev 96464)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/bundlenameimport/META-INF/MANIFEST.MF 2009-11-17
18:15:51 UTC (rev 96465)
@@ -1,3 +1,3 @@
Bundle-ManifestVersion: 2
Bundle-SymbolicName: bundlenameimport
-Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=bundlenameexport
+Import-Package:
org.jboss.test.osgi.classloader.support.a;bundle-symbolic-name=simpleexport
Copied:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageexportversion
(from rev 96450,
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/versionexportpackage)
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageexportversion/META-INF/MANIFEST.MF
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/versionexportpackage/META-INF/MANIFEST.MF 2009-11-16
20:22:45 UTC (rev 96450)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageexportversion/META-INF/MANIFEST.MF 2009-11-17
18:15:51 UTC (rev 96465)
@@ -1,3 +1,3 @@
Bundle-ManifestVersion: 2
-Bundle-SymbolicName: versionexportpackage
+Bundle-SymbolicName: packageexportversion
Export-Package: org.jboss.test.osgi.classloader.support.a;version=1.0.0
Copied:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportoptional
(from rev 96450,
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/optionalimportpackage)
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportoptional/META-INF/MANIFEST.MF
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/optionalimportpackage/META-INF/MANIFEST.MF 2009-11-16
20:22:45 UTC (rev 96450)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportoptional/META-INF/MANIFEST.MF 2009-11-17
18:15:51 UTC (rev 96465)
@@ -1,3 +1,3 @@
Bundle-ManifestVersion: 2
-Bundle-SymbolicName: optionalimportpackage
+Bundle-SymbolicName: packageimportoptional
Import-Package: org.jboss.test.osgi.classloader.support.a;resolution:=optional
Copied:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportversion
(from rev 96450,
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/versionimportpackage)
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportversion/META-INF/MANIFEST.MF
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/versionimportpackage/META-INF/MANIFEST.MF 2009-11-16
20:22:45 UTC (rev 96450)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportversion/META-INF/MANIFEST.MF 2009-11-17
18:15:51 UTC (rev 96465)
@@ -1,3 +1,3 @@
Bundle-ManifestVersion: 2
-Bundle-SymbolicName: versionimportpackage
+Bundle-SymbolicName: packageimportversion
Import-Package:
org.jboss.test.osgi.classloader.support.a;version="[0.0.0,1.0.0]"
Copied:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportversionfails
(from rev 96450,
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/versionimportpackagefails)
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportversionfails/META-INF/MANIFEST.MF
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/versionimportpackagefails/META-INF/MANIFEST.MF 2009-11-16
20:22:45 UTC (rev 96450)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/packageimportversionfails/META-INF/MANIFEST.MF 2009-11-17
18:15:51 UTC (rev 96465)
@@ -1,3 +1,3 @@
Bundle-ManifestVersion: 2
-Bundle-SymbolicName: versionimportpackagefails
+Bundle-SymbolicName: versionimportversionfails
Import-Package: org.jboss.test.osgi.classloader.support.a;version="[3.0,4.0)"
Added:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleexportsecond/META-INF/MANIFEST.MF
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleexportsecond/META-INF/MANIFEST.MF
(rev 0)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/bundles/resolver/simpleexportsecond/META-INF/MANIFEST.MF 2009-11-17
18:15:51 UTC (rev 96465)
@@ -0,0 +1,3 @@
+Bundle-ManifestVersion: 2
+Bundle-SymbolicName: simpleexportsecond
+Export-Package: org.jboss.test.osgi.classloader.support.a