Hi,
As mentioned previously, I've been doing some experimenting with using
the above contexts in Web Beans within the Java SE environment. Here are
some patches, diffed from the root webbeans directory, which will add
support for these contexts to the Web Beans SE Module project, plus
modify the Swing SE Numberguess example to use these scopes.
The key points are:
NUMBERGUESS
- A Session is pretty much the whole lifespan of the application, since
it's single-user.
- A Conversation is a single instance of the game, until it is either
won or lost.
- A Request is a single button click, and is mostly present to support
Conversations using the existing paradigms.
- The Game class is now Conversation scoped. No restart() necessary, the
NumberGuessFrame simply ends the current conversation when the game is
over and starts a new one.
- This allows the @Random number to be injected directly into Game for
each fresh conversation (rather than injecting the generator and hanging
on to it)
- NumberGuessFrame injects the current conversation and conversation
manager, as well as the JavaSELifecycle, all of which it uses to manage
the various contexts (Request, Session and Conversation)
- You can see these contexts being started and stopped during the
start(), guessButtonActionPerformed() and replayButtonActionPerformed()
methods.
WEB BEANS SE MODULE
- JavaSELifecycle added to help client apps and frameworks manage
lifecycle in SE. This would eventually end up in the SPI perhaps, or as
a better abstraction of an existing SPI interface.
- JavaSEConversationManager is copied from ServletConversationManager
and much of the common code should probably be pushed into an abstract
class.
- WebBeansBootstrap now registers everything except
ServletConversationManager and HttpSessionManager when in SE mode. It
also registers the new JavaSEConversationManager.
I would like to clean up the syntax for starting requests because it's
obviously pretty ugly and verbose right now. Maybe some kind of
annotation and interceptor pair perhaps? And possibly some
Swing-specific helpers to make it easy to attach the Request context to
a button click? Making this sort of stuff more transparent is my next
goal.
Let me know what you think, anyone. Cheers.
Pete.
Show replies by date