Author: remy.maucherat(a)jboss.com
Date: 2010-05-07 07:46:06 -0400 (Fri, 07 May 2010)
New Revision: 1466
Removed:
trunk/java/org/apache/tomcat/util/log/CaptureLog.java
trunk/java/org/apache/tomcat/util/log/SystemLogHandler.java
Modified:
trunk/java/org/apache/catalina/Context.java
trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
trunk/java/org/apache/catalina/core/StandardContext.java
trunk/java/org/apache/catalina/core/StandardWrapper.java
trunk/java/org/apache/catalina/core/StandardWrapperValve.java
trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
trunk/webapps/docs/changelog.xml
Log:
- Drop system streams capture.
Modified: trunk/java/org/apache/catalina/Context.java
===================================================================
--- trunk/java/org/apache/catalina/Context.java 2010-05-06 13:36:51 UTC (rev 1465)
+++ trunk/java/org/apache/catalina/Context.java 2010-05-07 11:46:06 UTC (rev 1466)
@@ -481,22 +481,6 @@
/**
- * Return the value of the swallowOutput flag.
- */
- public boolean getSwallowOutput();
-
-
- /**
- * Set the value of the swallowOutput flag. If set to true, the system.out
- * and system.err will be redirected to the logger during a servlet
- * execution.
- *
- * @param swallowOutput The new value
- */
- public void setSwallowOutput(boolean swallowOutput);
-
-
- /**
* Return the Java class name of the Wrapper implementation used
* for servlets registered in this Context.
*/
Modified: trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java 2010-05-06 13:36:51
UTC (rev 1465)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java 2010-05-07 11:46:06
UTC (rev 1466)
@@ -75,7 +75,6 @@
import org.apache.catalina.security.SecurityUtil;
import org.apache.catalina.util.Enumerator;
import org.apache.catalina.util.StringManager;
-import org.apache.tomcat.util.log.SystemLogHandler;
import org.apache.tomcat.util.modeler.Registry;
@@ -445,20 +444,7 @@
filterInstance = null;
}
- if (context instanceof StandardContext &&
- context.getSwallowOutput()) {
- try {
- SystemLogHandler.startCapture();
- filter.init(this);
- } finally {
- String log = SystemLogHandler.stopCapture();
- if (log != null && log.length() > 0) {
- getServletContext().log(log);
- }
- }
- } else {
- filter.init(this);
- }
+ filter.init(this);
// Expose filter via JMX
registerJMX();
Modified: trunk/java/org/apache/catalina/core/StandardContext.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardContext.java 2010-05-06 13:36:51 UTC (rev
1465)
+++ trunk/java/org/apache/catalina/core/StandardContext.java 2010-05-07 11:46:06 UTC (rev
1466)
@@ -533,13 +533,6 @@
/**
- * Set flag to true to cause the system.out and system.err to be redirected
- * to the logger when executing a servlet.
- */
- protected boolean swallowOutput = false;
-
-
- /**
* The JSP tag libraries for this web application, keyed by URI
*/
protected HashMap<String, String> taglibs = new HashMap<String,
String>();
@@ -1532,28 +1525,6 @@
/**
- * Return the value of the swallowOutput flag.
- */
- public boolean getSwallowOutput() {
- return (this.swallowOutput);
- }
-
-
- /**
- * Set the value of the swallowOutput flag. If set to true, the system.out
- * and system.err will be redirected to the logger during a servlet
- * execution.
- *
- * @param swallowOutput The new value
- */
- public void setSwallowOutput(boolean swallowOutput) {
- boolean oldSwallowOutput = this.swallowOutput;
- this.swallowOutput = swallowOutput;
- support.firePropertyChange("swallowOutput", oldSwallowOutput,
this.swallowOutput);
- }
-
-
- /**
* Return the value of the unloadDelay flag.
*/
public long getUnloadDelay() {
Modified: trunk/java/org/apache/catalina/core/StandardWrapper.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapper.java 2010-05-06 13:36:51 UTC (rev
1465)
+++ trunk/java/org/apache/catalina/core/StandardWrapper.java 2010-05-07 11:46:06 UTC (rev
1466)
@@ -62,7 +62,6 @@
import org.apache.catalina.util.InstanceSupport;
import org.apache.tomcat.InstanceManager;
import org.apache.tomcat.PeriodicEventListener;
-import org.apache.tomcat.util.log.SystemLogHandler;
import org.apache.tomcat.util.modeler.Registry;
/**
@@ -289,11 +288,6 @@
protected ObjectName jspMonitorON;
- /**
- * Should we swallow System.out
- */
- protected boolean swallowOutput = false;
-
// To support jmx attributes
protected StandardWrapperValve swValve;
protected long loadTime=0;
@@ -607,7 +601,6 @@
throw new IllegalArgumentException
(sm.getString("standardWrapper.notContext"));
if (container instanceof StandardContext) {
- swallowOutput = ((StandardContext)container).getSwallowOutput();
unloadDelay = ((StandardContext)container).getUnloadDelay();
}
super.setParent(container);
@@ -1129,12 +1122,9 @@
return instance;
PrintStream out = System.out;
- if (swallowOutput) {
- SystemLogHandler.startCapture();
- }
Servlet servlet;
- try {
+
long t1=System.currentTimeMillis();
// If this "servlet" is really a JSP file, get the right class.
// HOLD YOUR NOSE - this is a kludge that avoids having to do special
@@ -1269,18 +1259,7 @@
fireContainerEvent("load", this);
loadTime=System.currentTimeMillis() -t1;
- } finally {
- if (swallowOutput) {
- String log = SystemLogHandler.stopCapture();
- if (log != null && log.length() > 0) {
- if (getServletContext() != null) {
- getServletContext().log(log);
- } else {
- out.println(log);
- }
- }
- }
- }
+
return servlet;
}
@@ -1397,9 +1376,6 @@
unloading = true;
PrintStream out = System.out;
- if (swallowOutput) {
- SystemLogHandler.startCapture();
- }
// Call the servlet destroy() method
try {
@@ -1431,18 +1407,6 @@
throw new ServletException
(sm.getString("standardWrapper.destroyException", getName()),
t);
- } finally {
- // Write captured output
- if (swallowOutput) {
- String log = SystemLogHandler.stopCapture();
- if (log != null && log.length() > 0) {
- if (getServletContext() != null) {
- getServletContext().log(log);
- } else {
- out.println(log);
- }
- }
- }
}
// Deregister the destroyed instance
Modified: trunk/java/org/apache/catalina/core/StandardWrapperValve.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2010-05-06 13:36:51 UTC
(rev 1465)
+++ trunk/java/org/apache/catalina/core/StandardWrapperValve.java 2010-05-07 11:46:06 UTC
(rev 1466)
@@ -74,7 +74,6 @@
import org.apache.catalina.util.InstanceSupport;
import org.apache.catalina.util.StringManager;
import org.apache.catalina.valves.ValveBase;
-import org.apache.tomcat.util.log.SystemLogHandler;
import org.jboss.servlet.http.HttpEvent;
import org.jboss.servlet.http.HttpEventServlet;
import org.jboss.servlet.http.HttpEvent.EventType;
@@ -267,35 +266,14 @@
support.fireInstanceEvent(InstanceEvent.BEFORE_REQUEST_EVENT,
servlet, request, response);
if ((servlet != null) && (filterChain != null)) {
- // Swallow output if needed
- if (context.getSwallowOutput()) {
- try {
- SystemLogHandler.startCapture();
- if (event) {
- request.setEventMode(true);
- request.getSession(true);
- filterChain.doFilterEvent(request.getEvent());
- } else {
- filterChain.doFilter(request.getRequest(),
- response.getResponse());
- }
- } finally {
- String log = SystemLogHandler.stopCapture();
- if (log != null && log.length() > 0) {
- context.getLogger().info(log);
- }
- }
+ if (event) {
+ request.setEventMode(true);
+ request.getSession(true);
+ filterChain.doFilterEvent(request.getEvent());
} else {
- if (event) {
- request.setEventMode(true);
- request.getSession(true);
- filterChain.doFilterEvent(request.getEvent());
- } else {
- filterChain.doFilter
- (request.getRequest(), response.getResponse());
- }
+ filterChain.doFilter
+ (request.getRequest(), response.getResponse());
}
-
}
request.removeAttribute(Globals.JSP_FILE_ATTR);
support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
@@ -493,20 +471,7 @@
support.fireInstanceEvent(InstanceEvent.BEFORE_REQUEST_EVENT,
servlet, request, response);
if ((servlet != null) && (filterChain != null)) {
- // Swallow output if needed
- if (context.getSwallowOutput()) {
- try {
- SystemLogHandler.startCapture();
- filterChain.doFilterEvent(request.getEvent());
- } finally {
- String log = SystemLogHandler.stopCapture();
- if (log != null && log.length() > 0) {
- context.getLogger().info(log);
- }
- }
- } else {
- filterChain.doFilterEvent(request.getEvent());
- }
+ filterChain.doFilterEvent(request.getEvent());
}
request.removeAttribute(Globals.JSP_FILE_ATTR);
support.fireInstanceEvent(InstanceEvent.AFTER_REQUEST_EVENT,
Modified: trunk/java/org/apache/catalina/core/mbeans-descriptors.xml
===================================================================
--- trunk/java/org/apache/catalina/core/mbeans-descriptors.xml 2010-05-06 13:36:51 UTC
(rev 1465)
+++ trunk/java/org/apache/catalina/core/mbeans-descriptors.xml 2010-05-07 11:46:06 UTC
(rev 1466)
@@ -184,10 +184,6 @@
type="javax.naming.directory.DirContext"
writeable="false"/>
- <attribute name="swallowOutput"
- description="Flag to set to cause the system.out and system.err to be
redirected to the logger when executing a servlet"
- type="boolean"/>
-
<attribute name="unloadDelay"
description="Amount of ms that the container will wait for servlets
to unload"
type="long"/>
Deleted: trunk/java/org/apache/tomcat/util/log/CaptureLog.java
===================================================================
--- trunk/java/org/apache/tomcat/util/log/CaptureLog.java 2010-05-06 13:36:51 UTC (rev
1465)
+++ trunk/java/org/apache/tomcat/util/log/CaptureLog.java 2010-05-07 11:46:06 UTC (rev
1466)
@@ -1,50 +0,0 @@
-/*
- * 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.tomcat.util.log;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-
-/**
- * Per Thread System.err and System.out log capture data.
- *
- * @author Glenn L. Nielsen
- */
-
-class CaptureLog {
-
- protected CaptureLog() {
- baos = new ByteArrayOutputStream();
- ps = new PrintStream(baos);
- }
-
- private ByteArrayOutputStream baos;
- private PrintStream ps;
-
- protected PrintStream getStream() {
- return ps;
- }
-
- protected void reset() {
- baos.reset();
- }
-
- protected String getCapture() {
- return baos.toString();
- }
-}
Deleted: trunk/java/org/apache/tomcat/util/log/SystemLogHandler.java
===================================================================
--- trunk/java/org/apache/tomcat/util/log/SystemLogHandler.java 2010-05-06 13:36:51 UTC
(rev 1465)
+++ trunk/java/org/apache/tomcat/util/log/SystemLogHandler.java 2010-05-07 11:46:06 UTC
(rev 1466)
@@ -1,245 +0,0 @@
-/*
- * 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.tomcat.util.log;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.EmptyStackException;
-import java.util.Stack;
-
-/**
- * This helper class may be used to do sophisticated redirection of
- * System.out and System.err on a per Thread basis.
- *
- * A stack is implemented per Thread so that nested startCapture
- * and stopCapture can be used.
- *
- * @author Remy Maucherat
- * @author Glenn L. Nielsen
- */
-public class SystemLogHandler extends PrintStream {
-
-
- // ----------------------------------------------------------- Constructors
-
-
- /**
- * Construct the handler to capture the output of the given steam.
- */
- public SystemLogHandler(PrintStream wrapped) {
- super(wrapped);
- out = wrapped;
- }
-
-
- // ----------------------------------------------------- Instance Variables
-
-
- /**
- * Wrapped PrintStream.
- */
- protected PrintStream out = null;
-
-
- /**
- * Thread <-> CaptureLog associations.
- */
- protected static ThreadLocal logs = new ThreadLocal();
-
-
- /**
- * Spare CaptureLog ready for reuse.
- */
- protected static Stack reuse = new Stack();
-
-
- // --------------------------------------------------------- Public Methods
-
-
- /**
- * Start capturing thread's output.
- */
- public static void startCapture() {
- CaptureLog log = null;
- if (!reuse.isEmpty()) {
- try {
- log = (CaptureLog)reuse.pop();
- } catch (EmptyStackException e) {
- log = new CaptureLog();
- }
- } else {
- log = new CaptureLog();
- }
- Stack stack = (Stack)logs.get();
- if (stack == null) {
- stack = new Stack();
- logs.set(stack);
- }
- stack.push(log);
- }
-
-
- /**
- * Stop capturing thread's output and return captured data as a String.
- */
- public static String stopCapture() {
- Stack stack = (Stack)logs.get();
- if (stack == null || stack.isEmpty()) {
- return null;
- }
- CaptureLog log = (CaptureLog)stack.pop();
- if (log == null) {
- return null;
- }
- String capture = log.getCapture();
- log.reset();
- reuse.push(log);
- return capture;
- }
-
-
- // ------------------------------------------------------ Protected Methods
-
-
- /**
- * Find PrintStream to which the output must be written to.
- */
- protected PrintStream findStream() {
- Stack stack = (Stack)logs.get();
- if (stack != null && !stack.isEmpty()) {
- CaptureLog log = (CaptureLog)stack.peek();
- if (log != null) {
- PrintStream ps = log.getStream();
- if (ps != null) {
- return ps;
- }
- }
- }
- return out;
- }
-
-
- // ---------------------------------------------------- PrintStream Methods
-
-
- public void flush() {
- findStream().flush();
- }
-
- public void close() {
- findStream().close();
- }
-
- public boolean checkError() {
- return findStream().checkError();
- }
-
- protected void setError() {
- //findStream().setError();
- }
-
- public void write(int b) {
- findStream().write(b);
- }
-
- public void write(byte[] b)
- throws IOException {
- findStream().write(b);
- }
-
- public void write(byte[] buf, int off, int len) {
- findStream().write(buf, off, len);
- }
-
- public void print(boolean b) {
- findStream().print(b);
- }
-
- public void print(char c) {
- findStream().print(c);
- }
-
- public void print(int i) {
- findStream().print(i);
- }
-
- public void print(long l) {
- findStream().print(l);
- }
-
- public void print(float f) {
- findStream().print(f);
- }
-
- public void print(double d) {
- findStream().print(d);
- }
-
- public void print(char[] s) {
- findStream().print(s);
- }
-
- public void print(String s) {
- findStream().print(s);
- }
-
- public void print(Object obj) {
- findStream().print(obj);
- }
-
- public void println() {
- findStream().println();
- }
-
- public void println(boolean x) {
- findStream().println(x);
- }
-
- public void println(char x) {
- findStream().println(x);
- }
-
- public void println(int x) {
- findStream().println(x);
- }
-
- public void println(long x) {
- findStream().println(x);
- }
-
- public void println(float x) {
- findStream().println(x);
- }
-
- public void println(double x) {
- findStream().println(x);
- }
-
- public void println(char[] x) {
- findStream().println(x);
- }
-
- public void println(String x) {
- findStream().println(x);
- }
-
- public void println(Object x) {
- findStream().println(x);
- }
-
-}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2010-05-06 13:36:51 UTC (rev 1465)
+++ trunk/webapps/docs/changelog.xml 2010-05-07 11:46:06 UTC (rev 1466)
@@ -33,7 +33,7 @@
Add filter before method fix. (markt, kkolinko)
</fix>
<update>
- More standalone code removal. (remm)
+ More standalone code removal (incl system streams swallowing). (remm)
</update>
</changelog>
</subsection>