打字猴:1.700483126e+09
1700483126
1700483127 private Vector<EventCustomType>customType=new Vector<EventCustomType>();
1700483128
1700483129 //每个消费者都要声明自己处理哪一类别的事件
1700483130
1700483131 public EventCustomer(EventCustomType_type){
1700483132
1700483133 addCustomType(_type);
1700483134
1700483135 }
1700483136
1700483137 //每个消费者可以消费多个事件
1700483138
1700483139 public void addCustomType(EventCustomType_type){
1700483140
1700483141 customType.add(_type);
1700483142
1700483143 }
1700483144
1700483145 //得到自己的处理能力
1700483146
1700483147 public Vector<EventCustomType>getCustomType(){
1700483148
1700483149 return customType;
1700483150
1700483151 }
1700483152
1700483153 //每个事件都要对事件进行声明式消费
1700483154
1700483155 public abstract void exec(ProductEvent event);
1700483156
1700483157 }
1700483158
1700483159 很简单,我们定义了一个Vector变量来存储处理者的处理能力,然后通过构造函数约束子类必须定义一个自己的处理能力。在代码中,我们用到了事件处理类型枚举,如代码清单36-9所示。
1700483160
1700483161 代码清单36-9 事件处理枚举
1700483162
1700483163 public enum EventCustomType{
1700483164
1700483165 //新建立事件
1700483166
1700483167 NEW(1),
1700483168
1700483169 //删除事件
1700483170
1700483171 DEL(2),
1700483172
1700483173 //修改事件
1700483174
1700483175 EDIT(3),
[ 上一页 ]  [ :1.700483126e+09 ]  [ 下一页 ]