1.自定义Valve类
[java] view plain copy
- public class MyValve extends AbstractValve
- {
- public void invoke(PipelineContext context) throws Exception
- {
- System.out.println("this is my valve : stated");
- context.invokeNext();
- System.out.println("this is my valve : ended");
- }
- }
(1)继承AbstractValve类
也可以实现Valve接口,效果一样
[java] view plain copy
- public abstract class AbstractValve extends BeanSupport implements Valve {
- }
(2)实现invoke方法
注意:和filter一样,需要调用下一个valve。使用invokeNext()方法
2.在pipeline.xml中配置
[html] view plain copy
- <services:pipeline xmlns="http://www.alibaba.com/schema/services/pipeline/valves">
- <!-- 初始化turbine rundata,并在pipelineContext中设置可能会用到的对象(如rundata、utils),以便valve取得。 -->
- <prepareForTurbine />
- .......
- <valve class="com.alibaba.webx.tutorial1.app1.value.MyValve"/>
- .......
- </services:pipeline>
最后欢迎大家访问我的个人网站:1024s