Author: thomas.diesler(a)jboss.com
Date: 2009-11-19 05:00:29 -0500 (Thu, 19 Nov 2009)
New Revision: 96555
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/resolver-rules.drl
Log:
Prefer wire to resolved exporter
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-19
09:56:32 UTC (rev 96554)
+++
projects/jboss-osgi/trunk/reactor/framework/src/test/resources/META-INF/resolver-rules.drl 2009-11-19
10:00:29 UTC (rev 96555)
@@ -41,7 +41,7 @@
*/
function void log(String message)
{
- // System.out.println(message);
+ //System.out.println(message);
}
# Types
###########################################################################################
@@ -56,9 +56,9 @@
rule "Add ImportPackage for new Resolvable"
salience 10000
when
- $owner : Resolvable( resolved == false, state == Bundle.INSTALLED )
- $import : ImportPackage( ) from $owner.importPackages
- not ImportPackage( owner == $owner, this == $import )
+ $importer : Resolvable( resolved == false, state == Bundle.INSTALLED )
+ $import : ImportPackage( ) from $importer.importPackages
+ not ImportPackage( owner == $importer, this == $import )
then
log("Add " + $import);
insert( $import );
@@ -71,9 +71,9 @@
rule "Add ExportPackage for new Resolvable"
salience 10000
when
- $owner : Resolvable( resolved == false, state == Bundle.INSTALLED )
- $export : ExportPackage( ) from $owner.exportPackages
- not ExportPackage( owner == $owner, this == $export )
+ $exporter : Resolvable( resolved == false, state == Bundle.INSTALLED )
+ $export : ExportPackage( ) from $exporter.exportPackages
+ not ExportPackage( owner == $exporter, this == $export )
then
log("Add " + $export);
insert( $export );
@@ -86,9 +86,9 @@
rule "Add RequiredBundle for new Resolvable"
salience 10000
when
- $owner : Resolvable( resolved == false, state == Bundle.INSTALLED )
- $reqbundle : RequiredBundle( ) from $owner.requiredBundles
- not RequiredBundle( owner == $owner, this == $reqbundle )
+ $importer : Resolvable( resolved == false, state == Bundle.INSTALLED )
+ $reqbundle : RequiredBundle( ) from $importer.requiredBundles
+ not RequiredBundle( owner == $importer, this == $reqbundle )
then
log("Add " + $reqbundle);
insert( $reqbundle );
@@ -162,8 +162,8 @@
rule "Retract WireCandidate to unresolved exporter"
salience 100
when
- $owner : Resolvable( resolved == false )
- $import : ImportPackage( owner == $owner, exporter == null )
+ $importer : Resolvable( resolved == false )
+ $import : ImportPackage( owner == $importer, exporter == null )
$reskeep : Resolvable( resolved == true )
$expkeep : ExportPackage( owner == $reskeep )
$wckeep : WireCandidate( importPackage == $import, exportPackage == $expkeep )
@@ -205,41 +205,82 @@
/**************************************************************************************************
* A rule that applies the WireCandidate if there is only one
-* possible WireCandidate left that refers to an ImportPackage.
+* possible WireCandidate left associated with an ImportPackage.
+* The exporter must be resolved.
*/
-rule "Use WireCandidate"
+rule "Wire to resolved exporter"
+salience 50
when
- $owner : Resolvable( resolved == false )
- $import : ImportPackage( owner == $owner, exporter == null )
- $wc : WireCandidate( importPackage == $import )
+ $importer : Resolvable( resolved == false )
+ $import : ImportPackage( owner == $importer, exporter == null )
+ $exporter : Resolvable( resolved == true )
+ $export : ExportPackage( owner == $exporter )
+ $wc : WireCandidate( importPackage == $import, exportPackage == $export )
not( WireCandidate( this != $wc, importPackage == $import ) )
then
- log("Use " + $wc);
+ log("Wire to resolved exporter " + $wc);
modify ( $import ) { setExporter( $wc.getExportPackage() ) };
retract ( $wc );
end
/**************************************************************************************************
-* A rule that marks the Resolvable as resolved if there
-* is no more ImportPackage that is not wired to an ExportPackage.
+* A rule that applies the WireCandidate if there is only one
+* possible WireCandidate left associated with an ImportPackage.
+* The exporter is also the importer.
*/
-rule "Mark resolved"
+rule "Wire self import"
+salience 50
when
- $owner : Resolvable( state != Bundle.UNINSTALLED, resolved == false )
- not( ImportPackage( owner == $owner, optional == false, exporter == null ))
- not( RequiredBundle( owner == $owner, optional == false, provider == null ))
+ $import : ImportPackage( exporter == null )
+ $export : ExportPackage( owner == $import.owner )
+ $wc : WireCandidate( importPackage == $import, exportPackage == $export )
+ not( WireCandidate( this != $wc, importPackage == $import ) )
then
- log("Resolved " + $owner);
- modify ( $owner ) { markResolved ( ) };
+ log("Wire self import " + $wc);
+ modify ( $import ) { setExporter( $wc.getExportPackage() ) };
+ retract ( $wc );
end
/**************************************************************************************************
+* A rule that marks the Resolvable as resolved on the condition that
+*
+* # All ImportPackage wire to an exporter
+* # All non-optional RequiredBundles have a provider
+*/
+rule "Resolve required imports"
+salience 20
+when
+ $importer : Resolvable( state != Bundle.UNINSTALLED, resolved == false )
+ not( ImportPackage( owner == $importer, exporter == null ))
+ not( RequiredBundle( owner == $importer, optional == false, provider == null ))
+then
+ log("Resolved " + $importer);
+ modify ( $importer ) { markResolved ( ) };
+end
+
+/**************************************************************************************************
+* A rule that marks the Resolvable as resolved on the condition that
+*
+* # All non-optional ImportPackage wire to an exporter
+* # All non-optional RequiredBundles have a provider
+*/
+rule "Resolve optional imports"
+when
+ $importer : Resolvable( state != Bundle.UNINSTALLED, resolved == false )
+ not( ImportPackage( owner == $importer, optional == false, exporter == null ))
+ not( RequiredBundle( owner == $importer, optional == false, provider == null ))
+then
+ log("Resolved " + $importer);
+ modify ( $importer ) { markResolved ( ) };
+end
+
+/**************************************************************************************************
* A rule that retracts ImportPackage facts for UNINSTALLED bundles
*/
rule "Retract uninstalled ImportPackage"
when
- $owner : Resolvable( state == Bundle.UNINSTALLED )
- $import : ImportPackage( owner == $owner )
+ $importer : Resolvable( state == Bundle.UNINSTALLED )
+ $import : ImportPackage( owner == $importer )
then
log("Uninstall " + $import);
retract ( $import );
@@ -250,8 +291,8 @@
*/
rule "Retract uninstalled ExportPackage"
when
- $owner : Resolvable( state == Bundle.UNINSTALLED )
- $export : ExportPackage( owner == $owner )
+ $exporter : Resolvable( state == Bundle.UNINSTALLED )
+ $export : ExportPackage( owner == $exporter )
then
log("Uninstall " + $export);
retract ( $export );
@@ -286,8 +327,8 @@
*/
rule "Retract uninstalled RequiredBundles"
when
- $owner : Resolvable( state == Bundle.UNINSTALLED )
- $reqbundle : RequiredBundle( owner == $owner )
+ $importer : Resolvable( state == Bundle.UNINSTALLED )
+ $reqbundle : RequiredBundle( owner == $importer )
then
log("Uninstall " + $reqbundle);
retract ( $reqbundle );