X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fgeneral%2FLookupProxyFactory.java;h=a703e2bfc1497ca41695e5d99e7cb007984c4b5f;hb=4a575582a5c2999bd816b197d9cf274b4b3ddcd7;hp=286e5f5651ead211874d53773753be89a7a56431;hpb=7d3754ca3d757ef89241cdbd679f82941e64cfc6;p=utils diff --git a/support/general/src/main/java/org/wamblee/general/LookupProxyFactory.java b/support/general/src/main/java/org/wamblee/general/LookupProxyFactory.java index 286e5f56..a703e2bf 100644 --- a/support/general/src/main/java/org/wamblee/general/LookupProxyFactory.java +++ b/support/general/src/main/java/org/wamblee/general/LookupProxyFactory.java @@ -34,23 +34,25 @@ import javax.naming.NamingException; * */ public class LookupProxyFactory { - + /** - * 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 { } /** - * 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 implements InvocationHandler, Serializable { - - private Class clazz; - private Lookup lookup; - + private static class LookupInvocationHandler 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 { 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 { * * @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 aClass, Lookup aLookup) { @@ -130,15 +136,15 @@ public class LookupProxyFactory { " 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. */