Hi Guys (and Ladies of course ;-) )!
I stumbled upon a jee6-tutorial (link to tutorial) where a shopping-cart is used as an example for a stateful session bean. There I learned something about the @Remove annotation. Within this example the checkout is "done" (in fact nothing happens in the code ) via a method annotated with @Remove.
The problem: As far as I know you cannot use the stateful session bean anymore after you have called the method with the @Remove annotation --> further calls on the same instance will result in an javax.ejb.EJBNoSuchObjectException. In my opinion the default-behavior of a shopping-cart should be that the old one is processed and afterwards an empty new one should be available. Therefore I was wondering about the following scenario:
The SessionController is a CDI-managed-bean used in a JSF-page. The ShoppingCart is my stateful session bean with the @Remove-method checkout(). After I have called the checkout()-method I cannot use the injected instance of ShoppingCart anymore and therefore I have to start a completely new browser-session which generates a new session for JSF which further injects a new instance of my ShoppingCart.
So the question is:
Is there a way to get a new instance of ShoppingCart injected via a standardized way (dependency injection)?
Thanks for your help in advance,
kind regards, Valentin
I stumbled upon a jee6-tutorial (link to tutorial) where a shopping-cart is used as an example for a stateful session bean. There I learned something about the @Remove annotation. Within this example the checkout is "done" (in fact nothing happens in the code ) via a method annotated with @Remove.
The problem: As far as I know you cannot use the stateful session bean anymore after you have called the method with the @Remove annotation --> further calls on the same instance will result in an javax.ejb.EJBNoSuchObjectException. In my opinion the default-behavior of a shopping-cart should be that the old one is processed and afterwards an empty new one should be available. Therefore I was wondering about the following scenario:
The SessionController is a CDI-managed-bean used in a JSF-page. The ShoppingCart is my stateful session bean with the @Remove-method checkout(). After I have called the checkout()-method I cannot use the injected instance of ShoppingCart anymore and therefore I have to start a completely new browser-session which generates a new session for JSF which further injects a new instance of my ShoppingCart.
So the question is:
Is there a way to get a new instance of ShoppingCart injected via a standardized way (dependency injection)?
Thanks for your help in advance,
kind regards, Valentin