[jboss-dev-forums] [Design of JBoss Serialization] - Re: Interceptor medasata issue
tterm
do-not-reply at jboss.com
Sun Sep 17 04:40:22 EDT 2006
Hello Clebert,
so now let's come to the details and sorry for the long response time. I have a lot to do at the moment.
The interceptors are requested during an ejb3 method call. The client side interceptor code is the following:
| public class ExampleClientInterceptor implements Interceptor, Serializable {
| private static Logger logger = Logger.getLogger(ExampleClientInterceptor.class);
|
| public String getName() {
| return "ExampleClientInterceptor";
| }
|
| public Object invoke(Invocation invocation) throws Throwable {
| logger.debug("Client: request");
| SimpleMetaData metaData = invocation.getMetaData();
| metaData.addMetaData("tag", "attr", "Hello JBoss;-)");
| Object obj = invocation.invokeNext();
| logger.debug("Client: response");
| return obj;
| }
| }
You can see I just add a simple string to the metadata which should be read later from the server side interceptor. The server side interceptor has the following code:
public class ExampleServerInterceptor implements Interceptor{
| private static Logger logger = Logger.getLogger(ExampleServerInterceptor.class);
|
| public String getName(){
| return "ExampleServerInterceptor";
| }
|
| public Object invoke(Invocation invocation) throws Throwable{
| logger.debug("Server: request");
| SimpleMetaData metaData = invocation.getMetaData();
| String str = (String)metaData.getMetaData("tag", "attr");
| logger.debug("Output from metaData: " + str);
| Object obj = invocation.invokeNext();
| logger.debug("Server: response");
| return obj;
| }
| }
The interceptors are both registerded in the ejb3-interceptors-aop.xml which looks like the following:
| <aop>
| <interceptor class="de.example.ExampleClientInterceptor" scope="PER_VM"/>
| <interceptor class="de.example.ExampleServerInterceptor" scope="PER_VM"/>
|
| ....
|
| <stack name="StatelessSessionClientInterceptors">
| <interceptor-ref name="de.example.ExampleClientInterceptor"/>
| ...
| </stack>
| ... the same for the other client side stacks like stateful and so on
|
| server side stuff
|
| <domain name="Stateless Bean">
| <bind pointcut="execution(public * *->*(..))">
| <interceptor-ref name="de.example.ExampleServerInterceptor"/>
| ...
| </domain>
|
| ... the same for the other session bean stuff
|
| </aop>
|
So if you invoke an ejb3 method then you get allways the exception I described before and you will never come to the server side interceptor. I don't know if I do something wrong here but as I said before it works fine until JBoss4.0.3SP1.
It would be very nice if we could sorting out this things because I need it to finish an performance instrumentation project.
You can download the test project described before from http://www.strace.org/~tterm/jboss-testcase.zip (You can contact me private if you use this domain and put the username before the @ sign). If you need an ejb project for testing this things I can give you also an test project. Just let me know.
Thanks in advance.
Thomas Termin
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3972138#3972138
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3972138
More information about the jboss-dev-forums
mailing list