geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Łukasz Budnik" <lukasz.bud...@gmail.com>
Subject Re: Interceptors on SessionBeans
Date Fri, 28 Nov 2008 09:02:38 GMT
Hi jsmch,

I had some problems with XML defined interceptors in Geronimo 2.1 too.

Maybe you could use @AroundInvoke and @Interceptors annotations instead?

If so, maybe my post will be more helpful for you:
http://jee-bpel-soa.blogspot.com/2008/10/aspect-oriented-programming-in-ejb3.html

All was tested on Geronimo 2.1, and just like you, I was also using
@PersistenceContext in my interceptor.

thanks and best regards
Łukasz

2008/11/27 jsmch <jsmch@web.de>

>
> Hi,
>
> today i got an interceptor to be built into my geronimo-application.
> The interceptor is correctly deployed (no errors on deployment), but when
> testing the application the interceptor-method is never used (i tried it
> with System.out.println-code which should be visible on the server - but
> only original code is being accessed - not the interceptor methods).
>
> As you can see, the interceptor-class uses AroundInvoke:
>
> The interceptor class:
> ------------------------------------------------------
> public class MessageInterceptor
> {
>        public MessageInterceptor()
>        {
>                System.out.println("bla");
>        }
>
>        @PersistenceContext(unitName="chatbench")
>        private EntityManager em;
>        private int measureId = -1;
>        private int appserverid = -1;
>        private boolean deletedLogFlag = true;
>
>
>
>        @AroundInvoke
>        public Object invoke(InvocationContext context) throws Exception
>        {
>              some code...
> ----------------------------------------
>
> The ejb-jar describes the ejb-name, the interceptor-class and the method
> that has to be intercepted:
> The ejb-jar.xml
> ----------------------------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
>                  http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
>        version="3.0">
>        <display-name>ChatKernelGeronimo</display-name>
>        <assembly-descriptor>
>                <interceptor-binding>
>                        <ejb-name>ChatClient</ejb-name>
>
>  <interceptor-class>chat.benchmark.MessageInterceptor</interceptor-class>
>                        <method>
>                                <method-name>sendMessage</method-name>
>                        </method>
>                </interceptor-binding>
>        </assembly-descriptor>
> </ejb-jar>
> ----------------------------------------
>
> The Bean is the ChatClient-class (with sendMessage to be intercepted):
> --------------------------------------
> public @Stateful
> class ChatClient extends Client implements IChatClient {
>   ...some code
>
>        public void sendMessage(String message) {
>
>                sendMessage(message, user.getId());
>        }
>
>  ...some code
>
> }
> --------------------------------------
>
> Note: In our project an other team is using exactly the same application
> running on JBoss (with a few other configuration issues due to JBoss) - and
> there it´s running quit fine.
> Any idea what the problem could be? Is there any code necessary to be added
> to the openejb-jar.xml for interceptors? (i didn´t find any useful
> information in documentation for interceptors)
>
> Thank you in advance if there is anybody how can help me
>
> jsmch
> --
> View this message in context:
> http://www.nabble.com/Interceptors-on-SessionBeans-tp20724489s134p20724489.html
> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>
>
Mime
View raw message