[jboss-cvs] JBossAS SVN: r57338 - branches/JBoss_4_0_2_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/jasper
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Oct 1 20:40:45 EDT 2006
Author: ryan.campbell at jboss.com
Date: 2006-10-01 20:40:44 -0400 (Sun, 01 Oct 2006)
New Revision: 57338
Modified:
branches/JBoss_4_0_2_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/jasper/TagLibCache.java
Log:
ASPATCH-36: JBAS-2847: Patch for jboss TagLibCache on 4.0.2
Modified: branches/JBoss_4_0_2_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/jasper/TagLibCache.java
===================================================================
--- branches/JBoss_4_0_2_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/jasper/TagLibCache.java 2006-10-02 00:25:35 UTC (rev 57337)
+++ branches/JBoss_4_0_2_CP/tomcat/src/main/org/jboss/web/tomcat/tc5/jasper/TagLibCache.java 2006-10-02 00:40:44 UTC (rev 57338)
@@ -5,14 +5,20 @@
* See terms of license at gnu.org.
*/
/*
+* JBoss, the OpenSource J2EE webOS
+*
+* Distributable under LGPL license.
+* See terms of license at gnu.org.
+*/
+/*
* Copyright 1999,2004 The Apache Software Foundation.
- *
+ *
* Licensed 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.
@@ -35,6 +41,7 @@
import java.net.URLConnection;
import java.net.MalformedURLException;
import javax.servlet.ServletContext;
+import java.util.Map; // SYNC
import org.apache.jasper.compiler.TldLocationsCache;
import org.apache.jasper.compiler.Localizer;
@@ -90,26 +97,36 @@
return locations;
}
- private void init() throws JasperException
+ private synchronized void init() throws JasperException
{
+ if (mappings != null)
+ {
+ return;
+ }
+
+ HashMap tmpMappings = null;
try
{
- mappings = new HashMap();
- processWebDotXml();
- loadStandardTlds();
- processTldsInFileSystem("/WEB-INF/");
+ tmpMappings = new HashMap();
+ processWebDotXml(tmpMappings);
+ loadStandardTlds(tmpMappings);
+ processTldsInFileSystem("/WEB-INF/", tmpMappings);
}
catch (Exception ex)
{
String msg = Localizer.getMessage("jsp.error.internal.tldinit", ex.getMessage());
throw new JasperException(msg, ex);
}
+ finally
+ {
+ mappings = tmpMappings;
+ }
}
/*
* Populates taglib map described in web.xml.
*/
- protected void processWebDotXml() throws Exception
+ protected void processWebDotXml(Map tmpMappings) throws Exception
{
InputStream is = null;
@@ -189,7 +206,7 @@
tagLoc = ctx.getResource(tagLoc).toString();
tagLoc2 = "META-INF/taglib.tld";
}
- mappings.put(tagUri, new String[]{tagLoc, tagLoc2});
+ tmpMappings.put(tagUri, new String[]{tagLoc, tagLoc2}); // SYNC
}
}
finally
@@ -207,7 +224,7 @@
}
}
- protected void loadStandardTlds() throws MalformedURLException
+ protected void loadStandardTlds(Map tmpMappings) throws MalformedURLException // SYNC
{
if( tagLibJars.size() == 0 )
return;
@@ -226,7 +243,7 @@
log.debug("Scanning for tlds in: "+resourcePath);
URLConnection conn = url.openConnection();
conn.setUseCaches(false);
- scanJar(conn, resourcePath, true);
+ scanJar(conn, resourcePath, true, tmpMappings); // SYNC
}
catch (Exception e)
{
@@ -240,7 +257,7 @@
* an implicit map entry to the taglib map for any TLD that has a <uri>
* element.
*/
- protected void processTldsInFileSystem(String startPath)
+ protected void processTldsInFileSystem(String startPath, Map tmpMappings) // SYNC
throws Exception
{
@@ -253,14 +270,14 @@
String path = (String) it.next();
if (path.endsWith("/"))
{
- processTldsInFileSystem(path);
+ processTldsInFileSystem(path, tmpMappings); // SYNC
}
if( path.endsWith(".jar") )
{
URL resURL = ctx.getResource(path);
URLConnection conn = resURL.openConnection();
conn.setUseCaches(false);
- this.scanJar(conn, resURL.toString(), false);
+ this.scanJar(conn, resURL.toString(), false, tmpMappings); // SYNC
}
else if ( path.endsWith(".tld") == true )
{
@@ -286,9 +303,9 @@
}
// Add implicit map entry only if its uri is not already
// present in the map
- if (uri != null && mappings.get(uri) == null)
+ if (uri != null && tmpMappings.get(uri) == null) // SYNC
{
- mappings.put(uri, new String[]{path, null});
+ tmpMappings.put(uri, new String[]{path, null}); // SYNC
}
}
}
@@ -303,7 +320,7 @@
* @param ignore true if any exceptions raised when processing the given JAR
* should be ignored, false otherwise
*/
- private void scanJar(URLConnection conn, String resourcePath, boolean ignore)
+ private void scanJar(URLConnection conn, String resourcePath, boolean ignore, Map tmpMappings) // SYNC
throws JasperException, IOException
{
InputStream connIS = conn.getInputStream();
@@ -324,9 +341,9 @@
String uri = getUriFromTld(resourcePath, eis);
// Add implicit map entry only if its uri is not already
// present in the map
- if (uri != null && mappings.get(uri) == null)
+ if (uri != null && tmpMappings.get(uri) == null) // SYNC
{
- mappings.put(uri, new String[]{resourcePath, name});
+ tmpMappings.put(uri, new String[]{resourcePath, name}); // SYNC
}
entry = jis.getNextJarEntry();
}
@@ -438,4 +455,4 @@
return jis.read(b, off, len);
}
}
-}
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list