diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-23 22:48:13 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-23 22:48:13 +0000 |
commit | 90ba7b1a18706b434520d531358619438a43b4f0 (patch) | |
tree | 4c571d7829da8a0df07368ac51292bc07db5526e | |
parent | 40ddf83655bc926c1babc72ba36a1c658eadb516 (diff) |
Add a QName as the type for binding/implementation and use it to compare model types instead of class
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@787865 13f79535-47bb-0310-9956-ffa450edef68
57 files changed, 818 insertions, 743 deletions
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java index 7a2eba494f..59465b9700 100644 --- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java +++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.assembly.xml; @@ -107,8 +107,8 @@ import org.apache.tuscany.sca.policy.PolicySubject; import org.w3c.dom.Document; /** - * A composite processor. - * + * A composite processor. + * * @version $Rev$ $Date$ */ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArtifactProcessor<Composite> { @@ -117,29 +117,29 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt private StAXAttributeProcessor<Object> extensionAttributeProcessor; private ContributionFactory contributionFactory; - + /** * Construct a new composite processor - * + * * @param extensionPoints * @param extensionProcessor */ public CompositeProcessor(ExtensionPointRegistry extensionPoints, StAXArtifactProcessor extensionProcessor, - StAXAttributeProcessor extensionAttributeProcessor, + StAXAttributeProcessor extensionAttributeProcessor, Monitor monitor) { - - this(modelFactories(extensionPoints), - extensionProcessor, - extensionAttributeProcessor, + + this(modelFactories(extensionPoints), + extensionProcessor, + extensionAttributeProcessor, monitor(extensionPoints)); - + this.extensionAttributeProcessor = extensionAttributeProcessor; } - + /** * Constructs a new composite processor - * + * * @param modelFactories * @param extensionProcessor * @param monitor @@ -148,15 +148,15 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt StAXArtifactProcessor extensionProcessor, StAXAttributeProcessor extensionAttributeProcessor, Monitor monitor) { - + super(modelFactories, extensionProcessor, monitor); this.intentAttachPointTypeFactory = modelFactories.getFactory(PolicyFactory.class); this.xPathFactory = modelFactories.getFactory(XPathFactory.class); this.contributionFactory = modelFactories.getFactory(ContributionFactory.class); this.extensionAttributeProcessor = extensionAttributeProcessor; - + } - + public Composite read(XMLStreamReader reader) throws ContributionReadException { Composite composite = null; Composite include = null; @@ -179,60 +179,60 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt switch (event) { case START_ELEMENT: name = reader.getName(); - + if (COMPOSITE_QNAME.equals(name)) { - + // Read a <composite> composite = assemblyFactory.createComposite(); composite.setSpecVersion(Constants.SCA11_NS); - + composite.setName(new QName(getString(reader, TARGET_NAMESPACE), getString(reader, NAME))); - + if(!isSet(reader, TARGET_NAMESPACE)){ // spec says that a composite must have a namespace - warning("NoCompositeNamespace", composite, composite.getName().toString()); + warning("NoCompositeNamespace", composite, composite.getName().toString()); } - + if(isSet(reader, AUTOWIRE)) { composite.setAutowire(getBoolean(reader, AUTOWIRE)); } - + //handle extension attributes this.readExtendedAttributes(reader, name, composite, extensionAttributeProcessor); - + composite.setLocal(getBoolean(reader, LOCAL)); composite.setConstrainingType(readConstrainingType(reader)); policyProcessor.readPolicies(composite, reader); - + } else if (INCLUDE_QNAME.equals(name)) { - + // Read an <include> include = assemblyFactory.createComposite(); include.setName(getQName(reader, NAME)); include.setURI(getString(reader, URI)); include.setUnresolved(true); composite.getIncludes().add(include); - + } else if (SERVICE_QNAME.equals(name)) { if (component != null) { - + // Read a <component><service> componentService = assemblyFactory.createComponentService(); contract = componentService; componentService.setName(getString(reader, NAME)); - + //handle extension attributes this.readExtendedAttributes(reader, name, componentService, extensionAttributeProcessor); - + component.getServices().add(componentService); policyProcessor.readPolicies(contract, reader); } else { - + // Read a <composite><service> compositeService = assemblyFactory.createCompositeService(); contract = compositeService; compositeService.setName(getString(reader, NAME)); - + String promoted = getString(reader, PROMOTE); if (promoted != null) { String promotedComponentName; @@ -245,25 +245,25 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt promotedComponentName = promoted.substring(0, s); promotedServiceName = promoted.substring(s + 1); } - + Component promotedComponent = assemblyFactory.createComponent(); promotedComponent.setUnresolved(true); promotedComponent.setName(promotedComponentName); compositeService.setPromotedComponent(promotedComponent); - + ComponentService promotedService = assemblyFactory.createComponentService(); promotedService.setUnresolved(true); promotedService.setName(promotedServiceName); compositeService.setPromotedService(promotedService); } - + //handle extension attributes this.readExtendedAttributes(reader, name, compositeService, extensionAttributeProcessor); - + composite.getServices().add(compositeService); policyProcessor.readPolicies(contract, reader); } - + } else if (REFERENCE_QNAME.equals(name)) { if (component != null) { // Read a <component><reference> @@ -281,10 +281,10 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } readTargets(componentReference, reader); componentReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL)); - + //handle extension attributes this.readExtendedAttributes(reader, name, componentReference, extensionAttributeProcessor); - + component.getReferences().add(componentReference); policyProcessor.readPolicies(contract, reader); } else { @@ -303,7 +303,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt if (index == -1) { error("Invalid reference name", compositeReference, refName); } - String promotedComponentName = refName.substring(0, index); + String promotedComponentName = refName.substring(0, index); promotedComponent.setName(promotedComponentName); promotedComponent.setUnresolved(true); compositeReference.getPromotedComponents().add(promotedComponent); @@ -315,17 +315,17 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } } compositeReference.setWiredByImpl(getBoolean(reader, WIRED_BY_IMPL)); - + //handle extension attributes this.readExtendedAttributes(reader, name, compositeReference, extensionAttributeProcessor); - - composite.getReferences().add(compositeReference); + + composite.getReferences().add(compositeReference); policyProcessor.readPolicies(contract, reader); } - + } else if (PROPERTY_QNAME.equals(name)) { if (component != null) { - + // Read a <component><property> componentProperty = assemblyFactory.createComponentProperty(); property = componentProperty; @@ -359,41 +359,41 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } } componentProperty.setFile(getString(reader, FILE)); - + //handle extension attributes this.readExtendedAttributes(reader, name, componentProperty, extensionAttributeProcessor); - + policyProcessor.readPolicies(property, reader); readAbstractProperty(componentProperty, reader); - + // Read the property value Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader); property.setValue(value); - + component.getProperties().add(componentProperty); } else { - + // Read a <composite><property> property = assemblyFactory.createProperty(); policyProcessor.readPolicies(property, reader); readAbstractProperty(property, reader); - + // Read the property value Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader); property.setValue(value); - + composite.getProperties().add(property); } - + // TUSCANY-1949 // If the property doesn't have a value, the END_ELEMENT event is read by the readPropertyValue if (reader.getEventType() == END_ELEMENT && PROPERTY_QNAME.equals(reader.getName())) { property = null; componentProperty = null; } - + } else if (COMPONENT_QNAME.equals(name)) { - + // Read a <component> component = assemblyFactory.createComponent(); component.setName(getString(reader, NAME)); @@ -403,70 +403,70 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt if (isSet(reader, URI)) { component.setURI(getString(reader, URI)); } - + //handle extension attributes this.readExtendedAttributes(reader, name, component, extensionAttributeProcessor); - + component.setConstrainingType(readConstrainingType(reader)); composite.getComponents().add(component); policyProcessor.readPolicies(component, reader); - + } else if (WIRE_QNAME.equals(name)) { - + // Read a <wire> wire = assemblyFactory.createWire(); ComponentReference source = assemblyFactory.createComponentReference(); source.setUnresolved(true); source.setName(getString(reader, SOURCE)); wire.setSource(source); - + ComponentService target = assemblyFactory.createComponentService(); target.setUnresolved(true); target.setName(getString(reader, TARGET)); wire.setTarget(target); - + // Read @replace String replace = reader.getAttributeValue(null, REPLACE); if (replace != null) { wire.setReplace(Boolean.parseBoolean(replace)); } - + //handle extension attributes this.readExtendedAttributes(reader, name, wire, extensionAttributeProcessor); - + composite.getWires().add(wire); policyProcessor.readPolicies(wire, reader); - + } else if (CALLBACK_QNAME.equals(name)) { - + // Read a <callback> callback = assemblyFactory.createCallback(); contract.setCallback(callback); - + //handle extension attributes this.readExtendedAttributes(reader, name, callback, extensionAttributeProcessor); - + policyProcessor.readPolicies(callback, reader); - + } else if (IMPLEMENTATION_COMPOSITE_QNAME.equals(name)) { - + // Read an implementation.composite Composite implementation = assemblyFactory.createComposite(); implementation.setName(getQName(reader, NAME)); implementation.setUnresolved(true); - + //handle extension attributes this.readExtendedAttributes(reader, name, implementation, extensionAttributeProcessor); - + component.setImplementation(implementation); policyProcessor.readPolicies(implementation, reader); } else { - + // Read an extension element Object extension = extensionProcessor.read(reader); if (extension != null) { if (extension instanceof InterfaceContract) { - + // <service><interface> and // <reference><interface> if (contract != null) { @@ -484,7 +484,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt ExtensionType bindingType = intentAttachPointTypeFactory.createBindingType(); bindingType.setType(name); bindingType.setUnresolved(true); - ((PolicySubject)extension).setType(bindingType); + ((PolicySubject)extension).setExtensionType(bindingType); } // <service><binding> and // <reference><binding> @@ -502,13 +502,13 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } } } - + } else if (extension instanceof Implementation) { if ( extension instanceof PolicySubject ) { ExtensionType implType = intentAttachPointTypeFactory.createImplementationType(); implType.setType(name); implType.setUnresolved(true); - ((PolicySubject)extension).setType(implType); + ((PolicySubject)extension).setExtensionType(implType); } // <component><implementation> if (component != null) { @@ -522,7 +522,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } } } else { - + // Add the extension element to the current // element if (callback != null) { @@ -540,13 +540,13 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } } break; - + case XMLStreamConstants.CHARACTERS: break; - + case END_ELEMENT: name = reader.getName(); - + // Clear current state when reading reaching end element if (SERVICE_QNAME.equals(name)) { componentService = null; @@ -570,7 +570,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } break; } - + // Read the next element if (reader.hasNext()) { reader.next(); @@ -581,7 +581,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt ContributionReadException ex = new ContributionReadException(e); error("XMLStreamException", reader, ex); } - + return composite; } @@ -596,7 +596,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt new XAttr(LOCAL, composite.isLocal() ? Boolean.TRUE : null), new XAttr(AUTOWIRE, composite.getAutowire()), policyProcessor.writePolicies(composite)); - + //write extended attributes this.writeExtendedAttributes(writer, composite, extensionAttributeProcessor); @@ -610,7 +610,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt //write extended attributes this.writeExtendedAttributes(writer, include, extensionAttributeProcessor); - + writeEnd(writer); } @@ -631,11 +631,11 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), new XAttr(PROMOTE, promote), policyProcessor.writePolicies(service)); - + //write extended attributes this.writeExtendedAttributes(writer, service, extensionAttributeProcessor); - + // Write service interface extensionProcessor.write(service.getInterfaceContract(), writer); @@ -649,7 +649,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt Callback callback = service.getCallback(); writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback)); - + //write extended attributes this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor); @@ -657,12 +657,12 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt for (Binding binding : callback.getBindings()) { extensionProcessor.write(binding, writer); } - - // Write extensions + + // Write extensions for (Object extension : callback.getExtensions()) { extensionProcessor.write(extension, writer); } - + writeEnd(writer); } @@ -670,7 +670,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt for (Object extension : service.getExtensions()) { extensionProcessor.write(extension, writer); } - + writeEnd(writer); } @@ -680,15 +680,15 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt new XAttr(URI, component.getURI()), new XAttr(AUTOWIRE, component.getAutowire()), policyProcessor.writePolicies(component)); - + //write extended attributes this.writeExtendedAttributes(writer, component, extensionAttributeProcessor); - + // Write the component implementation Implementation implementation = component.getImplementation(); if (implementation instanceof Composite) { writeStart(writer, IMPLEMENTATION_COMPOSITE, new XAttr(NAME, ((Composite)implementation).getName())); - + //write extended attributes this.writeExtendedAttributes(writer, (Composite)implementation, extensionAttributeProcessor); @@ -696,11 +696,11 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } else { extensionProcessor.write(component.getImplementation(), writer); } - + for (Object extension : component.getExtensions()) { extensionProcessor.write(extension, writer); - } - + } + // Write <service> elements for (ComponentService service : component.getServices()) { writeStart(writer, SERVICE, new XAttr(NAME, service.getName()), @@ -711,12 +711,12 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt // Write service interface extensionProcessor.write(service.getInterfaceContract(), writer); - + // Write bindings for (Binding binding : service.getBindings()) { extensionProcessor.write(binding, writer); } - + // Write <callback> element if (service.getCallback() != null) { Callback callback = service.getCallback(); @@ -729,32 +729,32 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt for (Binding binding : callback.getBindings()) { extensionProcessor.write(binding, writer); } - - // Write extensions + + // Write extensions for (Object extension : callback.getExtensions()) { extensionProcessor.write(extension, writer); } - + writeEnd(writer); } - + // Write extensions for (Object extension : service.getExtensions()) { extensionProcessor.write(extension, writer); } - + writeEnd(writer); } - + // Write <reference> elements for (ComponentReference reference : component.getReferences()) { - writeStart(writer, - REFERENCE, - new XAttr(NAME, reference.getName()), - new XAttr(AUTOWIRE, reference.getAutowire()), - (reference.isNonOverridable() ? new XAttr(NONOVERRIDABLE, true) : null), - writeMultiplicity(reference), - writeTargets(reference), + writeStart(writer, + REFERENCE, + new XAttr(NAME, reference.getName()), + new XAttr(AUTOWIRE, reference.getAutowire()), + (reference.isNonOverridable() ? new XAttr(NONOVERRIDABLE, true) : null), + writeMultiplicity(reference), + writeTargets(reference), policyProcessor.writePolicies(reference)); //write extended attributes @@ -767,12 +767,12 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt for (Binding binding : reference.getBindings()) { extensionProcessor.write(binding, writer); } - + // Write callback if (reference.getCallback() != null) { Callback callback = reference.getCallback(); writeStart(writer, CALLBACK, policyProcessor.writePolicies(callback)); - + //write extended attributes this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor); @@ -780,23 +780,23 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt for (Binding binding : callback.getBindings()) { extensionProcessor.write(binding, writer); } - + // Write extensions for (Object extensions : callback.getExtensions()) { extensionProcessor.write(extensions, writer); } - + writeEnd(writer); } - + // Write extensions for (Object extensions : reference.getExtensions()) { extensionProcessor.write(extensions, writer); } - + writeEnd(writer); } - + // Write <property> elements for (ComponentProperty property : component.getProperties()) { writeStart(writer, @@ -823,7 +823,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt writeEnd(writer); } - + writeEnd(writer); } @@ -836,7 +836,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt for (ComponentReference promoted: compositeReference.getPromotedReferences()) { promote.add(promoted.getName()); } - + // Write <reference> element writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()), new XAttr(PROMOTE, promote), @@ -848,17 +848,17 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt // Write reference interface extensionProcessor.write(reference.getInterfaceContract(), writer); - + // Write bindings for (Binding binding : reference.getBindings()) { extensionProcessor.write(binding, writer); } - + // Write <callback> element if (reference.getCallback() != null) { Callback callback = reference.getCallback(); writeStart(writer, CALLBACK); - + //write extended attributes this.writeExtendedAttributes(writer, callback, extensionAttributeProcessor); @@ -866,20 +866,20 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt for (Binding binding : callback.getBindings()) { extensionProcessor.write(binding, writer); } - + // Write extensions for (Object extension : callback.getExtensions()) { extensionProcessor.write(extension, writer); } - + writeEnd(writer); } - + // Write extensions for (Object extension : reference.getExtensions()) { extensionProcessor.write(extension, writer); } - + writeEnd(writer); } @@ -912,7 +912,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt for (Wire wire : composite.getWires()) { writeStart(writer, WIRE, new XAttr(SOURCE, wire.getSource().getName()), new XAttr(TARGET, wire.getTarget() .getName()), wire.isReplace() ? new XAttr(Constants.REPLACE, true) : null); - + //write extended attributes this.writeExtendedAttributes(writer, wire, extensionAttributeProcessor); @@ -926,7 +926,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt for (Object extension : composite.getExtensions()) { extensionProcessor.write(extension, writer); } - + writeEndDocument(writer); } @@ -966,11 +966,11 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt constrainingType = resolver.resolveModel(ConstrainingType.class, constrainingType); component.setConstrainingType(constrainingType); } - - //resolve component services and references + + //resolve component services and references resolveContracts(component, component.getServices(), resolver); resolveContracts(component, component.getReferences(), resolver); - + for (ComponentProperty componentProperty : component.getProperties()) { if (componentProperty.getFile() != null) { Artifact artifact = contributionFactory.createArtifact(); @@ -981,7 +981,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } } } - + //resolve component implementation Implementation implementation = component.getImplementation(); if (implementation != null) { @@ -1008,7 +1008,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } } } - + public QName getArtifactType() { return COMPOSITE_QNAME; } @@ -1019,17 +1019,17 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt /** * Returns the model factory extension point to use. - * + * * @param extensionPoints * @return */ private static FactoryExtensionPoint modelFactories(ExtensionPointRegistry extensionPoints) { return extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); } - + /** * Returns the monitor to use. - * + * * @param extensionPoints * @return */ @@ -1043,5 +1043,5 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt } return null; } - + } diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java index 8eebf1f5e5..1f9dfcd237 100644 --- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java +++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/EndpointProcessor.java @@ -97,6 +97,7 @@ public class EndpointProcessor extends BaseAssemblyProcessor implements StAXArti try {
Composite composite = assemblyFactory.createComposite();
composite.setName(ENDPOINT_QNAME);
+ composite.setLocal(false);
Component component = (Component)endpoint.getComponent().clone();
composite.getComponents().add(component);
component.getReferences().clear();
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java index dfdc26f7ad..a5c1f97c66 100644 --- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java +++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/SCABindingProcessor.java @@ -6,15 +6,15 @@ * 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.
+ * under the License.
*/
package org.apache.tuscany.sca.assembly.xml;
@@ -28,7 +28,6 @@ import javax.xml.stream.XMLStreamWriter; import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.assembly.SCABindingFactory;
-import org.apache.tuscany.sca.assembly.xml.PolicySubjectProcessor;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
@@ -46,14 +45,14 @@ import org.apache.tuscany.sca.policy.PolicySubject; */
public class SCABindingProcessor implements StAXArtifactProcessor<SCABinding> {
- private static final String NAME = "name";
- private static final String URI = "uri";
-
- private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
+ private static final String NAME = "name";
+ private static final String URI = "uri";
+
+ private static final String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903";
private static final String BINDING_SCA = "binding.sca";
private static final QName BINDING_SCA_QNAME = new QName(SCA11_NS, BINDING_SCA);
-
- private PolicyFactory policyFactory;
+
+ private PolicyFactory policyFactory;
private SCABindingFactory scaBindingFactory;
private PolicySubjectProcessor policyProcessor;
private PolicyFactory intentAttachPointTypeFactory;
@@ -79,11 +78,11 @@ public class SCABindingProcessor implements StAXArtifactProcessor<SCABinding> { ExtensionType bindingType = intentAttachPointTypeFactory.createBindingType();
bindingType.setType(getArtifactType());
bindingType.setUnresolved(true);
- ((PolicySubject)scaBinding).setType(bindingType);
-
+ ((PolicySubject)scaBinding).setExtensionType(bindingType);
+
// Read policies
policyProcessor.readPolicies(scaBinding, reader);
-
+
// Read binding name
String name = reader.getAttributeValue(null, NAME);
if (name != null) {
@@ -104,10 +103,10 @@ public class SCABindingProcessor implements StAXArtifactProcessor<SCABinding> { }
return scaBinding;
}
-
+
public void resolve(SCABinding model, ModelResolver resolver) throws ContributionResolveException {
policyProcessor.resolvePolicies(model, resolver);
- }
+ }
public void write(SCABinding scaBinding, XMLStreamWriter writer) throws ContributionWriteException, XMLStreamException {
@@ -120,13 +119,13 @@ public class SCABindingProcessor implements StAXArtifactProcessor<SCABinding> { if (scaBinding.getName() != null) {
writer.writeAttribute(NAME, scaBinding.getName());
}
-
+
// Write binding URI
if (scaBinding.getURI() != null) {
writer.writeAttribute(URI, scaBinding.getURI());
}
-
+
writer.writeEndElement();
}
-
+
}
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java index d41881dc37..2f13eb8b6d 100644 --- a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java +++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/TestSCABindingImpl.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.assembly.xml; @@ -36,18 +36,18 @@ import org.apache.tuscany.sca.policy.PolicySubject; /** * A test cheel for the SCA binding. - * + * * @version $Rev$ $Date$ */ public class TestSCABindingImpl implements SCABinding, OptimizableBinding, PolicySubject { private String name; private String uri; private List<Object> extensions = new ArrayList<Object>(); - + private Component targetComponent; private ComponentService targetComponentService; private Binding targetBinding; - + private List<Intent> requiredIntents = new ArrayList<Intent>(); private List<PolicySet> policySets = new ArrayList<PolicySet>(); private ExtensionType bindingType = new TestSCABindingType(); @@ -57,7 +57,7 @@ public class TestSCABindingImpl implements SCABinding, OptimizableBinding, Polic */ protected TestSCABindingImpl() { } - + public String getName() { return name; } @@ -77,11 +77,11 @@ public class TestSCABindingImpl implements SCABinding, OptimizableBinding, Polic public List<Object> getExtensions() { return extensions; } - + public boolean isUnresolved() { return false; } - + public void setUnresolved(boolean unresolved) { } @@ -134,7 +134,7 @@ public class TestSCABindingImpl implements SCABinding, OptimizableBinding, Polic public void setTargetBinding(Binding targetBinding) { this.targetBinding = targetBinding; } - + public List<PolicySet> getPolicySets() { // TODO Auto-generated method stub return policySets; @@ -145,15 +145,19 @@ public class TestSCABindingImpl implements SCABinding, OptimizableBinding, Polic return requiredIntents; } - public ExtensionType getType() { + public ExtensionType getExtensionType() { // TODO Auto-generated method stub return bindingType; } - public void setType(ExtensionType type) { + public void setExtensionType(ExtensionType type) { this.bindingType = type; } - + + public QName getType() { + return TYPE; + } + private class TestSCABindingType implements ExtensionType { private QName name = new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903","binding"); public QName getBaseType() { @@ -182,5 +186,5 @@ public class TestSCABindingImpl implements SCABinding, OptimizableBinding, Polic public void setUnresolved(boolean unresolved) { } } - + } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java index 76511d351d..cb19ab5acb 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Base.java @@ -6,36 +6,38 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.assembly; /** * Base interface for all assembly model objects. - * + * * @version $Rev$ $Date$ */ public interface Base { + String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903"; + String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; /** * Returns true if the model element is unresolved. - * + * * @return true if the model element is unresolved. */ boolean isUnresolved(); /** * Sets whether the model element is unresolved. - * + * * @param unresolved whether the model element is unresolved */ void setUnresolved(boolean unresolved); diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java index 0423e0b128..069b4d4c5a 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Binding.java @@ -6,59 +6,64 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.assembly; +import javax.xml.namespace.QName; + + /** * Represents a binding. - * + * * @version $Rev$ $Date$ */ public interface Binding extends Base, Cloneable { /** * Returns the binding URI. - * + * * @return the binding URI */ String getURI(); /** * Sets the binding URI. - * + * * @param uri the binding URI */ void setURI(String uri); /** * Returns the binding name. - * + * * @return the binding name */ String getName(); /** * Sets the binding name. - * + * * @param name the binding name */ void setName(String name); - + /** * Clone the binding - * + * * @return */ - Object clone() throws CloneNotSupportedException; + Object clone() throws CloneNotSupportedException; + + QName getType(); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java index 12542297b3..27bc79788e 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.assembly; @@ -27,56 +27,56 @@ import org.apache.tuscany.sca.policy.PolicySubject; /** * Represents a composite. - * + * * @version $Rev$ $Date$ */ public interface Composite extends Implementation, Extensible, Cloneable, PolicySubject { - + QName TYPE = new QName(SCA11_NS, "implementation.composite"); /** * Returns the spec version of the composite used to build this model - * + * * @return the spec version used to build this model */ String getSpecVersion(); /** * Sets the spec version of the composite used to build this model - * + * * @param specVersion the spec version used to build this model */ void setSpecVersion(String specVersion); - + /** * Returns the name of the composite. - * + * * @return the name of the composite */ QName getName(); /** * Sets the name of the composite. - * + * * @param name the name of the composite */ void setName(QName name); /** * Returns a list of composites included in this composite. - * + * * @return a list of composites included in this composite. */ List<Composite> getIncludes(); /** * Returns a list of components contained in this composite. - * + * * @return a list of components contained in this composite */ List<Component> getComponents(); /** * Returns a list of wires contained in this composite. - * + * * @return a list of wires contained in this composite */ List<Wire> getWires(); @@ -84,7 +84,7 @@ public interface Composite extends Implementation, Extensible, Cloneable, Policy /** * Returns true if all the components within the composite must run in the * same process. - * + * * @return true if all the components within the composite must run in the * same process */ @@ -93,7 +93,7 @@ public interface Composite extends Implementation, Extensible, Cloneable, Policy /** * Sets whether all the components within the composite must run in the same * process. - * + * * @param local whether all the components within the composite must run in * the same process */ @@ -107,7 +107,7 @@ public interface Composite extends Implementation, Extensible, Cloneable, Policy /** * Sets whether component references should be autowired. - * + * * @param autowire whether component references should be autowired */ void setAutowire(Boolean autowire); @@ -115,7 +115,7 @@ public interface Composite extends Implementation, Extensible, Cloneable, Policy /** * Returns a clone of the component type. - * + * * @return a clone of the component type * @throws CloneNotSupportedException */ diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java index 8fb4215e36..daa57caaea 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/DistributedSCABinding.java @@ -6,37 +6,37 @@ * 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.
+ * under the License.
*/
package org.apache.tuscany.sca.assembly;
-import org.apache.tuscany.sca.assembly.Binding;
-import org.apache.tuscany.sca.assembly.SCABinding;
+import javax.xml.namespace.QName;
/**
* Represents an SCA binding used in the distributed runtime.
- * It provides us with a sensibly named type against which
+ * It provides us with a sensibly named type against which
* distributed sca binding providers can be registered
- *
+ *
* @version $Rev: 556322 $ $Date: 2007-07-14 19:53:15 +0100 (Sat, 14 Jul 2007) $
*/
public interface DistributedSCABinding extends Binding {
-
- /**
- * Return the wrapped SCA binding
- * @return the SCA binding model element
- */
+ QName TYPE = SCABinding.TYPE;
+
+ /**
+ * Return the wrapped SCA binding
+ * @return the SCA binding model element
+ */
SCABinding getSCABinding();
-
+
/**
* Set the wrapped SCA binding
* @param scaBinding the SCA binding model element
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java index 720a6801a2..d15334000f 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java @@ -6,22 +6,25 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.assembly; +import javax.xml.namespace.QName; + /** * Represents a component implementation. - * + * * @version $Rev$ $Date$ */ public interface Implementation extends ComponentType { + QName getType(); } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java index 2cf04277cd..aa356e3857 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/SCABinding.java @@ -6,22 +6,25 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.assembly; +import javax.xml.namespace.QName; + /** * Represents an SCA binding. - * + * * @version $Rev$ $Date$ */ public interface SCABinding extends Binding { + QName TYPE = new QName(SCA11_NS, "binding.sca"); } 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 59dbc85d1f..84368b810f 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 @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.assembly.builder.impl; @@ -49,7 +49,7 @@ import org.apache.tuscany.sca.policy.ExtensionType; import org.apache.tuscany.sca.policy.PolicySubject; /** - * Base class for Builder implementations + * Base class for Builder implementations * * @version $Rev$ $Date$ */ @@ -76,10 +76,10 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { this.transformerFactory = transformerFactory; this.interfaceContractMapper = interfaceContractMapper; } - + /** * Report a warning. - * + * * @param monitor * @param problems * @param message @@ -91,10 +91,10 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { monitor.problem(problem); } } - + /** * Report a error. - * + * * @param monitor * @param problems * @param message @@ -105,11 +105,11 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { Problem problem = monitor.createProblem(this.getClass().getName(), "assembly-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters); monitor.problem(problem); } - } - + } + /** * Report a exception. - * + * * @param problems * @param message * @param model @@ -120,11 +120,11 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { problem = monitor.createProblem(this.getClass().getName(), "assembly-validation-messages", Severity.ERROR, model, message, ex); monitor.problem(problem); } - } - + } + /** * Index components inside a composite - * + * * @param composite * @param componentServices @@ -134,12 +134,12 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { for (Component component : composite.getComponents()) { // Index components by name components.put(component.getName(), component); - } + } } - + /** * Index services inside a composite - * + * * @param composite * @param componentServices */ @@ -147,18 +147,18 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { Map<String, ComponentService> componentServices) { for (Component component : composite.getComponents()) { - + ComponentService nonCallbackService = null; int nonCallbackServiceCount = 0; - - for (ComponentService componentService : component.getServices()) { + + for (ComponentService componentService : component.getServices()) { // Index component services by component name / service name String uri = component.getName() + '/' + componentService.getName(); componentServices.put(uri, componentService); - + // count how many non-callback there are - if (!componentService.isCallback()) { - + if (!componentService.isCallback()) { + if (nonCallbackServiceCount == 0) { nonCallbackService = componentService; } @@ -170,9 +170,9 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { // component name as well componentServices.put(component.getName(), nonCallbackService); } - } - } - + } + } + /** * Index components, services and references inside a composite. @@ -187,28 +187,28 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { Map<String, ComponentReference> componentReferences) { for (Component component : composite.getComponents()) { - + // Index components by name components.put(component.getName(), component); - + ComponentService nonCallbackService = null; int nonCallbackServices = 0; for (ComponentService componentService : component.getServices()) { - + // Index component services by component name / service name String uri = component.getName() + '/' + componentService.getName(); componentServices.put(uri, componentService); - + // TODO - EPR - $promoted$ no longer used but it doesn't do any harm here boolean promotedService = false; if (componentService.getName() != null && componentService.getName().indexOf("$promoted$") > -1) { promotedService = true; } - + // count how many non-callback, non-promoted services there are // if there is only one the component name also acts as the service name - if ((!componentService.isCallback()) && (!promotedService)) { - + if ((!componentService.isCallback()) && (!promotedService)) { + // Check how many non callback non-promoted services we have if (nonCallbackServices == 0) { nonCallbackService = componentService; @@ -217,13 +217,13 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { } } - + if (nonCallbackServices == 1) { // If we have a single non callback service, index it by // component name as well componentServices.put(component.getName(), nonCallbackService); } - + // Index references by component name / reference name for (ComponentReference componentReference : component.getReferences()) { String uri = component.getName() + '/' + componentReference.getName(); @@ -231,7 +231,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { } } } - + protected void indexComponentPropertiesServicesAndReferences( Component component, Map<String, ComponentService> componentServices, @@ -319,12 +319,12 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { } } - } - + } + /** * Reconcile component properties and the properties defined by the * component type. - * + * * @param component * @param properties * @param componentProperties @@ -379,7 +379,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { if (componentProperty.getValue() == null) { componentProperty.setValue(property.getValue()); } - + // Override the property value for the composite if(component.getImplementation() instanceof Composite) { property.setValue(componentProperty.getValue()); @@ -419,7 +419,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { /** * Reconcile component references with the references defined on the * component type. - * + * * @param component * @param references * @param componentReferences @@ -488,11 +488,11 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { componentReference.setInterfaceContract(interfaceContract); } - // Reconcile bindings + // Reconcile bindings if (componentReference.getBindings().isEmpty()) { componentReference.getBindings().addAll(reference.getBindings()); } - + // Reconcile callback bindings if (componentReference.getCallback() == null) { componentReference.setCallback(reference.getCallback()); @@ -506,7 +506,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { componentReference.getCallback().getBindings().addAll(reference.getCallback() .getBindings()); } - + // Propagate autowire setting from the component if (componentReference.getAutowire() == null) { componentReference.setAutowire(component.getAutowire()); @@ -522,7 +522,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { /** * Reconcile component services and services defined on the component type. - * + * * @param component * @param services * @param componentServices @@ -583,7 +583,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { if (componentService.getBindings().isEmpty()) { componentService.getBindings().addAll(service.getBindings()); } - + // Reconcile callback bindings if (componentService.getCallback() == null) { componentService.setCallback(service.getCallback()); @@ -598,25 +598,25 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { } } } - } - + } + protected SCABinding createSCABinding(Definitions definitions) { SCABinding scaBinding = scaBindingFactory.createSCABinding(); - - // mark the bindings that are added automatically so that they can + + // mark the bindings that are added automatically so that they can // be disregarded for overriding purposes if (scaBinding instanceof AutomaticBinding){ ((AutomaticBinding)scaBinding).setIsAutomatic(true); } - + if ( definitions != null ) { for ( ExtensionType attachPointType : definitions.getBindingTypes() ) { if ( attachPointType.getType().equals(BINDING_SCA_QNAME)) { - ((PolicySubject)scaBinding).setType(attachPointType); + ((PolicySubject)scaBinding).setExtensionType(attachPointType); } } } - + return scaBinding; - } + } } 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 dea683e750..2daf8cbaf6 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 @@ -315,7 +315,7 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C // Skip the current binding continue; } - if (binding.getClass() != otherBinding.getClass()) { + if (!binding.getType().equals(otherBinding.getType())) { // Look for a binding of the same type continue; } @@ -420,7 +420,7 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C URI baseURI = null; if (defaultBindings != null) { for (Binding defaultBinding : defaultBindings){ - if (binding.getClass() == defaultBinding.getClass()){ + if (binding.getType().equals(defaultBinding.getType())){ baseURI = new URI(addSlashToPath(defaultBinding.getURI())); break; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java index a7a40e62e6..37f4ae6672 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyConfigurationUtil.java @@ -6,15 +6,15 @@ * 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.
+ * under the License.
*/
package org.apache.tuscany.sca.assembly.builder.impl;
@@ -49,18 +49,18 @@ import org.apache.tuscany.sca.policy.util.PolicyValidationUtils; * @version $Rev$ $Date$
*/
abstract class PolicyConfigurationUtil {
-
- private static List<Intent> computeInheritableIntents(ExtensionType attachPointType,
+
+ private static List<Intent> computeInheritableIntents(ExtensionType attachPointType,
List<Intent> inheritableIntents) throws PolicyValidationException {
List<Intent> validInheritableIntents = new ArrayList<Intent>();
-
+
//expand profile intents in inherited intents
PolicyComputationUtils.expandProfileIntents(inheritableIntents);
- //validate if inherited intent applies to the attachpoint (binding / implementation) and
+ //validate if inherited intent applies to the attachpoint (binding / implementation) and
//only add such intents to the attachpoint (binding / implementation)
for (Intent intent : inheritableIntents) {
- if ( !intent.isUnresolved() ) {
+ if ( !intent.isUnresolved() ) {
for (ExtensionType constrained : intent.getConstrainedTypes()) {
if ( PolicyValidationUtils.isConstrained(constrained, attachPointType)) {
validInheritableIntents.add(intent);
@@ -71,10 +71,10 @@ abstract class PolicyConfigurationUtil { throw new PolicyValidationException("Policy Intent '" + intent.getName() + "' is not defined in this domain");
}
}
-
+
return validInheritableIntents;
}
-
+
private static void normalizeIntents(PolicySubject intentAttachPoint) {
//expand profile intents specified in the attachpoint (binding / implementation)
PolicyComputationUtils.expandProfileIntents(intentAttachPoint.getRequiredIntents());
@@ -83,9 +83,9 @@ abstract class PolicyConfigurationUtil { //where qualified form of intent exists retain it and remove the qualifiable intent
filterDuplicatesAndQualifiableIntents(intentAttachPoint);
}
-
+
private static void trimInherentlyProvidedIntents(ExtensionType attachPointType, List<Intent>intents) {
- //exclude intents that are inherently supported by the
+ //exclude intents that are inherently supported by the
//attachpoint-type (binding-type / implementation-type)
List<Intent> requiredIntents = new ArrayList<Intent>(intents);
for ( Intent intent : requiredIntents ) {
@@ -94,33 +94,33 @@ abstract class PolicyConfigurationUtil { }
}
}
-
-
- private static List<PolicySet> computeInheritablePolicySets(List<PolicySet> inheritablePolicySets)
+
+
+ private static List<PolicySet> computeInheritablePolicySets(List<PolicySet> inheritablePolicySets)
throws PolicyValidationException {
// FIXME:
return inheritablePolicySets;
}
-
+
private static void normalizePolicySets(PolicySubject subject ) {
//get rid of duplicate entries
Set<PolicySet> policySetTable = new HashSet<PolicySet>(subject.getPolicySets());
-
+
subject.getPolicySets().clear();
subject.getPolicySets().addAll(policySetTable);
-
+
//expand profile intents
for ( PolicySet policySet : subject.getPolicySets() ) {
PolicyComputationUtils.expandProfileIntents(policySet.getProvidedIntents());
}
}
-
+
private static void trimProvidedIntents(List<Intent> requiredIntents, List<PolicySet> policySets) {
for ( PolicySet policySet : policySets ) {
trimProvidedIntents(requiredIntents, policySet);
}
}
-
+
private static void determineApplicableDomainPolicySets(List<PolicySet> applicablePolicySets,
PolicySubject policySetAttachPoint,
ExtensionType intentAttachPointType) {
@@ -134,7 +134,7 @@ abstract class PolicyConfigurationUtil { combinedTargetIntents.addAll(PolicyComputationUtils.findAndExpandProfileIntents(targetPolicySet.getProvidedIntents()));
}
- //since the set of applicable policysets for this attachpoint is known
+ //since the set of applicable policysets for this attachpoint is known
//we only need to check in that list if there is a policyset that matches
for (PolicySet policySet : applicablePolicySets) {
// do not use the policy set if it provides intents that conflict with required intents
@@ -157,40 +157,40 @@ abstract class PolicyConfigurationUtil { if (prevSize != policySetAttachPoint.getRequiredIntents().size()) {
policySetAttachPoint.getPolicySets().add(policySet);
}
- }
+ }
}
}
-
+
private static boolean isProvidedInherently(ExtensionType attachPointType, Intent intent) {
- return ( attachPointType != null &&
+ return ( attachPointType != null &&
(( attachPointType.getAlwaysProvidedIntents() != null &&
- attachPointType.getAlwaysProvidedIntents().contains(intent) ) ||
+ attachPointType.getAlwaysProvidedIntents().contains(intent) ) ||
( attachPointType.getMayProvidedIntents() != null &&
attachPointType.getMayProvidedIntents().contains(intent) )
) );
}
-
+
private static void trimProvidedIntents(List<Intent> requiredIntents, PolicySet policySet) {
for ( Intent providedIntent : policySet.getProvidedIntents() ) {
if ( requiredIntents.contains(providedIntent) ) {
requiredIntents.remove(providedIntent);
- }
+ }
}
-
+
for ( IntentMap intentMap : policySet.getIntentMaps() ) {
if ( requiredIntents.contains(intentMap.getProvidedIntent()) ) {
requiredIntents.remove(intentMap.getProvidedIntent());
- }
+ }
}
}
-
+
private static void filterDuplicatesAndQualifiableIntents(PolicySubject intentAttachPoint) {
//remove duplicates
Map<QName, Intent> intentsTable = new HashMap<QName, Intent>();
for ( Intent intent : intentAttachPoint.getRequiredIntents() ) {
intentsTable.put(intent.getName(), intent);
}
-
+
//where qualified form of intent exists retain it and remove the qualifiable intent
Map<QName, Intent> intentsTableCopy = new HashMap<QName, Intent>(intentsTable);
//if qualified form of intent exists remove the unqualified form
@@ -210,50 +210,50 @@ abstract class PolicyConfigurationUtil { if (binding instanceof PolicySubject) {
PolicySubject policiedBinding = (PolicySubject)binding;
computeIntents((PolicySubject)binding, contract.getRequiredIntents());
-
+
computePolicySets(policiedBinding, contract.getPolicySets());
-
+
PolicyComputationUtils.checkForMutuallyExclusiveIntents(
policiedBinding.getRequiredIntents(),
policiedBinding.getPolicySets(),
- policiedBinding.getType(),
+ policiedBinding.getExtensionType(),
contract.getName());
}
}
-
+
if ( contract.getCallback() != null ) {
for (Binding binding : contract.getCallback().getBindings()) {
if (binding instanceof PolicySubject) {
PolicySubject policiedBinding = (PolicySubject)binding;
computeIntents((PolicySubject)binding, contract.getCallback().getRequiredIntents());
-
+
computePolicySets(policiedBinding, contract.getCallback().getPolicySets());
-
+
PolicyComputationUtils.checkForMutuallyExclusiveIntents(
policiedBinding.getRequiredIntents(),
policiedBinding.getPolicySets(),
- policiedBinding.getType(),
+ policiedBinding.getExtensionType(),
contract.getName() + " callback");
-
+
}
}
}
}
- private static void computeIntents(PolicySubject policiedBinding, List<Intent> inheritedIntents)
+ private static void computeIntents(PolicySubject policiedBinding, List<Intent> inheritedIntents)
throws PolicyValidationException {
//since the parent component could also contain intents that apply to implementation
//and binding elements within, we filter out only those that apply to this binding type
- List<Intent> prunedIntents = computeInheritableIntents(policiedBinding.getType(),
+ List<Intent> prunedIntents = computeInheritableIntents(policiedBinding.getExtensionType(),
inheritedIntents);
policiedBinding.getRequiredIntents().addAll(prunedIntents);
-
+
normalizeIntents(policiedBinding);
}
private static void computePolicySets(PolicySubject policiedBinding,
List<PolicySet> inheritedPolicySets) throws PolicyValidationException {
-
+
List<PolicySet> prunedPolicySets = computeInheritablePolicySets(inheritedPolicySets);
policiedBinding.getPolicySets().addAll(prunedPolicySets);
normalizePolicySets(policiedBinding);
@@ -264,9 +264,9 @@ abstract class PolicyConfigurationUtil { for (Binding aBinding : source.getBindings()) {
if (aBinding instanceof PolicySubject) {
PolicySubject policiedBinding = (PolicySubject)aBinding;
- ExtensionType bindingType = policiedBinding.getType();
-
-
+ ExtensionType bindingType = policiedBinding.getExtensionType();
+
+
intentsCopy = new ArrayList<Intent>(policiedBinding.getRequiredIntents());
// add the target component's intents to the reference binding
if (target != null) {
@@ -284,12 +284,12 @@ abstract class PolicyConfigurationUtil { }
}
}
-
- trimInherentlyProvidedIntents(policiedBinding.getType(),
+
+ trimInherentlyProvidedIntents(policiedBinding.getExtensionType(),
policiedBinding.getRequiredIntents());
trimProvidedIntents(policiedBinding.getRequiredIntents(), policiedBinding
.getPolicySets());
-
+
// determine additional policysets that match remaining intents
// TODO: resolved to domain policy registry and attach suitable
// policy sets to the binding
@@ -297,34 +297,34 @@ abstract class PolicyConfigurationUtil { // if there are intents that are not provided by any policy set
// throw a warning
determineApplicableDomainPolicySets(source, policiedBinding);
-
+
//the intents list could have been trimmed when matching for policysets
//since the bindings may need the original set of intents we copy that back
policiedBinding.getRequiredIntents().clear();
policiedBinding.getRequiredIntents().addAll(intentsCopy);
-
+
}
}
}
- private static void determineApplicableDomainPolicySets(Contract contract,
- PolicySubject policiedBinding)
+ private static void determineApplicableDomainPolicySets(Contract contract,
+ PolicySubject policiedBinding)
throws PolicyConfigurationException {
// FIXME:
/*
//if ( domainPolicySets != null) {
- determineApplicableDomainPolicySets(policiedBinding.getApplicablePolicySets(),
+ determineApplicableDomainPolicySets(policiedBinding.getApplicablePolicySets(),
policiedBinding,
- policiedBinding.getType());
-
+ policiedBinding.getExtensionType());
+
if ( policiedBinding.getRequiredIntents().size() > 0 ) {
if ( contract instanceof Service ) {
throw new PolicyConfigurationException("The following are unfulfilled intents for " +
- "binding in service - " + contract.getName() + "\nUnfulfilled Intents = " +
+ "binding in service - " + contract.getName() + "\nUnfulfilled Intents = " +
policiedBinding.getRequiredIntents());
} else {
throw new PolicyConfigurationException("The are unfulfilled intents for " +
- "binding in reference - " + contract.getName() + "\nUnfulfilled Intents = " +
+ "binding in reference - " + contract.getName() + "\nUnfulfilled Intents = " +
policiedBinding.getRequiredIntents());
}
}
@@ -339,15 +339,15 @@ abstract class PolicyConfigurationUtil { for ( PolicySet policySet : target ) {
policySetTable.put(policySet.getName(), policySet);
}
-
+
target.clear();
target.addAll(policySetTable.values());
}
static <C extends Contract> void inheritDefaultPolicies(Base parent, List<C> contracts) {
-
+
for (Contract contract : contracts) {
-
+
// The contract inherits default policies from the parent composite/component.
if ( parent instanceof PolicySubject ) {
PolicyComputationUtils.addDefaultPolicies(
@@ -356,7 +356,7 @@ abstract class PolicyConfigurationUtil { contract.getRequiredIntents(),
contract.getPolicySets());
}
-
+
// The contract's callback inherits default policies from the contract.
if (contract.getCallback() != null) {
PolicyComputationUtils.addDefaultPolicies(
@@ -365,35 +365,35 @@ abstract class PolicyConfigurationUtil { contract.getCallback().getRequiredIntents(),
contract.getCallback().getPolicySets());
}
-
+
}
}
- static void computeImplementationIntentsAndPolicySets(Implementation implementation, Component parent)
+ static void computeImplementationIntentsAndPolicySets(Implementation implementation, Component parent)
throws PolicyValidationException, PolicyConfigurationException {
if ( implementation instanceof PolicySubject ) {
PolicySubject policiedImplementation = (PolicySubject)implementation;
//since for an implementation the component has its policy intents and policysets its possible
- //that there are some intents there that does not constrain the implementation.. so prune
- List<Intent> prunedIntents = computeInheritableIntents(policiedImplementation.getType(),
+ //that there are some intents there that does not constrain the implementation.. so prune
+ List<Intent> prunedIntents = computeInheritableIntents(policiedImplementation.getExtensionType(),
parent.getRequiredIntents());
parent.getRequiredIntents().clear();
parent.getRequiredIntents().addAll(prunedIntents);
normalizeIntents(parent);
-
+
List<PolicySet> prunedPolicySets = computeInheritablePolicySets(parent.getPolicySets());
parent.getPolicySets().clear();
parent.getPolicySets().addAll(prunedPolicySets);
normalizePolicySets(parent);
-
+
PolicyComputationUtils.checkForMutuallyExclusiveIntents(
parent.getRequiredIntents(),
parent.getPolicySets(),
- policiedImplementation.getType(),
+ policiedImplementation.getExtensionType(),
parent.getName());
-
+
determineApplicableImplementationPolicySets(parent);
-
+
}
}
@@ -401,24 +401,24 @@ abstract class PolicyConfigurationUtil { List<Intent> intentsCopy = null;
if ( component.getImplementation() instanceof PolicySubject ) {
PolicySubject policiedImplementation = (PolicySubject)component.getImplementation();
-
+
intentsCopy = new ArrayList<Intent>(component.getRequiredIntents());
- trimInherentlyProvidedIntents(policiedImplementation.getType(),
+ trimInherentlyProvidedIntents(policiedImplementation.getExtensionType(),
component.getRequiredIntents());
trimProvidedIntents(component.getRequiredIntents(), component.getPolicySets());
-
+
//determine additional policysets that match remaining intents
//if there are intents that are not provided by any policy set throw a warning
//TODO: resolved to domain policy registry and attach suitable policy sets to the implementation
//...for now using the SCA Definitions instead of registry
//if ( domainPolicySets != null) {
-
+
if (component.getRequiredIntents().size() > 0) {
throw new PolicyConfigurationException("The following are unfulfilled intents for component implementation - " + component
.getName() + "\nUnfulfilled Intents = " + component.getRequiredIntents());
}
//}
-
+
//the intents list could have been trimmed when matching for policysets
//since the bindings may need the original set of intents we copy that back
component.getRequiredIntents().clear();
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java index 1e69dfcc87..40ffb6a4b5 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BindingImpl.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.assembly.impl; @@ -22,21 +22,34 @@ package org.apache.tuscany.sca.assembly.impl; import java.util.ArrayList; import java.util.List; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.policy.ExtensionType; import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.PolicySet; /** - * + * Base Binding implementation class */ public abstract class BindingImpl extends ExtensibleImpl implements Binding { private String name; - private ExtensionType type; + private ExtensionType extensionType; private String uri; private List<Intent> requiredIntents = new ArrayList<Intent>(); private List<PolicySet> policySets = new ArrayList<PolicySet>(); + protected QName type; + + protected BindingImpl(QName type) { + super(); + this.type = type; + } + + public QName getType() { + return type; + } + public List<Intent> getRequiredIntents() { return requiredIntents; } @@ -58,12 +71,12 @@ public abstract class BindingImpl extends ExtensibleImpl implements Binding { this.name = name; } - public ExtensionType getType() { - return type; + public ExtensionType getExtensionType() { + return extensionType; } - public void setType(ExtensionType type) { - this.type = type; + public void setExtensionType(ExtensionType type) { + this.extensionType = type; } public String getURI() { diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java index f8f856f1b4..2d8513309e 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java @@ -53,11 +53,11 @@ public class CallbackImpl extends ExtensibleImpl implements Callback { return bindings; } - public ExtensionType getType() { + public ExtensionType getExtensionType() { return null; } - public void setType(ExtensionType type) { + public void setExtensionType(ExtensionType type) { } public void setRequiredIntents(List<Intent> intents) { diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java index d751d59f83..8eee73b469 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java @@ -137,11 +137,11 @@ public class ComponentImpl extends ExtensibleImpl implements Component, Cloneabl return autowire; } - public ExtensionType getType() { + public ExtensionType getExtensionType() { return type; } - public void setType(ExtensionType type) { + public void setExtensionType(ExtensionType type) { this.type = type; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java index c79aaf6b2e..5d55f76903 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java @@ -126,10 +126,10 @@ public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType, return policySets; } - public ExtensionType getType() { + public ExtensionType getExtensionType() { return null; } - public void setType(ExtensionType type) { + public void setExtensionType(ExtensionType type) { } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java index 4e14cf0e53..7ebd770935 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CompositeImpl.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.assembly.impl; @@ -51,6 +51,7 @@ public class CompositeImpl extends ImplementationImpl implements Composite, Clon * Constructs a new composite. */ protected CompositeImpl() { + super(TYPE); } @Override @@ -86,13 +87,13 @@ public class CompositeImpl extends ImplementationImpl implements Composite, Clon } return clone; } - + public String getSpecVersion() { return specVersion; } - + public void setSpecVersion(String specVersion) { - this.specVersion = specVersion; + this.specVersion = specVersion; } public List<Component> getComponents() { @@ -126,11 +127,11 @@ public class CompositeImpl extends ImplementationImpl implements Composite, Clon public void setAutowire(Boolean autowire) { this.autowire = autowire; } - + public Boolean getAutowire() { return autowire; } - + public void setName(QName name) { this.name = name; } @@ -154,7 +155,7 @@ public class CompositeImpl extends ImplementationImpl implements Composite, Clon return false; } } - + @Override public String toString(){ return ( this.name != null ) ? getName().toString() : "null"; diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java index 641e0f17df..b1e36ee60d 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ConstrainingTypeImpl.java @@ -98,11 +98,11 @@ public class ConstrainingTypeImpl extends ExtensibleImpl implements Constraining } } - public ExtensionType getType() { + public ExtensionType getExtensionType() { return null; } - public void setType(ExtensionType type) { + public void setExtensionType(ExtensionType type) { } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java index a121635323..ab8d7dc19e 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ContractImpl.java @@ -74,11 +74,11 @@ public class ContractImpl extends ExtensibleImpl implements AbstractContract { this.isCallback = isCallback; } - public ExtensionType getType() { + public ExtensionType getExtensionType() { return null; } - public void setType(ExtensionType type) { + public void setExtensionType(ExtensionType type) { } public List<PolicySet> getPolicySets() { diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java index 898aec0c42..d6bcbba797 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/DistributedSCABindingImpl.java @@ -6,40 +6,42 @@ * 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.
+ * under the License.
*/
package org.apache.tuscany.sca.assembly.impl;
-import org.apache.tuscany.sca.assembly.SCABinding;
+import javax.xml.namespace.QName;
+
import org.apache.tuscany.sca.assembly.DistributedSCABinding;
+import org.apache.tuscany.sca.assembly.SCABinding;
/**
* The Distributed SCA binding wrapper for the SCA binding model object. This is currently
* just used to locate the remote binding extension and pass the SCA binding to the remote
* extension. It isn't used in the model itself
- *
+ *
* @version $Rev: 564307 $ $Date: 2007-08-09 18:48:29 +0100 (Thu, 09 Aug 2007) $
*/
public class DistributedSCABindingImpl implements DistributedSCABinding {
-
+
private SCABinding scaBinding;
-
+
public SCABinding getSCABinding(){
return scaBinding;
}
-
+
public void setSCABinding(SCABinding scaBinding){
this.scaBinding = scaBinding;
}
-
+
public String getURI(){
return null;
}
@@ -54,7 +56,7 @@ public class DistributedSCABindingImpl implements DistributedSCABinding { public void setName(String name){
}
-
+
public boolean isUnresolved(){
return false;
}
@@ -62,9 +64,13 @@ public class DistributedSCABindingImpl implements DistributedSCABinding { public void setUnresolved(boolean unresolved){
}
-
+
@Override
public Object clone() throws CloneNotSupportedException {
return super.clone();
- }
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java index 8e2f482f1e..2a7c010c11 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointImpl.java @@ -131,14 +131,14 @@ public class EndpointImpl implements Endpoint { return requiredIntents; } - public ExtensionType getType() { + public ExtensionType getExtensionType() { if (binding instanceof PolicySubject) { - return ((PolicySubject)binding).getType(); + return ((PolicySubject)binding).getExtensionType(); } return null; } - public void setType(ExtensionType type) { + public void setExtensionType(ExtensionType type) { throw new UnsupportedOperationException(); } @@ -187,12 +187,12 @@ public class EndpointImpl implements Endpoint { public void setExtensionPointRegistry(ExtensionPointRegistry registry) { this.registry = registry; } - + public boolean isRemote() { return remote; } - + public void setRemote(boolean remote) { this.remote = remote; - } + } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java index b2e5b8b9cf..7ff0b45e97 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/EndpointReferenceImpl.java @@ -141,14 +141,14 @@ public class EndpointReferenceImpl implements EndpointReference { return requiredIntents; } - public ExtensionType getType() { + public ExtensionType getExtensionType() { if (binding instanceof PolicySubject) { - return ((PolicySubject)binding).getType(); + return ((PolicySubject)binding).getExtensionType(); } return null; } - public void setType(ExtensionType type) { + public void setExtensionType(ExtensionType type) { throw new UnsupportedOperationException(); } @@ -200,11 +200,11 @@ public class EndpointReferenceImpl implements EndpointReference { public void setURI(String uri) { this.uri = uri; } - + public boolean isRemote() { return remote; } - + public void setRemote(boolean remote) { this.remote = remote; } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java index 1c28192b3a..181874039e 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.assembly.impl; @@ -22,6 +22,8 @@ package org.apache.tuscany.sca.assembly.impl; import java.util.ArrayList; import java.util.List; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.policy.ExtensionType; import org.apache.tuscany.sca.policy.Intent; @@ -34,12 +36,14 @@ import org.apache.tuscany.sca.policy.PolicySubject; * @version $Rev$ $Date$ */ public abstract class ImplementationImpl extends ComponentTypeImpl implements Implementation, PolicySubject { - private ExtensionType type; + private QName type; + private ExtensionType extensionType; private List<PolicySet> policySets = new ArrayList<PolicySet>(); private List<Intent> requiredIntents = new ArrayList<Intent>(); - protected ImplementationImpl() { + protected ImplementationImpl(QName type) { super(); + this.type = type; } public List<PolicySet> getPolicySets() { @@ -50,11 +54,15 @@ public abstract class ImplementationImpl extends ComponentTypeImpl implements Im return requiredIntents; } - public ExtensionType getType() { - return type; + public ExtensionType getExtensionType() { + return extensionType; } - public void setType(ExtensionType type) { - this.type = type; + public void setExtensionType(ExtensionType extensionType) { + this.extensionType = extensionType; + } + + public QName getType() { + return type; } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java index 4a962db005..3a24759cd3 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/SCABindingImpl.java @@ -6,21 +6,23 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.assembly.impl; import java.util.ArrayList; import java.util.List; +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.ComponentService; @@ -29,14 +31,14 @@ import org.apache.tuscany.sca.assembly.Extension; import org.apache.tuscany.sca.assembly.OptimizableBinding; import org.apache.tuscany.sca.assembly.SCABinding; import org.apache.tuscany.sca.assembly.builder.AutomaticBinding; -import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.ExtensionType; +import org.apache.tuscany.sca.policy.Intent; import org.apache.tuscany.sca.policy.PolicySet; import org.apache.tuscany.sca.policy.PolicySubject; /** * The assembly mode object for an SCA binding. - * + * * @version $Rev$ $Date$ */ public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, OptimizableBinding, AutomaticBinding { @@ -46,15 +48,15 @@ public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, Op private List<Extension> attributeExtensions = new ArrayList<Extension>(); private List<Intent> requiredIntents = new ArrayList<Intent>(); private List<PolicySet> policySets = new ArrayList<PolicySet>(); - private ExtensionType intentAttachPointType; - + private ExtensionType extensionType; + private Component targetComponent; private ComponentService targetComponentService; private Binding targetBinding; private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>(); - + private boolean isAutomatic = false; - + public List<PolicySet> getApplicablePolicySets() { return applicablePolicySets; } @@ -64,21 +66,21 @@ public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, Op */ protected SCABindingImpl() { } - + public String getName() { return name; } - + public void setName(String name) { this.name = name; } /** - * Getters for the binding URI. The computed URI for the + * Getters for the binding URI. The computed URI for the * service that the reference is targeting or which the service represents * depending on whether the biding is associated with a reference or * service - * + * * @return the binding URI */ public String getURI() { @@ -88,15 +90,15 @@ public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, Op public void setURI(String uri) { this.uri = uri; } - + public List<Object> getExtensions() { return extensions; } - + public List<Extension> getAttributeExtensions() { return attributeExtensions; } - + public boolean isUnresolved() { if (targetComponentService == null){ return true; @@ -111,19 +113,19 @@ public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, Op public List<PolicySet> getPolicySets() { return policySets; } - + public List<Intent> getRequiredIntents() { return requiredIntents; } - public ExtensionType getType() { - return intentAttachPointType; + public ExtensionType getExtensionType() { + return extensionType; } - - public void setType(ExtensionType intentAttachPointType) { - this.intentAttachPointType = intentAttachPointType; + + public void setExtensionType(ExtensionType intentAttachPointType) { + this.extensionType = intentAttachPointType; } - + // Wireable binding operations public Component getTargetComponent() { @@ -149,9 +151,9 @@ public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, Op public void setTargetBinding(Binding targetBinding) { this.targetBinding = targetBinding; } - + public void setPolicySets(List<PolicySet> policySets) { - this.policySets = policySets; + this.policySets = policySets; } public void setRequiredIntents(List<Intent> intents) { @@ -161,7 +163,7 @@ public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, Op public void setIsAutomatic(boolean isAutomatic){ this.isAutomatic = isAutomatic; } - + public boolean getIsAutomatic(){ return this.isAutomatic; } @@ -169,5 +171,9 @@ public class SCABindingImpl implements SCABinding, Extensible, PolicySubject, Op @Override public Object clone() throws CloneNotSupportedException { return super.clone(); - } + } + + public QName getType() { + return TYPE; + } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java index 9f8af0907d..19e9b775d1 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/WireImpl.java @@ -80,11 +80,11 @@ public class WireImpl extends ExtensibleImpl implements Wire, Cloneable { return policySets; } - public ExtensionType getType() { + public ExtensionType getExtensionType() { return null; } - public void setType(ExtensionType type) { + public void setExtensionType(ExtensionType type) { } public void setPolicySets(List<PolicySet> policySets) { diff --git a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java index 3a75bbcc36..5380a319d5 100644 --- a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java +++ b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestBinding.java @@ -18,16 +18,20 @@ */ package org.apache.tuscany.sca.assembly; -import org.apache.tuscany.sca.assembly.impl.BindingImpl; +import javax.xml.namespace.QName; +import org.apache.tuscany.sca.assembly.impl.BindingImpl; /** * A test interface model. - * + * * @version $Rev$ $Date$ */ public class TestBinding extends BindingImpl implements Binding { + private final static QName TYPE = new QName("http://test", "binding.test"); + public TestBinding(AssemblyFactory factory) { + super(TYPE); } public String getName() { @@ -37,7 +41,7 @@ public class TestBinding extends BindingImpl implements Binding { public String getURI() { return "http://test"; } - + public boolean isUnresolved() { return false; } diff --git a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java index 19702954c9..6777c33ff1 100644 --- a/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java +++ b/java/sca/modules/assembly/src/test/java/org/apache/tuscany/sca/assembly/TestImplementation.java @@ -24,12 +24,12 @@ import org.apache.tuscany.sca.assembly.impl.ImplementationImpl; /** * A test component implementation model. - * + * * @version $Rev$ $Date$ */ public class TestImplementation extends ImplementationImpl implements Implementation { public TestImplementation(AssemblyFactory factory) { - + super(new QName("http://test", "implementation.test")); Property p = factory.createProperty(); p.setName("currency"); p.setValue("USD"); diff --git a/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java b/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java index 093acead48..8872d78fa6 100644 --- a/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java +++ b/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBinding.java @@ -6,24 +6,26 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.binding.jsonp; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.assembly.Binding; /** * JSONP Binding model */ public interface JSONPBinding extends Binding { - + QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.jsonp"); } diff --git a/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java b/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java index b75383d978..523235377f 100644 --- a/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java +++ b/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/JSONPBindingFactory.java @@ -27,5 +27,5 @@ public interface JSONPBindingFactory { /**
* Create JSONPBinding model
*/
- JSONPBinding createRMIBinding();
+ JSONPBinding createJSONPBinding();
}
diff --git a/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingFactoryImpl.java b/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingFactoryImpl.java index dc5b9d32f0..cc757bfadd 100644 --- a/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingFactoryImpl.java +++ b/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingFactoryImpl.java @@ -27,7 +27,7 @@ import org.apache.tuscany.sca.binding.jsonp.JSONPBindingFactory; */
public class JSONPBindingFactoryImpl implements JSONPBindingFactory {
- public JSONPBinding createRMIBinding() {
+ public JSONPBinding createJSONPBinding() {
return new JSONPBindingImpl();
}
diff --git a/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.java b/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.java index be7a56e621..baa1c5eb11 100644 --- a/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.java +++ b/java/sca/modules/binding-jsonp/src/main/java/org/apache/tuscany/sca/binding/jsonp/impl/JSONPBindingImpl.java @@ -6,18 +6,20 @@ * 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.
+ * under the License.
*/
package org.apache.tuscany.sca.binding.jsonp.impl;
+import javax.xml.namespace.QName;
+
import org.apache.tuscany.sca.binding.jsonp.JSONPBinding;
/**
@@ -56,6 +58,10 @@ public class JSONPBindingImpl implements JSONPBinding { }
public void setUnresolved(boolean arg0) {
- }
+ }
+
+ public QName getType() {
+ return TYPE;
+ }
}
diff --git a/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java b/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java index 2cdb2dff9e..36354ddc01 100644 --- a/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java +++ b/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/RMIBinding.java @@ -19,6 +19,8 @@ package org.apache.tuscany.sca.binding.rmi; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.assembly.Binding; /** @@ -27,4 +29,5 @@ import org.apache.tuscany.sca.assembly.Binding; * @version $Rev$ $Date$ */ public interface RMIBinding extends Binding { + QName TYPE = new QName(SCA11_TUSCANY_NS, "binding.rmi"); } diff --git a/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java b/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java index de912d2fc1..498d03c60e 100644 --- a/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java +++ b/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/sca/binding/rmi/impl/RMIBindingImpl.java @@ -18,6 +18,8 @@ */ package org.apache.tuscany.sca.binding.rmi.impl; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.binding.rmi.RMIBinding; /** @@ -43,7 +45,7 @@ public class RMIBindingImpl implements RMIBinding { } public void setUnresolved(boolean unresolved) { - // The sample binding is always resolved + // The binding is always resolved } @Override @@ -59,5 +61,9 @@ public class RMIBindingImpl implements RMIBinding { this.name = name; } + public QName getType() { + return TYPE; + } + } diff --git a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RemoteBindingHelper.java b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RemoteBindingHelper.java index 29c5374d51..7ea9f01dd3 100644 --- a/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RemoteBindingHelper.java +++ b/java/sca/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RemoteBindingHelper.java @@ -6,36 +6,36 @@ * 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.
+ * under the License.
*/
package org.apache.tuscany.sca.binding.sca.provider;
/**
- * TODO: TUSCANY-2578, implement a pluggable mechanism so sca binding impls can
+ * TODO: TUSCANY-2578, implement a pluggable mechanism so sca binding impls can
* add their own code to the decision on whether or not to use
* the remote binding provider.
*/
public class RemoteBindingHelper {
-
+
private static boolean alwaysRemote;
static {
try {
Class.forName("org.apache.tuscany.sca.binding.sca.jms.JMSSCABindingProviderFactory");
alwaysRemote = true;
} catch (ClassNotFoundException e) {
- alwaysRemote = false;
+ alwaysRemote = true;
}
}
-
+
public static boolean isTargetRemote() {
return alwaysRemote;
}
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 0d07a55a14..83b66aa5ad 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 @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.binding.ws; @@ -32,13 +32,14 @@ import org.w3c.dom.Element; /** * Represents a WebService binding. - * + * * @version $Rev$ $Date$ */ public interface WebServiceBinding extends Binding, BindingBuilderExtension { + QName TYPE = new QName(SCA11_NS, "binding.ws"); /** - * Sets the WSDL location. + * Sets the WSDL location. * @param location the WSDL location */ void setLocation(String location); @@ -48,59 +49,59 @@ public interface WebServiceBinding extends Binding, BindingBuilderExtension { * @return the WSDL location */ String getLocation(); - + /** * Returns the name of the WSDL service. - * + * * @return the name of the WSDL service */ QName getServiceName(); /** * Sets the name of the WSDL service. - * + * * @param serviceName the name of the WSDL service */ void setServiceName(QName serviceName); /** * Returns the name of the WSDL port. - * + * * @return the name of the WSDL port */ String getPortName(); /** * Sets the name of the WSDL port. - * + * * @param portName the name of the WSDL port */ void setPortName(String portName); /** * Returns the name of the WSDL binding. - * + * * @return the name of the WSDL binding */ QName getBindingName(); /** * Sets the name of the WSDL binding. - * + * * @param bindingName the name of the WSDL binding */ void setBindingName(QName bindingName); /** * Returns the name of the WSDL endpoint. - * + * * @return the name of the WSDL endpoint */ String getEndpointName(); /** * Sets the name of the WSDL endpoint. - * + * * @param endpointName the name of the WSDL endpoint */ void setEndpointName(String endpointName); @@ -110,43 +111,43 @@ public interface WebServiceBinding extends Binding, BindingBuilderExtension { * @return the WSDL service */ Service getService(); - + /** * Sets the WSDL service. * @param service the WSDL service */ void setService(Service service); - + /** * Returns the WSDL port * @return the WSDL port */ Port getPort(); - + /** * Sets the WSDL endpoint * @param endpoint the WSDL endpoint */ void setEndpoint(Port endpoint); - + /** * Returns the WSDL endpoint * @return the WSDL endpoint */ Port getEndpoint(); - + /** * Sets the WSDL port * @param port the WSDL port */ void setPort(Port port); - + /** * Returns the WSDL binding. * @return the WSDL binding */ javax.wsdl.Binding getBinding(); - + /** * Sets the WSDL binding * @param binding the WSDL binding @@ -158,7 +159,7 @@ public interface WebServiceBinding extends Binding, BindingBuilderExtension { * @return the WSDL definition */ WSDLDefinition getWSDLDefinition(); - + /** * Sets the WSDL definition. * @param wsdlDefinition the WSDL definition @@ -170,33 +171,33 @@ public interface WebServiceBinding extends Binding, BindingBuilderExtension { * @return the WSDL namespace */ String getNamespace(); - + /** * Sets the WSDL namespace * @param namespace the WSDL namespace */ void setNamespace(String namespace); - + /** * Returns true if the model element is unresolved. - * + * * @return true if the model element is unresolved. */ boolean isUnresolved(); /** * Sets whether the model element is unresolved. - * + * * @param unresolved whether the model element is unresolved */ void setUnresolved(boolean unresolved); - + InterfaceContract getBindingInterfaceContract(); - + void setBindingInterfaceContract(InterfaceContract bindingInterfaceContract); - + Element getEndPointReference(); - + void setEndPointReference(Element element); /** 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 45a421e5ff..c8c4d5a7bb 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 @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.binding.ws.impl; @@ -55,7 +55,7 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi private List<Extension> attributeExtensions = new ArrayList<Extension>(); private List<Intent> requiredIntents = new ArrayList<Intent>(); private List<PolicySet> policySets = new ArrayList<PolicySet>(); - private ExtensionType intentAttachPointType; + private ExtensionType extensionType; private String location; private Binding binding; private Service service; @@ -71,17 +71,17 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi private Element endPointReference; private Definition generatedWSDLDocument; private BindingBuilder builder; - + protected WebServiceBindingImpl() { } - + /** * Provide a meaningful representation of this Binding */ public String toString() { return "Web Service Binding: " + name; } // end method toString - + public String getName() { return name; } @@ -101,7 +101,7 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi public boolean isUnresolved() { return unresolved; } - + public void setUnresolved(boolean unresolved) { this.unresolved = unresolved; } @@ -109,20 +109,20 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi @Override public Object clone() throws CloneNotSupportedException { return super.clone(); - } - + } + public List<Object> getExtensions() { return extensions; } - + public List<Extension> getAttributeExtensions() { return attributeExtensions; - } - + } + public String getLocation() { return location; } - + public void setLocation(String location) { this.location = location; } @@ -156,7 +156,7 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi return null; } } - + public Port getEndpoint() { return endpoint; } @@ -199,7 +199,7 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi } this.bindingName = bindingName; } - + public void setEndpoint(Port endpoint) { this.endpoint = endpoint; } @@ -262,21 +262,21 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi public void setBindingInterfaceContract(InterfaceContract bindingInterfaceContract) { this.bindingInterfaceContract = bindingInterfaceContract; } - + public List<PolicySet> getPolicySets() { return policySets; } - + public List<Intent> getRequiredIntents() { return requiredIntents; } - public ExtensionType getType() { - return intentAttachPointType; + public ExtensionType getExtensionType() { + return extensionType; } - - public void setType(ExtensionType intentAttachPointType) { - this.intentAttachPointType = intentAttachPointType; + + public void setExtensionType(ExtensionType intentAttachPointType) { + this.extensionType = intentAttachPointType; } public Element getEndPointReference() { @@ -302,4 +302,8 @@ class WebServiceBindingImpl implements WebServiceBinding, PolicySubject, Extensi 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/assembly/impl/CompositeActivatorImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java index ff49effc0f..cd27763885 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java @@ -49,7 +49,6 @@ import org.apache.tuscany.sca.core.context.CompositeContext; import org.apache.tuscany.sca.core.context.impl.CompositeContextImpl; import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor; import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.core.scope.Scope; import org.apache.tuscany.sca.core.scope.ScopeContainer; import org.apache.tuscany.sca.core.scope.ScopeRegistry; import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent; @@ -303,7 +302,7 @@ public class CompositeActivatorImpl implements CompositeActivator { } private ServiceBindingProvider addServiceBindingProvider( - Endpoint endpoint, + Endpoint endpoint, RuntimeComponent component, RuntimeComponentService service, Binding binding) { BindingProviderFactory providerFactory = (BindingProviderFactory) providerFactories @@ -327,8 +326,8 @@ public class CompositeActivatorImpl implements CompositeActivator { return bindingProvider; } else { throw new IllegalStateException( - "Provider factory not found for class: " - + binding.getClass().getName()); + "Provider factory not found for binding: " + + binding.getType()); } } @@ -459,8 +458,8 @@ public class CompositeActivatorImpl implements CompositeActivator { return bindingProvider; } else { throw new IllegalStateException( - "Provider factory not found for class: " - + binding.getClass().getName()); + "Provider factory not found for binding: " + + binding.getClass().getType()); } } */ @@ -531,7 +530,6 @@ public class CompositeActivatorImpl implements CompositeActivator { } RuntimeComponentService runtimeService = (RuntimeComponentService)service; for (Endpoint endpoint : service.getEndpoints()) { - endpointRegistry.addEndpoint(endpoint); final ServiceBindingProvider bindingProvider = runtimeService.getBindingProvider(endpoint.getBinding()); if (bindingProvider != null) { // bindingProvider.start(); @@ -542,6 +540,7 @@ public class CompositeActivatorImpl implements CompositeActivator { return null; } }); + endpointRegistry.addEndpoint(endpoint); } } } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java index e639bb5ea6..32645244fb 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java @@ -361,7 +361,7 @@ public class RuntimeWireImpl implements RuntimeWire { } private ReferenceBindingProvider addReferenceBindingProvider( - EndpointReference endpointReference, + EndpointReference endpointReference, RuntimeComponent component, RuntimeComponentReference reference, Binding binding) { BindingProviderFactory providerFactory = (BindingProviderFactory) providerFactories @@ -387,8 +387,8 @@ public class RuntimeWireImpl implements RuntimeWire { return bindingProvider; } else { throw new IllegalStateException( - "Provider factory not found for class: " - + binding.getClass().getName()); + "Provider factory not found for binding: " + + binding.getType()); } } 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 b52b97c5c6..b5abc48a33 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 @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.core.context.impl; @@ -59,7 +59,7 @@ import org.oasisopen.sca.ServiceRuntimeException; /** * Base class for implementations of service and callback references. - * + * * @version $Rev$ $Date$ * @param <B> the type of the business interface */ @@ -81,7 +81,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { private transient RuntimeComponentReference clonedRef; private transient ReferenceParameters refParams; private transient XMLStreamReader xmlReader; - + private FactoryExtensionPoint modelFactories; protected RuntimeAssemblyFactory assemblyFactory; @@ -111,29 +111,29 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { this.component = component; this.reference = reference; this.endpointReference = endpointReference; - + ExtensionPointRegistry registry = compositeActivator.getCompositeContext().getExtensionPointRegistry(); this.modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class); this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class); - - // FIXME: The SCA Specification is not clear how we should handle multiplicity + + // FIXME: The SCA Specification is not clear how we should handle multiplicity // for CallableReference if (this.endpointReference == null) { - + // TODO - EPR - If no endpoint reference specified assume the first one - // This will happen when a self reference is created in which case the - // the reference should only have on endpointReference so use that + // This will happen when a self reference is created in which case the + // the reference should only have on endpointReference so use that if (this.reference.getEndpointReferences().size() == 0){ - throw new ServiceRuntimeException("The reference " + reference.getName() + " in component " + + throw new ServiceRuntimeException("The reference " + reference.getName() + " in component " + component.getName() + " has no endpoint references"); } - + if (this.reference.getEndpointReferences().size() > 1){ - throw new ServiceRuntimeException("The reference " + reference.getName() + " in component " + + throw new ServiceRuntimeException("The reference " + reference.getName() + " in component " + component.getName() + " has more than one endpoint reference"); } - + this.endpointReference = this.reference.getEndpointReferences().get(0); } @@ -251,7 +251,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { * @throws IOException */ // TODO - EPR all needs sorting out for endpoint references - + private synchronized void resolve() throws Exception { if ((scdl != null || xmlReader != null) && component == null && reference == null) { CompositeContext componentContextHelper = CompositeContext.getCurrentCompositeContext(); @@ -308,7 +308,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { optimizableBinding.setTargetComponentService(targetService); if (targetService != null) { for (Binding serviceBinding : targetService.getBindings()) { - if (serviceBinding.getClass() == binding.getClass()) { + if (serviceBinding.getType().equals(binding.getType())) { optimizableBinding.setTargetBinding(serviceBinding); break; } @@ -317,7 +317,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { } } /* - // FIXME: The SCA Specification is not clear how we should handle multiplicity + // FIXME: The SCA Specification is not clear how we should handle multiplicity // for CallableReference if (binding == null) { binding = reference.getBinding(SCABinding.class); @@ -326,7 +326,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { } } */ - + Interface i = reference.getInterfaceContract().getInterface(); if (i instanceof JavaInterface) { JavaInterface javaInterface = (JavaInterface)i; @@ -348,7 +348,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { } this.businessInterface = (Class<B>)javaInterface.getJavaClass(); } -/* +/* if (binding instanceof BindingBuilderExtension) { ((BindingBuilderExtension)binding).getBuilder().build(component, reference, binding, null); } @@ -366,7 +366,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { /** * Follow a service promotion chain down to the inner most (non composite) * component service. - * + * * @param topCompositeService * @return */ @@ -421,7 +421,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { if (refParams == null) { refParams = new ReferenceParametersImpl(); - // remove any existing reference parameters from the clone + // remove any existing reference parameters from the clone Object toRemove = null; for (Object extension : clonedRef.getExtensions()) { if (extension instanceof ReferenceParameters) { @@ -445,7 +445,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { /** * Create a callback id - * + * * @return the callback id */ private String createCallbackID() { @@ -472,16 +472,16 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { InterfaceContract sourceContract = componentTypeRef == null ? reference.getInterfaceContract() : componentTypeRef.getInterfaceContract(); sourceContract = sourceContract.makeUnidirectional(false); - + EndpointReference epr = assemblyFactory.createEndpointReference(); epr.setComponent(component); epr.setReference(reference); //epr.setBinding(binding); epr.setInterfaceContract(sourceContract); - + Endpoint endpoint = assemblyFactory.createEndpoint(); epr.setTargetEndpoint(endpoint); - + return epr; } catch (Exception e) { throw new ServiceRuntimeException(e); @@ -499,7 +499,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { * <li>URI containing just Composite name(s) (i.e. no Service name specified) * <li>URI containing Composite name(s) and a Service Name * </ul> - * + * * @param componentURI The URI of the Component to resolve * @return The Component for the specified URI or null if not founds */ @@ -530,7 +530,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> { /** * Examines the Services on the specified Component and returns the Service that matches the * specified Binding URI. - * + * * @param bindingURI The Binding URI to resolve on the Component * @param targetComponent The Component containing the Services * @return The Service with the specified serviceName or null if no such Service found. diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java index ac977cbf37..c87426bac2 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java @@ -6,15 +6,15 @@ * 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.
+ * under the License.
*/
package org.apache.tuscany.sca.core.invocation.impl;
@@ -26,10 +26,8 @@ import java.util.List; import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
-import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.assembly.OptimizableBinding;
import org.apache.tuscany.sca.core.assembly.impl.RuntimeComponentReferenceImpl;
import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl;
import org.apache.tuscany.sca.core.context.CompositeContext;
@@ -124,8 +122,8 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> { // if no match, look for callback binding with same type as service binding
for (RuntimeWire wire : wires) {
- if (wire.getEndpointReference().getBinding().getClass() == to.getBinding().getClass()) {
- return wire;
+ if (wire.getEndpointReference().getBinding().getType().equals(to.getBinding().getType())) {
+ return wire;
}
}
@@ -142,7 +140,7 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> { }
try {
// TODO - EPR - is this correct?
-
+
// test if the call back wire is manually configured
if ((wire.getEndpointReference().isUnresolved()== false) &&
(wire.getEndpointReference().getTargetEndpoint().isUnresolved()== false)){
@@ -154,12 +152,12 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> { RuntimeComponentReference ref =
bind((RuntimeComponentReference)wire.getEndpointReference().getReference(),
resolvedEndpoint);
-
+
boundWire = ref.getRuntimeWires().get(0);
}
-
+
Binding binding = wire.getEndpointReference().getBinding();
-
+
((RuntimeWireImpl)wire).addToCache(resolvedEndpoint, boundWire);
} catch (CloneNotSupportedException e) {
// will not happen
@@ -171,24 +169,24 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> { // TODO - EPR - why static?
private static RuntimeComponentReference bind(RuntimeComponentReference reference,
Endpoint callbackEndpoint) throws CloneNotSupportedException {
-
+
// clone the callback reference ready to configure it for this callback endpoint
RuntimeComponentReference ref = (RuntimeComponentReference)reference.clone();
ref.getTargets().clear();
ref.getBindings().clear();
ref.getEndpointReferences().clear();
-
+
// no access to the assembly factory so clone an existing epr
EndpointReference callbackEndpointReference = (EndpointReference)reference.getEndpointReferences().get(0).clone();
callbackEndpointReference.setReference(ref);
callbackEndpointReference.setTargetEndpoint(callbackEndpoint);
callbackEndpointReference.setUnresolved(true);
-
- // The callback endpoint will be resolved with the registry
+
+ // The callback endpoint will be resolved with the registry
// when the wire chains are created
ref.getEndpointReferences().add(callbackEndpointReference);
-
+
return ref;
}
@@ -218,7 +216,7 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> { // Copy the Java Interface from the Service
final JavaInterface ji = (JavaInterface) targetServiceIfaceContract.getInterface();
this.businessInterface = (Class<B>) ji.getJavaClass();
-
+
// We need to re-create the callback wire. We need to do this on a clone of the Service
// wire since we need to change some details on it.
// FIXME: Is this the best way to do this?
@@ -229,7 +227,7 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> { throw new IOException(e.toString());
}
- // TODO - EPR - This doesn't sound right to me.
+ // TODO - EPR - This doesn't sound right to me.
// Setup the reference on the cloned wire
final RuntimeComponentReference ref = new RuntimeComponentReferenceImpl();
ref.setComponent((RuntimeComponent) targetComponent);
@@ -245,7 +243,7 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> { super.writeExternal(out);
out.writeObject(this.callbackID);
out.writeObject(this.convID);
-
+
// TODO - EPR - What to do about URI?
out.writeUTF(this.resolvedEndpoint.getBinding().getURI());
}
diff --git a/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java b/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java index 0786e0e267..cc16d80b47 100644 --- a/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java +++ b/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java @@ -19,11 +19,9 @@ package org.apache.tuscany.sca.endpoint.tribes;
-import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
@@ -31,8 +29,8 @@ import org.apache.catalina.tribes.Channel; import org.apache.catalina.tribes.ChannelException;
import org.apache.catalina.tribes.group.GroupChannel;
import org.apache.catalina.tribes.membership.McastService;
-import org.apache.catalina.tribes.tipis.AbstractReplicatedMap;
import org.apache.catalina.tribes.tipis.ReplicatedMap;
+import org.apache.catalina.tribes.tipis.AbstractReplicatedMap.MapEntry;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
@@ -220,7 +218,10 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry, LifeCycleLi Endpoint endpoint = (Endpoint)v;
// TODO: implement more complete matching
if (matches(targetEndpoint.getURI(), endpoint.getURI())) {
- // MapEntry entry = map.getInternal(endpoint.getURI());
+ MapEntry entry = map.getInternal(endpoint.getURI());
+ if (!entry.getPrimary().equals(map.getChannel().getLocalMember(false))) {
+ endpoint.setRemote(true);
+ }
// if (!entry.isPrimary()) {
endpoint.setExtensionPointRegistry(registry);
// }
@@ -281,33 +282,4 @@ public class ReplicatedEndpointRegistry implements EndpointRegistry, LifeCycleLi }
}
- public static void main(String[] args) throws Exception {
- //create a channel
- GroupChannel channel = new GroupChannel();
- McastService mcastService = (McastService)channel.getMembershipService();
- mcastService.setPort(MULTICAST_PORT);
- mcastService.setAddress(MULTICAST_ADDRESS);
-
- InetAddress localhost = InetAddress.getLocalHost();
-
- // REVIEW: In my case, there are multiple IP addresses
- // One for the WIFI and the other one for VPN. For some reason the VPN one doesn't support
- // Multicast
- mcastService.setBind("192.168.1.100");
- channel.start(Channel.DEFAULT);
- ReplicatedMap map = new ReplicatedMap(null, channel, 50, "01", null);
- map.put(UUID.randomUUID().toString(), localhost.getHostAddress());
- for (int i = 0; i < 5; i++) {
- Thread.sleep(2000);
- System.out.println(localhost + ": " + map.keySet());
- }
- for (Object e : map.entrySetFull()) {
- Map.Entry en = (Map.Entry)e;
- AbstractReplicatedMap.MapEntry entry = (AbstractReplicatedMap.MapEntry)en.getValue();
- System.out.println(entry);
- }
- map.breakdown();
- channel.stop(Channel.DEFAULT);
- }
-
}
diff --git a/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java b/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java index d4a9f31497..430b57f2ad 100644 --- a/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java +++ b/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java @@ -175,18 +175,18 @@ public class EndpointReferenceBuilderImpl implements CompositeBuilder, EndpointR } else { if (endpoint.isUnresolved() == false){ // Wired - service resolved - binding matched - // The service is in the same composite or the + // The service is in the same composite or the // binding is remote and has a full URI - + // still need to check that the callback endpoint is set correctly if ((endpointReference.getCallbackEndpoint() != null) && (endpointReference.getCallbackEndpoint().isUnresolved() == false)){ return; - } - + } + matchCallbackBinding(endpointReference, monitor); - + return; } @@ -271,7 +271,7 @@ public class EndpointReferenceBuilderImpl implements CompositeBuilder, EndpointR if (local) { for (Endpoint serviceEndpoint : endpoint.getService().getEndpoints()) { - if (referenceBinding.getClass() == serviceEndpoint.getBinding().getClass() && hasCompatiblePolicySets(referenceBinding, + if (referenceBinding.getType().equals(serviceEndpoint.getBinding().getType()) && hasCompatiblePolicySets(referenceBinding, serviceEndpoint .getBinding())) { @@ -281,7 +281,7 @@ public class EndpointReferenceBuilderImpl implements CompositeBuilder, EndpointR } } else { Endpoint serviceEndpoint = endpoint; - if (referenceBinding.getClass() == serviceEndpoint.getBinding().getClass() && hasCompatiblePolicySets(referenceBinding, + if (referenceBinding.getType().equals(serviceEndpoint.getBinding().getType()) && hasCompatiblePolicySets(referenceBinding, serviceEndpoint .getBinding())) { @@ -399,7 +399,7 @@ public class EndpointReferenceBuilderImpl implements CompositeBuilder, EndpointR for (EndpointReference epr : callbackEndpointReferences) { for (Endpoint ep : callbackEndpoints) { - if (epr.getBinding().getClass() == ep.getBinding().getClass() && + if (epr.getBinding().getType().equals(ep.getBinding().getType()) && hasCompatiblePolicySets(epr.getBinding(), ep.getBinding())) { matchedEndpoint.add(ep); diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java index a5048859f0..081693b02b 100644 --- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java +++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceDiscovery.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.List; +import java.util.logging.Logger; /** * Service discovery for Tuscany based on J2SE Jar service provider spec. @@ -35,6 +36,7 @@ import java.util.List; * @version $Rev$ $Date$ */ public final class ServiceDiscovery implements ServiceDiscoverer { + private final static Logger logger = Logger.getLogger(ServiceDiscovery.class.getName()); private final static ServiceDiscovery INSTANCE = new ServiceDiscovery(); private ServiceDiscoverer discoverer; @@ -86,6 +88,18 @@ public final class ServiceDiscovery implements ServiceDiscoverer { } if (!declarations.isEmpty()) { List<ServiceDeclaration> declarationList = new ArrayList<ServiceDeclaration>(declarations); + /* + for (ServiceDeclaration sd1 : declarations) { + for (Iterator<ServiceDeclaration> i = declarationList.iterator(); i.hasNext();) { + ServiceDeclaration sd2 = i.next(); + if (sd1 != sd2 && sd1.getAttributes().equals(sd2.getAttributes())) { + logger + .warning("Duplicate service declarations: " + sd1.getLocation() + "," + sd2.getLocation()); + i.remove(); + } + } + } + */ Collections.sort(declarationList, ServiceComparator.DESCENDING_ORDER); return declarationList; } else { diff --git a/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java b/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java index d54add5391..f8f7ee0ae2 100644 --- a/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java +++ b/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/BPELImplementation.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.bpel; @@ -26,57 +26,57 @@ import org.apache.tuscany.sca.contribution.resolver.ModelResolver; /** * The model representing the BPEL implementation in an SCA assembly model. - * + * * @version $Rev$ $Date$ */ public interface BPELImplementation extends Implementation { - + QName TYPE = new QName(SCA11_NS, "implementation.bpel"); /** * Get the BPEL process Name - * + * * @return */ QName getProcess(); - + /** * Set the BPEL process Name - * + * * @param processName process QName */ void setProcess(QName processName); - + /** * Get the BPEL process definition - * + * * @return */ BPELProcessDefinition getProcessDefinition(); - + /** * Set the BPEL process definition - * + * * @param processDefinition */ void setProcessDefinition(BPELProcessDefinition processDefinition); - - /** + + /** * Returns the componentType for this implementation. - * + * * @return */ - public ComponentType getComponentType(); + public ComponentType getComponentType(); /** * Sets the componentType for this implementation - * + * * @param componentType the component type to set */ - public void setComponentType(ComponentType componentType); + public void setComponentType(ComponentType componentType); /** * Returns the model resolver that can be used to resolve WSDLs and XSDs * referenced by the BPEL process. - * + * * @return */ ModelResolver getModelResolver(); @@ -84,7 +84,7 @@ public interface BPELImplementation extends Implementation { /** * Sets the model resolver that can be used to resolve WSDLs and XSDs referenced * by the BPEL process. - * + * * @param modelResolver */ void setModelResolver(ModelResolver modelResolver); diff --git a/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java b/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java index f1c943e49c..59e29fb579 100644 --- a/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java +++ b/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.bpel.impl; @@ -35,7 +35,7 @@ import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition; /** * The model representing a BPEL implementation in an SCA assembly model. - * + * * @version $Rev$ $Date$ */ class BPELImplementationImpl extends ImplementationImpl implements BPELImplementation { @@ -45,10 +45,14 @@ class BPELImplementationImpl extends ImplementationImpl implements BPELImplement private ComponentType componentType; private ModelResolver modelResolver; + protected BPELImplementationImpl() { + super(TYPE); + } + public QName getProcess() { return processName; } - + public void setProcess(QName processName) { this.processName = processName; } @@ -83,7 +87,7 @@ class BPELImplementationImpl extends ImplementationImpl implements BPELImplement // The BPEL implementation does not support properties return Collections.emptyList(); } - + public ComponentType getComponentType() { return componentType; } @@ -91,15 +95,15 @@ class BPELImplementationImpl extends ImplementationImpl implements BPELImplement public void setComponentType(ComponentType componentType) { this.componentType = componentType; } - + public ModelResolver getModelResolver() { return modelResolver; } - + public void setModelResolver(ModelResolver modelResolver) { this.modelResolver = modelResolver; } - + @Override public List<Service> getServices() { return componentType.getServices(); @@ -109,7 +113,7 @@ class BPELImplementationImpl extends ImplementationImpl implements BPELImplement public List<Reference> getReferences() { return componentType.getReferences(); } - + @Override public int hashCode() { return String.valueOf(this.getProcess()).hashCode(); diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java index db2d3efe56..d3c9c16f48 100644 --- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java +++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementation.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.java; @@ -26,13 +26,15 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import javax.xml.namespace.QName; + /** * Represents a Java implementation. * * @version $Rev$ $Date$ */ public interface JavaImplementation extends BaseJavaImplementation { - + QName TYPE = new QName(SCA11_NS, "implementation.java"); /** * Returns the constructor used to instantiate implementation instances. * diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.java index 97773879fa..3351ee85c0 100644 --- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.java +++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/BaseJavaImplementationImpl.java @@ -6,32 +6,35 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.java.impl; +import javax.xml.namespace.QName; + import org.apache.tuscany.sca.assembly.impl.ImplementationImpl; import org.apache.tuscany.sca.implementation.java.BaseJavaImplementation; /** * Represents a Java implementation. - * + * * @version $Rev$ $Date$ */ abstract class BaseJavaImplementationImpl extends ImplementationImpl implements BaseJavaImplementation { private String className; private Class<?> javaClass; - - protected BaseJavaImplementationImpl() { + + protected BaseJavaImplementationImpl(QName type) { + super(type); } public String getName() { @@ -71,7 +74,7 @@ abstract class BaseJavaImplementationImpl extends ImplementationImpl implements public int hashCode() { return String.valueOf(getName()).hashCode(); } - + @Override public boolean equals(Object obj) { if (obj == this) { diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java index 43a074e0ec..9e4c2eb8f4 100644 --- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java +++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationImpl.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.java.impl; @@ -54,10 +54,10 @@ public class JavaImplementationImpl extends BaseJavaImplementationImpl implement private long maxAge = -1; private long maxIdleTime = -1; private JavaScopeImpl scope = JavaScopeImpl.STATELESS; - + protected JavaImplementationImpl() { - super(); - } + super(TYPE); + } public JavaConstructorImpl<?> getConstructor() { return constructorDefinition; @@ -106,7 +106,7 @@ public class JavaImplementationImpl extends BaseJavaImplementationImpl implement public List<Method> getAllowsPassByReferenceMethods() { return allowsPassByReferenceMethods; } - + public boolean isAllowsPassByReference(Method method) { return allowsPassByReference || allowsPassByReferenceMethods.contains(method); } diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java index c325c871f4..4f74094a1f 100644 --- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java +++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.java.xml; @@ -84,7 +84,7 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm /** * Report a error. - * + * * @param problems * @param message * @param model @@ -104,7 +104,7 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm /** * Report a exception. - * + * * @param problems * @param message * @param model @@ -130,7 +130,7 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm ExtensionType implType = policyFactory.createImplementationType(); implType.setType(getArtifactType()); implType.setUnresolved(true); - javaImplementation.setType(implType); + javaImplementation.setExtensionType(implType); javaImplementation.setUnresolved(true); javaImplementation.setName(reader.getAttributeValue(null, CLASS)); @@ -176,9 +176,9 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm //throw new ContributionResolveException(new ClassNotFoundException(javaImplementation.getName())); return; } - + javaImplementation.setJavaClass(javaClass); - + try { javaFactory.createJavaImplementation(javaImplementation, javaImplementation.getJavaClass()); } catch (IntrospectionException e) { @@ -187,10 +187,10 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm //throw ce; return; } - + javaImplementation.setUnresolved(false); mergeComponentType(resolver, javaImplementation); - + // FIXME the introspector should always create at least one service if (javaImplementation.getServices().isEmpty()) { javaImplementation.getServices().add(assemblyFactory.createService()); diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java index 4551821f5a..ba5e5284be 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/OSGiImplementation.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.osgi; @@ -31,12 +31,10 @@ import org.osgi.framework.Bundle; * @version $Rev$ $Date$ */ public interface OSGiImplementation extends Implementation, Extensible { - // String SCA11_NS = "http://docs.oasis-open.org/ns/opencsa/sca/200903"; - String SCA11_TUSCANY_NS = "http://tuscany.apache.org/xmlns/sca/1.1"; - String BUNDLE_SYMBOLICNAME = "bundleSymbolicName"; String BUNDLE_VERSION = "bundleVersion"; QName IMPLEMENTATION_OSGI = new QName(SCA11_TUSCANY_NS, "implementation.osgi"); + QName TYPE = IMPLEMENTATION_OSGI; String getBundleSymbolicName(); diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java index 41deef131f..f3397619f5 100644 --- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java +++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.implementation.osgi.impl; @@ -25,7 +25,7 @@ import org.osgi.framework.Bundle; import org.osgi.framework.Constants; /** - * OSGi implementation + * OSGi implementation * All attributes from <implementation.osgi> have getters in this class * This class implements OSGiImplementationInterface which is associated with OSGiImplementationProvider. * @@ -40,12 +40,12 @@ public class OSGiImplementationImpl extends ImplementationImpl implements OSGiIm private FactoryExtensionPoint modelFactories; protected OSGiImplementationImpl(FactoryExtensionPoint modelFactories) { + super(TYPE); this.modelFactories = modelFactories; } public OSGiImplementationImpl(FactoryExtensionPoint modelFactories, String bundleSymbolicName, String bundleVersion) { - - super(); + super(TYPE); this.bundleSymbolicName = bundleSymbolicName; this.bundleVersion = bundleVersion; this.modelFactories = modelFactories; 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 24e78b9291..72ad5adb61 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 @@ -6,15 +6,15 @@ * 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.
+ * under the License.
*/
package org.apache.tuscany.sca.implementation.spring;
@@ -22,6 +22,8 @@ import java.net.URL; import java.util.Hashtable;
import java.util.List;
+import javax.xml.namespace.QName;
+
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.assembly.Extensible;
@@ -34,13 +36,14 @@ import org.apache.tuscany.sca.assembly.impl.ImplementationImpl; import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
/**
- * Represents a Spring implementation.
- *
- * @version $Rev: 511195 $ $Date: 2007-02-24 02:29:46 +0000 (Sat, 24 Feb 2007) $
+ * Represents a Spring implementation.
+ *
+ * @version $Rev: 511195 $ $Date: 2007-02-24 02:29:46 +0000 (Sat, 24 Feb 2007) $
*/
public class SpringImplementation extends ImplementationImpl implements Implementation, ComponentPreProcessor, 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;
// The application-context file as a Spring Resource
@@ -54,6 +57,7 @@ public class SpringImplementation extends ImplementationImpl implements Implemen private Hashtable<String, Reference> unresolvedBeanRef;
public SpringImplementation() {
+ super(TYPE);
this.location = null;
this.resource = null;
setUnresolved(true);
@@ -84,8 +88,8 @@ public class SpringImplementation extends ImplementationImpl implements Implemen return resource;
}
- /*
- * Returns the componentType for this Spring implementation
+ /*
+ * Returns the componentType for this Spring implementation
*/
public ComponentType getComponentType() {
return componentType;
@@ -145,35 +149,35 @@ public class SpringImplementation extends ImplementationImpl implements Implemen } // end method setPropertyClass
/**
- * Gets the Java Class for an SCA property
+ * Gets the Java Class for an SCA property
* @param propertyName - the property name
* @return - a Class object for the type of the property
*/
public Class<?> getPropertyClass(String propertyName) {
return propertyMap.get(propertyName);
} // end method getPropertyClass
-
+
public void setUnresolvedBeanRef(String refName, Reference reference) {
if (refName == null || reference == null)
return;
unresolvedBeanRef.put(refName, reference);
return;
} // end method setUnresolvedBeanRef
-
+
public Reference getUnresolvedBeanRef(String refName) {
return unresolvedBeanRef.get(refName);
} // end method getUnresolvedBeanRef
-
-
+
+
/**
- * Use preProcess to validate and map the references and properties dynamically
+ * Use preProcess to validate and map the references and properties dynamically
*/
public void preProcess(Component component) {
if (!(component instanceof RuntimeComponent))
return;
-
+
RuntimeComponent rtc = (RuntimeComponent) component;
-
+
for (Reference reference : rtc.getReferences()) {
if (unresolvedBeanRef.containsKey(reference.getName())) {
Reference ref = unresolvedBeanRef.get(reference.getName());
@@ -184,14 +188,14 @@ public class SpringImplementation extends ImplementationImpl implements Implemen }
for (Property property : rtc.getProperties()) {
- if (unresolvedBeanRef.containsKey(property.getName())) {
+ if (unresolvedBeanRef.containsKey(property.getName())) {
componentType.getProperties().add(createProperty(property));
this.setPropertyClass(property.getName(), property.getClass());
unresolvedBeanRef.remove(property.getName());
}
- }
+ }
}
-
+
protected Reference createReference(Reference reference, InterfaceContract interfaze) {
Reference newReference;
try {
@@ -203,7 +207,7 @@ public class SpringImplementation extends ImplementationImpl implements Implemen }
return newReference;
}
-
+
protected Property createProperty(Property property) {
Property newProperty;
try {
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 0495ccb600..d8a5935bea 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 @@ -6,15 +6,15 @@ * 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.
+ * under the License.
*/
package org.apache.tuscany.sca.implementation.web.impl;
@@ -22,6 +22,8 @@ import java.util.ArrayList; import java.util.Collections;
import java.util.List;
+import javax.xml.namespace.QName;
+
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ConstrainingType;
import org.apache.tuscany.sca.assembly.Property;
@@ -37,18 +39,20 @@ 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 {
+ private static final QName TYPE = new QName(SCA11_NS, "implementation.web");
- private List<Property> properties = new ArrayList<Property>();
- private List<Reference> references = new ArrayList<Reference>();
+ private List<Property> properties = new ArrayList<Property>();
+ private List<Reference> references = new ArrayList<Reference>();
private String uri;
private boolean unresolved;
-
+
private String webURI;
/**
* Constructs a new Web implementation.
*/
WebImplementationImpl() {
+ super(TYPE);
}
public ConstrainingType getConstrainingType() {
@@ -64,7 +68,7 @@ class WebImplementationImpl extends ImplementationImpl implements WebImplementat // The Web implementation does not offer services
return Collections.emptyList();
}
-
+
public List<Reference> getReferences() {
return references;
}
@@ -76,11 +80,11 @@ class WebImplementationImpl extends ImplementationImpl implements WebImplementat public String getURI() {
return uri;
}
-
+
public void setURI(String uri) {
this.uri = uri;
}
-
+
public boolean isUnresolved() {
return unresolved;
}
@@ -99,14 +103,14 @@ 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)
+ * TODO: also support introspection and handle WEB-INF/web.componentType (spec line 503)
*/
public void preProcess(Component component) {
if (!(component instanceof RuntimeComponent)) {
return;
}
RuntimeComponent rtc = (RuntimeComponent) component;
-
+
for (Reference reference : rtc.getReferences()) {
if (getReference(reference.getName()) == null) {
getReferences().add(createReference(reference));
diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java index 966e1358de..b6def5a42e 100644 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java +++ b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceImpl.java @@ -231,11 +231,11 @@ public class InterfaceImpl implements Interface { return requiredIntents; } - public ExtensionType getType() { + public ExtensionType getExtensionType() { return type; } - public void setType(ExtensionType type) { + public void setExtensionType(ExtensionType type) { this.type = type; } diff --git a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java index 5074afc84b..7a4b62c4ac 100644 --- a/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java +++ b/java/sca/modules/interface/src/main/java/org/apache/tuscany/sca/interfacedef/impl/OperationImpl.java @@ -335,11 +335,11 @@ public class OperationImpl implements Operation { return requiredIntents; } - public ExtensionType getType() { + public ExtensionType getExtensionType() { return type; } - public void setType(ExtensionType type) { + public void setExtensionType(ExtensionType type) { this.type = type; } diff --git a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java index 41847bad79..35a86ceedf 100644 --- a/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java +++ b/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/PolicySubject.java @@ -6,15 +6,15 @@ * 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. + * under the License. */ package org.apache.tuscany.sca.policy; @@ -22,9 +22,9 @@ package org.apache.tuscany.sca.policy; import java.util.List; /** - * A policy subject is an entity in the assembly with which a policy can be - * associated. - * + * A policy subject is an entity in the assembly with which a policy can be + * associated. + * * For example, a policy subject can be one of the following: * <ul> * <li>composite @@ -34,23 +34,23 @@ import java.util.List; * <li>reference * <li>binding * <li>interface - * </ul> + * </ul> */ public interface PolicySubject { /** * Get a list of required intents - * + * * @return */ List<Intent> getRequiredIntents(); /** - * Get a list of attached policySets - * - * @return A list of policySets + * Get a list of attached policySets + * + * @return A list of policySets */ List<PolicySet> getPolicySets(); - - ExtensionType getType(); - void setType(ExtensionType type); + + ExtensionType getExtensionType(); + void setExtensionType(ExtensionType type); } |