beehive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kyle Marvin <>
Subject Re: Lifecycle Questions
Date Mon, 29 Nov 2004 21:10:35 GMT
The resource scope of a controller is similar to the scope of the JSP
page.  It enables control resources to be held for the duration of the
processing of an action, not for the lifetime of an entire flow (which
may span multiple requests).  State another, resource acquisition
*never* spans across multiple (http) requests for either jsp pages or
pageflows, so should be appropriate (I think) for Hibernate sessions
in either context.

The onAcquire event is delivered once (and only once) before any
operation is invoked on a control within any given resource scope.  
The onRelease event is delivered once (and only once) at the end of
the associated resource scope.

With regards to onCreate it is called the first time a control bean is
invoked upon after creation.  This is because a ControlImplementation
instance associated with a bean are lazily instantiated on first use
of the bean.

When a bean get created somewhat depends upon the usage.  In the JSP
page case, if the bean is page or request scoped (ex. <jsp:useBean
scope="page">), you are going to get a new bean instantiated for each
page/request, so you'll see onCreate called each time.  If the bean is
session or applicationo scoped (ex. <jsp:useBean scope="session">),
the bean generally gets instantiated once per session, onCreate is
called once, and then the bean is serialized into session state.

For pageflows, I think the answer is that the control lifecycle is
generally tied to the flow lifecycle.   All the control instances
contained within a pageflow will be instantiated when the flow is
initialized (and get their onCreate events).

On Mon, 29 Nov 2004 11:42:45 -0500, Dan Diephouse
<> wrote:
> I am trying to understand the Context Lifecycle events and how I can use
> them.  Using the onAcquire/onRelease/onCreate methods seems simple
> enough but I am confused as to when they are actually called.  So I was
> wondering if someone could help me fill in the blanks here for the
> different cases:
> Within a JSP Page:
> onAcquire - called at the beginning of the scope (page, request, etc)
> onRelease - called at the end of the scope (page, request, etc)
> onCreate - called when the control is initialized at the beginning of a
> a new scope???
> Within a Controller:
> onAcquire - called once when first used??
> onRelease - called when the application exits??
> onCreate - called once when first initialized??
> Within another Control:
> onAcquire/onRelease/onCreate: called whenever the parent control's
> lifecycle methods are called
> I'm trying to figure out where I can put a control so it receives the
> lifecycle events for the page request to manage hibernate
> sessions/transactions, and from the above it looks like within the JSP
> page itself is my only choice.
> Thanks,
> - Dan
> --
> Dan Diephouse
> Envoi Solutions LLC

View raw message