(no commit message)
[utils] / support / general / src / main / java / org / wamblee / general / LookupProxyFactory.java
index 286e5f5651ead211874d53773753be89a7a56431..a703e2bfc1497ca41695e5d99e7cb007984c4b5f 100644 (file)
@@ -34,23 +34,25 @@ import javax.naming.NamingException;
  * 
  */
 public class LookupProxyFactory<T> {
-    
+
     /**
-     * Interface to lookup the object to delegate to. 
+     * Interface to lookup the object to delegate to.
      * 
      * @author Erik Brakkee
      */
-    public static interface Lookup extends Serializable { 
-         /**
-          * Looks up the object. 
-          * @return Object (non-null)
-          * @throws Any exception in case the object cannot be found. 
-          */
-         Object lookup() throws Exception; 
+    public static interface Lookup extends Serializable {
+        /**
+         * Looks up the object.
+         * 
+         * @return Object (non-null)
+         * @throws Any
+         *             exception in case the object cannot be found.
+         */
+        Object lookup() throws Exception;
     }
-    
+
     /**
-     * Exception thrown in case an object cannot be retrieved from JNDI. 
+     * Exception thrown in case an object cannot be retrieved from JNDI.
      * 
      * @author Erik Brakkee
      */
@@ -65,23 +67,26 @@ public class LookupProxyFactory<T> {
     }
 
     /**
-     * Invocation handler that does a lookup in JNDI and invokes the method on the 
-     * object it found. 
+     * Invocation handler that does a lookup in JNDI and invokes the method on
+     * the object it found.
      * 
      * @author Erik Brakkee
      */
-    private static class LookupInvocationHandler<T> implements InvocationHandler, Serializable {
-        
-        private Class clazz; 
-        private Lookup lookup; 
-        
+    private static class LookupInvocationHandler<T> implements
+        InvocationHandler, Serializable {
+
+        private Class clazz;
+        private Lookup lookup;
+
         /**
-         * Constructs the invocation handler. 
-         * @param aLookup Lookup class. 
+         * Constructs the invocation handler.
+         * 
+         * @param aLookup
+         *            Lookup class.
          */
         public LookupInvocationHandler(Class aClass, Lookup aLookup) {
             clazz = aClass;
-            lookup = aLookup; 
+            lookup = aLookup;
         }
 
         @Override
@@ -94,15 +99,15 @@ public class LookupProxyFactory<T> {
             try {
                 svcObj = lookup.lookup();
             } catch (Exception e) {
-                throw new LookupException(
-                    "Error looking up object", e);
+                throw new LookupException("Error looking up object", e);
             }
             if (svcObj == null) {
                 throw new LookupException("Object is null");
             }
             if (!clazz.isInstance(svcObj)) {
-                throw new LookupException("Object '" + svcObj + "' is not of type " + clazz.getName() +
-                    " but of type " + svcObj.getClass().getName());
+                throw new LookupException("Object '" + svcObj +
+                    "' is not of type " + clazz.getName() + " but of type " +
+                    svcObj.getClass().getName());
             }
             T svc = (T) svcObj;
             try {
@@ -121,7 +126,8 @@ public class LookupProxyFactory<T> {
      * 
      * @param aClass
      *            Interface class of the service to proxy.
-     * @param aJndi JNDI name of the object to lookup. 
+     * @param aJndi
+     *            JNDI name of the object to lookup.
      * 
      */
     public LookupProxyFactory(Class<T> aClass, Lookup aLookup) {
@@ -130,15 +136,15 @@ public class LookupProxyFactory<T> {
                 " is not an interface");
         }
         clazz = aClass;
-        lookup = aLookup; 
+        lookup = aLookup;
     }
 
     /**
      * Gets the proxy that delegates to the thread-specific instance set by
      * {@link #set(Object)}
      * 
-     * When at runtime the proxy cannot find lookup the object in JNDI, it 
-     * throws {@link LookupException}. 
+     * When at runtime the proxy cannot find lookup the object in JNDI, it
+     * throws {@link LookupException}.
      * 
      * @return Proxy.
      */