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;
/** 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.
+++ /dev/null
-/*
- * 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();
- }
-}
* 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
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() {
* @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 {
* @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 {
/**
* 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 {
*
* @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);
*
* @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);
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();
+ }
+ }
+
}