Default Creator Example
/* Pro Spring By Rob Harrop Jan Machacek ISBN: 1-59059-461-4 Publisher: Apress */ /////////////////////////////////////////////////////////////////////////////////////// //File: dpac.xml <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="autoBean" class="AutoBean"/> <bean id="otherBean" class="OtherBean"/> </beans> /////////////////////////////////////////////////////////////////////////////////////// public class AutoBean { public void foo() { System.out.println("foo()"); } } /////////////////////////////////////////////////////////////////////////////////////// public class OtherBean { public void foo() { System.out.println("foo()"); } } /////////////////////////////////////////////////////////////////////////////////////// import org.springframework.aop.support.AopUtils; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; public class DefaultCreatorExample { public static void main(String[] args) { ApplicationContext ctx = new FileSystemXmlApplicationContext( "build/dpac.xml"); AutoBean autoBean = (AutoBean)ctx.getBean("autoBean"); OtherBean otherBean = (OtherBean)ctx.getBean("otherBean"); autoBean.foo(); System.out.println(AopUtils.isAopProxy(autoBean)); otherBean.foo(); System.out.println(AopUtils.isAopProxy(otherBean)); } }