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 18:09:09 UTC
svn commit: r505725 - in /incubator/tuscany/java/sca/runtime/webapp:
webapp-api/src/main/java/org/apache/tuscany/runtime/webapp/Constants.java
webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
Author: jboynes
Date: Sat Feb 10 09:09:09 2007
New Revision: 505725
URL: http://svn.apache.org/viewvc?view=rev&rev=505725
Log:
have webapp runtime bind ComponentContext as a servlet context attribute
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-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=505725&r1=505724&r2=505725
==============================================================================
--- 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 Sat Feb 10 09:09:09 2007
@@ -18,6 +18,11 @@
static final String ONLINE_PARAM = "tuscany.online";
/**
+ * Name of the context attribute that contains the ComponentContext.
+ */
+ static final String CONTEXT_ATTRIBUTE = "tuscany.context";
+
+ /**
* Name of the parameter that defines the name of webapp resource containing bootstrap jars.
*/
static final String BOOTDIR_PARAM = "tuscany.bootDir";
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=505725&r1=505724&r2=505725
==============================================================================
--- 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 Sat Feb 10 09:09:09 2007
@@ -24,6 +24,8 @@
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
+import org.osoa.sca.ComponentContext;
+
import org.apache.tuscany.core.component.event.HttpRequestEnded;
import org.apache.tuscany.core.component.event.HttpRequestStart;
import org.apache.tuscany.core.component.event.HttpSessionEnd;
@@ -31,6 +33,8 @@
import org.apache.tuscany.core.runtime.AbstractRuntime;
import org.apache.tuscany.host.runtime.InitializationException;
import org.apache.tuscany.host.servlet.ServletRequestInjector;
+import static org.apache.tuscany.runtime.webapp.Constants.CONTEXT_ATTRIBUTE;
+import org.apache.tuscany.spi.component.Component;
import org.apache.tuscany.spi.component.ComponentRegistrationException;
import org.apache.tuscany.spi.component.CompositeComponent;
import org.apache.tuscany.spi.event.EventPublisher;
@@ -67,8 +71,8 @@
super.registerSystemComponents();
try {
getComponentManager().registerJavaObject(WebappRuntimeInfo.COMPONENT_NAME,
- WebappRuntimeInfo.class,
- (WebappRuntimeInfo) getRuntimeInfo());
+ WebappRuntimeInfo.class,
+ (WebappRuntimeInfo) getRuntimeInfo());
} catch (ComponentRegistrationException e) {
throw new InitializationException(e);
}
@@ -124,6 +128,12 @@
}
public void bindComponent(URI componentId) {
+ Component component = getComponentManager().getComponent(componentId);
+ if (component == null) {
+ throw new TuscanyInitException("No component found with id " + componentId, componentId.toString());
+ }
+ ComponentContext componentContext = component.getComponentContext();
+ servletContext.setAttribute(CONTEXT_ATTRIBUTE, componentContext);
}
public ServletRequestInjector getRequestInjector() {
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org