将windsor拦截器配置为仅挂接标记的方法 [英] Configure windsor interceptor to hook only marked methods

查看:126
本文介绍了将windsor拦截器配置为仅挂接标记的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有可能配置Interceptor只钩接特殊接口的方法,或者通过基类?
目前我注册的Interceptor与一个DB的连接范围工作。现在我添加了另一个范围工作与另一个数据库,并希望添加另一个拦截器,将钩子第二范围的方法。可以通过xml文件配置拦截器,而不是检查调用属性的目标。

Is there possibility to configure Interceptor to hook methods only of special interface, or by base class? Currently I have registered Interceptor that works with scope of connections to one DB. Now I added another scope working with another db and want to add another interceptor, which will hook methods of second scope. It is possible to configure interceptor via xml files, instead of checking target of invocation properties.

我通过组件添加了拦截器:

I've added interceptor via components:

 <component
    type="Common.IoC.SessionScopeInterceptor, Common"
    lifestyle="transient">
 </component>

AFAIK此拦截器截取在windsor容器中注册的所有类的所有方法。

AFAIK this interceptor intercepts all methods of all classes registered in windsor container.

我可以添加类似这样的东西^

I wand to add something like this^

 <component
    type="Common.IoC.SessionScopeInterceptor, Common"
    lifestyle="transient"
    interceptOnlyVirtualMethods="true"
    interceptClass="Common.IoC.SessionScope1, Common"
    >
 </component>


推荐答案

您需要创建自己的AbstractFacility,行为。基本上,你需要实现类似于Mikael Sundberg在

you need to create your own AbstractFacility that implements your desired behaviour. Essentially, you need to implement something similar to what Mikael Sundberg did in the answer to this question.

这篇关于将windsor拦截器配置为仅挂接标记的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