计数代理被设计成可以被客户访问的与服务提供者具有相同接口的对象。客户对象不是直接访问服务提供者,而是调用计数代理对象上的方法,计数代理执行必要的纪录日志(logging)和计数(counting)功能后,再把方法调用传递给服务提供着对象。如图1 2828o18m1i2q Figure1: Generic Class Association When the Counting Proxy Pattern Is Applied
public class Order implements OrderIF { public Vector getAllOrders() { FileUtil fileUtil = new FileUtil(). Vector v = fileUtil.fileToVector("orders.txt"). return v. } }