From a026d2b6897ce267238a99e4f185c104ecf2f5f5 Mon Sep 17 00:00:00 2001 From: edwardsmj Date: Mon, 17 Aug 2009 12:57:15 +0000 Subject: Add extra error reporting context through the Monitor git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@804958 13f79535-47bb-0310-9956-ffa450edef68 --- .../impl/ComponentConfigurationBuilderImpl.java | 217 +++++++++++---------- .../builder/impl/CompositeBuilderImpl.java | 6 +- 2 files changed, 117 insertions(+), 106 deletions(-) (limited to 'java/sca/modules') 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 990b936c84..7688ebe0a7 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,111 +98,118 @@ 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) { - - // Process nested composite - configureComponents((Composite)implementation, componentURI, definitions, monitor); - } - } - - // Initialize service bindings - List 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 components = new HashMap(); - for (Component component : composite.getComponents()) { - - // 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 services = new HashMap(); - Map references = new HashMap(); - Map properties = new HashMap(); - indexImplementationPropertiesServicesAndReferences(component, services, references, properties, monitor); - - // Index component services, references and properties - // Also check for duplicates - Map componentServices = new HashMap(); - Map componentReferences = new HashMap(); - Map componentProperties = new HashMap(); - 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); - } - } - } + 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()); + + // Process nested composite + configureComponents((Composite)implementation, componentURI, definitions, monitor); + + } finally { + monitor.popContext(); + } // end try + } + } // end for + + // Initialize service bindings + List 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 components = new HashMap(); + for (Component component : composite.getComponents()) { + + // 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 services = new HashMap(); + Map references = new HashMap(); + Map properties = new HashMap(); + indexImplementationPropertiesServicesAndReferences(component, services, references, properties, monitor); + + // Index component services, references and properties + // Also check for duplicates + Map componentServices = new HashMap(); + Map componentReferences = new HashMap(); + Map componentProperties = new HashMap(); + 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); + } + } + + } // end method /** * For all the references with callbacks, create a corresponding callback 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 b065a5eafe..cc52cb4ac8 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,6 +152,8 @@ public class CompositeBuilderImpl implements CompositeBuilder, CompositeBuilderT Monitor monitor) throws CompositeBuilderException { try { + monitor.pushContext("Composite: " + composite.getURI()); + // Collect and fuse includes compositeIncludeBuilder.build(composite, definitions, monitor); @@ -221,7 +223,9 @@ public class CompositeBuilderImpl implements CompositeBuilder, CompositeBuilderT compositePolicyBuilder.build(composite, definitions, monitor); } catch (Exception e) { throw new CompositeBuilderException("Exception while building composite " + composite.getName(), e); - } // end try + } finally { + monitor.popContext(); + } // end try } // end method build -- cgit v1.2.3