2 Replies Latest reply on Feb 11, 2007 1:37 PM by None None

    Outjection problems with interface variables

    Toni Beckman Novice

      Hi,

      I have the problem that I can't outject an instance of an Entity Bean from a SFSB into a context variable.

      The instance field of the SFSB from which I'm trying to outject the EntityBean is an INTERFACE, which two of my Enity Beans implement.

      I think this is causing problems. I can tell that there is something wrong, because if I use the following code in the SFSB

      @Out(required = false)
      InterfaceCitySettable interfaceCitySettable;

      then changes to the variable are NOT reflected in the context variable of the current conversation after invoking the SFSB.

      However, if I change the code to

      @Out(value="somethingnonexistent", required = false)
      InterfaceCitySettable interfaceCitySettable;

      then the EntityBean gets successfully outjected into the context variable "somethingnonexistent" of the current conversation.

      Why is this?

      I think it has to with the fact that the variable of the SFSB from which I'm trying to outject is an INTERFACE, which my hold two types of EntityBeans.

      It seems to me that the first Entity Bean, which gets outjected into the context variable kind of write protects it or something like this.

      After that I can only outject the same class into the interace, but not any other class also implementing the interface.

      I appreciate any suggestions and comments, because I'm really kind of stuck on this one.

        • 1. Re: Outjection problems with interface variables
          Pete Muir Master

          Please show the entities in question

          • 2. Re: Outjection problems with interface variables
            None None Master

            I'm pretty sure I know what's going on.

            Your interface is not a Seam-managed entity. Therefore the Seam-entity's scope specification doesn't apply to it. But when you use the real Seam entity, and not the interface, then those rules DO apply and you can't outject it to a wider context than the entity's specified context. Make sense?

            Here's an example. java.lang.String is obviously not a Seam entity. Let's say that I have a Seam entity called Book with Conversation scope, and the book implements the Item interface.

            I can do this:

            @Out(value="foo",scope=whatever) private String myString;

            and indeed that string will be outjected. The string is not a Seam-entity so it has no specified scope other than what I specify in the outjection.

            If I do this:

            @Out(value="foo",scope=Session) private Book myBook;

            It won't work because Book has a specified scope (conversation) and cannot be outjected to a wider scope.

            But if I do it like this:

            @Out(value="foo",scope=Session) private Item myBook;

            it's the exact same object, but Item is not a Seam entity, so the outjection works! I think you are seeing inconsistent results because when you use the interface, the Seam scope specification doesn't exist, so you are creating a new one, whereas if you use the Seam-entity you are letting Seam manage it.