From 06437a98ad81639862c09fe7013f4517033b1d59 Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 15 Oct 2009 20:35:36 +0000 Subject: Test that a component implementation has been found/resolved git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@825640 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/builder/impl/ComponentBuilderImpl.java | 39 +++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'java/sca/modules/builder/src/main') diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java index 9c4a1c9282..6b96f9b21e 100644 --- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java +++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java @@ -121,8 +121,13 @@ public class ComponentBuilderImpl { // do any work we need to do before we calculate the component type // for this component. Anything that needs to be pushed down the promotion // hierarchy must be done before we calculate the component type + + // check that the implementation is present + if (!isComponentImplementationPresent(component)){ + return; + } - // first carry out any implementation specific builder processing + // carry out any implementation specific builder processing Implementation impl = component.getImplementation(); if (impl != null) { ImplementationBuilder builder = builders.getImplementationBuilder(impl.getType()); @@ -151,6 +156,38 @@ public class ComponentBuilderImpl { monitor.popContext(); } } + + /** + * Checks that a component implementation is present and resolved + * before doing anything else + * + * @param component + * @return true if the implementation is present and resolved + */ + private boolean isComponentImplementationPresent(Component component){ + Implementation implementation = component.getImplementation(); + if (implementation == null) { + // A component must have an implementation + Monitor.error(monitor, + this, + Messages.ASSEMBLY_VALIDATION, + "NoComponentImplementation", + component.getName()); + return false; + } else if (implementation.isUnresolved()) { + // The implementation must be fully resolved + Monitor.error(monitor, + this, + Messages.ASSEMBLY_VALIDATION, + "UnresolvedComponentImplementation", + component, + component.getName(), + implementation.getURI()); + return false; + } + + return true; + } /** * Use the component type builder to build the component type for -- cgit v1.2.3