ejb@glassfish.java.net

Re: : stateful EJB

From: Mahesh Kannan <Mahesh.Kannan_at_Sun.COM>
Date: Thu, 14 Jan 2010 06:51:18 -0800

Can you share the servlet code as well?


נחום מורדוכוביץCan you share the Servlet
 wrote:
> this is the code.
> * *
> *Counter.java*
> *=============*
> *
> package myEjb;
>
> import javax.annotation.PostConstruct;
> import javax.ejb.Stateful;
>
> @Stateful
> public class Counter implements CounterRemote
> {
> private Integer x;
>
> @PostConstruct
> @Override
> public void initBean()
> {
> this.x = 0;
> }
>
> @Override
> public Integer getX()
> {
> return this.x;
> }
>
> @Override
> public void setX(Integer x)
> {
> this.x = x;
> }
>
> }
> *
>
> The remote interface
> CounterRemote.java
> =================
> package myEjb;
>
> import javax.ejb.Remote;
>
> @Remote
> public interface CounterRemote
> {
>
> @javax.annotation.PostConstruct
> public void initBean();
>
> Integer getX();
>
> void setX(Integer x);
> }
>
> On Thu, Jan 14, 2010 at 07:54, Dies Koper <diesk_at_fast.au.fujitsu.com
> <mailto:diesk_at_fast.au.fujitsu.com>> wrote:
>
> *Thanks,*
>
> *I wrote a simple stateful ejb that store int number and two
> methods
> getNumber() and setNumber(int x),*
> i'm calling the ejb from two separate sessions (two browsers)
> and if i set the number from first session i can see it from next
> session by calling getNumber().
> By your answer I understand it should not be so ?
>
>
> Right, it shouldn't. You must be doing something you're not
> telling us that make the EJB container think it's the same client.
> Or you're keeping the value in a static variable or another shared
> location.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net
> <mailto:ejb-unsubscribe_at_glassfish.dev.java.net>
> For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
> <mailto:ejb-help_at_glassfish.dev.java.net>
>
>