(no commit message)
[utils] / support / general / src / main / java / org / wamblee / general / ThreadSpecificInvocationHandler.java
index 49c2e177c71a5af22b59b49b5c125ae17589c64b..c7c9952b9c902730418bba9e9c0b9b77f3b5fc49 100644 (file)
@@ -24,39 +24,43 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 
 /**
- * Invocation handler for thread-specific proxies. 
+ * Invocation handler for thread-specific proxies.
  * 
  * @author Erik Brakkee
- *
+ * 
  * @param <T>
  */
-class ThreadSpecificInvocationHandler<T> implements InvocationHandler, Serializable {
-    
+class ThreadSpecificInvocationHandler<T> implements InvocationHandler,
+    Serializable {
+
     /**
-     * We store a map of unique ids of invocation handlers to thread local storage of the 
-     * service. In this way, serialiability of the generated proxy is obtained (required by 
-     * framweorks such as wicket). Also, different factories will still be separate and never
-     * use the same threadlocal storage. 
+     * We store a map of unique ids of invocation handlers to thread local
+     * storage of the service. In this way, serialiability of the generated
+     * proxy is obtained (required by framweorks such as wicket). Also,
+     * different factories will still be separate and never use the same
+     * threadlocal storage.
      */
-    private static Map<Integer,ThreadLocal> STORAGE = initializeThreadLocal();
-    
+    private static Map<Integer, ThreadLocal> STORAGE = initializeThreadLocal();
+
     private static AtomicInteger COUNTER = new AtomicInteger();
-    
+
     private static Map<Integer, ThreadLocal> initializeThreadLocal() {
-        Map<Integer,ThreadLocal> map = new ConcurrentHashMap<Integer,ThreadLocal>();
+        Map<Integer, ThreadLocal> map = new ConcurrentHashMap<Integer, ThreadLocal>();
         return map;
     }
 
-    
-    private int id; 
-    private Class clazz; 
-    
+    private int id;
+    private Class clazz;
+
     /**
-     * Constructs the handler. 
-     * @param aSvc Thread local for the service. 
-     * @param aClass Service interface class. 
+     * Constructs the handler.
+     * 
+     * @param aSvc
+     *            Thread local for the service.
+     * @param aClass
+     *            Service interface class.
      */
-    public ThreadSpecificInvocationHandler(ThreadLocal aSvc, Class aClass) { 
+    public ThreadSpecificInvocationHandler(ThreadLocal aSvc, Class aClass) {
         id = COUNTER.incrementAndGet();
         clazz = aClass;
         STORAGE.put(id, aSvc);
@@ -68,8 +72,9 @@ class ThreadSpecificInvocationHandler<T> implements InvocationHandler, Serializa
 
         ThreadLocal<T> local = STORAGE.get(id);
         T actualSvc = local.get();
-        if ( aMethod.getName().equals("toString") && actualSvc == null) { 
-            return "Thread-specific proxy for '" + clazz.getName() + "' id = " + id;
+        if (aMethod.getName().equals("toString") && actualSvc == null) {
+            return "Thread-specific proxy for '" + clazz.getName() + "' id = " +
+                id;
         }
         try {
             return aMethod.invoke(actualSvc, aArgs);