[seam-dev] declaratively beginning a LRC in Seam 3
Pete Muir
pmuir at redhat.com
Sat Jan 30 07:52:53 EST 2010
On 29 Jan 2010, at 21:34, Arbi Sookazian wrote:
> 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/main/java/org/jboss/seam/examples/booking/booking/BookingAgentBean.java):
>
> 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?
Yes, use an interceptor. We may add this to Seam 3, need to see what Gavin is thinking here.
>
> Also, is @ConversationScoped required if the component is @Stateful? Conversation scope is current default for SFSBs in Seam 2.x.
Yes, this is no longer true, @Dependent is the default scope for all beans in CDI
BTW this question is better suited to the user forum ;-)
More information about the seam-dev
mailing list