From: rjung Date: Thu, 28 Oct 2010 17:30:28 +0000 (+0000) Subject: Move Entry to an inner class of FastRemovalDequeue. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a0f05fa3185188fbb313af14a2e89805903806ae;p=tomcat7.0 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. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1028396 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/jasper/compiler/JspRuntimeContext.java b/java/org/apache/jasper/compiler/JspRuntimeContext.java index 94347214b..9e1085277 100644 --- a/java/org/apache/jasper/compiler/JspRuntimeContext.java +++ b/java/org/apache/jasper/compiler/JspRuntimeContext.java @@ -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 push(JspServletWrapper jsw) { + public FastRemovalDequeue.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 ticket) { + public void makeYoungest(FastRemovalDequeue.Entry ticket) { synchronized(jspQueue) { jspQueue.moveFirst(ticket); } diff --git a/java/org/apache/jasper/servlet/JspServletWrapper.java b/java/org/apache/jasper/servlet/JspServletWrapper.java index 96bc10051..0bbbb1625 100644 --- a/java/org/apache/jasper/servlet/JspServletWrapper.java +++ b/java/org/apache/jasper/servlet/JspServletWrapper.java @@ -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 ticket; + private FastRemovalDequeue.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 index 9a8ab030c..000000000 --- a/java/org/apache/jasper/util/Entry.java +++ /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 { - - /** 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; - - public Entry(T object) { - content = object; - } - - protected void setNext(final Entry next) { - this.next = next; - } - - protected void setPrevious(final Entry previous) { - this.previous = previous; - } - - protected T getContent() { - return content; - } - - protected Entry getPrevious() { - return previous; - } - - protected Entry getNext() { - return next; - } - - @Override - public String toString() { - return "Entry-" + content.toString(); - } -} diff --git a/java/org/apache/jasper/util/FastRemovalDequeue.java b/java/org/apache/jasper/util/FastRemovalDequeue.java index b30597a6f..900fd3115 100644 --- a/java/org/apache/jasper/util/FastRemovalDequeue.java +++ b/java/org/apache/jasper/util/FastRemovalDequeue.java @@ -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 { /** First element of the queue. */ - private Entry first; + private Entry first; /** Last element of the queue. */ - private Entry last; + private Entry last; /** Initialize empty queue. */ public FastRemovalDequeue() { @@ -58,8 +57,8 @@ public class FastRemovalDequeue { * @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 push(final T object) { - Entry entry = new Entry(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 { * @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 unpop(final T object) { - Entry entry = new Entry(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 { /** * Removes any element of the list and returns its content. **/ - public void remove(final Entry element) { - Entry next = element.getNext(); - Entry 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 { * * @param element the entry to move in front. * */ - public void moveFirst(final Entry element) { + public void moveFirst(final Entry element) { if (element.getPrevious() != null) { - Entry prev = element.getPrevious(); - Entry 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 { * * @param element the entry to move to the back. * */ - public void moveLast(final Entry element) { + public void moveLast(final Entry element) { if (element.getNext() != null) { - Entry next = element.getNext(); - Entry 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 { 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(); + } + } + }