Move Entry to an inner class of FastRemovalDequeue.
authorrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 28 Oct 2010 17:30:28 +0000 (17:30 +0000)
committerrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 28 Oct 2010 17:30:28 +0000 (17:30 +0000)
All implementation details of Entry are now opaque
to the consumer of the FastRemovalDequeue.

Remove double generification when using the inner
class.

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

java/org/apache/jasper/compiler/JspRuntimeContext.java
java/org/apache/jasper/servlet/JspServletWrapper.java
java/org/apache/jasper/util/Entry.java [deleted file]
java/org/apache/jasper/util/FastRemovalDequeue.java

index 9434721..9e10852 100644 (file)
@@ -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);
         }
index 96bc100..0bbbb16 100644 (file)
@@ -41,8 +41,8 @@ import org.apache.jasper.compiler.JspRuntimeContext;
 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.
diff --git a/java/org/apache/jasper/util/Entry.java b/java/org/apache/jasper/util/Entry.java
deleted file mode 100644 (file)
index 9a8ab03..0000000
+++ /dev/null
@@ -1,60 +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;
-
-/**
- * Implementation of a doubly linked list entry.
- * It exposes links to previous and next elements on package level only.
- */
-public class Entry<T> {
-
-    /** The content this entry is valid for. */
-    private final T content;
-    /** Pointer to next element in queue. */
-    private Entry<T> next;
-    /** Pointer to previous element in queue. */
-    private Entry<T> previous;
-
-    public Entry(T object) {
-        content = object;
-    }
-
-    protected void setNext(final Entry<T> next) {
-        this.next = next;
-    }
-
-    protected void setPrevious(final Entry<T> previous) {
-        this.previous = previous;
-    }
-
-    protected T getContent() {
-        return content;
-    }
-
-    protected Entry<T> getPrevious() {
-        return previous;
-    }
-
-    protected Entry<T> getNext() {
-        return next;
-    }
-
-    @Override
-    public String toString() {
-        return "Entry-" + content.toString();
-    }
-}
index b30597a..900fd31 100644 (file)
@@ -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();
+        }
+    }
+
 }