I just was reading the code for one of the Seam 3 booking example classes (
http://anonsvn.jboss.org/repos/seam/examples/trunk/booking/ejb-jar/src/ma...
):
public
@Named("bookingAgent")
@Stateful
@ConversationScoped
class BookingAgentBean implements BookingAgent
{
private @Logger Log log;
@PersistenceContext(type = EXTENDED) EntityManager em;
@Inject Conversation conversation;
@Inject StatusMessages statusMessages;
@Inject BookingFormControls formControls;
@Registered User user;
//@Fires @Confirmed Event<BookingEvent> bookingConfirmedEvent;
@Inject BeanManager manager;
private Hotel hotelSelection;
private Booking booking;
private boolean bookingValid;
public void selectHotel(Hotel hotel)
{
// NOTE get a fresh reference that's managed by the conversational
persistence context
hotelSelection = em.find(Hotel.class, hotel.getId());
log.info("Selected the {0} in {1}", hotelSelection.getName(),
hotelSelection.getCity());
conversation.begin();
}
...
}
Note the programmatic use of beginning a LRC in the selectHotel() method
above (begin()). AFAIK, in CDI/Weld, we don't have the capability to
declaratively begin a LRC (like we do in Seam 2.x with @Begin) but can we do
something like write @Begin at method level in Seam 3 apps?
Also, is @ConversationScoped required if the component is @Stateful?
Conversation scope is current default for SFSBs in Seam 2.x.
I found the following example in the weld ref doc:
@ConversationScoped @Stateful
public class OrderBuilder {...}