Java Reference
In-Depth Information
when a long-running conversation is starting versus a short chat. The container also needs
to know when the conversation ends. Both the explicit start and stop are used to man-
age resources. To start and stop a conversation, you interact with a javax .enter-
prise.context.Conversation object. It's acquired via injection. The methods on
this interface are documented in table 12.4 .
Table 12.4. Methods on conversation
void begin()
Converts the current transient conversation into a long-running conversation
Converts the current transient conversation into a long-running conversation
with a custom ID
void begin(String id)
void end()
Terminates the conversation and converts it to a transient conversation
String getId()
Returns the ID of the current conversation
long getTimeout()
Returns the timeout of the current conversation in milliseconds
Returns true if the current conversation is transient and will be lost at the end of
the request
boolean isTransient()
Sets a custom timeout for the current conversation; only applicable if the con-
versation isn't transient
void setTimeout(long timeout)
To better understand conversations, let's look at a relatively simple use case from Ac-
tionBazaar. This use case will leverage most of the CDI skills you've acquired throughout
the chapter, including producer methods and qualifiers. We'll look at how a user goes from
viewing a list of items to actually placing a bid, as shown in sequence in figure 12.5 .
Figure 12.5. Sequence for placing a bid in ActionBazaar
The user starts off on the welcome page viewing a list of items—sailboats, in this case. This
page has a picture of the item along with a short description. The user clicks an item that
Search WWH ::

Custom Search