首页 / 软件开发 / JAVA / Jakarta-Common-Chain使用笔记
Jakarta-Common-Chain使用笔记2011-01-28 csdn博客 沈斌可以在你需要定义和执行一些顺序操作的时候采用Commons Chain。下载地址:http://commons.apache.org/downloads/download_chain.cgi五个工作类:GetCustomerInfo.jarpackage demo.chain;
import org.apache.commons.chain.Command;
import org.apache.commons.chain.Context;
public class GetCustomerInfo implements Command ...{
public boolean execute(Context context) throws Exception ...{
System.out.println("Get customer info");
context.put("customerName","George Burdell");
return false;
}
}TestDriveVehicle.jarpackage demo.chain;
import org.apache.commons.chain.Command;
import org.apache.commons.chain.Context;
public class TestDriveVehicle implements Command ...{
public boolean execute(Context context) throws Exception ...{
System.out.println("Test drive the vehicle");
return false;
}
}NegotiateSale.jarpackage demo.chain;
import org.apache.commons.chain.Command;
import org.apache.commons.chain.Context;
public class NegotiateSale implements Command ...{
public boolean execute(Context context) throws Exception ...{
System.out.println("Negotiate sale");
return false;
}
}