From a2ccd8211b07aa94382e582d95f2bf52da4e680e Mon Sep 17 00:00:00 2001 From: antelder Date: Tue, 12 Aug 2008 11:13:29 +0000 Subject: Change taglib to use a ComponentContext if its available git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@685120 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/host/webapp/jsp/ReferenceTag.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'java/sca') diff --git a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java b/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java index 20545e88c3..bcee2ac2d2 100644 --- a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java +++ b/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java @@ -27,6 +27,7 @@ import javax.servlet.jsp.tagext.TagSupport; import org.apache.tuscany.sca.host.embedded.SCADomain; import org.apache.tuscany.sca.host.webapp.WebAppServletHost; +import org.osoa.sca.ComponentContext; /** * Tag to handle SCA references @@ -54,9 +55,13 @@ public class ReferenceTag extends TagSupport { } ServletContext servletContext = pageContext.getServletContext(); - SCADomain scaDomain = (SCADomain)servletContext.getAttribute(WebAppServletHost.SCA_DOMAIN_ATTRIBUTE); - if (scaDomain == null) { - throw new JspException("SCADomain is null. Check Tuscany configuration in web.xml"); + ComponentContext componentContext = (ComponentContext)servletContext.getAttribute("org.osoa.sca.ComponentContext"); + SCADomain scaDomain = null; + if (componentContext == null) { + scaDomain = (SCADomain)servletContext.getAttribute(WebAppServletHost.SCA_DOMAIN_ATTRIBUTE); + if (scaDomain == null) { + throw new JspException("SCADomain is null. Check Tuscany configuration in web.xml"); + } } Class typeClass; @@ -68,7 +73,11 @@ public class ReferenceTag extends TagSupport { Object o; try { - o = scaDomain.getService(typeClass, name); + if (componentContext != null) { + o = componentContext.getService(typeClass, name); + } else { + o = scaDomain.getService(typeClass, name); + } } catch (Exception e) { throw new JspException("Exception getting service for reference'" + name + "': " + e, e); } -- cgit v1.2.3