FileDocCategorySizeDatePackage
SomeClassFactory.javaAPI DocExample2534Sun Dec 14 22:47:40 GMT 2003oreilly.hcj.proxies

SomeClassFactory

public class SomeClassFactory extends Object
A demonstration of a proxy factory.
author
Robert Simmons jr. (kraythe)
version
$Revision: 1.2 $

Fields Summary
private static final Logger
LOGGER
Holds the logging object.
Constructors Summary
Methods Summary
public static final SomeClassCountingProxygetCountingProxy()
Gets a counting proxy to an object that is constructed with the user name.

return
The proxy to the implementation.


	                     	 
	     
		SomeClassImpl impl = new SomeClassImpl(System.getProperty("user.name"));
		return new SomeClassCountingProxy(impl);
	
public static final SomeClassgetDynamicSomeClassProxy()
Gets proxy to depending upon debug status in Log4J.

return
The proxy to the implementation.

		SomeClassImpl impl = new SomeClassImpl(System.getProperty("user.name"));
		InvocationHandler handler = new MethodCountingHandler(impl);
		Class[] interfaces = new Class[] { SomeClass.class };
		ClassLoader loader = SomeClassFactory.class.getClassLoader();
		SomeClass proxy = (SomeClass)Proxy.newProxyInstance(loader, interfaces, handler);
		return proxy;
	
public static final SomeClassProxygetProxy()
Gets a proxy to an object that is constructed with the user name.

return
The proxy to the implementation.

		SomeClassImpl impl = new SomeClassImpl(System.getProperty("user.name"));
		return new SomeClassProxy(impl);
	
public static final SomeClassgetSomeClassProxy()
Gets proxy to depending upon debug status in Log4J.

return
The proxy to the implementation.

		SomeClassImpl impl = new SomeClassImpl(System.getProperty("user.name"));
		if (LOGGER.isDebugEnabled()) {
			return new SomeClassCountingProxy(impl);
		} else {
			return new SomeClassProxy(impl);
		}