You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/04/02 05:53:59 UTC
svn commit: r524718 [2/2] - in
/incubator/tuscany/java/sca/scdl4j/assembly/src:
main/java/org/apache/tuscany/assembly/model/
main/java/org/apache/tuscany/assembly/model/impl/
main/java/org/apache/tuscany/assembly/util/
test/java/org/apache/tuscany/asse...
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ConstrainingTypeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ConstrainingTypeImpl.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ConstrainingTypeImpl.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ConstrainingTypeImpl.java Sun Apr 1 20:53:56 2007
@@ -27,42 +27,60 @@
import org.apache.tuscany.assembly.model.AbstractReference;
import org.apache.tuscany.assembly.model.AbstractService;
import org.apache.tuscany.assembly.model.ConstrainingType;
+import org.apache.tuscany.assembly.util.Visitor;
import org.apache.tuscany.policy.model.Intent;
/**
* Represents a constraining type.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class ConstrainingTypeImpl extends BaseImpl implements ConstrainingType {
- private QName name;
- private List<AbstractProperty> properties = new ArrayList<AbstractProperty>();
- private List<AbstractReference> references = new ArrayList<AbstractReference>();
- private List<AbstractService> services = new ArrayList<AbstractService>();
- private List<Intent> requiredIntents = new ArrayList<Intent>();
-
- public QName getName() {
- return name;
- }
-
- public void setName(QName name) {
- this.name = name;
- }
-
- public List<AbstractProperty> getProperties() {
- return properties;
- }
-
- public List<AbstractReference> getReferences() {
- return references;
- }
-
- public List<AbstractService> getServices() {
- return services;
- }
-
- public List<Intent> getRequiredIntents() {
- return requiredIntents;
- }
-
+ private QName name;
+ private List<AbstractProperty> properties = new ArrayList<AbstractProperty>();
+ private List<AbstractReference> references = new ArrayList<AbstractReference>();
+ private List<AbstractService> services = new ArrayList<AbstractService>();
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+
+ public QName getName() {
+ return name;
+ }
+
+ public void setName(QName name) {
+ this.name = name;
+ }
+
+ public List<AbstractProperty> getProperties() {
+ return properties;
+ }
+
+ public List<AbstractReference> getReferences() {
+ return references;
+ }
+
+ public List<AbstractService> getServices() {
+ return services;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public boolean accept(Visitor visitor) {
+ if (!super.accept(visitor))
+ return false;
+ for (AbstractProperty property : properties) {
+ if (!visitor.visit(property))
+ return false;
+ }
+ for (AbstractReference reference : references) {
+ if (!visitor.visit(reference))
+ return false;
+ }
+ for (AbstractService service : services) {
+ if (!visitor.visit(service))
+ return false;
+ }
+ return true;
+ }
}
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ContractImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ContractImpl.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ContractImpl.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ContractImpl.java Sun Apr 1 20:53:56 2007
@@ -26,37 +26,37 @@
import org.apache.tuscany.sca.idl.Interface;
public class ContractImpl extends BaseImpl implements AbstractContract {
- private Interface callbackInterface;
- private Interface callInterface;
- private String name;
- private List<Intent> requiredIntents = new ArrayList<Intent>();
-
- public Interface getCallbackInterface() {
- return callbackInterface;
- }
-
- public Interface getInterface() {
- return callInterface;
- }
-
- public String getName() {
- return name;
- }
-
- public void setCallbackInterface(Interface callbackInterface) {
- this.callbackInterface = callbackInterface;
- }
-
- public void setInterface(Interface callInterface) {
- this.callInterface = callInterface;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<Intent> getRequiredIntents() {
- return requiredIntents;
- }
+ private Interface callbackInterface;
+ private Interface callInterface;
+ private String name;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+
+ public Interface getCallbackInterface() {
+ return callbackInterface;
+ }
+
+ public Interface getInterface() {
+ return callInterface;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setCallbackInterface(Interface callbackInterface) {
+ this.callbackInterface = callbackInterface;
+ }
+
+ public void setInterface(Interface callInterface) {
+ this.callInterface = callInterface;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
}
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/DefaultAssemblyFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/DefaultAssemblyFactory.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/DefaultAssemblyFactory.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/DefaultAssemblyFactory.java Sun Apr 1 20:53:56 2007
@@ -43,84 +43,84 @@
/**
* A factory for the assembly model.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class DefaultAssemblyFactory implements AssemblyFactory {
- public AbstractProperty createAbstractProperty() {
- return new AbstractPropertyImpl();
- }
-
- public AbstractReference createAbstractReference() {
- return new AbstractReferenceImpl();
- }
-
- public AbstractService createAbstractService() {
- return new AbstractServiceImpl();
- }
-
- public Callback createCallback() {
- return new CallbackImpl();
- }
-
- public Component createComponent() {
- return new ComponentImpl();
- }
-
- public ComponentProperty createComponentProperty() {
- return new ComponentPropertyImpl();
- }
-
- public ComponentReference createComponentReference() {
- return new ComponentReferenceImpl();
- }
-
- public ComponentService createComponentService() {
- return new ComponentServiceImpl();
- }
-
- public ComponentType createComponentType() {
- return new ComponentTypeImpl();
- }
-
- public Composite createComposite() {
- return new CompositeImpl();
- }
-
- public CompositeReference createCompositeReference() {
- return new CompositeReferenceImpl();
- }
-
- public CompositeService createCompositeService() {
- return new CompositeServiceImpl();
- }
-
- public ConstrainingType createConstrainingType() {
- return new ConstrainingTypeImpl();
- }
-
- public Property createProperty() {
- return new PropertyImpl();
- }
-
- public Reference createReference() {
- return new ReferenceImpl();
- }
-
- public Service createService() {
- return new ServiceImpl();
- }
-
- public Wire createWire() {
- return new WireImpl();
- }
-
- public SCABinding createSCABinding() {
- return new SCABindingImpl();
- }
-
- public Operation createOperation() {
- return new OperationImpl();
- }
+ public AbstractProperty createAbstractProperty() {
+ return new AbstractPropertyImpl();
+ }
+
+ public AbstractReference createAbstractReference() {
+ return new AbstractReferenceImpl();
+ }
+
+ public AbstractService createAbstractService() {
+ return new AbstractServiceImpl();
+ }
+
+ public Callback createCallback() {
+ return new CallbackImpl();
+ }
+
+ public Component createComponent() {
+ return new ComponentImpl();
+ }
+
+ public ComponentProperty createComponentProperty() {
+ return new ComponentPropertyImpl();
+ }
+
+ public ComponentReference createComponentReference() {
+ return new ComponentReferenceImpl();
+ }
+
+ public ComponentService createComponentService() {
+ return new ComponentServiceImpl();
+ }
+
+ public ComponentType createComponentType() {
+ return new ComponentTypeImpl();
+ }
+
+ public Composite createComposite() {
+ return new CompositeImpl();
+ }
+
+ public CompositeReference createCompositeReference() {
+ return new CompositeReferenceImpl();
+ }
+
+ public CompositeService createCompositeService() {
+ return new CompositeServiceImpl();
+ }
+
+ public ConstrainingType createConstrainingType() {
+ return new ConstrainingTypeImpl();
+ }
+
+ public Property createProperty() {
+ return new PropertyImpl();
+ }
+
+ public Reference createReference() {
+ return new ReferenceImpl();
+ }
+
+ public Service createService() {
+ return new ServiceImpl();
+ }
+
+ public Wire createWire() {
+ return new WireImpl();
+ }
+
+ public SCABinding createSCABinding() {
+ return new SCABindingImpl();
+ }
+
+ public Operation createOperation() {
+ return new OperationImpl();
+ }
}
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/PropertyImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/PropertyImpl.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/PropertyImpl.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/PropertyImpl.java Sun Apr 1 20:53:56 2007
@@ -27,14 +27,14 @@
/**
* Represents a property.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class PropertyImpl extends AbstractPropertyImpl implements Property {
- private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
- public List<PolicySet> getPolicySets() {
- return policySets;
- }
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
}
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ReferenceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ReferenceImpl.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ReferenceImpl.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ReferenceImpl.java Sun Apr 1 20:53:56 2007
@@ -30,59 +30,59 @@
/**
* Represents a reference.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class ReferenceImpl extends AbstractReferenceImpl implements Reference {
- private List<Binding> bindings = new ArrayList<Binding>();
- private boolean wiredByImpl;
- private List<PolicySet> policySets = new ArrayList<PolicySet>();
- private List<ComponentService> targets = new ArrayList<ComponentService>();
- private Callback callback;
- private boolean autowire;
-
- public List<Binding> getBindings() {
- return bindings;
- }
-
- public <B> B getBinding(Class<B> bindingClass) {
- for (Binding binding: bindings) {
- if (bindingClass.isInstance(binding)) {
- return bindingClass.cast(binding);
- }
- }
- return null;
- }
-
- public boolean isWiredByImpl() {
- return wiredByImpl;
- }
-
- public void setWiredByImpl(boolean wiredByImpl) {
- this.wiredByImpl = wiredByImpl;
- }
-
- public List<PolicySet> getPolicySets() {
- return policySets;
- }
-
- public List<ComponentService> getTargets() {
- return targets;
- }
-
- public Callback getCallback() {
- return callback;
- }
-
- public void setCallback(Callback callback) {
- this.callback = callback;
- }
-
- public boolean isAutowire() {
- return autowire;
- }
-
- public void setAutowire(boolean autowire) {
- this.autowire = autowire;
- }
+ private List<Binding> bindings = new ArrayList<Binding>();
+ private boolean wiredByImpl;
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private List<ComponentService> targets = new ArrayList<ComponentService>();
+ private Callback callback;
+ private boolean autowire;
+
+ public List<Binding> getBindings() {
+ return bindings;
+ }
+
+ public <B> B getBinding(Class<B> bindingClass) {
+ for (Binding binding : bindings) {
+ if (bindingClass.isInstance(binding)) {
+ return bindingClass.cast(binding);
+ }
+ }
+ return null;
+ }
+
+ public boolean isWiredByImpl() {
+ return wiredByImpl;
+ }
+
+ public void setWiredByImpl(boolean wiredByImpl) {
+ this.wiredByImpl = wiredByImpl;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public List<ComponentService> getTargets() {
+ return targets;
+ }
+
+ public Callback getCallback() {
+ return callback;
+ }
+
+ public void setCallback(Callback callback) {
+ this.callback = callback;
+ }
+
+ public boolean isAutowire() {
+ return autowire;
+ }
+
+ public void setAutowire(boolean autowire) {
+ this.autowire = autowire;
+ }
}
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/SCABindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/SCABindingImpl.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/SCABindingImpl.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/SCABindingImpl.java Sun Apr 1 20:53:56 2007
@@ -22,8 +22,8 @@
/**
* Represents an SCA binding.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class SCABindingImpl extends BindingImpl implements SCABinding {
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ServiceImpl.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ServiceImpl.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/ServiceImpl.java Sun Apr 1 20:53:56 2007
@@ -29,37 +29,37 @@
/**
* Represents a reference.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class ServiceImpl extends AbstractServiceImpl implements Service {
- private List<Binding> bindings = new ArrayList<Binding>();
- private List<PolicySet> policySets = new ArrayList<PolicySet>();
- private Callback callback;
+ private List<Binding> bindings = new ArrayList<Binding>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+ private Callback callback;
- public List<Binding> getBindings() {
- return bindings;
- }
+ public List<Binding> getBindings() {
+ return bindings;
+ }
- public <B> B getBinding(Class<B> bindingClass) {
- for (Binding binding: bindings) {
- if (bindingClass.isInstance(binding)) {
- return bindingClass.cast(binding);
- }
- }
- return null;
- }
+ public <B> B getBinding(Class<B> bindingClass) {
+ for (Binding binding : bindings) {
+ if (bindingClass.isInstance(binding)) {
+ return bindingClass.cast(binding);
+ }
+ }
+ return null;
+ }
- public List<PolicySet> getPolicySets() {
- return policySets;
- }
-
- public Callback getCallback() {
- return callback;
- }
-
- public void setCallback(Callback callback) {
- this.callback = callback;
- }
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
+
+ public Callback getCallback() {
+ return callback;
+ }
+
+ public void setCallback(Callback callback) {
+ this.callback = callback;
+ }
}
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/WireImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/WireImpl.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/WireImpl.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/model/impl/WireImpl.java Sun Apr 1 20:53:56 2007
@@ -29,37 +29,37 @@
/**
* Represents a wire
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class WireImpl extends BaseImpl implements Wire {
- private ComponentReference source;
- private ComponentService target;
- private List<Intent> requiredIntents = new ArrayList<Intent>();
- private List<PolicySet> policySets = new ArrayList<PolicySet>();
-
- public ComponentReference getSource() {
- return source;
- }
-
- public ComponentService getTarget() {
- return target;
- }
-
- public void setSource(ComponentReference source) {
- this.source = source;
- }
-
- public void setTarget(ComponentService target) {
- this.target = target;
- }
-
- public List<Intent> getRequiredIntents() {
- return requiredIntents;
- }
-
- public List<PolicySet> getPolicySets() {
- return policySets;
- }
+ private ComponentReference source;
+ private ComponentService target;
+ private List<Intent> requiredIntents = new ArrayList<Intent>();
+ private List<PolicySet> policySets = new ArrayList<PolicySet>();
+
+ public ComponentReference getSource() {
+ return source;
+ }
+
+ public ComponentService getTarget() {
+ return target;
+ }
+
+ public void setSource(ComponentReference source) {
+ this.source = source;
+ }
+
+ public void setTarget(ComponentService target) {
+ this.target = target;
+ }
+
+ public List<Intent> getRequiredIntents() {
+ return requiredIntents;
+ }
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
+ }
}
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/CompositeUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/CompositeUtil.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/CompositeUtil.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/CompositeUtil.java Sun Apr 1 20:53:56 2007
@@ -39,227 +39,229 @@
/**
* A temporary utility class that resolves wires in a composite.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class CompositeUtil {
- private AssemblyFactory assemblyFactory;
- private Composite composite;
-
- public CompositeUtil(AssemblyFactory assemblyFactory, Composite composite) {
- this.assemblyFactory = assemblyFactory;
- this.composite = composite;
- }
-
- public void configure(List<Base> problems) {
- if (problems == null) {
- problems = new ArrayList<Base>();
- }
- init(problems);
- wire(problems);
- }
-
- private void init(List<Base> problems) {
-
- // Init all component services and references
- for (Component component: composite.getComponents()) {
- Map<String, Service> services = new HashMap<String, Service>();
- Map<String, Reference> references = new HashMap<String, Reference>();
-
- // Index services and references
- Implementation implementation = component.getImplementation();
- if (implementation != null) {
- for (Service service: implementation.getServices()) {
- services.put(service.getName(), service);
- }
- for (Reference reference: implementation.getReferences()) {
- references.put(reference.getName(), reference);
- }
- }
-
- // Index component services and references
- Map<String, ComponentService> cservices = new HashMap<String, ComponentService>();
- Map<String, ComponentReference> creferences = new HashMap<String, ComponentReference>();
- for (ComponentService componentService: component.getServices()) {
- cservices.put(componentService.getName(), componentService);
- }
- for (ComponentReference componentReference: component.getReferences()) {
- creferences.put(componentReference.getName(), componentReference);
- }
-
- // Reconcile component services/references and implementation services/references
- for (ComponentService componentService: cservices.values()) {
- Service service = services.get(componentService.getName());
- if (service != null) {
- componentService.setService(service);
- } else {
- problems.add(componentService);
- }
- }
- for (ComponentReference componentReference: creferences.values()) {
- Reference reference = references.get(componentReference.getName());
- if (reference != null) {
- componentReference.setReference(reference);
- } else {
- problems.add(componentReference);
- }
- }
-
- // Create component services/references for the services/references declared by
- // the implementation
- for (Service service: services.values()) {
- if (!cservices.containsKey(service.getName())) {
- ComponentService componentService = assemblyFactory.createComponentService();
- componentService.setName(service.getName());
- componentService.setService(service);
- component.getServices().add(componentService);
- }
- }
- for (Reference reference: references.values()) {
- if (!cservices.containsKey(reference.getName())) {
- ComponentReference componentReference = assemblyFactory.createComponentReference();
- componentReference.setName(reference.getName());
- componentReference.setReference(reference);
- component.getReferences().add(componentReference);
- }
- }
- }
- }
-
- private void wire(List<Base> problems) {
-
- // Index and bind all component services and references
- Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
- Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
- for (Component component: composite.getComponents()) {
- for (ComponentService componentService: component.getServices()) {
- String uri;
- if (componentService.getName() != null) {
- uri = component.getName() + '/' + componentService.getName();
- } else {
- uri = component.getName();
- }
- componentServices.put(uri, componentService);
-
- // Create and configure an SCA binding for the service
- SCABinding scaBinding = componentService.getBinding(SCABinding.class);
- if (scaBinding == null) {
- scaBinding = assemblyFactory.createSCABinding();
- componentService.getBindings().add(scaBinding);
- }
- scaBinding.setURI(uri);
- }
- for (ComponentReference componentReference: component.getReferences()) {
- String uri = component.getName() + '/' + componentReference.getName();
- componentReferences.put(uri, componentReference);
-
- // Create and configure an SCA binding for the reference
- SCABinding scaBinding = componentReference.getBinding(SCABinding.class);
- if (scaBinding == null) {
- scaBinding = assemblyFactory.createSCABinding();
- componentReference.getBindings().add(scaBinding);
- }
- scaBinding.setURI(uri);
- }
- }
-
- // Resolve promoted services and references
- for (Service service: composite.getServices()) {
- CompositeService compositeService = (CompositeService)service;
- ComponentService componentService = compositeService.getPromotedService();
- if (componentService != null && componentService.isUnresolved()) {
- ComponentService resolved = componentServices.get(componentService.getName());
- if (resolved != null) {
- compositeService.setPromotedService(resolved);
- } else {
- problems.add(compositeService);
- }
- }
- }
- for (Reference reference: composite.getReferences()) {
- CompositeReference compositeReference = (CompositeReference)reference;
- List<ComponentReference> promotedReferences = compositeReference.getPromotedReferences();
- for (int i =0, n = promotedReferences.size(); i < n; i++) {
- ComponentReference componentReference = promotedReferences.get(i);
- if (componentReference.isUnresolved()) {
- ComponentReference resolved = componentReferences.get(componentReference.getName());
- if (resolved != null) {
- promotedReferences.set(i, resolved);
- } else {
- problems.add(compositeReference);
- }
- }
- }
- }
-
- // Wire references to their targets
- for (ComponentReference componentReference: componentReferences.values()) {
- List<ComponentService> targets = componentReference.getTargets();
- if (!targets.isEmpty()) {
- for (int i = 0, n = targets.size(); i < n; i++) {
- ComponentService target = targets.get(i);
- if (target.isUnresolved()) {
- ComponentService resolved = componentServices.get(target.getName());
- if (resolved != null) {
- targets.set(i, resolved);
- } else {
- problems.add(target);
- }
- }
- }
- }
- else if (componentReference.getReference() != null) {
-
- // Wire reference targets from the corresponding reference in the componentType
- for (ComponentService target: componentReference.getReference().getTargets()) {
- if (target.isUnresolved()) {
- ComponentService resolved = componentServices.get(target.getName());
- if (resolved != null) {
- targets.add(resolved);
- } else {
- problems.add(target);
- }
- }
- }
- }
- }
-
- // Wire references as specified in wires
- List<Wire> wires = composite.getWires();
- for (int i = 0, n = wires.size(); i < n; i++) {
- Wire wire = wires.get(i);
-
- ComponentReference resolvedReference;
- ComponentService resolvedService;
-
- ComponentReference source = wire.getSource();
- if (source != null && source.isUnresolved()) {
- resolvedReference = componentReferences.get(source.getName());
- if (resolvedReference != null) {
- wire.setSource(resolvedReference);
- } else {
- problems.add(source);
- }
- } else {
- resolvedReference = wire.getSource();
- }
-
- ComponentService target = wire.getTarget();
- if (target != null && target.isUnresolved()) {
- resolvedService = componentServices.get(target.getName());
- if (resolvedService != null) {
- wire.setTarget(target);
- } else {
- problems.add(source);
- }
- } else {
- resolvedService = wire.getTarget();
- }
- if (resolvedReference != null && resolvedService != null) {
- resolvedReference.getTargets().add(resolvedService);
- }
- }
- }
-
+ private AssemblyFactory assemblyFactory;
+ private Composite composite;
+
+ public CompositeUtil(AssemblyFactory assemblyFactory, Composite composite) {
+ this.assemblyFactory = assemblyFactory;
+ this.composite = composite;
+ }
+
+ public void configure(List<Base> problems) {
+ if (problems == null) {
+ problems = new ArrayList<Base>();
+ }
+ init(problems);
+ wire(problems);
+ }
+
+ private void init(List<Base> problems) {
+
+ // Init all component services and references
+ for (Component component : composite.getComponents()) {
+ Map<String, Service> services = new HashMap<String, Service>();
+ Map<String, Reference> references = new HashMap<String, Reference>();
+
+ // Index services and references
+ Implementation implementation = component.getImplementation();
+ if (implementation != null) {
+ for (Service service : implementation.getServices()) {
+ services.put(service.getName(), service);
+ }
+ for (Reference reference : implementation.getReferences()) {
+ references.put(reference.getName(), reference);
+ }
+ }
+
+ // Index component services and references
+ Map<String, ComponentService> cservices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> creferences = new HashMap<String, ComponentReference>();
+ for (ComponentService componentService : component.getServices()) {
+ cservices.put(componentService.getName(), componentService);
+ }
+ for (ComponentReference componentReference : component.getReferences()) {
+ creferences.put(componentReference.getName(), componentReference);
+ }
+
+ // Reconcile component services/references and implementation
+ // services/references
+ for (ComponentService componentService : cservices.values()) {
+ Service service = services.get(componentService.getName());
+ if (service != null) {
+ componentService.setService(service);
+ } else {
+ problems.add(componentService);
+ }
+ }
+ for (ComponentReference componentReference : creferences.values()) {
+ Reference reference = references.get(componentReference.getName());
+ if (reference != null) {
+ componentReference.setReference(reference);
+ } else {
+ problems.add(componentReference);
+ }
+ }
+
+ // Create component services/references for the services/references
+ // declared by
+ // the implementation
+ for (Service service : services.values()) {
+ if (!cservices.containsKey(service.getName())) {
+ ComponentService componentService = assemblyFactory.createComponentService();
+ componentService.setName(service.getName());
+ componentService.setService(service);
+ component.getServices().add(componentService);
+ }
+ }
+ for (Reference reference : references.values()) {
+ if (!cservices.containsKey(reference.getName())) {
+ ComponentReference componentReference = assemblyFactory.createComponentReference();
+ componentReference.setName(reference.getName());
+ componentReference.setReference(reference);
+ component.getReferences().add(componentReference);
+ }
+ }
+ }
+ }
+
+ private void wire(List<Base> problems) {
+
+ // Index and bind all component services and references
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+ for (Component component : composite.getComponents()) {
+ for (ComponentService componentService : component.getServices()) {
+ String uri;
+ if (componentService.getName() != null) {
+ uri = component.getName() + '/' + componentService.getName();
+ } else {
+ uri = component.getName();
+ }
+ componentServices.put(uri, componentService);
+
+ // Create and configure an SCA binding for the service
+ SCABinding scaBinding = componentService.getBinding(SCABinding.class);
+ if (scaBinding == null) {
+ scaBinding = assemblyFactory.createSCABinding();
+ componentService.getBindings().add(scaBinding);
+ }
+ scaBinding.setURI(uri);
+ }
+ for (ComponentReference componentReference : component.getReferences()) {
+ String uri = component.getName() + '/' + componentReference.getName();
+ componentReferences.put(uri, componentReference);
+
+ // Create and configure an SCA binding for the reference
+ SCABinding scaBinding = componentReference.getBinding(SCABinding.class);
+ if (scaBinding == null) {
+ scaBinding = assemblyFactory.createSCABinding();
+ componentReference.getBindings().add(scaBinding);
+ }
+ scaBinding.setURI(uri);
+ }
+ }
+
+ // Resolve promoted services and references
+ for (Service service : composite.getServices()) {
+ CompositeService compositeService = (CompositeService)service;
+ ComponentService componentService = compositeService.getPromotedService();
+ if (componentService != null && componentService.isUnresolved()) {
+ ComponentService resolved = componentServices.get(componentService.getName());
+ if (resolved != null) {
+ compositeService.setPromotedService(resolved);
+ } else {
+ problems.add(compositeService);
+ }
+ }
+ }
+ for (Reference reference : composite.getReferences()) {
+ CompositeReference compositeReference = (CompositeReference)reference;
+ List<ComponentReference> promotedReferences = compositeReference.getPromotedReferences();
+ for (int i = 0, n = promotedReferences.size(); i < n; i++) {
+ ComponentReference componentReference = promotedReferences.get(i);
+ if (componentReference.isUnresolved()) {
+ ComponentReference resolved = componentReferences.get(componentReference.getName());
+ if (resolved != null) {
+ promotedReferences.set(i, resolved);
+ } else {
+ problems.add(compositeReference);
+ }
+ }
+ }
+ }
+
+ // Wire references to their targets
+ for (ComponentReference componentReference : componentReferences.values()) {
+ List<ComponentService> targets = componentReference.getTargets();
+ if (!targets.isEmpty()) {
+ for (int i = 0, n = targets.size(); i < n; i++) {
+ ComponentService target = targets.get(i);
+ if (target.isUnresolved()) {
+ ComponentService resolved = componentServices.get(target.getName());
+ if (resolved != null) {
+ targets.set(i, resolved);
+ } else {
+ problems.add(target);
+ }
+ }
+ }
+ } else if (componentReference.getReference() != null) {
+
+ // Wire reference targets from the corresponding reference in
+ // the componentType
+ for (ComponentService target : componentReference.getReference().getTargets()) {
+ if (target.isUnresolved()) {
+ ComponentService resolved = componentServices.get(target.getName());
+ if (resolved != null) {
+ targets.add(resolved);
+ } else {
+ problems.add(target);
+ }
+ }
+ }
+ }
+ }
+
+ // Wire references as specified in wires
+ List<Wire> wires = composite.getWires();
+ for (int i = 0, n = wires.size(); i < n; i++) {
+ Wire wire = wires.get(i);
+
+ ComponentReference resolvedReference;
+ ComponentService resolvedService;
+
+ ComponentReference source = wire.getSource();
+ if (source != null && source.isUnresolved()) {
+ resolvedReference = componentReferences.get(source.getName());
+ if (resolvedReference != null) {
+ wire.setSource(resolvedReference);
+ } else {
+ problems.add(source);
+ }
+ } else {
+ resolvedReference = wire.getSource();
+ }
+
+ ComponentService target = wire.getTarget();
+ if (target != null && target.isUnresolved()) {
+ resolvedService = componentServices.get(target.getName());
+ if (resolvedService != null) {
+ wire.setTarget(target);
+ } else {
+ problems.add(source);
+ }
+ } else {
+ resolvedService = wire.getTarget();
+ }
+ if (resolvedReference != null && resolvedService != null) {
+ resolvedReference.getTargets().add(resolvedService);
+ }
+ }
+ }
+
}
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/PrintUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/PrintUtil.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/PrintUtil.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/PrintUtil.java Sun Apr 1 20:53:56 2007
@@ -32,113 +32,116 @@
/**
* A simple print utility class to help print assembly model instances.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class PrintUtil {
-
- PrintWriter out;
- Set<Object> objects = new HashSet<Object>();
- int indent;
-
- public PrintUtil(OutputStream out) {
- this.out = new PrintWriter(new OutputStreamWriter(out), true);
- }
-
- void indent() {
- for (int i=0; i<indent; i++) {
- out.print(" ");
- }
- }
-
- /**
- * Print a model object.
- * @param object
- */
- public void print(Object object) {
- if (objects.contains(object)) {
-
- // If we've already printed an object, print just it's hashcode
- indent();
- out.println(object.getClass().getName()+"@"+System.identityHashCode(object));
- }
- else {
- objects.add(object);
- try {
-
- // Print the object class name
- indent();
- out.println(object.getClass().getSimpleName() + " {");
-
- // Get the object's properties
- BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass());
- for (PropertyDescriptor propertyDescriptor: beanInfo.getPropertyDescriptors()) {
- try {
-
- // Get the value of each property
- Object value = propertyDescriptor.getReadMethod().invoke(object);
- if (value != null) {
-
- // Convert array value into a list
- if (value.getClass().isArray()) {
- value = Arrays.asList((Object[])value);
- }
-
- // Print elements in a list
- if (value instanceof List) {
- if (!((List)value).isEmpty()) {
- indent++;
- indent();
- out.println(propertyDescriptor.getName() + "= [");
-
- // Print each element, recursively
- for (Object element: (List)value) {
- indent++;
- print(element);
- indent--;
- }
- indent();
- out.println( " ]");
- indent--;
- }
- }
- else {
- Class<?> valueClass = value.getClass();
-
- // Print a primitive, java built in type or enum, using toString()
- if (valueClass.isPrimitive() || valueClass.getName().startsWith("java.") || valueClass.getName().startsWith("javax.") || valueClass.isEnum()) {
- if (!propertyDescriptor.getName().equals("class")) {
- if (!(Boolean.FALSE.equals(value))) {
- indent++;
- indent();
- out.println(propertyDescriptor.getName() + "=" + value.toString());
- indent--;
- }
- }
- } else {
-
- // Print an object, recursively
- indent++;
- indent();
- out.println(propertyDescriptor.getName() + "= {" );
- indent++;
- print(value);
- indent--;
- indent();
- out.println("}");
- indent--;
- }
- }
- }
- } catch (Exception e) {}
- }
- indent();
- out.println("}");
- } catch (IntrospectionException e) {
- indent();
- out.println(e);
- }
- }
- }
+
+ PrintWriter out;
+ Set<Object> objects = new HashSet<Object>();
+ int indent;
+
+ public PrintUtil(OutputStream out) {
+ this.out = new PrintWriter(new OutputStreamWriter(out), true);
+ }
+
+ void indent() {
+ for (int i = 0; i < indent; i++) {
+ out.print(" ");
+ }
+ }
+
+ /**
+ * Print a model object.
+ *
+ * @param object
+ */
+ public void print(Object object) {
+ if (objects.contains(object)) {
+
+ // If we've already printed an object, print just it's hashcode
+ indent();
+ out.println(object.getClass().getName() + "@" + System.identityHashCode(object));
+ } else {
+ objects.add(object);
+ try {
+
+ // Print the object class name
+ indent();
+ out.println(object.getClass().getSimpleName() + " {");
+
+ // Get the object's properties
+ BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass());
+ for (PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors()) {
+ try {
+
+ // Get the value of each property
+ Object value = propertyDescriptor.getReadMethod().invoke(object);
+ if (value != null) {
+
+ // Convert array value into a list
+ if (value.getClass().isArray()) {
+ value = Arrays.asList((Object[])value);
+ }
+
+ // Print elements in a list
+ if (value instanceof List) {
+ if (!((List)value).isEmpty()) {
+ indent++;
+ indent();
+ out.println(propertyDescriptor.getName() + "= [");
+
+ // Print each element, recursively
+ for (Object element : (List)value) {
+ indent++;
+ print(element);
+ indent--;
+ }
+ indent();
+ out.println(" ]");
+ indent--;
+ }
+ } else {
+ Class<?> valueClass = value.getClass();
+
+ // Print a primitive, java built in type or
+ // enum, using toString()
+ if (valueClass.isPrimitive() || valueClass.getName().startsWith("java.")
+ || valueClass.getName().startsWith("javax.")
+ || valueClass.isEnum()) {
+ if (!propertyDescriptor.getName().equals("class")) {
+ if (!(Boolean.FALSE.equals(value))) {
+ indent++;
+ indent();
+ out.println(propertyDescriptor.getName() + "=" + value.toString());
+ indent--;
+ }
+ }
+ } else {
+
+ // Print an object, recursively
+ indent++;
+ indent();
+ out.println(propertyDescriptor.getName() + "= {");
+ indent++;
+ print(value);
+ indent--;
+ indent();
+ out.println("}");
+ indent--;
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+ indent();
+ out.println("}");
+ } catch (IntrospectionException e) {
+ indent();
+ out.println(e);
+ }
+ }
+ }
}
Added: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/Visitable.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/Visitable.java?view=auto&rev=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/Visitable.java (added)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/Visitable.java Sun Apr 1 20:53:56 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.assembly.util;
+
+/**
+ * This interface is implemented by object that can accept a visitor.
+ */
+public interface Visitable {
+
+ /**
+ * Accepts the given visitor. The visitor's visit method is called with this
+ * model object. If the visitor returns true, this method visits this
+ * object's children.
+ *
+ * @param visitor
+ * @return true if the model object's chidren should be visited, false if
+ * they should be skipped
+ */
+ boolean accept(Visitor visitor);
+
+}
Propchange: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/Visitable.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/Visitable.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/Visitor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/Visitor.java?view=auto&rev=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/Visitor.java (added)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/Visitor.java Sun Apr 1 20:53:56 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.assembly.util;
+
+import org.apache.tuscany.assembly.model.Base;
+
+/**
+ * This interface is implemented by objects that visit assembly model trees.
+ */
+public interface Visitor {
+
+ /**
+ * Visits the given assembly model object.
+ *
+ * @param object
+ * @return true if the model object's chidren should be visited, false if
+ * they should be skipped
+ */
+ boolean visit(Base object);
+
+}
Propchange: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/Visitor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/scdl4j/assembly/src/main/java/org/apache/tuscany/assembly/util/Visitor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/AssemblyFactoryTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/AssemblyFactoryTestCase.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/AssemblyFactoryTestCase.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/AssemblyFactoryTestCase.java Sun Apr 1 20:53:56 2007
@@ -26,198 +26,200 @@
/**
* Test building of assembly model instances using the assembly factory.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class AssemblyFactoryTestCase extends TestCase {
-
- AssemblyFactory factory;
- public void setUp() throws Exception {
- factory = new DefaultAssemblyFactory();
- }
-
- public void tearDown() throws Exception {
- factory = null;
- }
-
- public void testCreateComponent() {
- createComponent("AccountServiceComponent1");
- }
-
- public void testCreateComponentType() {
- createComponentType();
- }
-
- public void testCreateComposite() {
- createComposite();
- }
-
- public void testCreateConstrainingType() {
- createConstrainingType();
- }
-
- /**
- * Create a composite
- */
- Composite createComposite() {
- Composite c = factory.createComposite();
-
- Component c1 = createComponent("AccountServiceComponent1");
- c.getComponents().add(c1);
- Component c2 = createComponent("AccountServiceComponent2");
- c.getComponents().add(c2);
-
- Wire w = factory.createWire();
- w.setSource(c1.getReferences().get(0));
- w.setTarget(c2.getServices().get(0));
- c.getWires().add(w);
-
- CompositeService cs = factory.createCompositeService();
- cs.setName("AccountService");
- cs.setPromotedService(c1.getServices().get(0));
- cs.setInterface(new TestInterface(factory));
- c.getServices().add(cs);
- cs.getBindings().add(new TestBinding(factory));
-
- CompositeReference cr = factory.createCompositeReference();
- cr.setName("StockQuoteService");
- cr.getPromotedReferences().add(c2.getReferences().get(1));
- cr.setInterface(new TestInterface(factory));
- c.getReferences().add(cr);
- cr.getBindings().add(new TestBinding(factory));
-
- return c;
- }
-
- /**
- * Create a new component
- */
- Component createComponent(String name) {
- Component c = factory.createComponent();
- c.setName(name);
-
- ConstrainingType constraint = createConstrainingType();
- c.setConstrainingType(constraint);
-
- Implementation i = new TestImplementation(factory);
- c.setImplementation(i);
-
- ComponentProperty p = factory.createComponentProperty();
- p.setName("currency");
- p.setDefaultValue("USD");
- p.setMustSupply(true);
- p.setXSDType(new QName("", ""));
- p.setProperty(i.getProperties().get(0));
- c.getProperties().add(p);
-
- {
- ComponentReference r = factory.createComponentReference();
- r.setName("accountDataService");
- r.setMultiplicity(Multiplicity.ONE_ONE);
- r.setInterface(new TestInterface(factory));
- r.setReference(i.getReferences().get(0));
- c.getReferences().add(r);
- r.getBindings().add(new TestBinding(factory));
- }
-
- {
- ComponentReference r = factory.createComponentReference();
- r.setName("stockQuoteService");
- r.setMultiplicity(Multiplicity.ONE_ONE);
- r.setInterface(new TestInterface(factory));
- r.setReference(i.getReferences().get(1));
- c.getReferences().add(r);
- r.getBindings().add(new TestBinding(factory));
- }
-
- ComponentService s = factory.createComponentService();
- s.setName("AccountService");
- s.setInterface(new TestInterface(factory));
- s.setService(i.getServices().get(0));
- c.getServices().add(s);
- s.getBindings().add(new TestBinding(factory));
-
- return c;
- }
-
- /**
- * Create a new component type
- * @return
- */
- ComponentType createComponentType() {
- ComponentType ctype = factory.createComponentType();
-
- Property p = factory.createProperty();
- p.setName("currency");
- p.setDefaultValue("USD");
- p.setMustSupply(true);
- p.setXSDType(new QName("", ""));
- ctype.getProperties().add(p);
-
- {
- Reference r = factory.createReference();
- r.setName("accountDataService");
- r.setInterface(new TestInterface(factory));
- r.setMultiplicity(Multiplicity.ONE_ONE);
- ctype.getReferences().add(r);
- r.getBindings().add(new TestBinding(factory));
- }
-
- {
- Reference r = factory.createReference();
- r.setName("stockQuoteService");
- r.setInterface(new TestInterface(factory));
- r.setMultiplicity(Multiplicity.ONE_ONE);
- ctype.getReferences().add(r);
- r.getBindings().add(new TestBinding(factory));
- }
-
- Service s = factory.createService();
- s.setName("AccountService");
- s.setInterface(new TestInterface(factory));
- ctype.getServices().add(s);
- s.getBindings().add(new TestBinding(factory));
-
- return ctype;
- }
-
- /**
- * Create a new constraining type
- * @return
- */
- ConstrainingType createConstrainingType() {
- ConstrainingType ctype = factory.createConstrainingType();
-
- AbstractProperty p = factory.createAbstractProperty();
- p.setName("currency");
- p.setDefaultValue("USD");
- p.setMustSupply(true);
- p.setXSDType(new QName("", ""));
- ctype.getProperties().add(p);
-
- {
- AbstractReference r = factory.createAbstractReference();
- r.setName("accountDataService");
- r.setInterface(new TestInterface(factory));
- r.setMultiplicity(Multiplicity.ONE_ONE);
- ctype.getReferences().add(r);
- }
-
- {
- AbstractReference r = factory.createAbstractReference();
- r.setName("stockQuoteService");
- r.setInterface(new TestInterface(factory));
- r.setMultiplicity(Multiplicity.ONE_ONE);
- ctype.getReferences().add(r);
- }
-
- AbstractService s = factory.createAbstractService();
- s.setName("AccountService");
- s.setInterface(new TestInterface(factory));
- ctype.getServices().add(s);
-
- return ctype;
- }
+ AssemblyFactory factory;
+
+ public void setUp() throws Exception {
+ factory = new DefaultAssemblyFactory();
+ }
+
+ public void tearDown() throws Exception {
+ factory = null;
+ }
+
+ public void testCreateComponent() {
+ createComponent("AccountServiceComponent1");
+ }
+
+ public void testCreateComponentType() {
+ createComponentType();
+ }
+
+ public void testCreateComposite() {
+ createComposite();
+ }
+
+ public void testCreateConstrainingType() {
+ createConstrainingType();
+ }
+
+ /**
+ * Create a composite
+ */
+ Composite createComposite() {
+ Composite c = factory.createComposite();
+
+ Component c1 = createComponent("AccountServiceComponent1");
+ c.getComponents().add(c1);
+ Component c2 = createComponent("AccountServiceComponent2");
+ c.getComponents().add(c2);
+
+ Wire w = factory.createWire();
+ w.setSource(c1.getReferences().get(0));
+ w.setTarget(c2.getServices().get(0));
+ c.getWires().add(w);
+
+ CompositeService cs = factory.createCompositeService();
+ cs.setName("AccountService");
+ cs.setPromotedService(c1.getServices().get(0));
+ cs.setInterface(new TestInterface(factory));
+ c.getServices().add(cs);
+ cs.getBindings().add(new TestBinding(factory));
+
+ CompositeReference cr = factory.createCompositeReference();
+ cr.setName("StockQuoteService");
+ cr.getPromotedReferences().add(c2.getReferences().get(1));
+ cr.setInterface(new TestInterface(factory));
+ c.getReferences().add(cr);
+ cr.getBindings().add(new TestBinding(factory));
+
+ return c;
+ }
+
+ /**
+ * Create a new component
+ */
+ Component createComponent(String name) {
+ Component c = factory.createComponent();
+ c.setName(name);
+
+ ConstrainingType constraint = createConstrainingType();
+ c.setConstrainingType(constraint);
+
+ Implementation i = new TestImplementation(factory);
+ c.setImplementation(i);
+
+ ComponentProperty p = factory.createComponentProperty();
+ p.setName("currency");
+ p.setDefaultValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ p.setProperty(i.getProperties().get(0));
+ c.getProperties().add(p);
+
+ {
+ ComponentReference r = factory.createComponentReference();
+ r.setName("accountDataService");
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ r.setInterface(new TestInterface(factory));
+ r.setReference(i.getReferences().get(0));
+ c.getReferences().add(r);
+ r.getBindings().add(new TestBinding(factory));
+ }
+
+ {
+ ComponentReference r = factory.createComponentReference();
+ r.setName("stockQuoteService");
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ r.setInterface(new TestInterface(factory));
+ r.setReference(i.getReferences().get(1));
+ c.getReferences().add(r);
+ r.getBindings().add(new TestBinding(factory));
+ }
+
+ ComponentService s = factory.createComponentService();
+ s.setName("AccountService");
+ s.setInterface(new TestInterface(factory));
+ s.setService(i.getServices().get(0));
+ c.getServices().add(s);
+ s.getBindings().add(new TestBinding(factory));
+
+ return c;
+ }
+
+ /**
+ * Create a new component type
+ *
+ * @return
+ */
+ ComponentType createComponentType() {
+ ComponentType ctype = factory.createComponentType();
+
+ Property p = factory.createProperty();
+ p.setName("currency");
+ p.setDefaultValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ ctype.getProperties().add(p);
+
+ {
+ Reference r = factory.createReference();
+ r.setName("accountDataService");
+ r.setInterface(new TestInterface(factory));
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(r);
+ r.getBindings().add(new TestBinding(factory));
+ }
+
+ {
+ Reference r = factory.createReference();
+ r.setName("stockQuoteService");
+ r.setInterface(new TestInterface(factory));
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(r);
+ r.getBindings().add(new TestBinding(factory));
+ }
+
+ Service s = factory.createService();
+ s.setName("AccountService");
+ s.setInterface(new TestInterface(factory));
+ ctype.getServices().add(s);
+ s.getBindings().add(new TestBinding(factory));
+
+ return ctype;
+ }
+
+ /**
+ * Create a new constraining type
+ *
+ * @return
+ */
+ ConstrainingType createConstrainingType() {
+ ConstrainingType ctype = factory.createConstrainingType();
+
+ AbstractProperty p = factory.createAbstractProperty();
+ p.setName("currency");
+ p.setDefaultValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ ctype.getProperties().add(p);
+
+ {
+ AbstractReference r = factory.createAbstractReference();
+ r.setName("accountDataService");
+ r.setInterface(new TestInterface(factory));
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(r);
+ }
+
+ {
+ AbstractReference r = factory.createAbstractReference();
+ r.setName("stockQuoteService");
+ r.setInterface(new TestInterface(factory));
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ ctype.getReferences().add(r);
+ }
+
+ AbstractService s = factory.createAbstractService();
+ s.setName("AccountService");
+ s.setInterface(new TestInterface(factory));
+ ctype.getServices().add(s);
+
+ return ctype;
+ }
}
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestBinding.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestBinding.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestBinding.java Sun Apr 1 20:53:56 2007
@@ -22,15 +22,15 @@
/**
* A test interface model.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class TestBinding extends BindingImpl implements Binding {
- public TestBinding(AssemblyFactory factory) {
+ public TestBinding(AssemblyFactory factory) {
+
+ setName("test");
+ setURI("http://test");
+ }
- setName("test");
- setURI("http://test");
- }
-
}
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestImplementation.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestImplementation.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestImplementation.java Sun Apr 1 20:53:56 2007
@@ -24,43 +24,43 @@
/**
* A test component implementation model.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class TestImplementation extends ComponentTypeImpl implements Implementation {
- public TestImplementation(AssemblyFactory factory) {
-
- Property p = factory.createProperty();
- p.setName("currency");
- p.setDefaultValue("USD");
- p.setMustSupply(true);
- p.setXSDType(new QName("", ""));
- getProperties().add(p);
-
- {
- Reference r = factory.createReference();
- r.setName("accountDataService");
- r.setMultiplicity(Multiplicity.ONE_ONE);
- getReferences().add(r);
- r.getBindings().add(new TestBinding(factory));
- }
-
- {
- Reference r = factory.createReference();
- r.setName("stockQuoteService");
- r.setMultiplicity(Multiplicity.ONE_ONE);
- r.setInterface(new TestInterface(factory));
- getReferences().add(r);
- r.getBindings().add(new TestBinding(factory));
- }
-
- Service s = factory.createService();
- s.setName("AccountService");
- s.setInterface(new TestInterface(factory));
- getServices().add(s);
- s.getBindings().add(new TestBinding(factory));
-
- }
-
+ public TestImplementation(AssemblyFactory factory) {
+
+ Property p = factory.createProperty();
+ p.setName("currency");
+ p.setDefaultValue("USD");
+ p.setMustSupply(true);
+ p.setXSDType(new QName("", ""));
+ getProperties().add(p);
+
+ {
+ Reference r = factory.createReference();
+ r.setName("accountDataService");
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ getReferences().add(r);
+ r.getBindings().add(new TestBinding(factory));
+ }
+
+ {
+ Reference r = factory.createReference();
+ r.setName("stockQuoteService");
+ r.setMultiplicity(Multiplicity.ONE_ONE);
+ r.setInterface(new TestInterface(factory));
+ getReferences().add(r);
+ r.getBindings().add(new TestBinding(factory));
+ }
+
+ Service s = factory.createService();
+ s.setName("AccountService");
+ s.setInterface(new TestInterface(factory));
+ getServices().add(s);
+ s.getBindings().add(new TestBinding(factory));
+
+ }
+
}
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestInterface.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestInterface.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestInterface.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestInterface.java Sun Apr 1 20:53:56 2007
@@ -24,19 +24,19 @@
/**
* A test interface model.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class TestInterface extends InterfaceImpl implements Interface {
- public TestInterface(AssemblyFactory factory) {
-
- setRemotable(true);
-
- Operation operation = new TestOperation();
- operation.setName("test");
- getOperations().add(operation);
-
- }
-
+ public TestInterface(AssemblyFactory factory) {
+
+ setRemotable(true);
+
+ Operation operation = new TestOperation();
+ operation.setName("test");
+ getOperations().add(operation);
+
+ }
+
}
Modified: incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestOperation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestOperation.java?view=diff&rev=524718&r1=524717&r2=524718
==============================================================================
--- incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestOperation.java (original)
+++ incubator/tuscany/java/sca/scdl4j/assembly/src/test/java/org/apache/tuscany/assembly/model/TestOperation.java Sun Apr 1 20:53:56 2007
@@ -23,8 +23,8 @@
/**
* A test operation model.
- *
- * @version $Rev$ $Date$
+ *
+ * @version $Rev$ $Date$
*/
public class TestOperation extends OperationImpl implements Operation {
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org