You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2010/10/28 19:30:29 UTC

svn commit: r1028396 - in /tomcat/trunk/java/org/apache/jasper: compiler/JspRuntimeContext.java servlet/JspServletWrapper.java util/Entry.java util/FastRemovalDequeue.java

Author: rjung
Date: Thu Oct 28 17:30:28 2010
New Revision: 1028396

URL: http://svn.apache.org/viewvc?rev=1028396&view=rev
Log:
Move Entry to an inner class of FastRemovalDequeue.

All implementation details of Entry are now opaque
to the consumer of the FastRemovalDequeue.

Remove double generification when using the inner
class.

Removed:
    tomcat/trunk/java/org/apache/jasper/util/Entry.java
Modified:
    tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java
    tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java
    tomcat/trunk/java/org/apache/jasper/util/FastRemovalDequeue.java

Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java?rev=1028396&r1=1028395&r2=1028396&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/JspRuntimeContext.java Thu Oct 28 17:30:28 2010
@@ -218,7 +218,7 @@ public final class JspRuntimeContext {
      * @param jsw Servlet wrapper for jsp.
      * @return a ticket that can be pushed to front of queue at later execution times.
      * */
-    public org.apache.jasper.util.Entry<JspServletWrapper> push(JspServletWrapper jsw) {
+    public FastRemovalDequeue<JspServletWrapper>.Entry push(JspServletWrapper jsw) {
         synchronized (jspQueue) {
             return jspQueue.push(jsw);
         }
@@ -229,7 +229,7 @@ public final class JspRuntimeContext {
      *
      * @param ticket the ticket for the jsp.
      * */
-    public void makeYoungest(org.apache.jasper.util.Entry<JspServletWrapper> ticket) {
+    public void makeYoungest(FastRemovalDequeue<JspServletWrapper>.Entry ticket) {
         synchronized(jspQueue) {
             jspQueue.moveFirst(ticket);
         }

Modified: tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java?rev=1028396&r1=1028395&r2=1028396&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java (original)
+++ tomcat/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java Thu Oct 28 17:30:28 2010
@@ -41,8 +41,8 @@ import org.apache.jasper.compiler.JspRun
 import org.apache.jasper.compiler.Localizer;
 import org.apache.jasper.runtime.InstanceManagerFactory;
 import org.apache.jasper.runtime.JspSourceDependent;
-import org.apache.jasper.util.Entry;
 import org.apache.jasper.util.ExceptionUtils;
+import org.apache.jasper.util.FastRemovalDequeue;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.InstanceManager;
@@ -87,7 +87,7 @@ public class JspServletWrapper {
     /** Timestamp of last time servlet resource was modified */
     private volatile long servletClassLastModifiedTime;
     private long lastModificationTest = 0L;
-    private Entry<JspServletWrapper> ticket;
+    private FastRemovalDequeue<JspServletWrapper>.Entry ticket;
 
     /*
      * JspServletWrapper for JSP pages.

Modified: tomcat/trunk/java/org/apache/jasper/util/FastRemovalDequeue.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/util/FastRemovalDequeue.java?rev=1028396&r1=1028395&r2=1028396&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/util/FastRemovalDequeue.java (original)
+++ tomcat/trunk/java/org/apache/jasper/util/FastRemovalDequeue.java Thu Oct 28 17:30:28 2010
@@ -23,8 +23,7 @@ package org.apache.jasper.util;
  * added to the collection with an Entry type, that is returned to the consumer.
  * When removing an object from the list, the consumer provides this Entry object.
  *
- * The Entry type is mostly opaque to the consumer itself. The consumer can only
- * retrieve the original object - named content - from the Entry.
+ * The Entry type is completely opaque to the consumer itself.
  *
  * The Entry object contains the links pointing to the neighbours in the doubly
  * linked list, so that removal of an Entry does not need to search for it but
@@ -41,9 +40,9 @@ package org.apache.jasper.util;
 public class FastRemovalDequeue<T> {
 
     /** First element of the queue. */
-    private Entry<T> first;
+    private Entry first;
     /** Last element of the queue. */
-    private Entry<T> last;
+    private Entry last;
 
     /** Initialize empty queue. */
     public FastRemovalDequeue() {
@@ -58,8 +57,8 @@ public class FastRemovalDequeue<T> {
      * @param object the object to prepend to the start of the list.
      * @return an entry for use when the object should be moved.
      * */
-    public Entry<T> push(final T object) {
-        Entry<T> entry = new Entry<T>(object);
+    public Entry push(final T object) {
+        Entry entry = new Entry(object);
         if (first == null) {
             first = last = entry;
         } else {
@@ -78,8 +77,8 @@ public class FastRemovalDequeue<T> {
      * @param object the object to append to the end of the list.
      * @return an entry for use when the object should be moved.
      * */
-    public Entry<T> unpop(final T object) {
-        Entry<T> entry = new Entry<T>(object);
+    public Entry unpop(final T object) {
+        Entry entry = new Entry(object);
         if (first == null) {
             first = last = entry;
         } else {
@@ -128,9 +127,9 @@ public class FastRemovalDequeue<T> {
     /**
      * Removes any element of the list and returns its content.
      **/
-    public void remove(final Entry<T> element) {
-        Entry<T> next = element.getNext();
-        Entry<T> prev = element.getPrevious();
+    public void remove(final Entry element) {
+        Entry next = element.getNext();
+        Entry prev = element.getPrevious();
         if (next != null) {
             next.setPrevious(prev);
         } else {
@@ -151,10 +150,10 @@ public class FastRemovalDequeue<T> {
      * 
      * @param element the entry to move in front.
      * */
-    public void moveFirst(final Entry<T> element) {
+    public void moveFirst(final Entry element) {
         if (element.getPrevious() != null) {
-            Entry<T> prev = element.getPrevious();
-            Entry<T> next = element.getNext();
+            Entry prev = element.getPrevious();
+            Entry next = element.getNext();
             prev.setNext(next);
             if (next != null) {
                 next.setPrevious(prev);
@@ -176,10 +175,10 @@ public class FastRemovalDequeue<T> {
      * 
      * @param element the entry to move to the back.
      * */
-    public void moveLast(final Entry<T> element) {
+    public void moveLast(final Entry element) {
         if (element.getNext() != null) {
-            Entry<T> next = element.getNext();
-            Entry<T> prev = element.getPrevious();
+            Entry next = element.getNext();
+            Entry prev = element.getPrevious();
             next.setPrevious(prev);
             if (prev != null) {
                 prev.setNext(next);
@@ -192,4 +191,50 @@ public class FastRemovalDequeue<T> {
             last = element;
         }
     }
+
+    /**
+     * Implementation of a doubly linked list entry.
+     * All implementation details are private.
+     * For the consumer of the above collection, this
+     * is simply garbage in, garbage out.
+     */
+    public class Entry {
+
+        /** The content this entry is valid for. */
+        private final T content;
+        /** Pointer to next element in queue. */
+        private Entry next;
+        /** Pointer to previous element in queue. */
+        private Entry previous;
+
+        private Entry(T object) {
+            content = object;
+        }
+
+        private final void setNext(final Entry next) {
+            this.next = next;
+        }
+
+        private final void setPrevious(final Entry previous) {
+            this.previous = previous;
+        }
+
+        private final T getContent() {
+            return content;
+        }
+
+        private final Entry getPrevious() {
+            return previous;
+        }
+
+        private final Entry getNext() {
+            return next;
+        }
+
+        @Override
+        public String toString() {
+            return "Entry-" + content.toString();
+        }
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org