- Remove dead code.
authorremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 15 Feb 2007 00:23:18 +0000 (00:23 +0000)
committerremm <remm@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 15 Feb 2007 00:23:18 +0000 (00:23 +0000)
- Move the special purpose sys.out capture to an inner class of the Ant compiler.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@507751 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/compiler/AntCompiler.java
java/org/apache/jasper/runtime/JspFactoryImpl.java
java/org/apache/jasper/util/FastDateFormat.java [deleted file]
java/org/apache/jasper/util/Queue.java [deleted file]
java/org/apache/jasper/util/SimplePool.java [deleted file]
java/org/apache/jasper/util/SystemLogHandler.java [deleted file]

index d490b40..88b9563 100644 (file)
 
 package org.apache.jasper.compiler;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.PrintStream;
 import java.util.StringTokenizer;
 
 import org.apache.jasper.JasperException;
-import org.apache.jasper.util.SystemLogHandler;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.DefaultLogger;
 import org.apache.tools.ant.Project;
@@ -275,4 +276,197 @@ public class AntCompiler extends Compiler {
     }
 
     
+    protected static class SystemLogHandler extends PrintStream {
+
+
+        // ----------------------------------------------------------- Constructors
+
+
+        /**
+         * Construct the handler to capture the output of the given steam.
+         */
+        public SystemLogHandler(PrintStream wrapped) {
+            super(wrapped);
+            this.wrapped = wrapped;
+        }
+
+
+        // ----------------------------------------------------- Instance Variables
+
+
+        /**
+         * Wrapped PrintStream.
+         */
+        protected PrintStream wrapped = null;
+
+
+        /**
+         * Thread <-> PrintStream associations.
+         */
+        protected static ThreadLocal streams = new ThreadLocal();
+
+
+        /**
+         * Thread <-> ByteArrayOutputStream associations.
+         */
+        protected static ThreadLocal data = new ThreadLocal();
+
+
+        // --------------------------------------------------------- Public Methods
+
+
+        public PrintStream getWrapped() {
+          return wrapped;
+        }
+
+        /**
+         * Start capturing thread's output.
+         */
+        public static void setThread() {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            data.set(baos);
+            streams.set(new PrintStream(baos));
+        }
+
+
+        /**
+         * Stop capturing thread's output and return captured data as a String.
+         */
+        public static String unsetThread() {
+            ByteArrayOutputStream baos = 
+                (ByteArrayOutputStream) data.get();
+            if (baos == null) {
+                return null;
+            }
+            streams.set(null);
+            data.set(null);
+            return baos.toString();
+        }
+
+
+        // ------------------------------------------------------ Protected Methods
+
+
+        /**
+         * Find PrintStream to which the output must be written to.
+         */
+        protected PrintStream findStream() {
+            PrintStream ps = (PrintStream) streams.get();
+            if (ps == null) {
+                ps = wrapped;
+            }
+            return ps;
+        }
+
+
+        // ---------------------------------------------------- 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);
+        }
+
+    }
+
 }
index c06d91c..f06a49d 100644 (file)
@@ -24,12 +24,11 @@ import javax.servlet.ServletContext;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.jsp.JspApplicationContext;
-import javax.servlet.jsp.JspFactory;
 import javax.servlet.jsp.JspEngineInfo;
+import javax.servlet.jsp.JspFactory;
 import javax.servlet.jsp.PageContext;
 
 import org.apache.jasper.Constants;
