diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-12 11:13:29 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-12 11:13:29 +0000 |
commit | a2ccd8211b07aa94382e582d95f2bf52da4e680e (patch) | |
tree | fad8fd8b76420226af7d5203401197a3ee2af802 /java/sca/modules | |
parent | 26a224f07b26d2aa59e156d81d410b864db48273 (diff) |
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
Diffstat (limited to 'java/sca/modules')
-rw-r--r-- | java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/jsp/ReferenceTag.java | 17 |
1 files changed, 13 insertions, 4 deletions
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); } |