diff options
-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); } |