/*
 * The Spring Framework is published under the terms
 * of the Apache Software License.
 */
 
package org.springframework.aop.framework;

import org.aopalliance.intercept.Interceptor;
import org.springframework.aop.framework.support.AopUtils;
import org.springframework.aop.target.SingletonTargetSource;


/**
 * Factory for AOP proxies for programmatic use, rather than via a bean
 * factory. This class provides a simple way of obtaining and configuring
 * AOP proxies in code.
 * @since 14-Mar-2003
 * @author Rod Johnson
 * @version $Id: ProxyFactory.java,v 1.9 2003-11-30 17:17:34 johnsonr Exp $
 */
public class ProxyFactory extends AdvisedSupport {

	public ProxyFactory() {
	}

	/**
	 * Proxy all interfaces of the given target.
	 */
	public ProxyFactory(Object target) throws AopConfigException {
		if (target == null) {
			throw new AopConfigException("Can't proxy null object");
		}
		setInterfaces(AopUtils.getAllInterfaces(target));
		setTargetSource(new SingletonTargetSource(target));
	}
	
	/**
	 * No target, only interfaces. Must add interceptors.
	 */
	public ProxyFactory(Class[] interfaces) {
		setInterfaces(interfaces);
	}

	/**
	 * Create new proxy according to the settings in this factory.
	 * Can be called repeatedly. Effect will vary if we've added
	 * or removed interfaces. Can add and remove "interceptors"
	 * @return Object
	 */
	public Object getProxy() {
		AopProxy proxy = createAopProxy();
		return proxy.getProxy();
	}

	/**
	 * Create new proxy for the given interface and interceptor.
	 * Convenience method for creating a proxy for a single interceptor.
	 * @param proxyInterface the interface that the proxy should implement
	 * @param interceptor the interceptor that the proxy should invoke
	 * @return the new proxy
	 */
	public static Object getProxy(Class proxyInterface, Interceptor interceptor) {
		ProxyFactory proxyFactory = new ProxyFactory();
		proxyFactory.addInterface(proxyInterface);
		proxyFactory.addInterceptor(interceptor);
		return proxyFactory.getProxy();
	}

}

@@ -180,16 +180,17 @@
 ceptor;%0A
+%0A
 import o
@@ -244,69 +244,8 @@
 ls;%0A
-import org.springframework.aop.target.SingletonTargetSource;%0A
 %0A%0A/*
@@ -504,37 +504,38 @@
 v 1.
-9
+10
  2003-1
-1
+2
 -30 
-17:17:34 johnson
+01:06:37 jhoelle
 r Ex
@@ -898,48 +898,16 @@
 rget
-Source(new SingletonTargetSource
 (target)
 );%0A%09
@@ -902,17 +902,16 @@
 (target)
-)
 ;%0A%09%7D%0A%09%0A%09

use setTarget instead of setTargetSource