You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/06/29 09:53:56 UTC
svn commit: r417955 - in
/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon:
ProcessingUtil.java core/CoreUtil.java servlet/CocoonServletListener.java
servlet/RequestProcessor.java servlet/SimpleServlet.java
Author: cziegeler
Date: Thu Jun 29 00:53:56 2006
New Revision: 417955
URL: http://svn.apache.org/viewvc?rev=417955&view=rev
Log:
Further cleanup of CoreUtil and start of new way of starting up Cocoon by using a servlet listener which sets up
the Cocoon container and puts it into the servlet context. This allows to run Cocoon next to other frameworks.
Added:
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServletListener.java (with props)
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java (with props)
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/SimpleServlet.java (with props)
Modified:
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/ProcessingUtil.java
cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/ProcessingUtil.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/ProcessingUtil.java?rev=417955&r1=417954&r2=417955&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/ProcessingUtil.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/ProcessingUtil.java Thu Jun 29 00:53:56 2006
@@ -34,6 +34,9 @@
*/
public class ProcessingUtil {
+ /** Servlet context attribute name for getting the root container. */
+ public static final String CONTAINER_CONTEXT_ATTR_NAME = "org.apache.cocoon.Cocoon";
+
/** Bean name for the Avalon context. */
public static final String CONTEXT_ROLE = "org.apache.avalon.framework.context.Context";
Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java?rev=417955&r1=417954&r2=417955&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/CoreUtil.java Thu Jun 29 00:53:56 2006
@@ -524,9 +524,6 @@
public synchronized Processor createProcessor()
throws Exception {
try {
- if (this.log.isInfoEnabled()) {
- this.log.info("Reloading from: " + this.settings.getConfiguration());
- }
Processor p = (Processor)this.container.getBean("org.apache.cocoon.Cocoon");
this.processor = p;
Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServletListener.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServletListener.java?rev=417955&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServletListener.java (added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServletListener.java Thu Jun 29 00:53:56 2006
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.cocoon.servlet;
+
+import java.io.File;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.avalon.framework.context.DefaultContext;
+import org.apache.cocoon.Constants;
+import org.apache.cocoon.ProcessingUtil;
+import org.apache.cocoon.core.BootstrapEnvironment;
+import org.apache.cocoon.core.CoreUtil;
+import org.apache.cocoon.core.MutableSettings;
+import org.apache.cocoon.environment.http.HttpContext;
+import org.apache.commons.lang.exception.ExceptionUtils;
+
+/**
+ * The Cocoon Servlet listener starts and stops Cocoon and makes
+ * the Cocoon Core Container available via the servlet context.
+ *
+ * @version $Id$
+ */
+public class CocoonServletListener implements ServletContextListener {
+
+ /** CoreUtil */
+ protected CoreUtil coreUtil;
+
+ /**
+ * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
+ */
+ public void contextDestroyed(ServletContextEvent event) {
+ final ServletContext servletContext = event.getServletContext();
+ servletContext.log("Destroying Apache Cocoon Core Container.");
+ if (this.coreUtil != null) {
+ this.coreUtil.destroy();
+ this.coreUtil = null;
+ }
+ }
+
+ /**
+ * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
+ */
+ public void contextInitialized(ServletContextEvent event) {
+ final ServletContext servletContext = event.getServletContext();
+ servletContext.log("Initializing Apache Cocoon " + Constants.VERSION);
+
+ // initialize settings
+ ServletBootstrapEnvironment env = new ServletBootstrapEnvironment(servletContext);
+
+ try {
+ this.coreUtil = new CoreUtil(new HttpContext(servletContext), env);
+ this.coreUtil.createProcessor();
+ } catch (Exception e) {
+ servletContext.log("Error during initializing Apache Cocoon " + Constants.VERSION + " - aborting.");
+ servletContext.log(e.getMessage());
+ servletContext.log(ExceptionUtils.getFullStackTrace(e));
+ throw new RuntimeException(e);
+ }
+
+ servletContext.setAttribute(ProcessingUtil.CONTAINER_CONTEXT_ATTR_NAME, this.coreUtil.getContainer());
+ servletContext.log("Apache Cocoon " + Constants.VERSION + " is up and ready.");
+ }
+
+ protected static final class ServletBootstrapEnvironment
+ implements BootstrapEnvironment {
+
+ private final ServletContext context;
+
+ public ServletBootstrapEnvironment(ServletContext context) {
+ this.context = context;
+ }
+
+ /**
+ * @see org.apache.cocoon.core.BootstrapEnvironment#configure(org.apache.cocoon.core.MutableSettings)
+ */
+ public void configure(MutableSettings settings) {
+ // fill from the servlet parameters
+ SettingsHelper.fill(settings, this.context);
+ if ( settings.getWorkDirectory() == null ) {
+ final File workDir = (File)context.getAttribute("javax.servlet.context.tempdir");
+ settings.setWorkDirectory(workDir.getAbsolutePath());
+ }
+ if ( settings.getLoggingConfiguration() == null ) {
+ settings.setLoggingConfiguration("/WEB-INF/log4j.xconf");
+ }
+ }
+
+ /**
+ * @see org.apache.cocoon.core.BootstrapEnvironment#configure(org.apache.avalon.framework.context.DefaultContext)
+ */
+ public void configure(DefaultContext context) {
+ // nothing to do
+ }
+ }
+}
Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServletListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/CocoonServletListener.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java?rev=417955&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java (added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java Thu Jun 29 00:53:56 2006
@@ -0,0 +1,438 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.cocoon.servlet;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.ConnectionResetException;
+import org.apache.cocoon.Constants;
+import org.apache.cocoon.ProcessingUtil;
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.ResourceNotFoundException;
+import org.apache.cocoon.components.notification.DefaultNotifyingBuilder;
+import org.apache.cocoon.components.notification.Notifier;
+import org.apache.cocoon.components.notification.Notifying;
+import org.apache.cocoon.core.Settings;
+import org.apache.cocoon.environment.Context;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.http.HttpContext;
+import org.apache.cocoon.environment.http.HttpEnvironment;
+import org.apache.cocoon.environment.internal.EnvironmentHelper;
+import org.apache.cocoon.servlet.multipart.MultipartHttpServletRequest;
+import org.apache.cocoon.servlet.multipart.RequestFactory;
+import org.apache.commons.lang.time.StopWatch;
+import org.springframework.beans.factory.BeanFactory;
+
+/**
+ * This is the entry point for Cocoon execution as an HTTP Servlet.
+ * TODO - Move container encoding to properties
+ * - Remove support for settings config from web.xml
+ *
+ * @version $Id$
+ */
+public class RequestProcessor {
+
+ // Processing time message
+ protected static final String PROCESSED_BY = "Processed by "
+ + Constants.COMPLETE_NAME + " in ";
+
+ // Used by "show-time"
+ static final float SECOND = 1000;
+ static final float MINUTE = 60 * SECOND;
+ static final float HOUR = 60 * MINUTE;
+
+ /** The servlet context. */
+ protected final ServletContext servletContext;
+
+ protected final String containerEncoding;
+
+ /**
+ * The RequestFactory is responsible for wrapping multipart-encoded
+ * forms and for handing the file payload of incoming requests
+ */
+ protected final RequestFactory requestFactory;
+
+ /** The logger. */
+ protected final Logger log;
+
+ protected final Context environmentContext;
+
+ /** Root Cocoon Bean Factory. */
+ protected final BeanFactory cocoonBeanFactory;
+
+ /** The root settings. */
+ protected final Settings settings;
+
+ /** The root processor. */
+ protected final Processor rootProcessor;
+
+ public RequestProcessor(ServletContext servletContext) {
+ this.servletContext = servletContext;
+ this.cocoonBeanFactory = (BeanFactory) servletContext.getAttribute(ProcessingUtil.CONTAINER_CONTEXT_ATTR_NAME);
+ this.settings = (Settings) this.cocoonBeanFactory.getBean(ProcessingUtil.SETTINGS_ROLE);
+ final String encoding = this.servletContext.getInitParameter("container-encoding");
+ if ( encoding == null ) {
+ this.containerEncoding = "ISO-8859-1";
+ } else {
+ this.containerEncoding = encoding;
+ }
+ this.requestFactory = new RequestFactory(this.settings.isAutosaveUploads(),
+ new File(this.settings.getUploadDirectory()),
+ this.settings.isAllowOverwrite(),
+ this.settings.isSilentlyRename(),
+ this.settings.getMaxUploadSize(),
+ this.containerEncoding);
+ this.log = (Logger) this.cocoonBeanFactory.getBean(ProcessingUtil.LOGGER_ROLE);
+ this.rootProcessor = (Processor)this.cocoonBeanFactory.getBean(Processor.ROLE);
+ this.environmentContext = new HttpContext(this.servletContext);
+ }
+
+ /**
+ * Process the specified <code>HttpServletRequest</code> producing output
+ * on the specified <code>HttpServletResponse</code>.
+ */
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ throws ServletException, IOException {
+ // used for timing the processing
+ StopWatch stopWatch = new StopWatch();
+ stopWatch.start();
+
+ // add the cocoon header timestamp
+ if (this.settings.isShowVersion()) {
+ res.addHeader("X-Cocoon-Version", Constants.VERSION);
+ }
+
+ // get the request (wrapped if contains multipart-form data)
+ HttpServletRequest request;
+ try{
+ if (this.settings.isEnableUploads()) {
+ request = requestFactory.getServletRequest(req);
+ } else {
+ request = req;
+ }
+ } catch (Exception e) {
+ if (getLogger().isErrorEnabled()) {
+ getLogger().error("Problem with Cocoon servlet", e);
+ }
+
+ manageException(req, res, null, null,
+ HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ "Problem in creating the Request", null, null, e);
+ return;
+ }
+
+ // We got it... Process the request
+ String uri = request.getServletPath();
+ if (uri == null) {
+ uri = "";
+ }
+ String pathInfo = request.getPathInfo();
+ if (pathInfo != null) {
+ // VG: WebLogic fix: Both uri and pathInfo starts with '/'
+ // This problem exists only in WL6.1sp2, not in WL6.0sp2 or WL7.0b.
+ if (uri.length() > 0 && uri.charAt(0) == '/') {
+ uri = uri.substring(1);
+ }
+ uri += pathInfo;
+ }
+
+ if (uri.length() == 0) {
+ /* empty relative URI
+ -> HTTP-redirect from /cocoon to /cocoon/ to avoid
+ StringIndexOutOfBoundsException when calling
+ "".charAt(0)
+ else process URI normally
+ */
+ String prefix = request.getRequestURI();
+ if (prefix == null) {
+ prefix = "";
+ }
+
+ res.sendRedirect(res.encodeRedirectURL(prefix + "/"));
+ return;
+ }
+
+ String contentType = null;
+
+ Environment env;
+ try{
+ if (uri.charAt(0) == '/') {
+ uri = uri.substring(1);
+ }
+ // Pass uri into environment without URLDecoding, as it is already decoded.
+ env = getEnvironment(uri, request, res);
+ } catch (Exception e) {
+ if (getLogger().isErrorEnabled()) {
+ getLogger().error("Problem with Cocoon servlet", e);
+ }
+
+ manageException(request, res, null, uri,
+ HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ "Problem in creating the Environment", null, null, e);
+ return;
+ }
+
+ try {
+ try {
+ if (this.process(env)) {
+ contentType = env.getContentType();
+ } else {
+ // We reach this when there is nothing in the processing change that matches
+ // the request. For example, no matcher matches.
+ getLogger().fatalError("The Cocoon engine failed to process the request.");
+ manageException(request, res, env, uri,
+ HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ "Request Processing Failed",
+ "Cocoon engine failed in process the request",
+ "The processing engine failed to process the request. This could be due to lack of matching or bugs in the pipeline engine.",
+ null);
+ return;
+ }
+ } catch (ResourceNotFoundException e) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().warn(e.getMessage(), e);
+ } else if (getLogger().isWarnEnabled()) {
+ getLogger().warn(e.getMessage());
+ }
+
+ manageException(request, res, env, uri,
+ HttpServletResponse.SC_NOT_FOUND,
+ "Resource Not Found",
+ "Resource Not Found",
+ "The requested resource \"" + request.getRequestURI() + "\" could not be found",
+ e);
+ return;
+
+ } catch (ConnectionResetException e) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug(e.toString(), e);
+ } else if (getLogger().isWarnEnabled()) {
+ getLogger().warn(e.toString());
+ }
+
+ } catch (IOException e) {
+ // Tomcat5 wraps SocketException into ClientAbortException which extends IOException.
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug(e.toString(), e);
+ } else if (getLogger().isWarnEnabled()) {
+ getLogger().warn(e.toString());
+ }
+
+ } catch (Exception e) {
+ if (getLogger().isErrorEnabled()) {
+ getLogger().error("Internal Cocoon Problem", e);
+ }
+
+ manageException(request, res, env, uri,
+ HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+ "Internal Server Error", null, null, e);
+ return;
+ }
+
+ stopWatch.stop();
+ String timeString = null;
+ if (getLogger().isInfoEnabled()) {
+ timeString = processTime(stopWatch.getTime());
+ getLogger().info("'" + uri + "' " + timeString);
+ }
+
+ if (contentType != null && contentType.equals("text/html")) {
+ String showTime = request.getParameter(Constants.SHOWTIME_PARAM);
+ boolean show = this.settings.isShowTime();
+ if (showTime != null) {
+ show = !showTime.equalsIgnoreCase("no");
+ }
+ if (show) {
+ if ( timeString == null ) {
+ timeString = processTime(stopWatch.getTime());
+ }
+ boolean hide = this.settings.isHideShowTime();
+ if (showTime != null) {
+ hide = showTime.equalsIgnoreCase("hide");
+ }
+ ServletOutputStream out = res.getOutputStream();
+ out.print((hide) ? "<!-- " : "<p>");
+ out.print(timeString);
+ out.println((hide) ? " -->" : "</p>");
+ }
+ }
+ } finally {
+ try {
+ if (request instanceof MultipartHttpServletRequest) {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Deleting uploaded file(s).");
+ }
+ ((MultipartHttpServletRequest) request).cleanup();
+ }
+ } catch (IOException e) {
+ getLogger().error("Cocoon got an Exception while trying to cleanup the uploaded files.", e);
+ }
+
+ /*
+ * Servlet Specification 2.2, 6.5 Closure of Response Object:
+ *
+ * A number of events can indicate that the servlet has provided all of the
+ * content to satisfy the request and that the response object can be
+ * considered to be closed. The events are:
+ * o The termination of the service method of the servlet.
+ * o When the amount of content specified in the setContentLength method
+ * of the response has been written to the response.
+ * o The sendError method is called.
+ * o The sendRedirect method is called.
+ * When a response is closed, all content in the response buffer, if any remains,
+ * must be immediately flushed to the client.
+ *
+ * Due to the above, out.flush() and out.close() are not necessary, and sometimes
+ * (if sendError or sendRedirect were used) request may be already closed.
+ */
+ }
+ }
+
+ protected void manageException(HttpServletRequest req, HttpServletResponse res, Environment env,
+ String uri, int errorStatus,
+ String title, String message, String description,
+ Exception e)
+ throws IOException {
+ if (this.settings.isManageExceptions()) {
+ if (env != null) {
+ env.tryResetResponse();
+ } else {
+ res.reset();
+ }
+
+ String type = Notifying.FATAL_NOTIFICATION;
+ HashMap extraDescriptions = null;
+
+ if (errorStatus == HttpServletResponse.SC_NOT_FOUND) {
+ type = "resource-not-found";
+ // Do not show the exception stacktrace for such common errors.
+ e = null;
+ } else {
+ extraDescriptions = new HashMap(2);
+ extraDescriptions.put(Notifying.EXTRA_REQUESTURI, req.getRequestURI());
+ if (uri != null) {
+ extraDescriptions.put("Request URI", uri);
+ }
+
+ // Do not show exception stack trace when log level is WARN or above. Show only message.
+ if (!getLogger().isInfoEnabled()) {
+ Throwable t = DefaultNotifyingBuilder.getRootCause(e);
+ if (t != null) extraDescriptions.put(Notifying.EXTRA_CAUSE, t.getMessage());
+ e = null;
+ }
+ }
+
+ Notifying n = new DefaultNotifyingBuilder().build(this,
+ e,
+ type,
+ title,
+ "Cocoon Servlet",
+ message,
+ description,
+ extraDescriptions);
+
+ res.setContentType("text/html");
+ res.setStatus(errorStatus);
+ Notifier.notify(n, res.getOutputStream(), "text/html");
+ } else {
+ res.sendError(errorStatus, title);
+ res.flushBuffer();
+ }
+ }
+
+ /**
+ * Create the environment for the request
+ */
+ protected Environment getEnvironment(String uri,
+ HttpServletRequest req,
+ HttpServletResponse res)
+ throws Exception {
+ HttpEnvironment env;
+
+ String formEncoding = req.getParameter("cocoon-form-encoding");
+ if (formEncoding == null) {
+ formEncoding = this.settings.getFormEncoding();
+ }
+ env = new HttpEnvironment(uri,
+ req,
+ res,
+ this.servletContext,
+ this.environmentContext,
+ this.containerEncoding,
+ formEncoding);
+ env.enableLogging(getLogger());
+ return env;
+ }
+
+ private String processTime(long time) {
+ StringBuffer out = new StringBuffer(PROCESSED_BY);
+ if (time <= SECOND) {
+ out.append(time);
+ out.append(" milliseconds.");
+ } else if (time <= MINUTE) {
+ out.append(time / SECOND);
+ out.append(" seconds.");
+ } else if (time <= HOUR) {
+ out.append(time / MINUTE);
+ out.append(" minutes.");
+ } else {
+ out.append(time / HOUR);
+ out.append(" hours.");
+ }
+ return out.toString();
+ }
+
+ protected Logger getLogger() {
+ return this.log;
+ }
+
+ /**
+ * @see org.apache.cocoon.Processor#process(org.apache.cocoon.environment.Environment)
+ */
+ protected boolean process(Environment environment) throws Exception {
+ environment.startingProcessing();
+ final int environmentDepth = EnvironmentHelper.markEnvironment();
+ try {
+ boolean result;
+
+ result = this.rootProcessor.process(environment);
+
+ // commit response on success
+ environment.commitResponse();
+
+ return result;
+ } catch (Exception any) {
+ // reset response on error
+ environment.tryResetResponse();
+ throw any;
+ } finally {
+ EnvironmentHelper.leaveProcessor();
+ environment.finishingProcessing();
+ ProcessingUtil.cleanup();
+
+ EnvironmentHelper.checkEnvironment(environmentDepth, this.getLogger());
+ }
+ }
+}
Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/RequestProcessor.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/SimpleServlet.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/SimpleServlet.java?rev=417955&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/SimpleServlet.java (added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/SimpleServlet.java Thu Jun 29 00:53:56 2006
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.cocoon.servlet;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * This is the entry point for Cocoon execution as an HTTP Servlet.
+ *
+ * @version $Id$
+ */
+public class SimpleServlet extends HttpServlet {
+
+ /** The Cocoon request processor. */
+ protected RequestProcessor processor;
+
+ public void service(HttpServletRequest req, HttpServletResponse res)
+ throws ServletException, IOException {
+ this.processor.service(req, res);
+ }
+
+ /**
+ * @see javax.servlet.GenericServlet#init()
+ */
+ public void init() throws ServletException {
+ super.init();
+ this.processor = new RequestProcessor(this.getServletContext());
+ }
+}
Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/SimpleServlet.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/servlet/SimpleServlet.java
------------------------------------------------------------------------------
svn:keywords = Id