*
*/
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
*/
}
/**
- * 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
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 {
*
* @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) {
" 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.
*/