3 Replies Latest reply on May 7, 2007 7:22 PM by Matt Drees

    Seam component as a listener

    zzzz8 Newbie

      I would like to have a Seam component used as a listener. Here's what I mean:

      public class MyClassBean implements MyClass, PacketListener {
      Connection connection = null;
      List<MyMessageList> messageList = null;
      public void createBean() {
      public void processPacket(Packet packet) {

      The processPacket method has its interface defined by the PacketListener interface and is thus implemented in my bean. So I want the Seam component to be a listener - this can be seen in the statement:


      This seems to work... up to a point. So when the processPacket method is invoked, I notice messageList doesn't seem to be injected. What am I doing wrong and is there any way around this?

        • 1. Re: Seam component as a listener
          Matt Drees Master

          I ran into something like that. The problem is that in


          "this" is a reference to the actual bean, and not a reference to the bean's proxy. Interceptors (which are used for injection) are only called if you invoke a method on the proxy, not the bean itself.

          I don't know the best way to solve the problem. In your case you could do something like

          I don't really like it, but it should work.

          If anyone knows a nicer way for a bean to get a reference to its own proxy, please speak up.

          • 2. Re: Seam component as a listener
            zzzz8 Newbie

            Hi Matt,

            Thanks for the reply. I actually tried something similar to that:



            connection.addPacketListener(Component.getInstance("myBean", false));

            Both didn't work for me though...

            • 3. Re: Seam component as a listener
              Matt Drees Master

              Odd. Well, I'm not sure what's up. Sorry.