You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2007/02/10 08:13:46 UTC
svn commit: r505646 - in /incubator/tuscany/java/sca/runtime/webapp:
webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/
webapp-api/src/test/java/org/apache/tuscany/runtime/webapp/
webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/
Author: jboynes
Date: Fri Feb 9 23:13:45 2007
New Revision: 505646
URL: http://svn.apache.org/viewvc?view=rev&rev=505646
Log:
update TuscanyContextListener to proposed Webapp component model
Modified:
incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java
incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java
incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java
incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java
incubator/tuscany/java/sca/runtime/webapp/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
Modified: incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java?view=diff&rev=505646&r1=505645&r2=505646
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java Fri Feb 9 23:13:45 2007
@@ -8,6 +8,16 @@
public final class Constants {
/**
+ * Name of the servlet context-param that should contain the component id for the webapp.
+ */
+ static final String COMPONENT_PARAM = "tuscany.component";
+
+ /**
+ * Servlet context-param name for setting if the runtime is online.
+ */
+ static final String ONLINE_PARAM = "tuscany.online";
+
+ /**
* Name of the parameter that defines the name of webapp resource containing bootstrap jars.
*/
static final String BOOTDIR_PARAM = "tuscany.bootDir";
@@ -48,20 +58,9 @@
static final String APPLICATION_SCDL_PATH_DEFAULT = "/WEB-INF/default.scdl";
/**
- * Servlet context-param name for setting if the runtime is online.
- */
- static final String ONLINE_PARAM = "tuscany.online";
-
- /**
* Context attribute to which the Tuscany runtime for this servlet context is stored.
*/
static final String RUNTIME_ATTRIBUTE = "tuscany.runtime";
-
- /**
- * Context attribute for storing the CompositeContext that should be bound to the thread.`
- */
- @Deprecated
- static final String CONTEXT_ATTRIBUTE = "tuscany.context";
/**
* Servlet context-param name for the path to the composite to set as the webb app composite
Modified: incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java?view=diff&rev=505646&r1=505645&r2=505646
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java Fri Feb 9 23:13:45 2007
@@ -18,14 +18,15 @@
*/
package org.apache.tuscany.runtime.webapp;
-import java.net.MalformedURLException;
import java.net.URL;
+import java.net.URI;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.tuscany.api.TuscanyRuntimeException;
import org.apache.tuscany.host.runtime.ShutdownException;
+import static org.apache.tuscany.runtime.webapp.Constants.COMPONENT_PARAM;
import static org.apache.tuscany.runtime.webapp.Constants.ONLINE_PARAM;
import static org.apache.tuscany.runtime.webapp.Constants.RUNTIME_ATTRIBUTE;
@@ -56,34 +57,26 @@
try {
ClassLoader webappClassLoader = Thread.currentThread().getContextClassLoader();
ClassLoader bootClassLoader = utils.getBootClassLoader(webappClassLoader);
- WebappRuntime runtime = utils.getRuntime(bootClassLoader);
boolean online = Boolean.valueOf(utils.getInitParameter(ONLINE_PARAM, "true"));
+ URI componentId = new URI(servletContext.getInitParameter(COMPONENT_PARAM));
WebappRuntimeInfo info = new WebappRuntimeInfoImpl(servletContext,
- servletContext.getResource("/WEB-INF/tuscany/"),
- online);
+ servletContext.getResource("/WEB-INF/tuscany/"),
+ online);
URL systemScdl = utils.getSystemScdl(bootClassLoader);
- URL applicationScdl = utils.getApplicationScdl(webappClassLoader);
- String name = utils.getApplicationName();
+ WebappRuntime runtime = utils.getRuntime(bootClassLoader);
runtime.setServletContext(servletContext);
runtime.setRuntimeInfo(info);
runtime.setHostClassLoader(webappClassLoader);
runtime.setSystemScdl(systemScdl);
-/*
- runtime.setApplicationName(name);
- runtime.setApplicationScdl(applicationScdl);
-*/
runtime.initialize();
-
servletContext.setAttribute(RUNTIME_ATTRIBUTE, runtime);
+
+ runtime.bindComponent(componentId);
} catch (TuscanyRuntimeException e) {
servletContext.log(e.getMessage(), e);
e.printStackTrace();
throw e;
- } catch (MalformedURLException e) {
- servletContext.log(e.getMessage(), e);
- e.printStackTrace();
- throw new TuscanyInitException(e);
} catch (Throwable e) {
servletContext.log(e.getMessage(), e);
e.printStackTrace();
@@ -105,7 +98,7 @@
try {
runtime.destroy();
} catch (ShutdownException e) {
- servletContext.log("Error destorying runtume", e);
+ servletContext.log("Error destroying runtume", e);
}
}
Modified: incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java?view=diff&rev=505646&r1=505645&r2=505646
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java Fri Feb 9 23:13:45 2007
@@ -18,6 +18,7 @@
*/
package org.apache.tuscany.runtime.webapp;
+import java.net.URI;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSessionListener;
@@ -48,6 +49,13 @@
* @param servletContext the ServletContext associated with this runtime
*/
void setServletContext(ServletContext servletContext);
+
+ /**
+ * Bind the parameters, references and context for a component to the ServletContext.
+ *
+ * @param componentId the id of the component to bind
+ */
+ void bindComponent(URI componentId);
/**
* Returns the request injector for the runtime
Modified: incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java?view=diff&rev=505646&r1=505645&r2=505646
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/webapp-api/src/test/java/org/apache/tuscany/runtime/webapp/TuscanyContextListenerTestCase.java Fri Feb 9 23:13:45 2007
@@ -18,15 +18,19 @@
*/
package org.apache.tuscany.runtime.webapp;
-import java.net.URL;
import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URI;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import junit.framework.TestCase;
-import static org.easymock.classextension.EasyMock.*;
-
-import org.apache.tuscany.host.MonitorFactory;
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.easymock.classextension.EasyMock.eq;
+import static org.easymock.classextension.EasyMock.expect;
+import static org.easymock.classextension.EasyMock.isA;
+import static org.easymock.classextension.EasyMock.replay;
+import static org.easymock.classextension.EasyMock.verify;
/**
* @version $Rev$ $Date$
@@ -37,10 +41,8 @@
private ClassLoader cl;
private ClassLoader bootClassLoader;
private URL systemUrl;
- private URL applicationUrl;
- private Method getUtilsMethod;
- private MonitorFactory monitorFactory;
private WebappUtil utils;
+ private URI componentId;
public void testInitializationUsingDefaults() throws Exception {
ServletContextEvent event = createMock(ServletContextEvent.class);
@@ -52,11 +54,10 @@
expect(utils.getInitParameter("tuscany.online", "true")).andReturn("true");
expect(utils.getRuntime(bootClassLoader)).andReturn(runtime);
expect(utils.getSystemScdl(bootClassLoader)).andReturn(systemUrl);
- expect(utils.getApplicationScdl(cl)).andReturn(applicationUrl);
- expect(utils.getApplicationName()).andReturn("application");
replay(utils);
expect(context.getResource("/WEB-INF/tuscany/")).andReturn(null);
+ expect(context.getInitParameter("tuscany.component")).andReturn(componentId.toString());
context.setAttribute(eq(Constants.RUNTIME_ATTRIBUTE), isA(WebappRuntime.class));
replay(context);
replay(cl);
@@ -67,11 +68,8 @@
runtime.setRuntimeInfo(isA(WebappRuntimeInfo.class));
runtime.setHostClassLoader(cl);
runtime.setSystemScdl(systemUrl);
-/*
- runtime.setApplicationName("application");
- runtime.setApplicationScdl(applicationUrl);
-*/
runtime.initialize();
+ runtime.bindComponent(componentId);
replay(runtime);
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
@@ -82,6 +80,7 @@
Thread.currentThread().setContextClassLoader(oldCl);
}
verify(event);
+ verify(utils);
verify(context);
verify(listener);
verify(cl);
@@ -91,14 +90,13 @@
protected void setUp() throws Exception {
super.setUp();
- getUtilsMethod = TuscanyContextListener.class.getDeclaredMethod("getUtils", ServletContext.class);
+ Method getUtilsMethod = TuscanyContextListener.class.getDeclaredMethod("getUtils", ServletContext.class);
utils = createMock(WebappUtil.class);
listener = createMock(TuscanyContextListener.class, new Method[]{getUtilsMethod});
context = createMock(ServletContext.class);
cl = createMock(ClassLoader.class);
bootClassLoader = createMock(ClassLoader.class);
systemUrl = new URL("file:/system.scdl");
- applicationUrl = new URL("file:/application.scdl");
- monitorFactory = createMock(MonitorFactory.class);
+ componentId = URI.create("http://example.com/aComponent");
}
}
Modified: incubator/tuscany/java/sca/runtime/webapp/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java?view=diff&rev=505646&r1=505645&r2=505646
==============================================================================
--- incubator/tuscany/java/sca/runtime/webapp/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java (original)
+++ incubator/tuscany/java/sca/runtime/webapp/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java Fri Feb 9 23:13:45 2007
@@ -18,6 +18,7 @@
*/
package org.apache.tuscany.runtime.webapp;
+import java.net.URI;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -120,6 +121,9 @@
application = null;
}
super.destroy();
+ }
+
+ public void bindComponent(URI componentId) {
}
public ServletRequestInjector getRequestInjector() {
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org