summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-09-14 21:49:36 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-09-14 21:49:36 +0000
commit053d9c4b0bc3992e55d6d0c77a119de702a48eb3 (patch)
tree2740369607eeb9e5540e28cec056d560c8b69626 /java/sca/modules
parent587569bffde0f73937d64671d1bf175d564af5b2 (diff)
Enhance the CompositeBuilderExtensionPoint to include binding/implementation builders which replace BindingExtension and CompositePreProcessor
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@814879 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java8
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java15
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java186
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java (renamed from java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java)16
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java7
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentBuilderImpl.java26
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java34
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java19
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java8
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java7
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java10
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java17
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentTypeBuilderImpl.java4
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java16
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java21
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java84
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java78
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePolicyBuilderImpl.java6
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java8
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java7
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java13
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java7
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ModelBuilderImpl.java2
-rw-r--r--java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties3
-rw-r--r--java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java2
-rw-r--r--java/sca/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF1
-rw-r--r--java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java5
-rw-r--r--java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java (renamed from java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/BindingBuilderImpl.java)30
-rw-r--r--java/sca/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder17
-rw-r--r--java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java1
-rw-r--r--java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java3
-rw-r--r--java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java10
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java17
-rw-r--r--java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java (renamed from java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/MockPolicy.java)2
-rw-r--r--java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java (renamed from java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/ReadDocumentTestCase.java)3
-rw-r--r--java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java (renamed from java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/TestPolicyProcessor.java)2
-rw-r--r--java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml (renamed from java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/test_definitions.xml)1
-rw-r--r--java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java5
-rw-r--r--java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java (renamed from java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java)31
-rw-r--r--java/sca/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder17
-rw-r--r--java/sca/modules/implementation-web/META-INF/MANIFEST.MF1
-rw-r--r--java/sca/modules/implementation-web/pom.xml1
-rw-r--r--java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationBuilder.java41
-rw-r--r--java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java5
-rw-r--r--java/sca/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder17
-rw-r--r--java/sca/modules/policy-xml/META-INF/MANIFEST.MF17
-rw-r--r--java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java52
-rw-r--r--java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite2
-rw-r--r--java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml1
49 files changed, 596 insertions, 290 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java
index cd71f06279..dbb1bab44b 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilder.java
@@ -19,9 +19,9 @@
package org.apache.tuscany.sca.assembly.builder;
-import org.apache.tuscany.sca.assembly.AbstractContract;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.monitor.Monitor;
/**
@@ -29,7 +29,7 @@ import org.apache.tuscany.sca.monitor.Monitor;
*
* @version $Rev$ $Date$
*/
-public interface BindingBuilder {
+public interface BindingBuilder<B extends Binding> {
/**
* Configure a binding.
@@ -37,6 +37,8 @@ public interface BindingBuilder {
* @param component The component for the binding's service or reference
* @param contract The binding's service or reference
*/
- void build(Component component, AbstractContract contract, Binding binding, Monitor monitor);
+ void build(Component component, Contract contract, B binding, Monitor monitor);
+
+ Class<B> getModelType();
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java
index 151da31af0..d20c28d61e 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/CompositeBuilderExtensionPoint.java
@@ -19,6 +19,9 @@
package org.apache.tuscany.sca.assembly.builder;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Implementation;
+
/**
* An extension point for Composite builders.
*
@@ -47,5 +50,17 @@ public interface CompositeBuilderExtensionPoint {
* @return
*/
CompositeBuilder getCompositeBuilder(String id);
+
+ void addBindingBuilder(BindingBuilder<?> bindingBuilder);
+
+ <B extends Binding> BindingBuilder<B> getBindingBuilder(Class<B> bindingType);
+
+ <B extends Binding> void removeBindingBuilder(BindingBuilder<B> builder);
+
+ void addImplementationBuilder(ImplementationBuilder<?> implementationBuilder);
+
+ <I extends Implementation> ImplementationBuilder<I> getImplementationBuilder(Class<I> implementationType);
+
+ <I extends Implementation> void removeImplementationBuilder(ImplementationBuilder<I> builder);
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java
index c98e31d95b..7fdd3b19f5 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/DefaultCompositeBuilderExtensionPoint.java
@@ -27,7 +27,11 @@ import java.util.Map;
import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
@@ -46,6 +50,9 @@ public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderEx
private ExtensionPointRegistry registry;
private final Map<String, CompositeBuilder> builders = new HashMap<String, CompositeBuilder>();
+ private final Map<Class<?>, BindingBuilder> bindingBuilders = new HashMap<Class<?>, BindingBuilder>();
+ private final Map<Class<?>, ImplementationBuilder> implementationBuilders =
+ new HashMap<Class<?>, ImplementationBuilder>();
private boolean loaded;
public DefaultCompositeBuilderExtensionPoint(ExtensionPointRegistry registry) {
@@ -90,19 +97,84 @@ public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderEx
Map<String, String> attributes = builderDeclaration.getAttributes();
String id = attributes.get("id");
- CompositeBuilder builder =
- new LazyCompositeBuilder(registry, id, builderDeclaration, this, factories, mapper);
+ CompositeBuilder builder = new LazyCompositeBuilder(id, builderDeclaration, this, factories, mapper);
builders.put(id, builder);
}
+
+ try {
+ builderDeclarations = serviceDiscovery.getServiceDeclarations(BindingBuilder.class);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration builderDeclaration : builderDeclarations) {
+ BindingBuilder<?> builder = new LazyBindingBuilder(builderDeclaration);
+ bindingBuilders.put(builder.getModelType(), builder);
+ }
+
+ try {
+ builderDeclarations = serviceDiscovery.getServiceDeclarations(ImplementationBuilder.class);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ for (ServiceDeclaration builderDeclaration : builderDeclarations) {
+ ImplementationBuilder<?> builder = new LazyImplementationBuilder(builderDeclaration);
+ implementationBuilders.put(builder.getModelType(), builder);
+ }
+
+ }
+
+ public void addBindingBuilder(BindingBuilder<?> bindingBuilder) {
+ bindingBuilders.put(bindingBuilder.getModelType(), bindingBuilder);
+ }
+
+ public void addImplementationBuilder(ImplementationBuilder<?> implementationBuilder) {
+ implementationBuilders.put(implementationBuilder.getModelType(), implementationBuilder);
+ }
+
+ public <B extends Binding> BindingBuilder<B> getBindingBuilder(Class<B> bindingType) {
+ if (bindingType.isInterface()) {
+ return (BindingBuilder<B>)bindingBuilders.get(bindingType);
+ }
+ Class<?>[] classes = bindingType.getInterfaces();
+ for (Class<?> i : classes) {
+ BindingBuilder<B> builder = (BindingBuilder<B>)bindingBuilders.get(i);
+ if (builder != null) {
+ return builder;
+ }
+ }
+ return null;
+ }
+
+ public <I extends Implementation> ImplementationBuilder<I> getImplementationBuilder(Class<I> implementationType) {
+ if (implementationType.isInterface()) {
+ return (ImplementationBuilder<I>)implementationBuilders.get(implementationType);
+ }
+ Class<?>[] classes = implementationType.getInterfaces();
+ for (Class<?> i : classes) {
+ ImplementationBuilder<I> builder = (ImplementationBuilder<I>)implementationBuilders.get(i);
+ if (builder != null) {
+ return builder;
+ }
+ }
+ return null;
+ }
+
+ public <B extends Binding> void removeBindingBuilder(BindingBuilder<B> builder) {
+ bindingBuilders.remove(builder.getModelType());
+ }
+
+ public <I extends Implementation> void removeImplementationBuilder(ImplementationBuilder<I> builder) {
+ implementationBuilders.remove(builder.getModelType());
}
/**
* A wrapper around a composite builder allowing lazy
* loading and initialization of implementation providers.
*/
- private static class LazyCompositeBuilder implements CompositeBuilder, CompositeBuilderTmp {
+ private class LazyCompositeBuilder implements CompositeBuilder, CompositeBuilderTmp {
- private ExtensionPointRegistry registry;
private FactoryExtensionPoint factories;
private InterfaceContractMapper mapper;
private String id;
@@ -110,13 +182,11 @@ public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderEx
private CompositeBuilder builder;
private CompositeBuilderExtensionPoint builders;
- private LazyCompositeBuilder(ExtensionPointRegistry registry,
- String id,
+ private LazyCompositeBuilder(String id,
ServiceDeclaration factoryDeclaration,
CompositeBuilderExtensionPoint builders,
FactoryExtensionPoint factories,
InterfaceContractMapper mapper) {
- this.registry = registry;
this.id = id;
this.builderDeclaration = factoryDeclaration;
this.builders = builders;
@@ -170,4 +240,106 @@ public class DefaultCompositeBuilderExtensionPoint implements CompositeBuilderEx
}
+ private class LazyBindingBuilder implements BindingBuilder {
+ private ServiceDeclaration sd;
+ private String model;
+ private BindingBuilder<?> builder;
+ private Class<?> modelType;
+
+ /**
+ * @param sd
+ */
+ public LazyBindingBuilder(ServiceDeclaration sd) {
+ super();
+ this.sd = sd;
+ this.model = sd.getAttributes().get("model");
+ }
+
+ public void build(Component component, Contract contract, Binding binding, Monitor monitor) {
+ getBuilder().build(component, contract, binding, monitor);
+ }
+
+ public Class getModelType() {
+ if (modelType == null) {
+ try {
+ modelType = sd.loadClass(model);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+
+ private synchronized BindingBuilder getBuilder() {
+ if (builder == null) {
+ try {
+ Class<?> builderClass = sd.loadClass();
+ try {
+ Constructor<?> constructor = builderClass.getConstructor(ExtensionPointRegistry.class);
+ builder = (BindingBuilder)constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ Constructor<?> constructor = builderClass.getConstructor();
+ builder = (BindingBuilder)constructor.newInstance();
+
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+
+ }
+
+ private class LazyImplementationBuilder implements ImplementationBuilder {
+ private ServiceDeclaration sd;
+ private String model;
+ private ImplementationBuilder<?> builder;
+ private Class<?> modelType;
+
+ /**
+ * @param sd
+ */
+ public LazyImplementationBuilder(ServiceDeclaration sd) {
+ super();
+ this.sd = sd;
+ this.model = sd.getAttributes().get("model");
+ }
+
+ public void build(Component component, Implementation implementation, Monitor monitor) {
+ getBuilder().build(component, implementation, monitor);
+ }
+
+ public Class getModelType() {
+ if (modelType == null) {
+ try {
+ modelType = sd.loadClass(model);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+
+ private synchronized ImplementationBuilder getBuilder() {
+ if (builder == null) {
+ try {
+ Class<?> builderClass = sd.loadClass();
+ try {
+ Constructor<?> constructor = builderClass.getConstructor(ExtensionPointRegistry.class);
+ builder = (ImplementationBuilder)constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ Constructor<?> constructor = builderClass.getConstructor();
+ builder = (ImplementationBuilder)constructor.newInstance();
+
+ }
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return builder;
+ }
+
+ }
+
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java
index d2fae4d24a..2c2b3c1cba 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ComponentPreProcessor.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/ImplementationBuilder.java
@@ -20,14 +20,24 @@
package org.apache.tuscany.sca.assembly.builder;
import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.monitor.Monitor;
/**
- * Interface for Component Pre Processors.
+ * A builder that handles any build-time configuration needed by implementations.
*
* @version $Rev$ $Date$
*/
-public interface ComponentPreProcessor {
+public interface ImplementationBuilder<I extends Implementation> {
- void preProcess(Component component);
+ /**
+ * Configure a component implementation.
+ *
+ * @param component The component
+ * @param contract The implementation
+ */
+ void build(Component component, I implmentation, Monitor monitor);
+
+ Class<I> getModelType();
}
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 4b83606116..b512743972 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,7 @@ 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.assembly.builder.CompositeBuilderExtensionPoint;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
@@ -67,12 +68,15 @@ public abstract class BaseBuilderImpl implements CompositeBuilder {
protected InterfaceContractMapper interfaceContractMapper;
protected DocumentBuilderFactory documentBuilderFactory;
protected TransformerFactory transformerFactory;
+ protected CompositeBuilderExtensionPoint builders;
- protected BaseBuilderImpl(AssemblyFactory assemblyFactory,
+ protected BaseBuilderImpl(CompositeBuilderExtensionPoint builders,
+ AssemblyFactory assemblyFactory,
SCABindingFactory scaBindingFactory,
DocumentBuilderFactory documentBuilderFactory,
TransformerFactory transformerFactory,
InterfaceContractMapper interfaceContractMapper) {
+ this.builders = builders;
this.assemblyFactory = assemblyFactory;
this.scaBindingFactory = scaBindingFactory;
this.documentBuilderFactory = documentBuilderFactory;
@@ -85,6 +89,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder {
* @param registry
*/
protected BaseBuilderImpl(ExtensionPointRegistry registry) {
+ this.builders = registry.getExtensionPoint(CompositeBuilderExtensionPoint.class);
FactoryExtensionPoint factoryExtensionPoint = registry.getExtensionPoint(FactoryExtensionPoint.class);
this.assemblyFactory = factoryExtensionPoint.getFactory(AssemblyFactory.class);
this.scaBindingFactory = factoryExtensionPoint.getFactory(SCABindingFactory.class);
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentBuilderImpl.java
index 23493599bc..9d9b3165eb 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentBuilderImpl.java
@@ -18,21 +18,14 @@
*/
package org.apache.tuscany.sca.assembly.builder.impl;
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.TransformerFactory;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
-import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.CompositeService;
@@ -42,10 +35,8 @@ import org.apache.tuscany.sca.assembly.Reference;
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.ComponentPreProcessor;
-import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
-import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
-import org.apache.tuscany.sca.assembly.builder.CompositeBuilderTmp;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.assembly.builder.ImplementationBuilder;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
@@ -55,8 +46,6 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.MonitorFactory;
import org.apache.tuscany.sca.policy.ExtensionType;
-import org.apache.tuscany.sca.policy.Intent;
-import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySubject;
/**
@@ -74,6 +63,7 @@ public class ComponentBuilderImpl {
private AssemblyFactory assemblyFactory;
private SCABindingFactory scaBindingFactory;
private InterfaceContractMapper interfaceContractMapper;
+ private CompositeBuilderExtensionPoint builders;
public ComponentBuilderImpl(ExtensionPointRegistry registry) {
UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class);
@@ -85,6 +75,8 @@ public class ComponentBuilderImpl {
scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+
+ builders = registry.getExtensionPoint(CompositeBuilderExtensionPoint.class);
}
public void setComponentTypeBuilder(ComponentTypeBuilderImpl componentTypeBuilder){
@@ -99,8 +91,12 @@ public class ComponentBuilderImpl {
// do any required pre-processing on the implementation
// what does this do?
- if (component.getImplementation() instanceof ComponentPreProcessor) {
- ((ComponentPreProcessor)component.getImplementation()).preProcess(component);
+ Implementation impl = component.getImplementation();
+ if (impl != null) {
+ ImplementationBuilder builder = builders.getImplementationBuilder(impl.getClass());
+ if (builder != null) {
+ builder.build(component, impl, monitor);
+ }
}
// create the component type for this component
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java
index a44c5b262a..34917a3cd9 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java
@@ -24,10 +24,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.TransformerFactory;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentProperty;
import org.apache.tuscany.sca.assembly.ComponentReference;
@@ -38,14 +34,13 @@ import org.apache.tuscany.sca.assembly.CompositeService;
import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
-import org.apache.tuscany.sca.assembly.SCABindingFactory;
import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.assembly.builder.ComponentPreProcessor;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.ImplementationBuilder;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.Monitor;
/**
@@ -55,19 +50,8 @@ import org.apache.tuscany.sca.monitor.Monitor;
*/
public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implements CompositeBuilder {
- @Deprecated
- public ComponentConfigurationBuilderImpl(AssemblyFactory assemblyFactory,
- SCABindingFactory scaBindingFactory,
- InterfaceContractMapper interfaceContractMapper) {
- super(assemblyFactory, scaBindingFactory, null, null, interfaceContractMapper);
- }
-
- public ComponentConfigurationBuilderImpl(AssemblyFactory assemblyFactory,
- SCABindingFactory scaBindingFactory,
- DocumentBuilderFactory documentBuilderFactory,
- TransformerFactory transformerFactory,
- InterfaceContractMapper interfaceContractMapper) {
- super(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper);
+ public ComponentConfigurationBuilderImpl(ExtensionPointRegistry registry) {
+ super(registry);
}
public String getID() {
@@ -158,9 +142,13 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement
component.setAutowire(composite.getAutowire());
}
- if (component.getImplementation() instanceof ComponentPreProcessor) {
- ((ComponentPreProcessor)component.getImplementation()).preProcess(component);
- }
+ Implementation impl = component.getImplementation();
+ if (impl != null) {
+ ImplementationBuilder builder = builders.getImplementationBuilder(impl.getClass());
+ if (builder != null) {
+ builder.build(component, impl, monitor);
+ }
+ }
// Index implementation properties, services and references
Map<String, Service> services = new HashMap<String, Service>();
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java
index ca9e55662a..a9400d95ef 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceBindingBuilderImpl.java
@@ -24,9 +24,11 @@ import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -38,9 +40,12 @@ import org.apache.tuscany.sca.monitor.Monitor;
*/
public class ComponentReferenceBindingBuilderImpl implements CompositeBuilder {
- public ComponentReferenceBindingBuilderImpl() {
- }
+ private CompositeBuilderExtensionPoint builders;
+ public ComponentReferenceBindingBuilderImpl(ExtensionPointRegistry registry) {
+ this.builders = registry.getExtensionPoint(CompositeBuilderExtensionPoint.class);
+ }
+
public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
buildReferenceBindings(composite, monitor);
}
@@ -55,11 +60,9 @@ public class ComponentReferenceBindingBuilderImpl implements CompositeBuilder {
for (Component component : composite.getComponents()) {
for (ComponentReference componentReference : component.getReferences()) {
for (Binding binding : componentReference.getBindings()) {
- if (binding instanceof BindingBuilderExtension) {
- ((BindingBuilderExtension)binding).getBuilder().build(component,
- componentReference,
- binding,
- monitor);
+ BindingBuilder builder = builders.getBindingBuilder(binding.getClass());
+ if (builder != null) {
+ builder.build(component, componentReference, binding, monitor);
}
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java
index f83ca90331..f865c36263 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java
@@ -24,7 +24,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
@@ -39,9 +38,9 @@ import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.SCABinding;
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.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicySet;
@@ -58,9 +57,8 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI
//boolean useNew = true;
boolean useNew = false;
- public ComponentReferenceEndpointReferenceBuilderImpl(AssemblyFactory assemblyFactory,
- InterfaceContractMapper interfaceContractMapper) {
- super(assemblyFactory, null, null, null, interfaceContractMapper);
+ public ComponentReferenceEndpointReferenceBuilderImpl(ExtensionPointRegistry registry) {
+ super(registry);
}
public String getID() {
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java
index fb723bf43c..b4f3516bd3 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferencePromotionBuilderImpl.java
@@ -31,6 +31,8 @@ import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.SCABinding;
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.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -42,8 +44,9 @@ import org.apache.tuscany.sca.monitor.Monitor;
public class ComponentReferencePromotionBuilderImpl implements CompositeBuilder {
private AssemblyFactory assemblyFactory;
- public ComponentReferencePromotionBuilderImpl(AssemblyFactory assemblyFactory) {
- this.assemblyFactory = assemblyFactory;
+ public ComponentReferencePromotionBuilderImpl(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
}
public void build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException {
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java
index f6b6561bdd..53221fd3c5 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java
@@ -23,19 +23,16 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.Implementation;
-import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Wire;
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;
/**
@@ -45,9 +42,8 @@ import org.apache.tuscany.sca.monitor.Monitor;
*/
public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implements CompositeBuilder {
- public ComponentReferenceWireBuilderImpl(AssemblyFactory assemblyFactory,
- InterfaceContractMapper interfaceContractMapper) {
- super(assemblyFactory, null, null, null, interfaceContractMapper);
+ public ComponentReferenceWireBuilderImpl(ExtensionPointRegistry registry) {
+ super(registry);
}
public String getID() {
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java
index 613b39171f..f8d25887cf 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentServiceBindingBuilderImpl.java
@@ -25,9 +25,10 @@ import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
-import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -38,8 +39,10 @@ import org.apache.tuscany.sca.monitor.Monitor;
* @version $Rev$ $Date$
*/
public class ComponentServiceBindingBuilderImpl implements CompositeBuilder {
-
- public ComponentServiceBindingBuilderImpl() {
+ private CompositeBuilderExtensionPoint builders;
+
+ public ComponentServiceBindingBuilderImpl(ExtensionPointRegistry registry) {
+ this.builders = registry.getExtensionPoint(CompositeBuilderExtensionPoint.class);
}
public String getID() {
@@ -64,11 +67,9 @@ public class ComponentServiceBindingBuilderImpl implements CompositeBuilder {
for (Component component : composite.getComponents()) {
for (ComponentService componentService : component.getServices()) {
for (Binding binding : componentService.getBindings()) {
- if (binding instanceof BindingBuilderExtension) {
- BindingBuilder builder = ((BindingBuilderExtension)binding).getBuilder();
- if (builder != null) {
- builder.build(component, componentService, binding, monitor);
- }
+ BindingBuilder builder = builders.getBindingBuilder(binding.getClass());
+ if (builder != null) {
+ builder.build(component, componentService, binding, monitor);
}
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentTypeBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentTypeBuilderImpl.java
index 6750643c6f..f419432b1f 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentTypeBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentTypeBuilderImpl.java
@@ -37,7 +37,7 @@ import org.apache.tuscany.sca.assembly.Implementation;
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.ComponentPreProcessor;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
@@ -64,6 +64,7 @@ public class ComponentTypeBuilderImpl {
private AssemblyFactory assemblyFactory;
private SCABindingFactory scaBindingFactory;
private InterfaceContractMapper interfaceContractMapper;
+ private CompositeBuilderExtensionPoint builders;
public ComponentTypeBuilderImpl(ExtensionPointRegistry registry) {
@@ -76,6 +77,7 @@ public class ComponentTypeBuilderImpl {
scaBindingFactory = modelFactories.getFactory(SCABindingFactory.class);
interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
+ builders = registry.getExtensionPoint(CompositeBuilderExtensionPoint.class);
}
public void setComponentBuilder(ComponentBuilderImpl componentBuilder){
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java
index 1c1047da3e..417c0b60e0 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingConfigurationBuilderImpl.java
@@ -21,15 +21,12 @@ package org.apache.tuscany.sca.assembly.builder.impl;
import java.util.List;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.SCABindingFactory;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+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;
/**
@@ -44,15 +41,8 @@ import org.apache.tuscany.sca.monitor.Monitor;
public class CompositeBindingConfigurationBuilderImpl extends CompositeBindingURIBuilderImpl implements
CompositeBuilder {
- public CompositeBindingConfigurationBuilderImpl(FactoryExtensionPoint factories, InterfaceContractMapper mapper) {
- super(factories.getFactory(AssemblyFactory.class), factories.getFactory(SCABindingFactory.class), null, null,
- mapper);
- }
-
- public CompositeBindingConfigurationBuilderImpl(AssemblyFactory assemblyFactory,
- SCABindingFactory scaBindingFactory,
- InterfaceContractMapper interfaceContractMapper) {
- super(assemblyFactory, scaBindingFactory, null, null, interfaceContractMapper);
+ public CompositeBindingConfigurationBuilderImpl(ExtensionPointRegistry registry) {
+ super(registry);
}
public String getID() {
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java
index cf48c49add..b2deb54d1f 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java
@@ -26,10 +26,7 @@ import java.util.List;
import java.util.Map;
import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.TransformerFactory;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentProperty;
@@ -40,13 +37,12 @@ import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
-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.assembly.builder.CompositeBuilderException;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderTmp;
+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;
/**
@@ -56,19 +52,8 @@ import org.apache.tuscany.sca.monitor.Monitor;
*/
public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements CompositeBuilder, CompositeBuilderTmp {
- @Deprecated
- public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory,
- SCABindingFactory scaBindingFactory,
- InterfaceContractMapper interfaceContractMapper) {
- super(assemblyFactory, scaBindingFactory, null, null, interfaceContractMapper);
- }
-
- public CompositeBindingURIBuilderImpl(AssemblyFactory assemblyFactory,
- SCABindingFactory scaBindingFactory,
- DocumentBuilderFactory documentBuilderFactory,
- TransformerFactory transformerFactory,
- InterfaceContractMapper interfaceContractMapper) {
- super(assemblyFactory, scaBindingFactory, documentBuilderFactory, transformerFactory, interfaceContractMapper);
+ public CompositeBindingURIBuilderImpl(ExtensionPointRegistry registry) {
+ super(registry);
}
public String getID() {
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
index b42987c6db..275973023f 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
@@ -23,20 +23,17 @@ import java.util.Map;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.TransformerFactory;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.assembly.SCABindingFactory;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderTmp;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.definitions.Definitions;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.policy.PolicyFactory;
/**
* A builder that handles the configuration of the components inside a composite
@@ -66,74 +63,41 @@ public class CompositeBuilderImpl implements CompositeBuilder, CompositeBuilderT
private CompositeBuilder componentReferenceEndpointReferenceBuilder;
private CompositeBuilder componentServiceEndpointBuilder;
- //private CompositeBuilder endpointReferenceBuilder;
-
- public CompositeBuilderImpl(FactoryExtensionPoint factories, InterfaceContractMapper mapper) {
- this(factories.getFactory(AssemblyFactory.class), factories.getFactory(SCABindingFactory.class), factories
- .getFactory(PolicyFactory.class), factories.getFactory(DocumentBuilderFactory.class), factories
- .getFactory(TransformerFactory.class), mapper);
- }
-
- /**
- * Constructs a new composite builder.
- *
- * @param assemblyFactory
- * @param scaBindingFactory
- * @param endpointFactory
- * @param intentAttachPointTypeFactory
- * @param interfaceContractMapper
- * @param policyDefinitions
- * @param monitor
- */
- @Deprecated
- public CompositeBuilderImpl(AssemblyFactory assemblyFactory,
- SCABindingFactory scaBindingFactory,
- PolicyFactory intentAttachPointTypeFactory,
- InterfaceContractMapper interfaceContractMapper) {
- this(assemblyFactory, scaBindingFactory, intentAttachPointTypeFactory, null, null, interfaceContractMapper);
- }
+ private CompositeBuilderExtensionPoint builders;
+
/**
* Constructs a new composite builder.
- *
- * @param assemblyFactory
- * @param scaBindingFactory
- * @param endpointFactory
- * @param intentAttachPointTypeFactory
- * @param interfaceContractMapper
- * @param policyDefinitions
- * @param monitor
+ *
+ * @param registry
*/
- public CompositeBuilderImpl(AssemblyFactory assemblyFactory,
- SCABindingFactory scaBindingFactory,
- PolicyFactory intentAttachPointTypeFactory,
- DocumentBuilderFactory documentBuilderFactory,
- TransformerFactory transformerFactory,
- InterfaceContractMapper interfaceContractMapper) {
-
- compositeIncludeBuilder = new CompositeIncludeBuilderImpl(assemblyFactory);
- componentReferenceWireBuilder = new ComponentReferenceWireBuilderImpl(assemblyFactory, interfaceContractMapper);
+ public CompositeBuilderImpl(ExtensionPointRegistry registry) {
+
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.builders = registry.getExtensionPoint(CompositeBuilderExtensionPoint.class);
+ AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+
+ compositeIncludeBuilder = new CompositeIncludeBuilderImpl();
+ componentReferenceWireBuilder = new ComponentReferenceWireBuilderImpl(registry);
//componentReferencePromotionWireBuilder = new ComponentReferencePromotionWireBuilderImpl(assemblyFactory, endpointFactory);
- componentReferencePromotionBuilder = new ComponentReferencePromotionBuilderImpl(assemblyFactory);
+ componentReferencePromotionBuilder = new ComponentReferencePromotionBuilderImpl(registry);
//compositeReferenceWireBuilder = new CompositeReferenceWireBuilderImpl(assemblyFactory, endpointFactory);
compositeCloneBuilder = new CompositeCloneBuilderImpl();
componentConfigurationBuilder =
- new ComponentConfigurationBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory,
- transformerFactory, interfaceContractMapper);
- compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(assemblyFactory);
- compositeReferenceConfigurationBuilder = new CompositeReferenceConfigurationBuilderImpl(assemblyFactory);
+ new ComponentConfigurationBuilderImpl(registry);
+ compositeServiceConfigurationBuilder = new CompositeServiceConfigurationBuilderImpl(registry);
+ compositeReferenceConfigurationBuilder = new CompositeReferenceConfigurationBuilderImpl(registry);
compositeBindingURIBuilder =
- new CompositeBindingURIBuilderImpl(assemblyFactory, scaBindingFactory, documentBuilderFactory,
- transformerFactory, interfaceContractMapper);
+ new CompositeBindingURIBuilderImpl(registry);
//componentServicePromotionBuilder = new ComponentServicePromotionBuilderImpl(assemblyFactory);
//compositeServicePromotionBuilder = new CompositeServicePromotionBuilderImpl(assemblyFactory);
- compositePromotionBuilder = new CompositePromotionBuilderImpl(assemblyFactory, interfaceContractMapper);
- compositePolicyBuilder = new CompositePolicyBuilderImpl(assemblyFactory, interfaceContractMapper);
- componentServiceBindingBuilder = new ComponentServiceBindingBuilderImpl();
- componentReferenceBindingBuilder = new ComponentReferenceBindingBuilderImpl();
+ compositePromotionBuilder = new CompositePromotionBuilderImpl(registry);
+ compositePolicyBuilder = new CompositePolicyBuilderImpl(registry);
+ componentServiceBindingBuilder = new ComponentServiceBindingBuilderImpl(registry);
+ componentReferenceBindingBuilder = new ComponentReferenceBindingBuilderImpl(registry);
componentReferenceEndpointReferenceBuilder =
- new ComponentReferenceEndpointReferenceBuilderImpl(assemblyFactory, interfaceContractMapper);
+ new ComponentReferenceEndpointReferenceBuilderImpl(registry);
componentServiceEndpointBuilder = new ComponentServiceEndpointBuilderImpl(assemblyFactory);
//endpointReferenceBuilder = new EndpointReference2BuilderImpl(assemblyFactory, interfaceContractMapper);
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java
index 451c2e0212..1bd52cbe6f 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeIncludeBuilderImpl.java
@@ -22,17 +22,15 @@ package org.apache.tuscany.sca.assembly.builder.impl;
import java.util.HashSet;
import java.util.Set;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Component;
-import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.Implementation;
+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.definitions.Definitions;
import org.apache.tuscany.sca.monitor.Monitor;
-import org.apache.tuscany.sca.monitor.Problem;
-import org.apache.tuscany.sca.monitor.Problem.Severity;
/**
* Implementation of a CompositeBuilder.
@@ -41,10 +39,7 @@ import org.apache.tuscany.sca.monitor.Problem.Severity;
*/
public class CompositeIncludeBuilderImpl implements CompositeBuilder {
- private AssemblyFactory assemblyFactory;
-
- public CompositeIncludeBuilderImpl(AssemblyFactory assemblyFactory) {
- this.assemblyFactory = assemblyFactory;
+ public CompositeIncludeBuilderImpl() {
}
public String getID() {
@@ -69,6 +64,15 @@ public class CompositeIncludeBuilderImpl implements CompositeBuilder {
visited.add(composite);
for (Composite included : composite.getIncludes()) {
+ if(included.isLocal() && !composite.isLocal()) {
+ // ASM60041
+ Monitor.error(monitor,
+ this,
+ "assembly-validation-messages",
+ "IllegalCompositeIncusion",
+ composite.getName().toString(),
+ included.getName().toString());
+ }
Composite fusedComposite = fuseInclude(included, visited, monitor);
if (fusedComposite != null) {
composite.getComponents().addAll(fusedComposite.getComponents());
@@ -76,8 +80,6 @@ public class CompositeIncludeBuilderImpl implements CompositeBuilder {
composite.getReferences().addAll(fusedComposite.getReferences());
composite.getProperties().addAll(fusedComposite.getProperties());
composite.getWires().addAll(fusedComposite.getWires());
- composite.getPolicySets().addAll(fusedComposite.getPolicySets());
- composite.getRequiredIntents().addAll(fusedComposite.getRequiredIntents());
}
}
@@ -108,6 +110,8 @@ public class CompositeIncludeBuilderImpl implements CompositeBuilder {
private Composite fuseInclude(Composite include, Set<Composite> visited, Monitor monitor) {
if (visited.contains(include)) {
+ // FIXME: [rfeng] Do we need to have a warning? I think it is fine to have Composite A
+ // include B and C while both B and C include D.
Monitor.warning(monitor,
this,
"assembly-validation-messages",
@@ -127,6 +131,17 @@ public class CompositeIncludeBuilderImpl implements CompositeBuilder {
// get the components etc. from any included composites
for (Composite included : include.getIncludes()) {
+ if(included.isLocal() && !include.isLocal()) {
+ // ASM60041
+ Monitor.error(monitor,
+ this,
+ "assembly-validation-messages",
+ "IllegalCompositeIncusion",
+ include.getName().toString(),
+ included.getName().toString());
+ return null;
+ }
+
Composite fusedComposite = fuseInclude(included, visited, monitor);
if (fusedComposite != null) {
clone.getComponents().addAll(fusedComposite.getComponents());
@@ -134,8 +149,11 @@ public class CompositeIncludeBuilderImpl implements CompositeBuilder {
clone.getReferences().addAll(fusedComposite.getReferences());
clone.getProperties().addAll(fusedComposite.getProperties());
clone.getWires().addAll(fusedComposite.getWires());
- clone.getPolicySets().addAll(fusedComposite.getPolicySets());
- clone.getRequiredIntents().addAll(fusedComposite.getRequiredIntents());
+ // FIXME: What should we do for the extensions
+ /*
+ clone.getExtensions().addAll(fusedComposite.getExtensions());
+ clone.getAttributeExtensions().addAll(fusedComposite.getAttributeExtensions());
+ */
}
}
@@ -144,10 +162,44 @@ public class CompositeIncludeBuilderImpl implements CompositeBuilder {
if (include.getAutowire() == Boolean.TRUE) {
for (Component component : clone.getComponents()) {
if (component.getAutowire() == null) {
- component.setAutowire(true);
+ component.setAutowire(Boolean.TRUE);
}
}
}
+
+ // Merge the intents and policySets from the included composite into
+ // component/service/reference elements under the composite
+ for(Component component : clone.getComponents()) {
+ component.getRequiredIntents().addAll(include.getRequiredIntents());
+ component.getPolicySets().addAll(include.getPolicySets());
+ }
+
+ for(Service service: clone.getServices()) {
+ service.getRequiredIntents().addAll(include.getRequiredIntents());
+ service.getPolicySets().addAll(include.getPolicySets());
+ }
+
+ for(Reference reference: clone.getReferences()) {
+ reference.getRequiredIntents().addAll(include.getRequiredIntents());
+ reference.getPolicySets().addAll(include.getPolicySets());
+ }
+
+ // process any composites referenced through implementation.composite
+ for (Component component : clone.getComponents()) {
+
+ // recurse for composite implementations
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ try {
+ monitor.pushContext("Component: " + component.getName());
+ fuseIncludes((Composite)implementation, monitor);
+ } finally {
+ monitor.popContext();
+ }
+ }
+ }
+
+ clone.getIncludes().clear();
// return the fused composite we have built up so far
return clone;
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 9c7bd6b2d9..5d4a44f137 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
@@ -22,7 +22,6 @@ package org.apache.tuscany.sca.assembly.builder.impl;
import java.util.HashSet;
import java.util.Set;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
@@ -39,7 +38,6 @@ 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;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.IntentMap;
@@ -59,10 +57,6 @@ public class CompositePolicyBuilderImpl extends BaseBuilderImpl implements Compo
super(registry);
}
- public CompositePolicyBuilderImpl(AssemblyFactory assemblyFactory, InterfaceContractMapper interfaceContractMapper) {
- super(assemblyFactory, null, null, null, interfaceContractMapper);
- }
-
public String getID() {
return "org.apache.tuscany.sca.assembly.builder.CompositePolicyBuilder";
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java
index b60ba68032..21c8596ea4 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositePromotionBuilderImpl.java
@@ -23,7 +23,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
@@ -35,9 +34,9 @@ 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.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.Monitor;
/**
@@ -48,9 +47,8 @@ import org.apache.tuscany.sca.monitor.Monitor;
*/
public class CompositePromotionBuilderImpl extends BaseBuilderImpl implements CompositeBuilder {
- public CompositePromotionBuilderImpl(AssemblyFactory assemblyFactory,
- InterfaceContractMapper interfaceContractMapper) {
- super(assemblyFactory, null, null, null, interfaceContractMapper);
+ public CompositePromotionBuilderImpl(ExtensionPointRegistry registry) {
+ super(registry);
}
public String getID() {
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java
index 992d1915a3..702da49f54 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeReferenceConfigurationBuilderImpl.java
@@ -33,6 +33,8 @@ import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.assembly.Reference;
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.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -44,8 +46,9 @@ import org.apache.tuscany.sca.monitor.Monitor;
public class CompositeReferenceConfigurationBuilderImpl implements CompositeBuilder {
private AssemblyFactory assemblyFactory;
- public CompositeReferenceConfigurationBuilderImpl(AssemblyFactory assemblyFactory) {
- this.assemblyFactory = assemblyFactory;
+ public CompositeReferenceConfigurationBuilderImpl(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
}
public String getID() {
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java
index bf12b57a86..8fa2aeef1c 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceBindingBuilderImpl.java
@@ -25,9 +25,11 @@ import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.CompositeService;
import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilder;
import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -38,8 +40,10 @@ import org.apache.tuscany.sca.monitor.Monitor;
* @version $Rev$ $Date$
*/
public class CompositeServiceBindingBuilderImpl implements CompositeBuilder {
+ private CompositeBuilderExtensionPoint builders;
- public CompositeServiceBindingBuilderImpl() {
+ public CompositeServiceBindingBuilderImpl(ExtensionPointRegistry registry) {
+ this.builders = registry.getExtensionPoint(CompositeBuilderExtensionPoint.class);
}
public String getID() {
@@ -63,9 +67,10 @@ public class CompositeServiceBindingBuilderImpl implements CompositeBuilder {
// find all the composite service bindings
for (Service service : composite.getServices()) {
for (Binding binding : service.getBindings()) {
- if (binding instanceof BindingBuilderExtension) {
+ BindingBuilder builder = builders.getBindingBuilder(binding.getClass());
+ if (builder != null) {
Component component = ServiceConfigurationUtil.getPromotedComponent((CompositeService)service);
- ((BindingBuilderExtension)binding).getBuilder().build(component, service, binding, monitor);
+ builder.build(component, service, binding, monitor);
}
}
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java
index bed289c887..9bbfabf12a 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeServiceConfigurationBuilderImpl.java
@@ -31,6 +31,8 @@ import org.apache.tuscany.sca.assembly.Implementation;
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.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -42,8 +44,9 @@ import org.apache.tuscany.sca.monitor.Monitor;
public class CompositeServiceConfigurationBuilderImpl implements CompositeBuilder {
private AssemblyFactory assemblyFactory;
- public CompositeServiceConfigurationBuilderImpl(AssemblyFactory assemblyFactory) {
- this.assemblyFactory = assemblyFactory;
+ public CompositeServiceConfigurationBuilderImpl(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
}
public String getID() {
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ModelBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ModelBuilderImpl.java
index f59dc3dae9..5084e50622 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ModelBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ModelBuilderImpl.java
@@ -80,7 +80,7 @@ public class ModelBuilderImpl implements CompositeBuilder, CompositeBuilderTmp {
MonitorFactory monitorFactory = utilities.getUtility(MonitorFactory.class);
Monitor monitor = monitorFactory.createMonitor();
- compositeIncludeBuilder = new CompositeIncludeBuilderImpl(assemblyFactory);
+ compositeIncludeBuilder = new CompositeIncludeBuilderImpl();
compositeCloneBuilder = new CompositeCloneBuilderImpl();
componentTypeBuilder = new ComponentTypeBuilderImpl(registry);
diff --git a/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties b/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties
index d5915393f7..61b61279de 100644
--- a/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties
+++ b/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties
@@ -61,4 +61,5 @@ ReferenceInterfaceNotSubSet = Interface of composite reference {0} must be compa
ServiceInterfaceNotSubSet = Interface of composite service {0} must be subset of the interface declared by promoted component service.
NoComponentReferenceTarget = No target services found for the component reference to be autowired: {0}
NoTypeForComponentProperty = No type specified on component property: Component = {0} Property = {1}
-URLSyntaxException = URLSyntaxException when creating binding URI at component = {0} service = {1} binding = {2} \ No newline at end of file
+URLSyntaxException = URLSyntaxException when creating binding URI at component = {0} service = {1} binding = {2}
+IllegalCompositeIncusion = Local Composite {0} cannot include a non-local composite {1} \ No newline at end of file
diff --git a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java
index d33ad3ccef..57c6081859 100644
--- a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java
+++ b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderTestCase.java
@@ -77,7 +77,7 @@ public class CompositeBuilderTestCase {
c.setName(new QName("http://foo", "C"));
c.getIncludes().add(c1);
- new CompositeIncludeBuilderImpl(null).build(c, null, monitor);
+ new CompositeIncludeBuilderImpl().build(c, null, monitor);
assertTrue(c.getComponents().get(0).getName().equals("a"));
assertTrue(c.getComponents().get(1).getName().equals("b"));
diff --git a/java/sca/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF b/java/sca/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF
index 822e724c50..5d7c3a3457 100644
--- a/java/sca/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF
+++ b/java/sca/modules/binding-ws-wsdlgen/META-INF/MANIFEST.MF
@@ -34,6 +34,7 @@ Import-Package: javax.jws;resolution:=optional,
javax.xml.parsers,
javax.xml.ws;resolution:=optional,
org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.assembly.builder;version="2.0.0",
org.apache.tuscany.sca.binding.ws;version="2.0.0",
org.apache.tuscany.sca.binding.ws.wsdlgen;version="2.0.0",
org.apache.tuscany.sca.contribution;version="2.0.0";resolution:=optional,
diff --git a/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java
index d94290a641..a85b47f6f5 100644
--- a/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java
+++ b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/BindingWSDLGenerator.java
@@ -30,7 +30,6 @@ import javax.wsdl.xml.WSDLWriter;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
-import org.apache.tuscany.sca.assembly.AbstractContract;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
@@ -154,7 +153,7 @@ public class BindingWSDLGenerator {
* of these cases.
*/
public static void generateWSDL(Component component,
- AbstractContract contract,
+ Contract contract,
WebServiceBinding wsBinding,
ExtensionPointRegistry extensionPoints,
Monitor monitor) {
@@ -181,7 +180,7 @@ public class BindingWSDLGenerator {
}
private static void createWSDLDocument(Component component,
- AbstractContract contract,
+ Contract contract,
WebServiceBinding wsBinding,
ExtensionPointRegistry extensionPoints,
Monitor monitor) {
diff --git a/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/BindingBuilderImpl.java b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java
index f2376231ab..b090549985 100644
--- a/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/BindingBuilderImpl.java
+++ b/java/sca/modules/binding-ws-wsdlgen/src/main/java/org/apache/tuscany/sca/binding/ws/wsdlgen/WebServiceBindingBuilder.java
@@ -17,14 +17,12 @@
* under the License.
*/
-package org.apache.tuscany.sca.binding.ws.xml;
+package org.apache.tuscany.sca.binding.ws.wsdlgen;
-import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
-import org.apache.tuscany.sca.binding.ws.wsdlgen.BindingWSDLGenerator;
-import org.apache.tuscany.sca.assembly.AbstractContract;
-import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -33,19 +31,23 @@ import org.apache.tuscany.sca.monitor.Monitor;
*
* @version $Rev$ $Date$
*/
-public class BindingBuilderImpl implements BindingBuilder {
-
+public class WebServiceBindingBuilder implements BindingBuilder<WebServiceBinding> {
+
private ExtensionPointRegistry extensionPoints;
-
- public BindingBuilderImpl(ExtensionPointRegistry extensionPoints) {
+
+ public WebServiceBindingBuilder(ExtensionPointRegistry extensionPoints) {
this.extensionPoints = extensionPoints;
}
-
+
/**
* Create a calculated WSDL document and save it in the Web Service binding.
*/
- public void build(Component component, AbstractContract contract, Binding binding, Monitor monitor) {
- BindingWSDLGenerator.generateWSDL(component, contract, (WebServiceBinding)binding, extensionPoints, monitor);
- }
-
+ public void build(Component component, Contract contract, WebServiceBinding binding, Monitor monitor) {
+ BindingWSDLGenerator.generateWSDL(component, contract, binding, extensionPoints, monitor);
+ }
+
+ public Class<WebServiceBinding> getModelType() {
+ return WebServiceBinding.class;
+ }
+
}
diff --git a/java/sca/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder b/java/sca/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder
new file mode 100644
index 0000000000..cd9245401c
--- /dev/null
+++ b/java/sca/modules/binding-ws-wsdlgen/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.BindingBuilder
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+org.apache.tuscany.sca.binding.ws.wsdlgen.WebServiceBindingBuilder;model=org.apache.tuscany.sca.binding.ws.WebServiceBinding
diff --git a/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java b/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
index ecc72d18f4..6eac53a7f5 100644
--- a/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
+++ b/java/sca/modules/binding-ws-xml/src/main/java/org/apache/tuscany/sca/binding/ws/xml/WebServiceBindingProcessor.java
@@ -123,7 +123,6 @@ public class WebServiceBindingProcessor implements StAXArtifactProcessor<WebServ
bindingType.setUnresolved(true);
((PolicySubject)wsBinding).setType(bindingType);*/
wsBinding.setUnresolved(true);
- wsBinding.setBuilder(new BindingBuilderImpl(extensionPoints));
// Read policies
policyProcessor.readPolicies(wsBinding, reader);
diff --git a/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java b/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
index 83b66aa5ad..5e0f8a0a88 100644
--- a/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
+++ b/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/WebServiceBinding.java
@@ -24,7 +24,6 @@ import javax.wsdl.Service;
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLDefinition;
import org.w3c.dom.Element;
@@ -35,7 +34,7 @@ import org.w3c.dom.Element;
*
* @version $Rev$ $Date$
*/
-public interface WebServiceBinding extends Binding, BindingBuilderExtension {
+public interface WebServiceBinding extends Binding {
QName TYPE = new QName(SCA11_NS, "binding.ws");
/**
diff --git a/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java b/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
index c8c4d5a7bb..c1981b8809 100644
--- a/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
+++ b/java/sca/modules/binding-ws/src/main/java/org/apache/tuscany/sca/binding/ws/impl/WebServiceBindingImpl.java
@@ -30,7 +30,6 @@ import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.Extensible;
import org.apache.tuscany.sca.assembly.Extension;
-import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
import org.apache.tuscany.sca.binding.ws.WebServiceBinding;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
@@ -70,7 +69,6 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi
private InterfaceContract bindingInterfaceContract;
private Element endPointReference;
private Definition generatedWSDLDocument;
- private BindingBuilder builder;
protected WebServiceBindingImpl() {
}
@@ -295,14 +293,6 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi
this.generatedWSDLDocument = definition;
}
- public BindingBuilder getBuilder() {
- return builder;
- }
-
- public void setBuilder(BindingBuilder builder) {
- this.builder = builder;
- }
-
public QName getType() {
return TYPE;
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java
index cc3bbc1f6e..372651fcff 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java
@@ -35,11 +35,13 @@ import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.CompositeService;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension;
+import org.apache.tuscany.sca.assembly.builder.BindingBuilder;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderExtensionPoint;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@@ -49,7 +51,6 @@ import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.assembly.CompositeActivator;
import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
import org.apache.tuscany.sca.core.assembly.impl.ReferenceParametersImpl;
-import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl;
import org.apache.tuscany.sca.core.context.ComponentContextExt;
import org.apache.tuscany.sca.core.context.CompositeContext;
import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
@@ -98,6 +99,7 @@ public class CallableReferenceImpl<B> implements ServiceReferenceExt<B> {
private StAXArtifactProcessor<EndpointReference> staxProcessor;
private XMLInputFactory xmlInputFactory;
private XMLOutputFactory xmlOutputFactory;
+ private CompositeBuilderExtensionPoint builders;
/*
* Public constructor for Externalizable serialization/deserialization
@@ -164,6 +166,7 @@ public class CallableReferenceImpl<B> implements ServiceReferenceExt<B> {
this.xmlOutputFactory = modelFactories.getFactory(XMLOutputFactory.class);
this.staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
this.staxProcessor = staxProcessors.getProcessor(EndpointReference.class);
+ this.builders = registry.getExtensionPoint(CompositeBuilderExtensionPoint.class);
}
public CallableReferenceImpl(Class<B> businessInterface, RuntimeWire wire, ProxyFactory proxyFactory) {
@@ -423,9 +426,13 @@ public class CallableReferenceImpl<B> implements ServiceReferenceExt<B> {
this.businessInterface = (Class<B>)javaInterface.getJavaClass();
}
- if (endpointReference.getBinding() instanceof BindingBuilderExtension) {
- ((BindingBuilderExtension)endpointReference.getBinding()).getBuilder().build(component, reference, endpointReference.getBinding(), null);
- }
+ Binding binding = endpointReference.getBinding();
+ if (binding != null) {
+ BindingBuilder bindingBuilder = builders.getBindingBuilder(binding.getClass());
+ if (bindingBuilder != null) {
+ bindingBuilder.build(component, reference, endpointReference.getBinding(), null);
+ }
+ }
this.proxyFactory = compositeActivator.getCompositeContext().getProxyFactory();
} else if (compositeActivator == null) {
diff --git a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/MockPolicy.java b/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java
index 496a909572..58e6e534b9 100644
--- a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/MockPolicy.java
+++ b/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/MockPolicy.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.tuscany.sca.definitions;
+package org.apache.tuscany.sca.definitions.xml;
import javax.xml.namespace.QName;
diff --git a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/ReadDocumentTestCase.java b/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java
index 8ed836a5c1..7b9400b300 100644
--- a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/ReadDocumentTestCase.java
+++ b/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/ReadDocumentTestCase.java
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.tuscany.sca.definitions;
+package org.apache.tuscany.sca.definitions.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -38,6 +38,7 @@ import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensi
import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.policy.BindingType;
import org.apache.tuscany.sca.policy.ImplementationType;
import org.apache.tuscany.sca.policy.Intent;
diff --git a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/TestPolicyProcessor.java b/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java
index 4e5c62c8b2..89ec2d0ee9 100644
--- a/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/TestPolicyProcessor.java
+++ b/java/sca/modules/definitions-xml/src/test/java/org/apache/tuscany/sca/definitions/xml/TestPolicyProcessor.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.definitions;
+package org.apache.tuscany.sca.definitions.xml;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
diff --git a/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/test_definitions.xml b/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml
index 4325309463..dac8e384e3 100644
--- a/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/test_definitions.xml
+++ b/java/sca/modules/definitions-xml/src/test/resources/org/apache/tuscany/sca/definitions/xml/test_definitions.xml
@@ -38,6 +38,7 @@
</intent>
<policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ attachTo = "//sca:component[@name='CalculatorServiceComponent']/sca:reference[@name='addService']"
xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:PolicyAttachment>
<!-- policy expression and policy subject for
diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
index 9a8fac6a61..1a183b0543 100644
--- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
+++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
@@ -31,7 +31,6 @@ import org.apache.tuscany.sca.assembly.Implementation;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.assembly.builder.ComponentPreProcessor;
import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -42,7 +41,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent;
*
* @version $Rev$ $Date$
*/
-public class SpringImplementation extends ImplementationImpl implements Implementation, ComponentPreProcessor, Extensible {
+public class SpringImplementation extends ImplementationImpl implements Implementation, Extensible {
private final static QName TYPE = new QName(SCA11_NS, "implementation.spring");
// The location attribute which points to the Spring application-context XML file
private String location;
@@ -173,7 +172,7 @@ public class SpringImplementation extends ImplementationImpl implements Implemen
/**
* Use preProcess to validate and map the references and properties dynamically
*/
- public void preProcess(Component component) {
+ public void build(Component component) {
if (!(component instanceof RuntimeComponent))
return;
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java
index 0f1fee3c1d..121f1ca234 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/BindingBuilderExtension.java
+++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationBuilder.java
@@ -17,27 +17,24 @@
* under the License.
*/
-package org.apache.tuscany.sca.assembly.builder;
+package org.apache.tuscany.sca.implementation.spring;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.builder.ImplementationBuilder;
+import org.apache.tuscany.sca.monitor.Monitor;
/**
- * An extension that can be implemented by bindings to provide a binding builder.
- *
- * @version $Rev$ $Date$
+ *
*/
-public interface BindingBuilderExtension {
+public class SpringImplementationBuilder implements ImplementationBuilder<SpringImplementation> {
- /**
- * Returns the binding builder.
- *
- * @return the binding builder
- */
- BindingBuilder getBuilder();
+ public void build(Component component, SpringImplementation implmentation, Monitor monitor) {
+ implmentation.build(component);
+ }
- /**
- * Sets the binding builder.
- *
- * @param builder the binding builder
- */
- void setBuilder(BindingBuilder builder);
+ public Class<SpringImplementation> getModelType() {
+ // TODO Auto-generated method stub
+ return SpringImplementation.class;
+ }
}
diff --git a/java/sca/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder b/java/sca/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder
new file mode 100644
index 0000000000..346e2b757f
--- /dev/null
+++ b/java/sca/modules/implementation-spring/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+org.apache.tuscany.sca.implementation.spring.SpringImplementationBuilder;model=org.apache.tuscany.sca.implementation.spring.SpringImplementation
diff --git a/java/sca/modules/implementation-web/META-INF/MANIFEST.MF b/java/sca/modules/implementation-web/META-INF/MANIFEST.MF
index 017bb9894a..89d94b69fa 100644
--- a/java/sca/modules/implementation-web/META-INF/MANIFEST.MF
+++ b/java/sca/modules/implementation-web/META-INF/MANIFEST.MF
@@ -21,6 +21,7 @@ Import-Package: javax.xml.stream;resolution:=optional,
org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
org.apache.tuscany.sca.implementation.web;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
org.apache.tuscany.sca.policy;version="2.0.0",
org.apache.tuscany.sca.runtime;version="2.0.0",
org.apache.tuscany.sca.xsd;version="2.0.0"
diff --git a/java/sca/modules/implementation-web/pom.xml b/java/sca/modules/implementation-web/pom.xml
index cc1c76b88e..1dfb11ae58 100644
--- a/java/sca/modules/implementation-web/pom.xml
+++ b/java/sca/modules/implementation-web/pom.xml
@@ -59,7 +59,6 @@
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-monitor</artifactId>
<version>2.0-SNAPSHOT</version>
- <scope>test</scope>
</dependency>
<dependency>
diff --git a/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationBuilder.java b/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationBuilder.java
new file mode 100644
index 0000000000..2c95337766
--- /dev/null
+++ b/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationBuilder.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.implementation.web.impl;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.builder.ImplementationBuilder;
+import org.apache.tuscany.sca.implementation.web.WebImplementation;
+import org.apache.tuscany.sca.monitor.Monitor;
+
+/**
+ *
+ */
+public class WebImplementationBuilder implements ImplementationBuilder<WebImplementation> {
+
+ public void build(Component component, WebImplementation implmentation, Monitor monitor) {
+ ((WebImplementationImpl)implmentation).build(component);
+
+ }
+
+ public Class<WebImplementation> getModelType() {
+ return WebImplementation.class;
+ }
+
+}
diff --git a/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java b/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java
index 26e0799e45..9453eabbab 100644
--- a/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java
+++ b/java/sca/modules/implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/impl/WebImplementationImpl.java
@@ -29,7 +29,6 @@ import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.Property;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.assembly.builder.ComponentPreProcessor;
import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
import org.apache.tuscany.sca.implementation.web.WebImplementation;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -38,7 +37,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent;
/**
* The model representing an Web implementation in an SCA assembly model.
*/
-class WebImplementationImpl extends ImplementationImpl implements WebImplementation, ComponentPreProcessor {
+class WebImplementationImpl extends ImplementationImpl implements WebImplementation {
private static final QName TYPE = new QName(SCA11_NS, "implementation.web");
private List<Property> properties = new ArrayList<Property>();
@@ -105,7 +104,7 @@ class WebImplementationImpl extends ImplementationImpl implements WebImplementat
* Use preProcess to add any references and properties dynamically
* TODO: also support introspection and handle WEB-INF/web.componentType (spec line 503)
*/
- public void preProcess(Component component) {
+ public void build(Component component) {
if (!(component instanceof RuntimeComponent)) {
return;
}
diff --git a/java/sca/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder b/java/sca/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder
new file mode 100644
index 0000000000..da2481a304
--- /dev/null
+++ b/java/sca/modules/implementation-web/src/main/resources/META-INF/services/org.apache.tuscany.sca.assembly.builder.ImplementationBuilder
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+org.apache.tuscany.sca.implementation.web.impl.WebImplementationBuilder;model=org.apache.tuscany.sca.implementation.web.WebImplementation
diff --git a/java/sca/modules/policy-xml/META-INF/MANIFEST.MF b/java/sca/modules/policy-xml/META-INF/MANIFEST.MF
index 78cf2f5405..844978a333 100644
--- a/java/sca/modules/policy-xml/META-INF/MANIFEST.MF
+++ b/java/sca/modules/policy-xml/META-INF/MANIFEST.MF
@@ -9,12 +9,17 @@ Bnd-LastModified: 1225397115375
Bundle-ManifestVersion: 2
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-Description: Apache Tuscany SCA Policy XML Model
-Import-Package: javax.xml.namespace,javax.xml.stream,javax.xml.xpath,o
- rg.apache.tuscany.sca.contribution.processor;version="2.0.0",org.apache
- .tuscany.sca.contribution.resolver;version="2.0.0",org.apache.tuscany.s
- ca.core;version="2.0.0",org.apache.tuscany.sca.monitor;version="2.0.0",or
- g.apache.tuscany.sca.policy;version="2.0.0",org.apache.tuscany.sca.poli
- cy.impl;version="2.0.0"
+Import-Package: javax.xml.namespace,
+ javax.xml.stream,
+ javax.xml.xpath,
+ org.apache.tuscany.sca.assembly;version="2.0.0",
+ org.apache.tuscany.sca.common.xml.xpath;version="2.0.0",
+ org.apache.tuscany.sca.contribution.processor;version="2.0.0",
+ org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
+ org.apache.tuscany.sca.core;version="2.0.0",
+ org.apache.tuscany.sca.monitor;version="2.0.0",
+ org.apache.tuscany.sca.policy;version="2.0.0",
+ org.apache.tuscany.sca.policy.impl;version="2.0.0"
Bundle-SymbolicName: org.apache.tuscany.sca.policy.xml
Bundle-DocURL: http://www.apache.org/
Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
diff --git a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
index 955788ce8f..a6ee5efde6 100644
--- a/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
+++ b/java/sca/modules/policy-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java
@@ -26,20 +26,23 @@ import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
+import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
+import org.apache.tuscany.sca.common.xml.xpath.XPathHelper;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
@@ -61,17 +64,22 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
private PolicyFactory policyFactory;
private StAXArtifactProcessor<Object> extensionProcessor;
- private XPathFactory xpathFactory = XPathFactory.newInstance();
+ private XPathHelper xpathHelper;
+ // private XPathFactory xpathFactory;
private Monitor monitor;
- public PolicySetProcessor(FactoryExtensionPoint modelFactories,
+ public PolicySetProcessor(ExtensionPointRegistry registry,
StAXArtifactProcessor<Object> extensionProcessor,
Monitor monitor) {
+ FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
this.extensionProcessor = extensionProcessor;
this.monitor = monitor;
+ this.xpathHelper = XPathHelper.getInstance(registry);
+ // this.xpathFactory = modelFactories.getFactory(XPathFactory.class);
}
+ /*
public PolicySetProcessor(PolicyFactory policyFactory,
StAXArtifactProcessor<Object> extensionProcessor,
Monitor monitor) {
@@ -79,6 +87,7 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
this.extensionProcessor = extensionProcessor;
this.monitor = monitor;
}
+ */
/**
* Report a exception.
@@ -146,16 +155,35 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
policySet.setAppliesTo(appliesTo);
- XPath path = xpathFactory.newXPath();
- path.setNamespaceContext(reader.getNamespaceContext());
- try {
- if (appliesTo != null) {
- policySet.setAppliesToXPathExpression(path.compile(appliesTo));
+ if (appliesTo != null) {
+ try {
+ XPath path = xpathHelper.newXPath();
+ NamespaceContext context = xpathHelper.getNamespaceContext(appliesTo, reader.getNamespaceContext());
+ // path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(context));
+ XPathExpression expression = xpathHelper.compile(path, context, appliesTo);
+ policySet.setAppliesToXPathExpression(expression);
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", policySet, ce);
+ //throw ce;
}
- } catch (XPathExpressionException e) {
- ContributionReadException ce = new ContributionReadException(e);
- error("ContributionReadException", policySet, ce);
- //throw ce;
+ }
+
+ String attachTo = reader.getAttributeValue(null, ATTACH_TO);
+ if (attachTo != null) {
+ try {
+ XPath path = xpathHelper.newXPath();
+ NamespaceContext context = xpathHelper.getNamespaceContext(attachTo, reader.getNamespaceContext());
+ path.setXPathFunctionResolver(new PolicyXPathFunctionResolver(context));
+ XPathExpression expression = xpathHelper.compile(path, context, attachTo);
+ policySet.setAttachTo(attachTo);
+ policySet.setAttachToXPathExpression(expression);
+ } catch (XPathExpressionException e) {
+ ContributionReadException ce = new ContributionReadException(e);
+ error("ContributionReadException", policySet, ce);
+ //throw ce;
+ }
+
}
readProvidedIntents(policySet, reader);
diff --git a/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite b/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite
index 4d2dbe721c..d6082a936d 100644
--- a/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite
+++ b/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/Calculator.composite
@@ -22,7 +22,7 @@
xmlns:sample="http://sample"
name="Calculator">
- <component name="CalculatorServiceComponent" requires="sca:confidentiality">
+ <component name="CalculatorServiceComponent" requires="confidentiality">
<implementation.java class="calculator.CalculatorServiceImpl" xmlns:test="http://test" requiers="test:TestIntentOne"/>
<reference name="addService" target="AddServiceComponent" />
<reference name="subtractService" target="SubtractServiceComponent" />
diff --git a/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml b/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
index 17880254a1..b4857c499f 100644
--- a/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
+++ b/java/sca/modules/policy-xml/src/test/resources/org/apache/tuscany/sca/policy/xml/test_definitions.xml
@@ -38,6 +38,7 @@
</intent>
<policySet name="TestPolicySetOne" provides="test:TestIntentOne" appliesTo="sca:binding.ws"
+ attachTo = "//sca:component[@name='CalculatorServiceComponent']/sca:reference[@name='addService']"
xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:PolicyAttachment>
<!-- policy expression and policy subject for