summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/contribution/src
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-02-02 10:01:25 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-02-02 10:01:25 +0000
commitb88e412e331eeaa9658c21f37c31d4d08a149b12 (patch)
tree9358970ab6c1424c4d6bd3d3a6222c335c6c9bd4 /java/sca/modules/contribution/src
parent8751ca0a45b9343f37161c9f762fb4c485944a5f (diff)
TUSCANY-2801 - Create a SystemContribution to hold data from definitions.xml found in extensions and in application contributions. This change creates a system contribution on the fly in the node and installs a DefaultModelResolver for various policy elements. The default resolver not takes account of any default imports that are available. All application level contributions are linked to the system contribution via a default import that references the system contributions model resolver. Hence policy element resolution will traverse the tree to the system contribution if the element is not resolved locally. We may want to create specific policy resolvers here but this change allows for some experimentation. The next hurdle to getting this to work is to get policy set XPath applied to the assembly model again.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@739953 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/contribution/src')
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java
index 597fa6f4a0..5f4b5100c2 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java
@@ -22,6 +22,11 @@ package org.apache.tuscany.sca.contribution.resolver;
import java.util.HashMap;
import java.util.Map;
+import org.apache.tuscany.sca.assembly.Base;
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.DefaultImport;
+import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
/**
* A default implementation of a model resolver based on a map.
@@ -30,11 +35,16 @@ import java.util.Map;
*/
public class DefaultModelResolver implements ModelResolver {
+ private Contribution contribution;
private Map<Object, Object> map = new HashMap<Object, Object>();
public DefaultModelResolver() {
}
+ public DefaultModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ this.contribution = contribution;
+ }
+
public <T> T resolveModel(Class<T> modelClass, T unresolved) {
Object resolved = map.get(unresolved);
if (resolved != null) {
@@ -44,6 +54,19 @@ public class DefaultModelResolver implements ModelResolver {
} else {
+ // by default try and resolve through a default import
+ // if there is one.
+ if (contribution != null){
+ for (Import _import : contribution.getImports()){
+ if (_import instanceof DefaultImport){
+ resolved = _import.getModelResolver().resolveModel(modelClass, unresolved);
+ if (resolved != unresolved){
+ return modelClass.cast(resolved);
+ }
+ }
+ }
+ }
+
// Return the unresolved object
return unresolved;
}