summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-08-20 11:12:28 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-08-20 11:12:28 +0000
commit61b35b18fe64fc4eef8c84d0d6b35ef5fe7d3869 (patch)
tree46d06c87ac7b65b1d57435efdd654ecded66a666 /java/sca
parent939d98d62bb168856dade45a587859692048a973 (diff)
Move top level monitor.pushContext calls to each build so we are doing this consistently
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@806123 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java227
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java88
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBindingURIBuilderImpl.java150
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java3
4 files changed, 220 insertions, 248 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java
index ebd1b8da8e..a44c5b262a 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentConfigurationBuilderImpl.java
@@ -98,123 +98,124 @@ public class ComponentConfigurationBuilderImpl extends BaseBuilderImpl implement
* @param problems
*/
private void configureComponents(Composite composite, String uri, Definitions definitions, Monitor monitor) {
- String parentURI = uri;
-
- // Process nested composites recursively
- for (Component component : composite.getComponents()) {
-
- // Initialize component URI
- String componentURI;
- if (parentURI == null) {
- componentURI = component.getName();
- } else {
- componentURI = URI.create(parentURI + '/').resolve(component.getName()).toString();
- }
- component.setURI(componentURI);
-
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
- try {
- monitor.pushContext("Composite: " + ((Composite)implementation).getURI());
-
+ String parentURI = uri;
+
+ monitor.pushContext("Composite: " + composite.getName().toString());
+
+ try {
+
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+
+ // Initialize component URI
+ String componentURI;
+ if (parentURI == null) {
+ componentURI = component.getName();
+ } else {
+ componentURI = URI.create(parentURI + '/').resolve(component.getName()).toString();
+ }
+ component.setURI(componentURI);
+
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
// Process nested composite
configureComponents((Composite)implementation, componentURI, definitions, monitor);
-
- } finally {
- monitor.popContext();
- } // end try
+ }
+ } // end for
+
+ // Initialize service bindings
+ List<Service> compositeServices = composite.getServices();
+ for (Service service : compositeServices) {
+ // Set default binding names
+
+ // Create default SCA binding
+ attachSCABinding(service, definitions);
}
- } // end for
-
- // Initialize service bindings
- List<Service> compositeServices = composite.getServices();
- for (Service service : compositeServices) {
- // Set default binding names
-
- // Create default SCA binding
- attachSCABinding(service, definitions);
- }
-
- // Initialize reference bindings
- for (Reference reference : composite.getReferences()) {
- // Create default SCA binding
- attachSCABinding(reference, definitions);
- }
-
- // Initialize all component services and references
- Map<String, Component> components = new HashMap<String, Component>();
- for (Component component : composite.getComponents()) {
-
-
- monitor.pushContext("Component: " + component.getName());
-
- try {
- // Index all components and check for duplicates
- if (components.containsKey(component.getName())) {
- error(monitor, "DuplicateComponentName", component, composite.getName().toString(), component.getName());
- } else {
- components.put(component.getName(), component);
- }
-
- // Propagate the autowire flag from the composite to components
- if (component.getAutowire() == null) {
- component.setAutowire(composite.getAutowire());
- }
-
- if (component.getImplementation() instanceof ComponentPreProcessor) {
- ((ComponentPreProcessor)component.getImplementation()).preProcess(component);
- }
-
- // Index implementation properties, services and references
- Map<String, Service> services = new HashMap<String, Service>();
- Map<String, Reference> references = new HashMap<String, Reference>();
- Map<String, Property> properties = new HashMap<String, Property>();
- indexImplementationPropertiesServicesAndReferences(component, services, references, properties, monitor);
-
- // Index component services, references and properties
- // Also check for duplicates
- Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
- Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
- Map<String, ComponentProperty> componentProperties = new HashMap<String, ComponentProperty>();
- indexComponentPropertiesServicesAndReferences(component,
- componentServices,
- componentReferences,
- componentProperties,
- monitor);
-
- // Reconcile component services/references/properties and
- // implementation services/references and create component
- // services/references/properties for the services/references
- // declared by the implementation
- reconcileServices(component, services, componentServices, monitor);
- reconcileReferences(component, references, componentReferences, monitor);
- reconcileProperties(component, properties, componentProperties, monitor);
-
- // Configure or create callback services for component's references
- // with callbacks
- configureCallbackServices(component, componentServices);
-
- // Configure or create callback references for component's services
- // with callbacks
- configureCallbackReferences(component, componentReferences);
-
- // Initialize service bindings
- for (ComponentService componentService : component.getServices()) {
-
- // Create default SCA binding
- attachSCABinding(componentService, definitions);
- }
-
- // Initialize reference bindings
- for (ComponentReference componentReference : component.getReferences()) {
-
- // Create default SCA binding
- attachSCABinding(componentReference, definitions);
- }
- } finally {
- monitor.popContext();
+
+ // Initialize reference bindings
+ for (Reference reference : composite.getReferences()) {
+ // Create default SCA binding
+ attachSCABinding(reference, definitions);
}
- }
+
+ // Initialize all component services and references
+ Map<String, Component> components = new HashMap<String, Component>();
+ for (Component component : composite.getComponents()) {
+
+
+ monitor.pushContext("Component: " + component.getName());
+
+ try {
+ // Index all components and check for duplicates
+ if (components.containsKey(component.getName())) {
+ error(monitor, "DuplicateComponentName", component, composite.getName().toString(), component.getName());
+ } else {
+ components.put(component.getName(), component);
+ }
+
+ // Propagate the autowire flag from the composite to components
+ if (component.getAutowire() == null) {
+ component.setAutowire(composite.getAutowire());
+ }
+
+ if (component.getImplementation() instanceof ComponentPreProcessor) {
+ ((ComponentPreProcessor)component.getImplementation()).preProcess(component);
+ }
+
+ // Index implementation properties, services and references
+ Map<String, Service> services = new HashMap<String, Service>();
+ Map<String, Reference> references = new HashMap<String, Reference>();
+ Map<String, Property> properties = new HashMap<String, Property>();
+ indexImplementationPropertiesServicesAndReferences(component, services, references, properties, monitor);
+
+ // Index component services, references and properties
+ // Also check for duplicates
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+ Map<String, ComponentProperty> componentProperties = new HashMap<String, ComponentProperty>();
+ indexComponentPropertiesServicesAndReferences(component,
+ componentServices,
+ componentReferences,
+ componentProperties,
+ monitor);
+
+ // Reconcile component services/references/properties and
+ // implementation services/references and create component
+ // services/references/properties for the services/references
+ // declared by the implementation
+ reconcileServices(component, services, componentServices, monitor);
+ reconcileReferences(component, references, componentReferences, monitor);
+ reconcileProperties(component, properties, componentProperties, monitor);
+
+ // Configure or create callback services for component's references
+ // with callbacks
+ configureCallbackServices(component, componentServices);
+
+ // Configure or create callback references for component's services
+ // with callbacks
+ configureCallbackReferences(component, componentReferences);
+
+ // Initialize service bindings
+ for (ComponentService componentService : component.getServices()) {
+
+ // Create default SCA binding
+ attachSCABinding(componentService, definitions);
+ }
+
+ // Initialize reference bindings
+ for (ComponentReference componentReference : component.getReferences()) {
+
+ // Create default SCA binding
+ attachSCABinding(componentReference, definitions);
+ }
+ } finally {
+ monitor.popContext();
+ }
+ }
+
+ } finally {
+ monitor.popContext();
+ } // end try
} // end method
/**
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java
index fe5487921f..6dedb61d82 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceWireBuilderImpl.java
@@ -68,73 +68,37 @@ public class ComponentReferenceWireBuilderImpl extends BaseBuilderImpl implement
monitor.pushContext(composite.getName().toString());
- // Wire nested composites recursively
- for (Component component : composite.getComponents()) {
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
- wireComponentReferences((Composite)implementation, monitor);
- }
- }
-
- // Index components, services and references
- Map<String, Component> components = new HashMap<String, Component>();
- Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
- Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
- indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences);
-
- // Connect component references as described in wires
- connectWires(composite, componentServices, componentReferences, monitor);
-
- // Validate that references are wired or promoted, according
- // to their multiplicity
- for (Component component: components.values()){
- monitor.pushContext(component.getName());
- for (ComponentReference componentReference : component.getReferences()) {
- monitor.pushContext(componentReference.getName());
- if (!ReferenceConfigurationUtil.validateMultiplicityAndTargets(componentReference.getMultiplicity(),
- componentReference.getTargets(),
- componentReference.getBindings())) {
- if (componentReference.getTargets().isEmpty()) {
+ try {
+ // Wire nested composites recursively
+ for (Component component : composite.getComponents()) {
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
- // No warning if the reference is promoted out of the current composite
- boolean promoted = false;
- for (Reference reference : composite.getReferences()) {
- CompositeReference compositeReference = (CompositeReference)reference;
- if (compositeReference.getPromotedReferences().contains(componentReference)) {
- promoted = true;
- break;
- }
- }
- if (!promoted && !componentReference.isForCallback()) {
- warning(monitor,
- "ReferenceWithoutTargets",
- composite,
- composite.getName().toString(),
- componentReference.getName());
- }
- } else {
-// ---------------------------
-// TUSCANY-3132 first example of updated error handling
- Monitor.error(monitor,
- this,
- "assembly-validation-messages",
- "TooManyReferenceTargets",
- componentReference.getName());
-// ---------------------------
- }
+ wireComponentReferences((Composite)implementation, monitor);
+
}
- monitor.popContext();
}
+
+ // Index components, services and references
+ Map<String, Component> components = new HashMap<String, Component>();
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+ indexComponentsServicesAndReferences(composite, components, componentServices, componentReferences);
+
+ // Connect component references as described in wires
+ connectWires(composite, componentServices, componentReferences, monitor);
+
+
+ // Finally clear the original reference target lists as we now have
+ // bindings to represent the targets
+ // for (ComponentReference componentReference : componentReferences.values()) {
+ // componentReference.getTargets().clear();
+ // }
+
+ } finally {
monitor.popContext();
- }
+ }
- // Finally clear the original reference target lists as we now have
- // bindings to represent the targets
- // for (ComponentReference componentReference : componentReferences.values()) {
- // componentReference.getTargets().clear();
- // }
-
- monitor.popContext();
}
/**
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 2a88281f68..cf48c49add 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
@@ -138,86 +138,96 @@ public class CompositeBindingURIBuilderImpl extends BaseBuilderImpl implements C
Definitions definitions,
Map<QName, List<String>> defaultBindings,
Monitor monitor) throws CompositeBuilderException {
-
+
String parentComponentURI = uri;
-
- // Process nested composites recursively
- for (Component component : composite.getComponents()) {
-
- // Initialize component URI
- String componentURI;
- if (parentComponentURI == null) {
- componentURI = component.getName();
- } else {
- componentURI = URI.create(parentComponentURI + '/').resolve(component.getName()).toString();
- }
- component.setURI(componentURI);
-
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
-
- // Process nested composite
- configureBindingURIs((Composite)implementation, componentURI, definitions, defaultBindings, monitor);
- }
- }
-
- // Initialize composite service binding URIs
- List<Service> compositeServices = composite.getServices();
- for (Service service : compositeServices) {
- // Set default binding names
-
- // Create default SCA binding
- attachSCABinding(service, definitions);
-
- constructBindingNames(service, monitor);
-
- // Initialize binding names and URIs
- for (Binding binding : service.getBindings()) {
- constructBindingURI(parentComponentURI, composite, service, binding, defaultBindings, monitor);
+
+ monitor.pushContext("Composite: " + composite.getName().toString());
+ try {
+ // Process nested composites recursively
+ for (Component component : composite.getComponents()) {
+
+ // Initialize component URI
+ String componentURI;
+ if (parentComponentURI == null) {
+ componentURI = component.getName();
+ } else {
+ componentURI = URI.create(parentComponentURI + '/').resolve(component.getName()).toString();
+ }
+ component.setURI(componentURI);
+
+ Implementation implementation = component.getImplementation();
+ if (implementation instanceof Composite) {
+ // Process nested composite
+ configureBindingURIs((Composite)implementation, componentURI, definitions, defaultBindings, monitor);
+ }
}
- }
-
- // Initialize component service binding URIs
- for (Component component : composite.getComponents()) {
-
- // Index properties, services and references
- Map<String, Service> services = new HashMap<String, Service>();
- Map<String, Reference> references = new HashMap<String, Reference>();
- Map<String, Property> properties = new HashMap<String, Property>();
- indexImplementationPropertiesServicesAndReferences(component, services, references, properties, monitor);
-
- // Index component services, references and properties
- // Also check for duplicates
- Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
- Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
- Map<String, ComponentProperty> componentProperties = new HashMap<String, ComponentProperty>();
- indexComponentPropertiesServicesAndReferences(component,
- componentServices,
- componentReferences,
- componentProperties,
- monitor);
-
- // Reconcile component services/references/properties and
- // implementation services/references and create component
- // services/references/properties for the services/references
- // declared by the implementation
- reconcileServices(component, services, componentServices, monitor);
- reconcileReferences(component, references, componentReferences, monitor);
- reconcileProperties(component, properties, componentProperties, monitor);
-
- for (ComponentService service : component.getServices()) {
-
+
+ // Initialize composite service binding URIs
+ List<Service> compositeServices = composite.getServices();
+ for (Service service : compositeServices) {
+ // Set default binding names
+
// Create default SCA binding
attachSCABinding(service, definitions);
-
+
constructBindingNames(service, monitor);
// Initialize binding names and URIs
for (Binding binding : service.getBindings()) {
- constructBindingURI(component, service, binding, defaultBindings, monitor);
+ constructBindingURI(parentComponentURI, composite, service, binding, defaultBindings, monitor);
}
}
- }
+
+ // Initialize component service binding URIs
+ for (Component component : composite.getComponents()) {
+
+ monitor.pushContext("Component: " + component.getName());
+
+ try {
+ // Index properties, services and references
+ Map<String, Service> services = new HashMap<String, Service>();
+ Map<String, Reference> references = new HashMap<String, Reference>();
+ Map<String, Property> properties = new HashMap<String, Property>();
+ indexImplementationPropertiesServicesAndReferences(component, services, references, properties, monitor);
+
+ // Index component services, references and properties
+ // Also check for duplicates
+ Map<String, ComponentService> componentServices = new HashMap<String, ComponentService>();
+ Map<String, ComponentReference> componentReferences = new HashMap<String, ComponentReference>();
+ Map<String, ComponentProperty> componentProperties = new HashMap<String, ComponentProperty>();
+ indexComponentPropertiesServicesAndReferences(component,
+ componentServices,
+ componentReferences,
+ componentProperties,
+ monitor);
+
+ // Reconcile component services/references/properties and
+ // implementation services/references and create component
+ // services/references/properties for the services/references
+ // declared by the implementation
+ reconcileServices(component, services, componentServices, monitor);
+ reconcileReferences(component, references, componentReferences, monitor);
+ reconcileProperties(component, properties, componentProperties, monitor);
+
+ for (ComponentService service : component.getServices()) {
+
+ // Create default SCA binding
+ attachSCABinding(service, definitions);
+
+ constructBindingNames(service, monitor);
+
+ // Initialize binding names and URIs
+ for (Binding binding : service.getBindings()) {
+ constructBindingURI(component, service, binding, defaultBindings, monitor);
+ }
+ }
+ } finally {
+ monitor.popContext();
+ }
+ }
+ } finally {
+ monitor.popContext();
+ }
}
/**
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
index e86fbd7a03..b42987c6db 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeBuilderImpl.java
@@ -152,7 +152,6 @@ public class CompositeBuilderImpl implements CompositeBuilder, CompositeBuilderT
Monitor monitor) throws CompositeBuilderException {
try {
- monitor.pushContext("Composite: " + composite.getName().toString());
// Collect and fuse includes
compositeIncludeBuilder.build(composite, definitions, monitor);
@@ -223,8 +222,6 @@ public class CompositeBuilderImpl implements CompositeBuilder, CompositeBuilderT
compositePolicyBuilder.build(composite, definitions, monitor);
} catch (Exception e) {
throw new CompositeBuilderException("Exception while building composite " + composite.getName(), e);
- } finally {
- monitor.popContext();
} // end try
} // end method build