concept life cycle in category seam

appears as: life cycle, life cycle, The life cycle, life cycles
Seam in Action

This is an excerpt from Manning's book Seam in Action.

That’s it! You have the project running in Eclipse. Now you can get serious about developing the source code. To aid in development, the Seam source code has been attached to the Seam library in the Eclipse project. That means for any class in the Seam API you get context-sensitive JavaDoc, you can view the class source, and you can step into the class during a debug session. The other benefit of having the project in Eclipse is the integration between the Ant build script and Eclipse’s build life cycle. Let’s explore how that works and what it means for development.

Once again, we’ll examine the life cycle as it processes the initial request. I promise that the story is far more interesting this time around. Table 3.2 walks through the tasks that Seam wraps around the JSF phases on the initial request.

Table 3.2. A general overview of the tasks that Seam incorporates into the JSF life cycle on an initial request (JSF phases shown in bold; horizontal line signifies transition from Restore View to Render Response)

Step

Task

Description

1 Initial request The life cycle begins with a GET request captured by the JSF servlet.
2 Begin JTA transaction If transaction management is enabled and JTA transactions are being used, a JTA transaction is opened.
3 Restore View On an initial request, the Restore View phase merely creates an empty component hierarchy.
4 Restore or initialize conversation Restore the long-running conversation if requested. If there’s a problem restoring it due to a timeout or concurrent access and authentication isn’t required, advance to the no-conversation view. If a long-running conversation doesn’t exist, initialize a temporary conversation.
5 Handle conversation propagation Determine from the request parameters if a long-running conversation is to begin, end, be joined, or remain untouched.
6 Validate page flow If a stateful page flow is in use, it is validated to ensure the user isn’t attempting to request a page out of sequence. If the request isn’t compliant, appropriate action is taken.
7 Process page parameters The parameters associated with this view ID are read from the request, converted, validated, and stored in the view root.
8 Enforce login, long-running conversation, and permissions If the user must be authenticated to view this page, the nonauthenticated user is redirected to the login page. Once authenticated, the process of rendering this page is resumed. If a long-running conversation is required to view this page and one doesn’t exist, the user is forwarded to the no-conversation view. If the user doesn’t have appropriate permissions to view this page, a security error is raised.
9 Apply page parameters If all validations and conversations pass, the page parameters are applied to the model via the value bindings or stored in the page context (no value binding).
10 Begin non-JTA transaction If transaction management is enabled and resource-local (non-JTA) transactions are being used, the remaining response is wrapped in a resource-local transaction (through interaction with the persistence manager).
11 Emulate the Invoke Application phase The life cycle temporarily takes on the signature of the Invoke Application phase to accommodate postback features on an initial request.
12 Enforce login, long-running conversation, and permissions The restrictions are once again applied. This step occurs twice because some execution paths will skip steps 1–9 when rendering a given view ID after a navigation event.
13 Select data model row If request was initiated by a Seam UI command component within a UIData component, advance the index of DataModel to the corresponding row.
14 Execute page actions Each page action associated with the view ID is executed. This includes actions that are passed through a Seam UI command component. Navigation rules are applied after each execution. If more than one navigation rule is applicable, the one with the highest priority is used.
15 Commit transaction If transaction management is enabled and a transaction is active, it is committed. A new transaction is opened to prepare for the rendering of the response.
16 Migrate JSF messages Interpolate then migrate Seam-managed FacesMessages stored in the conversation to the FacesContext, having now survived any redirects.
17 Prepare conversation switching Conversations can be selected through a UI component. This step remembers the description and view ID for the current page. The stack must be prepared at this point in the event the life cycle is short-circuited before the Render Response phase.
18 Store conversation The conversation is stored in the session until the next request.
19 Render Response The response is rendered by reading the JSF view template and encoding it to the generated markup (typically XHTML). The UI component hierarchy is stored in either the client or the server to be restored on a postback.
20 Commit transaction If transaction management is enabled, commit the transaction that was active during the rendering of the response.
21 Prepare conversation switching Conversations can be selected through a UI component. This step remembers the description and view ID for the current page, and updates the stack prepared prior to the Render Response phase.
22 Clean up conversation Either end the temporary conversation or update the last request time of the long-running conversation.