/* * 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.compiler;
/** * This class caches parsed instances of TLD files to remove the need for the * same TLD to be parsed for each JSP that references it. It does not protect * against multiple threads processing the same, new TLD but it does ensure that * each all threads will use the same TLD object after parsing.
*/ publicclass TldCache {
privatelong[] getLastModified(TldResourcePath tldResourcePath) { long[] result = newlong[2];
result[0] = -1;
result[1] = -1; try {
String webappPath = tldResourcePath.getWebappPath(); if (webappPath != null) { // webappPath will be null for JARs containing TLDs that are on // the class path but not part of the web application
URL url = servletContext.getResource(tldResourcePath.getWebappPath());
URLConnection conn = url.openConnection();
result[0] = conn.getLastModified(); if ("file".equals(url.getProtocol())) { // Reading the last modified time opens an input stream so we // need to make sure it is closed again otherwise the TLD file // will be locked until GC runs.
conn.getInputStream().close();
}
} try (Jar jar = tldResourcePath.openJar()) { if (jar != null) {
result[1] = jar.getLastModified(tldResourcePath.getEntryName());
}
}
} catch (IOException e) { // Ignore (shouldn't happen)
} return result;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.