* Implement negative result caching in getPrototypeName(Object).
This commit is contained in:
		
							parent
							
								
									2b7e92d9f6
								
							
						
					
					
						commit
						4494d0bff5
					
				
					 1 changed files with 34 additions and 33 deletions
				
			
		|  | @ -168,9 +168,11 @@ public final class Application implements Runnable { | ||||||
|     Hashtable customCronJobs = null; |     Hashtable customCronJobs = null; | ||||||
| 
 | 
 | ||||||
|     private ResourceComparator resourceComparator; |     private ResourceComparator resourceComparator; | ||||||
| 
 |  | ||||||
|     private Resource currentCodeResource; |     private Resource currentCodeResource; | ||||||
| 
 | 
 | ||||||
|  |     // Field to cache unmapped java classes | ||||||
|  |     private final static String CLASS_NOT_MAPPED = "(unmapped)"; | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      *  Simple constructor for dead application instances. |      *  Simple constructor for dead application instances. | ||||||
|      */ |      */ | ||||||
|  | @ -1315,42 +1317,41 @@ public final class Application implements Runnable { | ||||||
|     public String getPrototypeName(Object obj) { |     public String getPrototypeName(Object obj) { | ||||||
|         if (obj == null) { |         if (obj == null) { | ||||||
|             return "global"; |             return "global"; | ||||||
|  |         } else if (obj instanceof IPathElement) { | ||||||
|  |             // check if e implements the IPathElement interface | ||||||
|  |             return ((IPathElement) obj).getPrototype(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // check if e implements the IPathElement interface |  | ||||||
|         if (obj instanceof IPathElement) { |  | ||||||
|             // e implements the getPrototype() method |  | ||||||
|             return ((IPathElement) obj).getPrototype(); |  | ||||||
|         } else { |  | ||||||
|             // look up prototype name by java class name |  | ||||||
|         Class clazz = obj.getClass(); |         Class clazz = obj.getClass(); | ||||||
|             String protoname = classMapping.getProperty(clazz.getName()); |         String className = clazz.getName(); | ||||||
|             if (protoname != null) { |         String protoName = classMapping.getProperty(className); | ||||||
|                 return protoname; |         if (protoName != null) { | ||||||
|  |             return protoName == CLASS_NOT_MAPPED ? null : protoName; | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|         // walk down superclass path |         // walk down superclass path | ||||||
|         while ((clazz = clazz.getSuperclass()) != null) { |         while ((clazz = clazz.getSuperclass()) != null) { | ||||||
|                 protoname = classMapping.getProperty(clazz.getName()); |             protoName = classMapping.getProperty(clazz.getName()); | ||||||
|                 if (protoname != null) { |             if (protoName != null) { | ||||||
|                 // cache the class name for the object so we run faster next time |                 // cache the class name for the object so we run faster next time | ||||||
|                     classMapping.setProperty(obj.getClass().getName(), protoname); |                 classMapping.setProperty(className, protoName); | ||||||
|                     return protoname; |                 return protoName; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         // check interfaces, too |         // check interfaces, too | ||||||
|         Class[] classes = obj.getClass().getInterfaces(); |         Class[] classes = obj.getClass().getInterfaces(); | ||||||
|         for (int i = 0; i < classes.length; i++) { |         for (int i = 0; i < classes.length; i++) { | ||||||
|                 protoname = classMapping.getProperty(classes[i].getName()); |             protoName = classMapping.getProperty(classes[i].getName()); | ||||||
|                 if (protoname != null) { |             if (protoName != null) { | ||||||
|                 // cache the class name for the object so we run faster next time |                 // cache the class name for the object so we run faster next time | ||||||
|                     classMapping.setProperty(obj.getClass().getName(), protoname); |                 classMapping.setProperty(className, protoName); | ||||||
|                     return protoname; |                 return protoName; | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|             // nada |         // not mapped - cache negative result | ||||||
|  |         classMapping.setProperty(className, CLASS_NOT_MAPPED); | ||||||
|         return null; |         return null; | ||||||
|     } |     } | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     public DocApplication getDoc() { |     public DocApplication getDoc() { | ||||||
|         RequestEvaluator eval = null; |         RequestEvaluator eval = null; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue