xwork / docs / wikidocs / Core Concepts.html

        <title>XWork : Core Concepts</title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">	    

	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
			    <td valign="top" class="pagebody">
				    <div class="pageheader">
					    <span class="pagetitle">
                            XWork : Core Concepts
				    <div class="pagesubheading">
					    This page last changed on Jun 02, 2004 by <font color="#0050B2">plightbo</font>.

				    <p class="paragraph"><h2 style="margin: 4px 0px 4px 0px;" class="heading2"><a name="CoreConcepts-XWorkCoreConcepts"> XWork Core Concepts</a></h2></p>XWork is based on a number of core concepts that helps to explain how the framework works. The core concepts can be broken down into two parts: Architecture Concepts and Terminology.<p class="paragraph"><h2 class="heading2"><a name="CoreConcepts-ArchitectureConcepts"> Architecture Concepts</a></h2>
<ul class="star">
<li> Explain Command Driven Architecture (in general)</li>
<li> Explain the implementation in XWork</li>
<h2 class="heading2"><a name="CoreConcepts-Terminology"> Terminology</a></h2></p><h3 class="heading3"><a name="CoreConcepts-Actions"> Actions</a></h3><p class="paragraph">Actions are classes that get invoked in response to a request, execute some code and return a Result. Actions implement at a minimum a single method, execute(), that defines the entry point called by the framework. This method allows developers to define a unit of work that will be executed each time the Action is called.</p><h3 class="heading3"><a name="CoreConcepts-ActionContext"> ActionContext</a></h3><p class="paragraph">The ActionContext provides access to the execution environment in the form of named objects during an Action invocation. A new ActionContext is created for each invocation allowing developers to access/modify these properties in a thread safe manner. The ActionContext makes a number of properties available that are typically set to appropriate values by the framework. In WebWork 2 for example, the ActionContext session map wraps an underlying HttpSession object. This allows access to environment specific properties without tying the core framework to a specific execution environment. For more information, see ActionContext in <a href="Basics.html" title="Basics">Basics</a>.</p><h3 class="heading3"><a name="CoreConcepts-Interceptors"> Interceptors</a></h3><p class="paragraph">In XWork, Interceptors are objects that dynamically intercept Action invocations. They provide the developer with the opportunity to define code that can be executed before and/or after the execution of an action. They also have the ability to prevent an action from executing. Interceptors provide developers a way to encapulate common functionality in a re-usable form that can be applied to one or more Actions. See <a href="Interceptors.html" title="Interceptors">Interceptors</a> for further details.</p><h3 class="heading3"><a name="CoreConcepts-Stacks"> Stacks</a></h3><p class="paragraph">To handle the case where developers want to apply more than a single Interceptor to an Action, Stacks have been introduced. Stacks are an ordered list of Interceptors and/or other Stacks that get applied when an Action is invoked. Stacks centralize the declaration of Interceptors and provide a convenient way to configure mutiple actions.</p><h3 class="heading3"><a name="CoreConcepts-Results"> Results</a></h3><p class="paragraph">Results are string constants that Actions return to indicate the status of an Action execution. A standard set of Results are defined by default: error, input, login, none and success.  Developers are, of course, free to create their own Results to indicate more application specific cases.</p><h3 class="heading3"><a name="CoreConcepts-ResultTypes"> Result Types</a></h3><p class="paragraph">Result Types are classes that determine what happens after an Action executes and a Result is returned. Developers are free to create their own Result Types according to the needs of their application or environment. In WebWork 2 for example, Servlet and Velocity Result Types have been created to handle rendering views in web applications.</p><h3 class="heading3"><a name="CoreConcepts-Packages"> Packages</a></h3><p class="paragraph">Packages are a way to group Actions, Results, Result Types, Interceptors and Stacks into a logical unit that shares a common configuration. Packages are similiar to objects in that they can be extended and have individual parts overridden by &quot;sub&quot; packages.</p><h3 class="heading3"><a name="CoreConcepts-ValueStack"> ValueStack</a></h3><p class="paragraph">The ValueStack is a stack implementation built on top of an OGNL core. The OGNL expression language can be used to traverse the stack and retrieve the desired object. The OGNL expression language provides a number of additional features including: automatic type conversion, method invocation and object comparisons. For more information, see the <a href="" title="Visit page outside Confluence">OGNL Website</a>.</p><h3 class="heading3"><a name="CoreConcepts-Components"> Components</a></h3><p class="paragraph">XWork provides the ComponentManager interface (and a corresponding implementation in the DefaultComponentManager class) to apply a design pattern known as <b class="strong">Inversion of Control</b> (or IoC for short). In a nutshell, the IoC pattern allows a parent object (in this case XWork&#039;s ComponentManager instance) to control a client object (usually an action, but it could be any object that implements the appropriate <em class="emphasis">enabler</em>). See <a href="Components.html" title="Components">Components</a> for further details.</p>

	    <table border="0" cellpadding="0" cellspacing="0" width="100%">
				<td height="12" background="border/border_bottom.gif"><img src="border/spacer.gif" width="1" height="1" border="0"/></td>
			    <td align="center"><font color="grey">Document generated by Confluence on Sep 07, 2004 00:34</font></td>