diff options
Diffstat (limited to '')
15 files changed, 86 insertions, 22 deletions
diff --git a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java index 153734ddc5..2102113ea1 100644 --- a/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java +++ b/sca-java-2.x/trunk/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java @@ -19,9 +19,6 @@ package org.apache.tuscany.sca.assembly.xml; -import java.util.ArrayList; -import java.util.List; - import javax.xml.namespace.QName; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.XMLStreamException; @@ -82,12 +79,16 @@ public class EndpointProcessor extends BaseAssemblyProcessor implements StAXArti if (reader.getEventType() == XMLStreamConstants.START_DOCUMENT) { reader.nextTag(); } + if (reader.getEventType() == XMLStreamConstants.START_ELEMENT && ENDPOINT_QNAME.equals(reader.getName())) { + // Skip the "endpoint" element wrapper + reader.nextTag(); + } Object model = extensionProcessor.read(reader, context); if (model instanceof Composite) { Composite composite = (Composite)model; Component component = composite.getComponents().get(0); ComponentService service = component.getServices().get(0); - Binding binding = service.getBindings().get(0); + Binding binding = service.getBindings().isEmpty() ? null : service.getBindings().get(0); endpoint.setComponent(component); endpoint.setService(service); endpoint.setBinding(binding); diff --git a/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/META-INF/MANIFEST.MF index ac68264fcb..b5862eff58 100644 --- a/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/META-INF/MANIFEST.MF +++ b/sca-java-2.x/trunk/modules/binding-ws-runtime-jaxws/META-INF/MANIFEST.MF @@ -29,6 +29,7 @@ Import-Package: javax.security.auth.callback;resolution:=optional, org.apache.tuscany.sca.contribution.processor;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
org.apache.tuscany.sca.core.assembly;version="2.0.0",
+ org.apache.tuscany.sca.core.invocation;version="2.0.0",
org.apache.tuscany.sca.databinding;version="2.0.0",
org.apache.tuscany.sca.definitions;version="2.0.0",
org.apache.tuscany.sca.host.http;version="2.0.0",
diff --git a/sca-java-2.x/trunk/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelper.java b/sca-java-2.x/trunk/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelper.java index ae4f01c032..73ff2e2fb0 100644 --- a/sca-java-2.x/trunk/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelper.java +++ b/sca-java-2.x/trunk/modules/common-java/src/main/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelper.java @@ -504,16 +504,18 @@ public final class JavaIntrospectionHelper { * Returns the set of interfaces implemented by the given class and its * ancestors or a blank set if none */ - public Set<Class<?>> getAllInterfaces(Class<?> clazz) { - Set<Class<?>> implemented = new HashSet<Class<?>>(); + public List<Class<?>> getAllInterfaces(Class<?> clazz) { + List<Class<?>> implemented = new ArrayList<Class<?>>(); getAllInterfaces(clazz, implemented); return implemented; } - private static void getAllInterfaces(Class<?> clazz, Set<Class<?>> implemented) { + private static void getAllInterfaces(Class<?> clazz, List<Class<?>> implemented) { Class<?>[] interfaces = clazz.getInterfaces(); for (Class<?> interfaze : interfaces) { - implemented.add(interfaze); + if (!implemented.contains(interfaze)) { + implemented.add(interfaze); + } } Class<?> superClass = clazz.getSuperclass(); // Object has no superclass so check for null diff --git a/sca-java-2.x/trunk/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelperTestCase.java b/sca-java-2.x/trunk/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelperTestCase.java index 11931a354f..25d694a9d7 100644 --- a/sca-java-2.x/trunk/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelperTestCase.java +++ b/sca-java-2.x/trunk/modules/common-java/src/test/java/org/apache/tuscany/sca/common/java/reflection/JavaIntrospectionHelperTestCase.java @@ -21,6 +21,7 @@ package org.apache.tuscany.sca.common.java.reflection; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.util.List; import java.util.Set; import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry; @@ -56,7 +57,7 @@ public class JavaIntrospectionHelperTestCase { @Test public void testGetAllInterfaces() { - Set<Class<?>> interfaces = helper.getAllInterfaces(SubTestImpl.class); + List<Class<?>> interfaces = helper.getAllInterfaces(SubTestImpl.class); System.out.println(interfaces); } diff --git a/sca-java-2.x/trunk/modules/contribution/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/contribution/META-INF/MANIFEST.MF index 5ba88ca08f..fbac65daab 100644 --- a/sca-java-2.x/trunk/modules/contribution/META-INF/MANIFEST.MF +++ b/sca-java-2.x/trunk/modules/contribution/META-INF/MANIFEST.MF @@ -38,6 +38,7 @@ Import-Package: javax.xml.namespace, org.apache.tuscany.sca.assembly.impl;version="2.0.0",
org.apache.tuscany.sca.assembly.xsd;version="2.0.0";resolution:=optional,
org.apache.tuscany.sca.common.java.io;version="2.0.0",
+ org.apache.tuscany.sca.common.java.reflection;version="2.0.0",
org.apache.tuscany.sca.common.xml;version="2.0.0",
org.apache.tuscany.sca.common.xml.stax;version="2.0.0",
org.apache.tuscany.sca.contribution;version="2.0.0",
diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java index c871e4c868..774971b8be 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java +++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultArtifactProcessorExtensionPoint.java @@ -19,8 +19,12 @@ package org.apache.tuscany.sca.contribution.processor; import java.util.HashMap; +import java.util.List; import java.util.Map; +import org.apache.tuscany.sca.common.java.reflection.JavaIntrospectionHelper; +import org.apache.tuscany.sca.core.ExtensionPointRegistry; + /** * The default implementation of an artifact processor extension point. * @@ -30,10 +34,15 @@ abstract class DefaultArtifactProcessorExtensionPoint<P extends ArtifactProcesso protected final Map<Object, P> processorsByArtifactType = new HashMap<Object, P>(); protected final Map<Class<?>, P> processorsByModelType = new HashMap<Class<?>, P>(); + protected ExtensionPointRegistry registry; + private JavaIntrospectionHelper introspectionHelper; + /** * Constructs a new loader registry. */ - DefaultArtifactProcessorExtensionPoint() { + DefaultArtifactProcessorExtensionPoint(ExtensionPointRegistry registry) { + this.registry = registry; + this.introspectionHelper = JavaIntrospectionHelper.getInstance(registry); } /** @@ -53,14 +62,18 @@ abstract class DefaultArtifactProcessorExtensionPoint<P extends ArtifactProcesso * @return The processor associated with the given model type */ public <T> P getProcessor(Class<T> modelType) { - Class<?>[] classes = modelType.getInterfaces(); + P processor = processorsByModelType.get(modelType); + if (processor != null) { + return processor; + } + List<Class<?>> classes = introspectionHelper.getAllInterfaces(modelType); for (Class<?> c : classes) { - P processor = processorsByModelType.get(c); + processor = processorsByModelType.get(c); if (processor != null) { return processor; } } - return processorsByModelType.get(modelType); + return null; } } diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java index 151edeae0b..814c8c63ef 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java +++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java @@ -47,7 +47,6 @@ import org.apache.tuscany.sca.monitor.Problem.Severity; public class DefaultStAXArtifactProcessorExtensionPoint extends DefaultArtifactProcessorExtensionPoint<StAXArtifactProcessor<?>> implements StAXArtifactProcessorExtensionPoint { - private ExtensionPointRegistry registry; private FactoryExtensionPoint modelFactories; private boolean loaded; private StAXArtifactProcessor<Object> extensibleStAXProcessor; @@ -57,7 +56,7 @@ public class DefaultStAXArtifactProcessorExtensionPoint extends * Constructs a new extension point. */ public DefaultStAXArtifactProcessorExtensionPoint(ExtensionPointRegistry extensionPoints) { - this.registry = extensionPoints; + super(extensionPoints); this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class); diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java index e76d6cb299..36dec73898 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java +++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java @@ -49,7 +49,6 @@ import org.apache.tuscany.sca.monitor.Problem.Severity; public class DefaultStAXAttributeProcessorExtensionPoint extends DefaultArtifactProcessorExtensionPoint<StAXAttributeProcessor<?>> implements StAXAttributeProcessorExtensionPoint { - private ExtensionPointRegistry registry; private FactoryExtensionPoint modelFactories; private StAXAttributeProcessor<Object> extensibleStAXAttributeProcessor; private boolean loaded; @@ -59,7 +58,7 @@ public class DefaultStAXAttributeProcessorExtensionPoint extends * Constructs a new extension point. */ public DefaultStAXAttributeProcessorExtensionPoint(ExtensionPointRegistry extensionPoints) { - this.registry = extensionPoints; + super(extensionPoints); this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class); diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java index e22d7762fa..812695575d 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java +++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java @@ -45,7 +45,6 @@ import org.apache.tuscany.sca.extensibility.ServiceDeclaration; public class DefaultURLArtifactProcessorExtensionPoint extends DefaultArtifactProcessorExtensionPoint<URLArtifactProcessor<?>> implements URLArtifactProcessorExtensionPoint { - private ExtensionPointRegistry registry; private StAXArtifactProcessor<?> staxProcessor; private boolean loaded; @@ -53,7 +52,7 @@ public class DefaultURLArtifactProcessorExtensionPoint extends * Constructs a new extension point. */ public DefaultURLArtifactProcessorExtensionPoint(ExtensionPointRegistry extensionPoints) { - this.registry = extensionPoints; + super(extensionPoints); FactoryExtensionPoint modelFactories = this.registry.getExtensionPoint(FactoryExtensionPoint.class); XMLInputFactory inputFactory = modelFactories.getFactory(XMLInputFactory.class); XMLOutputFactory outputFactory = modelFactories.getFactory(XMLOutputFactory.class); diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java index 210affc216..4f45685071 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java +++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java @@ -630,7 +630,7 @@ public class SpringXMLComponentTypeLoader { } Class<?> beanClass = resolveClass(resolver, bean.getClassName(), context); - Set<Class<?>> ifaces = javaIntrospectionHelper.getAllInterfaces(beanClass); + List<Class<?>> ifaces = javaIntrospectionHelper.getAllInterfaces(beanClass); for (Class<?> interfaze : ifaces) { if (interfaze.isAnnotationPresent(Remotable.class)) { return interfaze; diff --git a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java index ec9148483c..1ed7c2d408 100644 --- a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java +++ b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java @@ -28,6 +28,8 @@ import java.util.Map; import javax.xml.namespace.QName; +import org.apache.tuscany.sca.assembly.Endpoint; + /** * The configuration for a Node which represents the deployment of an SCA composite application * @tuscany.spi.extension.asclient @@ -105,6 +107,12 @@ public interface NodeConfiguration { NodeConfiguration addBinding(QName bindingType, String...baseURIs); NodeConfiguration addBinding(QName bindingType, URI...baseURIs); + /** + * Get a list of endpoint descriptions for external services. + * @return + */ + List<Endpoint> getEndpointDescriptions(); + List<Object> getExtensions(); diff --git a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java index 97fbb5b950..55c3bef605 100644 --- a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java +++ b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java @@ -30,6 +30,7 @@ import java.util.Map; import javax.xml.namespace.QName; +import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.node.configuration.BindingConfiguration; import org.apache.tuscany.sca.node.configuration.ContributionConfiguration; import org.apache.tuscany.sca.node.configuration.NodeConfiguration; @@ -44,6 +45,7 @@ public class NodeConfigurationImpl implements NodeConfiguration { private List<ContributionConfiguration> contributions = new ArrayList<ContributionConfiguration>(); private List<BindingConfiguration> bindings = new ArrayList<BindingConfiguration>(); private List<Object> extensions = new ArrayList<Object>(); + private List<Endpoint> endpoints = new ArrayList<Endpoint>(); private transient Map<String, Object> attributes = new HashMap<String, Object>(); @@ -194,4 +196,9 @@ public class NodeConfigurationImpl implements NodeConfiguration { return this; } + @Override + public List<Endpoint> getEndpointDescriptions() { + return endpoints; + } + } diff --git a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java index 663129bc0f..48d76225fb 100644 --- a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java +++ b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/configuration/xml/NodeConfigurationProcessor.java @@ -31,6 +31,7 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamWriter; +import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.common.xml.stax.StAXHelper; import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.ContributionReadException; @@ -157,7 +158,12 @@ public class NodeConfigurationProcessor extends BaseStAXArtifactProcessor implem helper.save(reader, writer); composite.setContent(sw.toString()); } else { - node.getExtensions().add(processor.read(reader, context)); + Object ext = processor.read(reader, context); + if (ext instanceof Endpoint) { + node.getEndpointDescriptions().add((Endpoint)ext); + } else { + node.getExtensions().add(ext); + } } break; @@ -238,6 +244,11 @@ public class NodeConfigurationProcessor extends BaseStAXArtifactProcessor implem writeEnd(writer); } + // FIXME: The composite processor assumes that composite is root element +// for (Endpoint o : node.getEndpointDescriptions()) { +// processor.write(o, writer, context); +// } + for(Object o: node.getExtensions()) { processor.write(o, writer, context); } diff --git a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java index 22562a5b97..453b4fb486 100644 --- a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java +++ b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java @@ -136,7 +136,12 @@ public class NodeImpl implements Node, NodeExtension { // Pass down the context attributes compositeContext.getAttributes().putAll(configuration.getAttributes()); - + // Add endpoint descriptions from the node configuration if the domain registry is local + if (!domainRegistry.isDistributed()) { + for (Endpoint e : configuration.getEndpointDescriptions()) { + domainRegistry.addEndpoint(e); + } + } // Activate the composite compositeActivator.activate(compositeContext, domainComposite); @@ -234,6 +239,14 @@ public class NodeImpl implements Node, NodeExtension { compositeActivator.deactivate(domainComposite); } // end if + + // Remove the external endpoint descriptions from node.xml + DomainRegistry domainRegistry = compositeContext.getEndpointRegistry(); + if (!domainRegistry.isDistributed()) { + for (Endpoint e : configuration.getEndpointDescriptions()) { + domainRegistry.removeEndpoint(e); + } + } nodeFactory.removeNode(configuration); /* diff --git a/sca-java-2.x/trunk/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml b/sca-java-2.x/trunk/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml index 4afc52d73b..0e574e61fe 100644 --- a/sca-java-2.x/trunk/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml +++ b/sca-java-2.x/trunk/modules/node-impl/src/test/resources/org/apache/tuscany/sca/node/configuration/node1.xml @@ -55,4 +55,13 @@ </contribution> <option name="debug" value="true"/> <option name="validation">true</option> + <endpoint> + <sca:composite name="endpoint"> + <sca:component name="Component1"> <!-- first component --> + <sca:service name="Service1"> + <tuscany:binding.rest uri="http://localhost:8080/services/myResource" /> + </sca:service> + </sca:component> + </sca:composite> + </endpoint> </node>
\ No newline at end of file |