From a08ed65533ef649c2d56c0289c911a70a1780c12 Mon Sep 17 00:00:00 2001 From: slaws Date: Tue, 18 Aug 2009 14:27:28 +0000 Subject: Change no component reference target warning to error (ASM_6020). Push some context into the monitor. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@805425 13f79535-47bb-0310-9956-ffa450edef68 --- ...onentReferenceEndpointReferenceBuilderImpl.java | 107 ++++++++++++--------- 1 file changed, 64 insertions(+), 43 deletions(-) (limited to 'java/sca/modules') diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java index 9f14df547f..4019a6eed2 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java @@ -80,50 +80,62 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI private void processComponentReferences(Composite composite) { - // index all of the components in the composite - Map components = new HashMap(); - indexComponents(composite, components); - - // index all of the services in the composite - Map componentServices = new HashMap(); - indexServices(composite, componentServices); - - // create endpoint references for each component's references - for (Component component : composite.getComponents()) { - - if (useNew) { - for (ComponentReference reference : component.getReferences()) { - createReferenceEndpointReferences2(composite, component, reference, components, componentServices); - } // end for - } - - // recurse for composite implementations - Implementation implementation = component.getImplementation(); - if (implementation instanceof Composite) { - processComponentReferences((Composite)implementation); - } - - // create endpoint references to represent the component reference - for (ComponentReference reference : component.getReferences()) { - - if (!useNew) { - createReferenceEndpointReferences(composite, component, reference, components, componentServices); - } // end if - - // fix up links between endpoints and endpoint references that represent callbacks - for (ComponentService service : component.getServices()) { - if ((service.getInterfaceContract() != null) && (service.getInterfaceContract() - .getCallbackInterface() != null)) { - if (reference.getName().equals(service.getName())) { - for (Endpoint endpoint : service.getEndpoints()) { - endpoint.getCallbackEndpointReferences().addAll(reference.getEndpointReferences()); - } - break; + monitor.pushContext("Composite: " + composite.getName().toString()); + + try { + // index all of the components in the composite + Map components = new HashMap(); + indexComponents(composite, components); + + // index all of the services in the composite + Map componentServices = new HashMap(); + indexServices(composite, componentServices); + + // create endpoint references for each component's references + for (Component component : composite.getComponents()) { + monitor.pushContext("Component: " + component.getName()); + + try { + if (useNew) { + for (ComponentReference reference : component.getReferences()) { + createReferenceEndpointReferences2(composite, component, reference, components, componentServices); + } // end for + } + + // recurse for composite implementations + Implementation implementation = component.getImplementation(); + if (implementation instanceof Composite) { + processComponentReferences((Composite)implementation); + } + + // create endpoint references to represent the component reference + for (ComponentReference reference : component.getReferences()) { + + if (!useNew) { + createReferenceEndpointReferences(composite, component, reference, components, componentServices); } // end if - } // end if - } // end for + + // fix up links between endpoints and endpoint references that represent callbacks + for (ComponentService service : component.getServices()) { + if ((service.getInterfaceContract() != null) && (service.getInterfaceContract() + .getCallbackInterface() != null)) { + if (reference.getName().equals(service.getName())) { + for (Endpoint endpoint : service.getEndpoints()) { + endpoint.getCallbackEndpointReferences().addAll(reference.getEndpointReferences()); + } + break; + } // end if + } // end if + } // end for + } // end for + + } finally { + monitor.popContext(); + } } // end for - } // end for + } finally { + monitor.popContext(); + } } // end method processCompoenntReferences private void createReferenceEndpointReferences(Composite composite, @@ -131,6 +143,9 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI ComponentReference reference, Map components, Map componentServices) { + + monitor.pushContext("Reference: " + reference.getName()); + // Get reference targets List refTargets = getReferenceTargets(reference); if (reference.getAutowire() == Boolean.TRUE && reference.getTargets().isEmpty()) { @@ -163,7 +178,11 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI if (multiplicity == Multiplicity.ONE_N || multiplicity == Multiplicity.ONE_ONE) { if (reference.getEndpointReferences().size() == 0) { - warning(monitor, "NoComponentReferenceTarget", reference, reference.getName()); + Monitor.error(monitor, + this, + "assembly-validation-messages", + "NoComponentReferenceTarget", + reference.getName()); } } @@ -370,6 +389,8 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI } } + monitor.popContext(); + } // end method /** -- cgit v1.2.3