Author: jmarino
Date: Sat Dec 9 10:35:18 2006
New Revision: 485026
URL: http://svn.apache.org/viewvc?view=rev&rev=485026
Log:
cleanup webapp integration
Added:
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/InvalidResourcePath.java
(with props)
Modified:
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebResourceScanExtender.java
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyFilter.java
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfo.java
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtil.java
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtilImpl.java
Modified:
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java?view=diff&rev=485026&r1=485025&r2=485026
==============================================================================
---
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java
(original)
+++
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/ServletHostImpl.java
Sat Dec 9 10:35:18 2006
@@ -51,29 +51,26 @@
*/
@Service(ServletHost.class)
public class ServletHostImpl implements ServletHost, ServletRequestInjector,
EventPublisher {
-
protected Map<String, Servlet> servlets;
+ protected ScopeRegistry registry;
+ protected WorkContext workContext;
public ServletHostImpl() {
this.servlets = new HashMap<String, Servlet>();
}
- @Init(eager = true)
- public void init() {
- }
-
- protected ScopeRegistry registry = null;
-
@Autowire(required = false)
public void setSessionScopeContainer(ScopeRegistry registry) {
this.registry = registry;
}
- WorkContext workContext = null;
-
@Autowire(required = false)
public void setWorkContext(WorkContext workContext) {
this.workContext = workContext;
+ }
+
+ @Init(eager = true)
+ public void init() {
}
public void service(ServletRequest req, ServletResponse resp) throws
ServletException, IOException {
Modified:
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebResourceScanExtender.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebResourceScanExtender.java?view=diff&rev=485026&r1=485025&r2=485026
==============================================================================
---
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebResourceScanExtender.java
(original)
+++
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebResourceScanExtender.java
Sat Dec 9 10:35:18 2006
@@ -18,18 +18,17 @@
*/
package org.apache.tuscany.runtime.webapp;
-import java.net.URL;
import java.net.MalformedURLException;
+import java.net.URL;
import java.util.Set;
-
import javax.servlet.ServletContext;
import org.osoa.sca.annotations.Init;
import org.osoa.sca.annotations.Property;
-import org.apache.tuscany.core.services.extension.AbstractExtensionDeployer;
-import org.apache.tuscany.runtime.webapp.WebappRuntimeInfo;
import org.apache.tuscany.spi.annotation.Autowire;
+
+import org.apache.tuscany.core.services.extension.AbstractExtensionDeployer;
/**
* @version $Rev$ $Date$
Modified:
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java?view=diff&rev=485026&r1=485025&r2=485026
==============================================================================
---
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
(original)
+++
incubator/tuscany/java/sca/runtime/webapp-host/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeImpl.java
Sat Dec 9 10:35:18 2006
@@ -18,10 +18,7 @@
*/
package org.apache.tuscany.runtime.webapp;
-import java.util.HashMap;
-import java.util.Map;
import java.util.StringTokenizer;
-import java.util.logging.Level;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpSessionEvent;
import javax.xml.stream.XMLInputFactory;
@@ -44,7 +41,6 @@
import org.apache.tuscany.core.component.event.RequestEnd;
import org.apache.tuscany.core.component.event.RequestStart;
import org.apache.tuscany.core.launcher.CompositeContextImpl;
-import org.apache.tuscany.core.monitor.MonitorFactoryUtil;
import org.apache.tuscany.core.runtime.AbstractRuntime;
import org.apache.tuscany.host.MonitorFactory;
import org.apache.tuscany.host.RuntimeInfo;
@@ -148,14 +144,14 @@
String path =
servletContext.getInitParameter(Constants.CURRENT_COMPOSITE_PATH_PARAM);
if (path != null) {
StringTokenizer tokenizer = new StringTokenizer(path, "/");
- while(tokenizer.hasMoreTokens()) {
+ while (tokenizer.hasMoreTokens()) {
SCAObject o = current.getChild(tokenizer.nextToken());
- if (!(o instanceof CompositeComponent)){
+ if (!(o instanceof CompositeComponent)) {
ServletLauncherInitException e = new
ServletLauncherInitException("Invalid context path");
e.setIdentifier(path);
throw e;
}
- current = (CompositeComponent)o;
+ current = (CompositeComponent) o;
}
}
context = new CompositeContextImpl(current);
@@ -230,22 +226,22 @@
*
* @param loggingLevel
*/
- private MonitorFactory getMonitorFactory(String loggingLevel) {
- String factoryName =
"org.apache.tuscany.core.monitor.NullMonitorFactory";
- Map<String, Object> props = null;
- if (loggingLevel != null) {
- factoryName =
"org.apache.tuscany.core.monitor.JavaLoggingMonitorFactory";
- props = new HashMap<String, Object>();
- Level level = Level.SEVERE;
- try {
- level = Level.parse(loggingLevel);
- } catch (IllegalArgumentException e) {
- // ignore bad loggingLevel
- }
- props.put("bundleName", "SystemMessages");
- props.put("defaultLevel", level);
- }
-
- return MonitorFactoryUtil.createMonitorFactory(factoryName, props);
- }
+// private MonitorFactory getMonitorFactory(String loggingLevel) {
+// String factoryName =
"org.apache.tuscany.core.monitor.NullMonitorFactory";
+// Map<String, Object> props = null;
+// if (loggingLevel != null) {
+// factoryName =
"org.apache.tuscany.core.monitor.JavaLoggingMonitorFactory";
+// props = new HashMap<String, Object>();
+// Level level = Level.SEVERE;
+// try {
+// level = Level.parse(loggingLevel);
+// } catch (IllegalArgumentException e) {
+// // ignore bad loggingLevel
+// }
+// props.put("bundleName", "SystemMessages");
+// props.put("defaultLevel", level);
+// }
+//
+// return MonitorFactoryUtil.createMonitorFactory(factoryName, props);
+// }
}
Added:
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/InvalidResourcePath.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/InvalidResourcePath.java?view=auto&rev=485026
==============================================================================
---
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/InvalidResourcePath.java
(added)
+++
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/InvalidResourcePath.java
Sat Dec 9 10:35:18 2006
@@ -0,0 +1,39 @@
+/*
+ * 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.runtime.webapp;
+
+/**
+ * Denotes an invalid or non-existing path for a resource required by the
runtime bootstrap
+ *
+ * @version $Rev$ $Date$
+ */
+public class InvalidResourcePath extends TuscanyInitException {
+ public InvalidResourcePath(String string) {
+
+ super(string);
+ }
+
+ public InvalidResourcePath(String string, Throwable throwable) {
+ super(string, throwable);
+ }
+
+ public InvalidResourcePath(Throwable throwable) {
+ super(throwable);
+ }
+}
Propchange:
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/InvalidResourcePath.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/InvalidResourcePath.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java?view=diff&rev=485026&r1=485025&r2=485026
==============================================================================
---
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java
(original)
+++
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyContextListener.java
Sat Dec 9 10:35:18 2006
@@ -76,17 +76,14 @@
servletContext.setAttribute(RUNTIME_ATTRIBUTE, runtime);
} catch (TuscanyRuntimeException e) {
servletContext.log(e.getMessage(), e);
- // TODO: Dump the stack trace so that we can see from the Tomcat
console
e.printStackTrace();
throw e;
} catch (MalformedURLException e) {
servletContext.log(e.getMessage(), e);
- // TODO: Dump the stack trace so that we can see from the Tomcat
console
e.printStackTrace();
throw new TuscanyInitException(e);
} catch (Throwable e) {
servletContext.log(e.getMessage(), e);
- // TODO: Dump the stack trace so that we can see from the Tomcat
console
e.printStackTrace();
throw new TuscanyInitException(e);
}
@@ -102,7 +99,6 @@
if (runtime == null) {
return;
}
-
servletContext.removeAttribute(RUNTIME_ATTRIBUTE);
runtime.destroy();
}
Modified:
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyFilter.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyFilter.java?view=diff&rev=485026&r1=485025&r2=485026
==============================================================================
---
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyFilter.java
(original)
+++
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyFilter.java
Sat Dec 9 10:35:18 2006
@@ -38,7 +38,6 @@
* @version $Rev$ $Date$
*/
public class TuscanyFilter implements Filter {
-
private SCA context;
private WebappRuntime runtime;
Modified:
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java?view=diff&rev=485026&r1=485025&r2=485026
==============================================================================
---
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java
(original)
+++
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/TuscanyServlet.java
Sat Dec 9 10:35:18 2006
@@ -36,7 +36,6 @@
* TODO a better URL mapping scheme out to be implemented that corresponds to
the SCA specification
*/
public class TuscanyServlet extends HttpServlet {
-
private static final long serialVersionUID = 1L;
private ServletRequestInjector requestInjector;
Modified:
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java?view=diff&rev=485026&r1=485025&r2=485026
==============================================================================
---
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java
(original)
+++
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntime.java
Sat Dec 9 10:35:18 2006
@@ -64,15 +64,13 @@
void stopRequest();
/**
- * httpRequestStarted request has been started with sessid id
- * @param session id.
+ * Request has been started with the given session id
*/
void httpRequestStarted(Object id);
-
+
/**
- * httpRequestEnded request has been ended with sessid id
- * @param session id.
+ * Request has been ended with the given session id
*/
-
+
void httpRequestEnded(Object id);
}
Modified:
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfo.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfo.java?view=diff&rev=485026&r1=485025&r2=485026
==============================================================================
---
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfo.java
(original)
+++
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappRuntimeInfo.java
Sat Dec 9 10:35:18 2006
@@ -26,7 +26,7 @@
* @version $Rev$ $Date$
*/
public interface WebappRuntimeInfo extends RuntimeInfo {
- static String COMPONENT_NAME = "WebappRuntimeInfo";
+ String COMPONENT_NAME = "WebappRuntimeInfo";
/**
* Returns the ServletContext associated with this webapp runtime.
*
Modified:
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtil.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtil.java?view=diff&rev=485026&r1=485025&r2=485026
==============================================================================
---
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtil.java
(original)
+++
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtil.java
Sat Dec 9 10:35:18 2006
@@ -25,25 +25,25 @@
* @version $Rev$ $Date$
*/
public interface WebappUtil {
+
+ String getApplicationName();
+
+ WebappRuntime getRuntime(ClassLoader bootClassLoader) throws
TuscanyInitException;
+
/**
- * Return the classloader that should be used to boot the Tuscany runtime.
- * This will be a child of the web application's ClassLoader.
+ * Return the classloader that should be used to boot the Tuscany runtime.
This will be a child of the web
+ * application's ClassLoader.
*
* @param webappClassLoader the web application's classloader
* @return a classloader that can be used to load the Tuscany runtime
classes
*/
- ClassLoader getBootClassLoader(ClassLoader webappClassLoader);
+ ClassLoader getBootClassLoader(ClassLoader webappClassLoader) throws
InvalidResourcePath;
- WebappRuntime getRuntime(ClassLoader bootClassLoader);
-
- URL getSystemScdl(ClassLoader bootClassLoader);
-
- String getApplicationName();
+ URL getSystemScdl(ClassLoader bootClassLoader) throws InvalidResourcePath;
- URL getApplicationScdl(ClassLoader bootClassLoader);
+ URL getApplicationScdl(ClassLoader bootClassLoader) throws
InvalidResourcePath;
- URL getScdlURL(String path, ClassLoader classLoader)
- throws MalformedURLException;
+ URL getScdlURL(String path, ClassLoader classLoader) throws
MalformedURLException;
/**
* Return a init parameter from the servlet context or provide a default.
Modified:
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtilImpl.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtilImpl.java?view=diff&rev=485026&r1=485025&r2=485026
==============================================================================
---
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtilImpl.java
(original)
+++
incubator/tuscany/java/sca/runtime/webapp/src/main/java/org/apache/tuscany/runtime/webapp/WebappUtilImpl.java
Sat Dec 9 10:35:18 2006
@@ -43,7 +43,20 @@
this.servletContext = servletContext;
}
- public ClassLoader getBootClassLoader(ClassLoader webappClassLoader) {
+ public WebappRuntime getRuntime(ClassLoader bootClassLoader) throws
TuscanyInitException {
+ try {
+ String className = getInitParameter(RUNTIME_PARAM,
RUNTIME_DEFAULT);
+ return (WebappRuntime)
bootClassLoader.loadClass(className).newInstance();
+ } catch (InstantiationException e) {
+ throw new TuscanyInitException(e);
+ } catch (IllegalAccessException e) {
+ throw new TuscanyInitException(e);
+ } catch (ClassNotFoundException e) {
+ throw new TuscanyInitException("Runtime Implementation not found",
e);
+ }
+ }
+
+ public ClassLoader getBootClassLoader(ClassLoader webappClassLoader)
throws InvalidResourcePath {
String bootDirName = getInitParameter(BOOTDIR_PARAM, BOOTDIR_DEFAULT);
Set paths = servletContext.getResourcePaths(bootDirName);
if (paths == null) {
@@ -56,32 +69,22 @@
try {
urls[i++] = servletContext.getResource((String) path);
} catch (MalformedURLException e) {
- throw new AssertionError("getResourcePaths returned an invalid
path: " + path);
+ InvalidResourcePath ie = new
InvalidResourcePath(APPLICATION_SCDL_PATH_PARAM, e);
+ ie.setIdentifier(path.toString());
+ throw ie;
}
}
return new URLClassLoader(urls, webappClassLoader);
}
- public WebappRuntime getRuntime(ClassLoader bootClassLoader) {
- try {
- String className = getInitParameter(RUNTIME_PARAM,
RUNTIME_DEFAULT);
- Class<?> runtimeClass = bootClassLoader.loadClass(className);
- return (WebappRuntime) runtimeClass.newInstance();
- } catch (InstantiationException e) {
- throw new TuscanyInitException("Invalid runtime class", e);
- } catch (IllegalAccessException e) {
- throw new TuscanyInitException("Invalid runtime class", e);
- } catch (ClassNotFoundException e) {
- throw new TuscanyInitException("Runtime Implementation not found",
e);
- }
- }
-
- public URL getSystemScdl(ClassLoader bootClassLoader) {
+ public URL getSystemScdl(ClassLoader bootClassLoader) throws
InvalidResourcePath {
String path = getInitParameter(SYSTEM_SCDL_PATH_PARAM,
SYSTEM_SCDL_PATH_DEFAULT);
try {
return getScdlURL(path, bootClassLoader);
} catch (MalformedURLException e) {
- throw new TuscanyInitException("Invalid resource path for " +
SYSTEM_SCDL_PATH_PARAM + " : " + path, e);
+ InvalidResourcePath ie = new
InvalidResourcePath(SYSTEM_SCDL_PATH_PARAM, e);
+ ie.setIdentifier(path);
+ throw ie;
}
}
@@ -93,18 +96,18 @@
return name;
}
- public URL getApplicationScdl(ClassLoader bootClassLoader) {
+ public URL getApplicationScdl(ClassLoader bootClassLoader) throws
InvalidResourcePath {
String path = getInitParameter(APPLICATION_SCDL_PATH_PARAM,
APPLICATION_SCDL_PATH_DEFAULT);
try {
return getScdlURL(path, bootClassLoader);
} catch (MalformedURLException e) {
- throw new TuscanyInitException("Invalid resource path for " +
APPLICATION_SCDL_PATH_PARAM + " : " + path,
- e);
+ InvalidResourcePath ie = new
InvalidResourcePath(APPLICATION_SCDL_PATH_PARAM, e);
+ ie.setIdentifier(path);
+ throw ie;
}
}
- public URL getScdlURL(String path, ClassLoader classLoader)
- throws MalformedURLException {
+ public URL getScdlURL(String path, ClassLoader classLoader) throws
MalformedURLException {
URL ret = null;
if (path.charAt(0) == '/') {
// user supplied an absolute path - look up as a webapp resource
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]