-import org.apache.jasper.util.SimplePool;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 
diff --git a/java/org/apache/jasper/util/FastDateFormat.java b/java/org/apache/jasper/util/FastDateFormat.java
deleted file mode 100644 (file)
index c24ba19..0000000
+++ /dev/null
@@ -1,134 +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.jasper.util;
-
-import java.util.Date;
-
-import java.text.DateFormat;
-import java.text.FieldPosition;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-
-/**
- * Fast date formatter that caches recently formatted date information
- * and uses it to avoid too-frequent calls to the underlying
- * formatter.  Note: breaks fieldPosition param of format(Date,
- * StringBuffer, FieldPosition).  If you care about the field
- * position, call the underlying DateFormat directly.
- *
- * @author Stan Bailes
- * @author Alex Chaffee
- */
-public class FastDateFormat extends DateFormat {
-
-    private DateFormat df;
-    private long lastSec = -1;
-    private StringBuffer sb = new StringBuffer();
-    private FieldPosition fp = new FieldPosition(DateFormat.MILLISECOND_FIELD);
-    
-    public FastDateFormat(DateFormat df) {
-        this.df = df;
-    }
-
-    public Date parse(String text, ParsePosition pos) {
-       return df.parse(text, pos);
-    }
-
-    /**
-     * Note: breaks functionality of fieldPosition param. Also:
-     * there's a bug in SimpleDateFormat with "S" and "SS", use "SSS"
-     * instead if you want a msec field.
-     */
-    public StringBuffer format(Date date, StringBuffer toAppendTo,
-                              FieldPosition fieldPosition) {
-        long dt = date.getTime();
-        long ds = dt / 1000;
-        if (ds != lastSec) {
-            sb.setLength(0);
-            df.format(date, sb, fp);
-            lastSec = ds;
-        } else {
-           // munge current msec into existing string
-            int ms = (int)(dt % 1000);
-            int pos = fp.getEndIndex();
-           int begin = fp.getBeginIndex();
-           if (pos > 0) {
-               if (pos > begin)
-                   sb.setCharAt(--pos, Character.forDigit(ms % 10, 10));
-               ms /= 10;
-               if (pos > begin)
-                   sb.setCharAt(--pos, Character.forDigit(ms % 10, 10));
-               ms /= 10;
-               if (pos > begin)
-                   sb.setCharAt(--pos, Character.forDigit(ms % 10, 10));
-           }
-        }
-       toAppendTo.append(sb.toString());
-       return toAppendTo;
-    }
-
-    public static void main(String[] args) {
-       String format = "yyyy-MM-dd HH:mm:ss.SSS";
-       if (args.length > 0)
-           format = args[0];
-        SimpleDateFormat sdf = new SimpleDateFormat(format);
-        FastDateFormat fdf = new FastDateFormat(sdf);
-        Date d = new Date();
-
-       d.setTime(1);
-       System.out.println(fdf.format(d) + "\t" + sdf.format(d));
-       d.setTime(20);
-       System.out.println(fdf.format(d) + "\t" + sdf.format(d));
-       d.setTime(500);
-       System.out.println(fdf.format(d) + "\t" + sdf.format(d));
-       d.setTime(543);
-       System.out.println(fdf.format(d) + "\t" + sdf.format(d));
-       d.setTime(999);
-       System.out.println(fdf.format(d) + "\t" + sdf.format(d));
-       d.setTime(1050);
-       System.out.println(fdf.format(d) + "\t" + sdf.format(d));
-       d.setTime(2543);
-       System.out.println(fdf.format(d) + "\t" + sdf.format(d));
-       d.setTime(12345);
-       System.out.println(fdf.format(d) + "\t" + sdf.format(d));
-       d.setTime(12340);
-       System.out.println(fdf.format(d) + "\t" + sdf.format(d));
-       
-        final int reps = 100000;
-        {
-            long start = System.currentTimeMillis();
-            for (int i = 0; i < reps; i++) {
-                d.setTime(System.currentTimeMillis());
-                fdf.format(d);
-            }
-            long elap = System.currentTimeMillis() - start;
-            System.out.println("fast: " + elap + " elapsed");
-           System.out.println(fdf.format(d));
-        }
-        {
-            long start = System.currentTimeMillis();
-            for (int i = 0; i < reps; i++) {
-                d.setTime(System.currentTimeMillis());
-                sdf.format(d);
-            }
-            long elap = System.currentTimeMillis() - start;        
-            System.out.println("slow: " + elap + " elapsed");
-           System.out.println(sdf.format(d));
-        }
-    }
-}
diff --git a/java/org/apache/jasper/util/Queue.java b/java/org/apache/jasper/util/Queue.java
deleted file mode 100644 (file)
index 9d51b78..0000000
+++ /dev/null
@@ -1,89 +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.jasper.util;
-
-import java.util.Vector;
-
-/**
- * A simple FIFO queue class which causes the calling thread to wait
- * if the queue is empty and notifies threads that are waiting when it
- * is not empty.
- *
- * @author Anil V (akv@eng.sun.com)
- */
-public class Queue {
-    private Vector vector = new Vector();
-
-    /** 
-     * Put the object into the queue.
-     * 
-     * @param  object          the object to be appended to the
-     *                                 queue. 
-     */
-    public synchronized void put(Object object) {
-       vector.addElement(object);
-       notify();
-    }
-    
-    /**
-     * Pull the first object out of the queue. Wait if the queue is
-     * empty.
-     */
-    public synchronized Object pull() {
-       while (isEmpty())
-           try {
-               wait();
-           } catch (InterruptedException ex) {
-           }
-       return get();
-    }
-
-    /**
-     * Get the first object out of the queue. Return null if the queue
-     * is empty. 
-     */
-    public synchronized Object get() {
-       Object object = peek();
-       if (object != null)
-           vector.removeElementAt(0);
-       return object;
-    }
-
-    /**
-     * Peek to see if something is available.
-     */
-    public Object peek() {
-       if (isEmpty())
-           return null;
-       return vector.elementAt(0);
-    }
-    
-    /**
-     * Is the queue empty?
-     */
-    public boolean isEmpty() {
-       return vector.isEmpty();
-    }
-
-    /**
-     * How many elements are there in this queue?
-     */
-    public int size() {
-       return vector.size();
-    }
-}
diff --git a/java/org/apache/jasper/util/SimplePool.java b/java/org/apache/jasper/util/SimplePool.java
deleted file mode 100644 (file)
index aba574e..0000000
+++ /dev/null
@@ -1,86 +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.jasper.util;
-
-/**
- * Simple object pool. Based on ThreadPool and few other classes
- *
- * The pool will ignore overflow and return null if empty.
- *
- * @author Gal Shachor
- * @author Costin
- */
-public final class SimplePool  {
-
-    private static final int DEFAULT_SIZE=16;
-
-    /*
-     * Where the threads are held.
-     */
-    private Object pool[];
-
-    private int max;
-    private int current=-1;
-
-    private Object lock;
-    
-    public SimplePool() {
-       this.max=DEFAULT_SIZE;
-       this.pool=new Object[max];
-       this.lock=new Object();
-    }
-    
-    public SimplePool(int max) {
-       this.max=max;
-       this.pool=new Object[max];
-       this.lock=new Object();
-    }
-
-    /**
-     * Adds the given object to the pool, and does nothing if the pool is full
-     */
-    public void put(Object o) {
-       synchronized( lock ) {
-           if( current < (max-1) ) {
-               current += 1;
-               pool[current] = o;
-            }
-       }
-    }
-
-    /**
-     * Get an object from the pool, null if the pool is empty.
-     */
-    public Object get() {
-       Object item = null;
-       synchronized( lock ) {
-           if( current >= 0 ) {
-               item = pool[current];
-               current -= 1;
-           }
-       }
-       return item;
-    }
-
-    /**
-     * Return the size of the pool
-     */
-    public int getMax() {
-       return max;
-    }
-}
diff --git a/java/org/apache/jasper/util/SystemLogHandler.java b/java/org/apache/jasper/util/SystemLogHandler.java
deleted file mode 100644 (file)
index b2b1e74..0000000
+++ /dev/null
@@ -1,222 +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.jasper.util;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-
-
-/**
- * This helper class may be used to do sophisticated redirection of 
- * System.out and System.err.
- * 
- * @author Remy Maucherat
- */
-public class SystemLogHandler extends PrintStream {
-
-
-    // ----------------------------------------------------------- Constructors
-
-
-    /**
-     * Construct the handler to capture the output of the given steam.
-     */
-    public SystemLogHandler(PrintStream wrapped) {
-        super(wrapped);
-        this.wrapped = wrapped;
-    }
-
-
-    // ----------------------------------------------------- Instance Variables
-
-
-    /**
-     * Wrapped PrintStream.
-     */
-    protected PrintStream wrapped = null;
-
-
-    /**
-     * Thread <-> PrintStream associations.
-     */
-    protected static ThreadLocal streams = new ThreadLocal();
-
-
-    /**
-     * Thread <-> ByteArrayOutputStream associations.
-     */
-    protected static ThreadLocal data = new ThreadLocal();
-
-
-    // --------------------------------------------------------- Public Methods
-
-
-    public PrintStream getWrapped() {
-      return wrapped;
-    }
-
-    /**
-     * Start capturing thread's output.
-     */
-    public static void setThread() {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        data.set(baos);
-        streams.set(new PrintStream(baos));
-    }
-
-
-    /**
-     * Stop capturing thread's output and return captured data as a String.
-     */
-    public static String unsetThread() {
-        ByteArrayOutputStream baos = 
-            (ByteArrayOutputStream) data.get();
-        if (baos == null) {
-            return null;
-        }
-        streams.set(null);
-        data.set(null);
-        return baos.toString();
-    }
-
-
-    // ------------------------------------------------------ Protected Methods
-
-
-    /**
-     * Find PrintStream to which the output must be written to.
-     */
-    protected PrintStream findStream() {
-        PrintStream ps = (PrintStream) streams.get();
-        if (ps == null) {
-            ps = wrapped;
-        }
-        return ps;
-    }
-
-
-    // ---------------------------------------------------- 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);
-    }
-
-}