i've done some trial:.

an action

@InjectEJB(name = "WAP-Shop/TestDeiBeanBean")
    TestDeiBeanLocal tdb;
   public String execute() throws Exception {
//        scb = lookupShopCartBean();
        System.out.println("value --> " + tdb.value());
        System.out.println("setTrue " + tdb.setTrue());

...}

the ejb

    private boolean b = false;

    public boolean value() {
        return b;
    }

    public boolean setTrue() {
        b = true;
        return b;
    }

    public boolean setFalse() {
        b = false;
        return b;
    }


the output is:


21:27:46,062 INFO  [STDOUT] value --> false
21:27:46,078 INFO  [STDOUT] setTrue true

--lose data--
21:27:47,578 INFO  [STDOUT] value --> false
21:27:47,578 INFO  [STDOUT] setTrue true

--mantain data--
21:27:48,265 INFO  [STDOUT] value --> true
21:27:48,265 INFO  [STDOUT] setTrue true

--lose data--
21:27:48,671 INFO  [STDOUT] value --> false
21:27:48,671 INFO  [STDOUT] setTrue true
21:27:49,453 INFO  [STDOUT] value --> false
21:27:49,453 INFO  [STDOUT] setTrue true


--manatain data
21:27:49,875 INFO  [STDOUT] value --> true
21:27:49,875 INFO  [STDOUT] setTrue true
21:27:50,328 INFO  [STDOUT] value --> true
21:27:50,328 INFO  [STDOUT] setTrue true
21:27:50,734 INFO  [STDOUT] value --> true
21:27:50,734 INFO  [STDOUT] setTrue true
21:27:51,046 INFO  [STDOUT] value --> true
21:27:51,046 INFO  [STDOUT] setTrue true
21:27:51,671 INFO  [STDOUT] value --> true
21:27:51,671 INFO  [STDOUT] setTrue true
21:27:52,265 INFO  [STDOUT] value --> true
21:27:52,265 INFO  [STDOUT] setTrue true

what appends?

On Mon, Apr 20, 2009 at 18:31, Stefano Tranquillini <
stefano.tranquill...@gmail.com> wrote:

> Hi all.
>
> i've a problem with ejb stateful bean.
>
> in my stateful ejb i've this method
>
> @Stateful
> public class ShopCartBean implements ShopCartLocal {
>
>    @EJB
>    private MGMTLocal man;
>
>
>
>
>    private Customer customer;
>
>    public boolean *enableShopping*(String user, String password) {
>        customer  = man.loginUser(user, password);
>        if (customer  != null) {
>            return true;
>        } else {
>            return false;
>        }
>    }
>
>  public boolean *addItem*(int idItem, int quan) {
>        if (customer != null) {
>                  ......
>        } else {
>            System.out.println("no customer");
>            return false;
>        }
>    }
>
> }
>
> i've an action that perform the login and has to set customer corrisponding
> class
>
>     @InjectEJB(name = "WAP-Shop/ShopCartBean")
>     private ShopCartLocal scb;
>
> ....
>
>
>   if (scb.*enableShopping*(username_login, password_login)) {
>                return SUCCESS;
>            } else {
>                return ERROR;
>            }
>
> this action return success OK.
>
> now, i call another class
>
>     @InjectEJB(name = "WAP-Shop/ShopCartBean")
>     private ShopCartLocal scb;
>
> if (scb.*addItem*(idItemtoAdd,quantity)) {
>
>                     return SUCCESS;
>                 } else {
> return ERROR;
> }
>
> this action return ALWAYS ERROR: Customer is always set to NULL.
> stateful usaually doesn't store information?
> or i miss something?
> --
> Stefano
>
>


-- 
Stefano

Reply via email to