package com.shengshu.spring.aop;
import java.util.Vector;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;
/**
*
* @author 毛汲先 [ E-mail(pangshuqiang@163.com) QQ(127015919) ]
* @version 1.0 @Jun 9, 2009 12:18:55 PM
*
*/
public class TestShopping {
public TestShopping() {
super();
// TODO Auto-generated constructor stub
}
/**
* @param args
*/
public static void main(String[] args) {
// BeanFactory factory =
// new XmlBeanFactory(new FileSystemResource(new
// File("E:\\myworkspace\\testspring\\src\\applicationContext.xml")));
BeanFactory factory = new XmlBeanFactory(new FileSystemResource(
"src\\applicationContext.xml"));
// ShoppingCart cart = (ShoppingCart)factory.getBean("cart");
ICustomer cust = (ICustomer) factory.getBean("customerService1");
// ICustomer cust = (ICustomer) factory.getBean("customerService2");
// CustomerNoIMPL cust = (CustomerNoIMPL) factory.getBean("customerNoIMPLService1");
// CustomerNoIMPL cust = (CustomerNoIMPL) factory.getBean("customerNoIMPLService2");
System.out.println("--------- buy book ------------");
ShoppingCart cart = new ShoppingCart();
cart.add("first book");
cart.add("second book");
cust.setCart(cart);
cust.buy("four book");
System.out.println("------- cust.getCart() ----------");
ShoppingCart cartShow = cust.getCart();
if (cartShow != null && cartShow.items != null) {
Vector<String> items = cartShow.items;
for (int i = 0; i < items.size(); i++) {
System.out.println("arg value: " + items.get(i));
}
}
}
}