API Overview API Index Package Overview Direct link to this page
JavaOnTracks 0.1.2
  net.jot.web. JOTFlowClassCache View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

/*
------------------------------------
JavaOnTracks          Thibaut Colar
tcolar-jot AT colar DOT net
Artistic Licence 2.0
http://www.javaontracks.net
------------------------------------
 */
package net.jot.web;

import java.util.Hashtable;

import net.jot.logger.JOTLogger;

/**
 * Cache that stores "Class" objects requested by flow.conf (ie: controllers and views)
 * Such as class.forName won't have to be called repeatedly.
 * @author thibautc
 */
public class JOTFlowClassCache {

	private static Hashtable cache=new Hashtable();
	
	public static Class getClass(String className) throws Exception
	{
		try
		{
		if(!cache.containsKey(className))
		{
			synchronized(JOTFlowClassCache.class)
			{
				if(!cache.containsKey(className))
				{
					Class theClass=Class.forName(className);
					cache.put(className, theClass);
				}
			}
			JOTLogger.log(JOTLogger.CAT_FLOW,JOTLogger.DEBUG_LEVEL, JOTFlowClassCache.class, "Loaded class in cache: "+className);
		}
		
		JOTLogger.log(JOTLogger.CAT_FLOW,JOTLogger.TRACE_LEVEL, JOTFlowClassCache.class, "Fetched class from cache: "+className);
		}
		catch(ClassNotFoundException e)
		{
			JOTLogger.log(JOTLogger.CAT_FLOW,JOTLogger.ERROR_LEVEL, JOTFlowClassCache.class, "!! Could not find class: "+className);
			Exception e2=new Exception("!! Could not find class: "+className,e);
			throw(e2);
		}
		
		
		return (Class)cache.get(className);
	}
}

Generated By: JavaOnTracks Doclet 0.1.5     ©Thibaut Colar