X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fenterprise%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsupport%2FThreadSpecificProxyFactory.java;h=02668cdc9cbb3cdfbf04437e5c2c32778b0d4543;hb=f9ccadb956bac942258d9892c66e481ac2aec446;hp=1e9c3468d355370d81242d8ed39d1eb2b61f3fe2;hpb=4c4b45259c4af24c2551c40df72ad776dd037cbe;p=utils diff --git a/test/enterprise/src/main/java/org/wamblee/support/ThreadSpecificProxyFactory.java b/test/enterprise/src/main/java/org/wamblee/support/ThreadSpecificProxyFactory.java index 1e9c3468..02668cdc 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/ThreadSpecificProxyFactory.java +++ b/test/enterprise/src/main/java/org/wamblee/support/ThreadSpecificProxyFactory.java @@ -49,28 +49,42 @@ public class ThreadSpecificProxyFactory { private Class clazz; /** - * Constructs the factory. - * @param aClass Interface class of the service to proxy. + * Constructs the factory. + * + * @param aClass + * Interface class of the service to proxy. */ public ThreadSpecificProxyFactory(Class aClass) { - if ( !aClass.isInterface() ) { - throw new IllegalArgumentException("Class " + aClass.getName() + " is not an interface"); + if (!aClass.isInterface()) { + throw new IllegalArgumentException("Class " + aClass.getName() + + " is not an interface"); } clazz = aClass; } /** - * Sets the thread-specific service. - * @param aService Service, use null value to reset. + * Sets the thread-specific service. + * + * @param aService + * Service, use null value to reset. */ public void set(T aService) { svc.set(aService); } + + /** + * Gets the current thread-specific service. + * @return Service. + */ + public T get() { + return svc.get(); + } /** - * Gets the proxy that delegates to the thread-specific instance set by + * Gets the proxy that delegates to the thread-specific instance set by * {@link #set(Object)} - * @return Proxy. + * + * @return Proxy. */ public T getProxy() { InvocationHandler handler = new ThreadSpecificInvocationHandler(); @@ -82,8 +96,9 @@ public class ThreadSpecificProxyFactory { new Class[] { InvocationHandler.class }).newInstance( new Object[] { handler }); return proxy; - } catch (Exception e) { - throw new RuntimeException("Could not create proxy for " + clazz.getName(), e); + } catch (Exception e) { + throw new RuntimeException("Could not create proxy for " + + clazz.getName(), e); } } }