From d05eb9a9012a851f2fc4990ccc992c695640e959 Mon Sep 17 00:00:00 2001 From: antelder Date: Wed, 18 Feb 2009 17:15:48 +0000 Subject: Simplify the code a bit git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@745577 13f79535-47bb-0310-9956-ffa450edef68 --- .../implementation/web/runtime/jsp/ReferenceTag.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'java/sca') diff --git a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java index c46b507749..a82b33fc2d 100644 --- a/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java +++ b/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java @@ -24,7 +24,6 @@ import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.TagSupport; -import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.oasisopen.sca.ServiceReference; @@ -52,27 +51,19 @@ public class ReferenceTag extends TagSupport { ServletContext servletContext = pageContext.getServletContext(); RuntimeComponent component = (RuntimeComponent)servletContext.getAttribute("org.apache.tuscany.sca.implementation.web.RuntimeComponent"); - Class typeClass; + Class typeClass; try { typeClass = Class.forName(type, true, Thread.currentThread().getContextClassLoader()); } catch (ClassNotFoundException e) { throw new JspException("Reference '" + name + "' type class not found: " + type); } - Object o = null; - for (ComponentReference ref : component.getReferences()) { - if (name.equals(ref.getName())) { - ServiceReference sr = component.getComponentContext().getServiceReference(typeClass, name); - o = sr.getService(); - break; - } - } - - if (o == null) { - throw new JspException("Reference '" + name + "' not found"); + ServiceReference sr = component.getComponentContext().getServiceReference(typeClass, name); + if (sr == null) { + throw new JspException("Reference '" + name + "' undefined"); } - pageContext.setAttribute(name, o, scope); + pageContext.setAttribute(name, sr.getService(), scope); return EVAL_PAGE; } -- cgit v1.2.3