summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-07-07 22:00:41 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-07-07 22:00:41 +0000
commit7c535773f216d7f87d71718a27df6c0b85a59854 (patch)
treeb45a2245697f9e55072b6d5b818132c37e204c5a /java/sca
parent7503791fc1255a986cf349460c6420c54d69e8b3 (diff)
Fix the code to read policies and intents
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@791991 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java17
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java30
2 files changed, 41 insertions, 6 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java
index 7f5ad695cd..ef0da067bf 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java
@@ -39,6 +39,9 @@ import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.assembly.SCABindingFactory;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
@@ -75,6 +78,20 @@ public abstract class BaseBuilderImpl implements CompositeBuilder {
this.transformerFactory = transformerFactory;
this.interfaceContractMapper = interfaceContractMapper;
}
+
+ /**
+ * Construct a builder from the extension point registry
+ * @param registry
+ */
+ protected BaseBuilderImpl(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factoryExtensionPoint = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factoryExtensionPoint.getFactory(AssemblyFactory.class);
+ this.scaBindingFactory = factoryExtensionPoint.getFactory(SCABindingFactory.class);
+ this.documentBuilderFactory = factoryExtensionPoint.getFactory(DocumentBuilderFactory.class);
+ this.transformerFactory = factoryExtensionPoint.getFactory(TransformerFactory.class);
+ this.interfaceContractMapper =
+ registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(InterfaceContractMapper.class);
+ }
/**
* Report a warning.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java
index 5c3249369b..9483810d9a 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java
@@ -38,6 +38,7 @@ import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -53,7 +54,10 @@ import org.apache.tuscany.sca.policy.PolicySubject;
* @version $Rev$ $Date$
*/
public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements CompositeBuilder {
-
+ public CompositePolicyBuilderImpl(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
public CompositePolicyBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) {
super(assemblyFactory, null, null, null, interfaceContractMapper);
}
@@ -181,15 +185,29 @@ public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements Compo
return name2.equals(name1);
}
}
+
+ private Intent resolve(Definitions definitions, Intent proxy) {
+ for(Intent i: definitions.getIntents()) {
+ if(i.equals(proxy)) {
+ return i;
+ }
+ for(Intent qi: i.getQualifiedIntents()) {
+ if(qi.equals(proxy)) {
+ return qi;
+ }
+ }
+ }
+ return null;
+ }
private void resolveAndNormalize(PolicySubject subject, Definitions definitions, Monitor monitor) {
Set<Intent> intents = new HashSet<Intent>();
if (definitions != null) {
for (Intent i : subject.getRequiredIntents()) {
- int index = definitions.getIntents().indexOf(i);
- if (index != -1) {
- intents.add(definitions.getIntents().get(index));
+ Intent resolved = resolve(definitions, i);
+ if (resolved != null) {
+ intents.add(resolved);
} else {
warning(monitor, "intent-not-found", subject, i.getName().toString());
// Intent cannot be resolved
@@ -198,8 +216,8 @@ public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements Compo
}
// Replace profile intents with their required intents
- boolean profileIntentsFound = false;
- while (true) {
+ while (!intents.isEmpty()) {
+ boolean profileIntentsFound = false;
Set<Intent> copy = new HashSet<Intent>(intents);
for (Intent i : copy) {
if (!i.getRequiredIntents().isEmpty()) {