cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources ProxyDirContext.java
remm2005/09/12 03:57:46 Modified:catalina/src/share/org/apache/naming/resources ProxyDirContext.java Log: - Minor tweak: call a load to avoid possible useless allocate call when concurrently trying to add the same entry. Revision ChangesPath 1.19 +2 -2 jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java Index: ProxyDirContext.java === RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- ProxyDirContext.java 20 Jul 2005 21:25:18 - 1.18 +++ ProxyDirContext.java 12 Sep 2005 10:57:46 - 1.19 @@ -1596,7 +1596,7 @@ // Add new entry to cache synchronized (cache) { // Check cache size, and remove elements if too big -if (cache.allocate(entry.size)) { +if ((cache.lookup(name) == null) cache.allocate(entry.size)) { cache.load(entry); } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources ProxyDirContext.java
remm2003/08/20 09:30:38 Modified:catalina/src/share/org/apache/naming/resources ProxyDirContext.java Log: - Fix bug where no resource over 512 bytes would get cached. The problem was a lack of conversion between bytes and K bytes, introduced a long time ago (likely) when I made the cache more user friendly to configure. Revision ChangesPath 1.13 +6 -5 jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java Index: ProxyDirContext.java === RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- ProxyDirContext.java 30 Jul 2003 18:35:50 - 1.12 +++ ProxyDirContext.java 20 Aug 2003 16:30:38 - 1.13 @@ -1561,7 +1561,8 @@ if ((exists) (entry.resource != null) (entry.resource.getContent() == null) (entry.attributes.getContentLength() = 0) - (entry.attributes.getContentLength() cacheObjectMaxSize)) { + (entry.attributes.getContentLength() +(cacheObjectMaxSize * 1024))) { int length = (int) entry.attributes.getContentLength(); // The entry size is 1 + the resource size in KB, if it will be // cached - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources ProxyDirContext.java
remm2003/06/12 15:03:35 Modified:catalina/src/share/org/apache/naming/resources ProxyDirContext.java Log: - Add /WEB-INF/lib and /WEB-INF/classes as non cacheable. - This should be configurable eventually, but I think it should work fine for 99% of apps. Revision ChangesPath 1.11 +17 -4 jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java Index: ProxyDirContext.java === RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- ProxyDirContext.java 24 Apr 2003 17:02:44 - 1.10 +++ ProxyDirContext.java 12 Jun 2003 22:03:34 - 1.11 @@ -233,6 +233,12 @@ new ImmutableNameNotFoundException(); +/** + * Non cacheable resources. + */ +protected String[] nonCacheable = { /WEB-INF/lib/, /WEB-INF/classes/ }; + + // - Public Methods @@ -1427,6 +1433,13 @@ throws NamingException { if (cache == null) return (null); +if (name == null) +name = ; +for (int i = 0; i nonCacheable.length; i++) { +if (name.startsWith(nonCacheable[i])) { +return (null); +} +} CacheEntry cacheEntry = cache.lookup(name); if (cacheEntry == null) { cacheEntry = new CacheEntry(); - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources ProxyDirContext.java
remm2002/12/16 01:04:22 Modified:catalina/src/share/org/apache/naming/resources ProxyDirContext.java Log: - Should fix cache invalidation when creating subcontexts and modify atributes. - Fix WebDAV (bug 15378). Revision ChangesPath 1.4 +26 -8 jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java Index: ProxyDirContext.java === RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ProxyDirContext.java 10 Oct 2002 07:41:27 - 1.3 +++ ProxyDirContext.java 16 Dec 2002 09:04:22 - 1.4 @@ -594,7 +594,9 @@ */ public Context createSubcontext(Name name) throws NamingException { -return dirContext.createSubcontext(parseName(name)); +Context context = dirContext.createSubcontext(parseName(name)); +cacheUnload(name.toString()); +return context; } @@ -610,7 +612,9 @@ */ public Context createSubcontext(String name) throws NamingException { -return dirContext.createSubcontext(parseName(name)); +Context context = dirContext.createSubcontext(parseName(name)); +cacheUnload(name.toString()); +return context; } @@ -905,6 +909,7 @@ public void modifyAttributes(Name name, int mod_op, Attributes attrs) throws NamingException { dirContext.modifyAttributes(parseName(name), mod_op, attrs); +cacheUnload(name.toString()); } @@ -923,6 +928,7 @@ public void modifyAttributes(String name, int mod_op, Attributes attrs) throws NamingException { dirContext.modifyAttributes(parseName(name), mod_op, attrs); +cacheUnload(name); } @@ -943,6 +949,7 @@ public void modifyAttributes(Name name, ModificationItem[] mods) throws NamingException { dirContext.modifyAttributes(parseName(name), mods); +cacheUnload(name.toString()); } @@ -960,6 +967,7 @@ public void modifyAttributes(String name, ModificationItem[] mods) throws NamingException { dirContext.modifyAttributes(parseName(name), mods); +cacheUnload(name); } @@ -981,6 +989,7 @@ public void bind(Name name, Object obj, Attributes attrs) throws NamingException { dirContext.bind(parseName(name), obj, attrs); +cacheUnload(name.toString()); } @@ -998,6 +1007,7 @@ public void bind(String name, Object obj, Attributes attrs) throws NamingException { dirContext.bind(parseName(name), obj, attrs); +cacheUnload(name); } @@ -1022,6 +1032,7 @@ public void rebind(Name name, Object obj, Attributes attrs) throws NamingException { dirContext.rebind(parseName(name), obj, attrs); +cacheUnload(name.toString()); } @@ -1039,6 +1050,7 @@ public void rebind(String name, Object obj, Attributes attrs) throws NamingException { dirContext.rebind(parseName(name), obj, attrs); +cacheUnload(name); } @@ -1061,7 +1073,10 @@ */ public DirContext createSubcontext(Name name, Attributes attrs) throws NamingException { -return dirContext.createSubcontext(parseName(name), attrs); +DirContext context = +dirContext.createSubcontext(parseName(name), attrs); +cacheUnload(name.toString()); +return context; } @@ -1078,7 +1093,10 @@ */ public DirContext createSubcontext(String name, Attributes attrs) throws NamingException { -return dirContext.createSubcontext(parseName(name), attrs); +DirContext context = +dirContext.createSubcontext(parseName(name), attrs); +cacheUnload(name); +return context; } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources ProxyDirContext.java
remm2002/12/16 06:19:07 Modified:catalina/src/share/org/apache/naming/resources ProxyDirContext.java Log: - Remove useless toString. Revision ChangesPath 1.5 +5 -5 jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java Index: ProxyDirContext.java === RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- ProxyDirContext.java 16 Dec 2002 09:04:22 - 1.4 +++ ProxyDirContext.java 16 Dec 2002 14:19:07 - 1.5 @@ -613,7 +613,7 @@ public Context createSubcontext(String name) throws NamingException { Context context = dirContext.createSubcontext(parseName(name)); -cacheUnload(name.toString()); +cacheUnload(name); return context; } -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources ProxyDirContext.java
remm2002/10/07 01:25:37 Modified:catalina/src/share/org/apache/naming/resources ProxyDirContext.java Log: - Port patch. - Fix caching bugs. Revision ChangesPath 1.2 +31 -23 jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java Index: ProxyDirContext.java === RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/naming/resources/ProxyDirContext.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ProxyDirContext.java 18 Jul 2002 16:47:34 - 1.1 +++ ProxyDirContext.java 7 Oct 2002 08:25:37 - 1.2 @@ -267,7 +267,6 @@ if (entry != null) { if (entry.resource != null) { // Check content caching. - return entry.resource; } else { return entry.context; @@ -1375,7 +1374,8 @@ /** * Lookup in cache. */ -protected CacheEntry cacheLookup(String name) { +protected CacheEntry cacheLookup(String name) +throws NamingException { if (cache == null) return (null); CacheEntry cacheEntry = (CacheEntry) cache.get(name); @@ -1383,9 +1383,7 @@ cacheEntry = new CacheEntry(); cacheEntry.name = name; // Load entry -if (!cacheLoad(cacheEntry)) -return null; -return (cacheEntry); +cacheLoad(cacheEntry); } else { if (!validate(cacheEntry)) { if (!revalidate(cacheEntry)) { @@ -1396,8 +1394,11 @@ System.currentTimeMillis() + cacheTTL; } } -return (cacheEntry); } +if (!cacheEntry.exists) { +throw new NamingException(Resource not found); +} +return (cacheEntry); } @@ -1405,8 +1406,10 @@ * Validate entry. */ protected boolean validate(CacheEntry entry) { -if ((entry.resource != null) - (entry.resource.getContent() != null) +if (((!entry.exists) + || (entry.context != null) + || ((entry.resource != null) + (entry.resource.getContent() != null))) (System.currentTimeMillis() entry.timestamp)) { return true; } @@ -1420,6 +1423,8 @@ protected boolean revalidate(CacheEntry entry) { // Get the attributes at the given path, and check the last // modification date +if (!entry.exists) +return false; if (entry.attributes == null) return false; long lastModified = entry.attributes.getLastModified(); @@ -1447,14 +1452,12 @@ /** * Load entry into cache. */ -protected boolean cacheLoad(CacheEntry entry) { - -if (cache == null) -return false; +protected void cacheLoad(CacheEntry entry) { String name = entry.name; // Retrieve missing info +boolean exists = true; // Retrieving attributes if (entry.attributes == null) { @@ -1467,12 +1470,12 @@ entry.attributes = (ResourceAttributes) attributes; } } catch (NamingException e) { -return false; +exists = false; } } // Retriving object -if ((entry.resource == null) (entry.context == null)) { +if ((exists) (entry.resource == null) (entry.context == null)) { try { Object object = dirContext.lookup(name); if (object instanceof InputStream) { @@ -1486,12 +1489,13 @@ (object.toString().getBytes())); } } catch (NamingException e) { -return false; +exists = false; } } // Load object content -if ((entry.resource != null) (entry.resource.getContent() == null) +if ((exists) (entry.resource != null) + (entry.resource.getContent() == null) (entry.attributes.getContentLength() = 0) (entry.attributes.getContentLength() cacheObjectMaxSize)) { int length = (int) entry.attributes.getContentLength(); @@ -1518,15 +1522,16 @@ } } } - + +// Set existence flag +entry.exists = exists; + // Set timestamp entry.timestamp = System.currentTimeMillis() + cacheTTL; // Add new