hi, im not certain i understood you question, but ill try to clarify a bit.
first off your jboss-aop.xml is completly valid and will work, but its a bit
"wierd". for readability i would recommend:
| <?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
| <aop>
| <interceptor name="TextformatInterceptor"
class="segn.util.interceptor.TextFormatInterceptor"
scope="PER_CLASS"/>
| <bind pointcut="call(public void
$instanceof{segn.util.model*}->set*(java.lang.String))">
| <interceptor-ref name="TextFormatInterceptor"/>
| </bind>
| </aop>
|
with your version you would have gotten an error if you tried to use the same interceptor
on several pointcuts (multiple definitions but possibly different scope).
for the second question i would recommend to take a look at the examples given in the
jboss-aop dist. but to the point, if an invocations is of type
"methodinvocation" you can just try to cast it to that type. eg:
| public class TextFormatInterceptor implements Interceptor {
| public String getName() { return "TextFormatInterceptor"; }
|
| public Object invoke(Invocation invocation)
| throws Throwable
| {
| if(invocation instanceof MethodInvocation)
| try
| {
| MethodInvocation mi = (MethodInvocation) invocation;
| Object rsp = mi.invokeNext();
| if (rsp instanceof java.lang.String)
| {
| //do whatever you want
| //eg: return new String("foo");
| }
| else
| return rsp;
|
| }
| catch(Exception e) {}
| }
| }
|
i havent compiled this code, its just to give you an idea, and with the MethodInvocation
object you have other methods you can get data from than just Invocation. look at the
examples for more info. if i was way off, try to explain you problem again and ill do my
best to help.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3969442#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...