Author: antelder
Date: Wed Feb 18 17:15:48 2009
New Revision: 745577

URL: http://svn.apache.org/viewvc?rev=745577&view=rev
Log:
Simplify the code a bit

Modified:
    
tuscany/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java

Modified: 
tuscany/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java?rev=745577&r1=745576&r2=745577&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java
 (original)
+++ 
tuscany/java/sca/modules/implementation-web-runtime/src/main/java/org/apache/tuscany/sca/implementation/web/runtime/jsp/ReferenceTag.java
 Wed Feb 18 17:15:48 2009
@@ -24,7 +24,6 @@
 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 @@
         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;
     }


Reply via email to