Server running on GlassFish 3.0
@Stateless(mappedName="messengerservice")
public class MessengerService implements MsnService{
int count;
@Override
public int getCount() {
// TODO Auto-generated method stub
count = count+1;
return count;
}
}
Client
for(int i=0;i<5;i++){
MsnService br = (MsnService) ctx.lookup("java:global/EJbTutorial/MessengerService");
System.out.println(br.getCount());
}
Output
1
2
3
4
5
EJB spec says that server maintains a pool of session beans , i increment the value in one instance , re look up hopefully get a new instance and it seems the instance variable value is maintained
How is it possible ? unless server keeps returning me the same instance every time, or is it.
I even tried it executing it in a loop and same result. Can any shed some light