You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by va...@apache.org on 2008/11/07 13:15:15 UTC

svn commit: r712114 - in /geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web: ComponentContextLocator.java taglib/ReferenceTag.java

Author: vamsic007
Date: Fri Nov  7 04:15:14 2008
New Revision: 712114

URL: http://svn.apache.org/viewvc?rev=712114&view=rev
Log:
GERONIMO-4343 Tuscany Geronimo plugin bring up
 o Applying addComponentContextLocator.diff from Ant Elder.

Added:
    geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextLocator.java   (with props)
Modified:
    geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/taglib/ReferenceTag.java

Added: geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextLocator.java
URL: http://svn.apache.org/viewvc/geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextLocator.java?rev=712114&view=auto
==============================================================================
--- geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextLocator.java (added)
+++ geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextLocator.java Fri Nov  7 04:15:14 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+
+package org.apache.tuscany.sca.implementation.web;
+
+import javax.servlet.ServletContext;
+
+import org.apache.tuscany.sca.implementation.web.runtime.WebImplementationProviderFactory;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.ServiceRuntimeException;
+
+/**
+ * TODO: design a proper solution to do this
+ */
+public class ComponentContextLocator {
+    
+    public static ComponentContext getComponentContext(ServletContext servletContext) {
+        String path = servletContext.getContextPath();
+        String warName = path.substring(1) + ".war";
+        ComponentContext componentContext = WebImplementationProviderFactory.getWebAppContext(warName);
+        if (componentContext == null) {
+            throw new ServiceRuntimeException("no component found for webapp:" + warName);
+        }
+        return componentContext;
+    }
+
+}

Propchange: geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextLocator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextLocator.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/ComponentContextLocator.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/taglib/ReferenceTag.java
URL: http://svn.apache.org/viewvc/geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/taglib/ReferenceTag.java?rev=712114&r1=712113&r2=712114&view=diff
==============================================================================
--- geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/taglib/ReferenceTag.java (original)
+++ geronimo/plugins/tuscany/trunk/geronimo-tuscany-implementation-web/src/main/java/org/apache/tuscany/sca/implementation/web/taglib/ReferenceTag.java Fri Nov  7 04:15:14 2008
@@ -24,7 +24,7 @@
 import javax.servlet.jsp.PageContext;
 import javax.servlet.jsp.tagext.TagSupport;
 
-import org.apache.tuscany.sca.implementation.web.runtime.WebImplementationProviderFactory;
+import org.apache.tuscany.sca.implementation.web.ComponentContextLocator;
 import org.osoa.sca.ComponentContext;
 
 /**
@@ -69,16 +69,11 @@
 //        event.getServletContext().setAttribute("org.apache.tuscany.sca.SCADomain", domain);
 
         ServletContext servletContext = pageContext.getServletContext();
-        String path = servletContext.getContextPath();
-        String warName = path.substring(1) + ".war";
-        ComponentContext componentContext = WebImplementationProviderFactory.getWebAppContext(warName);
-        if (componentContext == null) {
-            throw new JspException("no component found for webapp:" + warName);
-        }
+        ComponentContext componentContext = ComponentContextLocator.getComponentContext(servletContext);
 
         Object o = componentContext.getService(typeClass, name);
         if (o == null) {
-            throw new JspException("Reference '" + name + "' not found on component for webapp: " + warName);
+            throw new JspException("Reference '" + name + "' not found on component for webapp");
         }
 
         pageContext.setAttribute(name, o, scope);