Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Thursday, November 22, 2007

java code for Default Creator

/*
Pro Spring
By Rob Harrop
Jan Machacek
ISBN: 1-59059-461-4
Publisher: Apress
*/


///////////////////////////////////////////////////////////////////////////////////////
//File: dpac.xml








///////////////////////////////////////////////////////////////////////////////////////

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));
}
}

No comments: