The Controller is serially reusable, when one transformation or query is finished, it can be used to run another. However, there is no advantage in doing this rather than allocating a new Controller each time. An inert version of the controller can be used to simply hold state for the benefit of the JavaScript API, controller settings can then be copied to a 'live' Controller instance using importControllerSettings()
A dummy Controller is created by the JavaScript API for holding settings.
The Controller holds those parts of the dynamic context that do not vary during the course of a transformation or query, or that do not change once their value has been computed. This also includes those parts of the static context that are required at run-time.
@author Michael H. Kay @since 8.4
A class implementing this interface is expected to have a single public contructor with its formal parameter list observing the following convention:
- the single constructor should accept no formal parameters or
- the single constructor should declare formal parameters using only the
following types:
- javax.servlet.ServletContext
- javax.servlet.ServletConfig
A class implementing this interface may optionally define a single public method named init(). If defined this method will be called after the controller is created using the constructor. The init() method if defined should have its formal parameter list observe the convention described above for the constructor.
A class implementing this interface may optionally define a single public method named destroy(). If defined this method will be called when the controller instance is taken out of service. If there is more than one destroy method or if it the single destroy method requires arguments then the method will be ignored.
@created Mar 14, 2008 @author Adinath Raveendra Raj
@Controller
.
javax.swing.JPanel
or something conceptually similar) and the control code lives in an associated controller class. The controller philosophy is thus: The panel class (and its UI components) convert basic user interface actions into higher level actions that more cleanly encapsulate the action desired by the user and they pass those actions on to their controller. The controller then performs abstract processing based on the users desires and the changing state of the application and calls back to the panel to affect changes to the display.
Controllers also support the notion of scope. When a panel wishes to post an action, it doesn't do it directly to the controller. Instead it does it using a controller utility function called {@link #postAction}, which searches up the user interface hierarchy looking for a component that implements {@link ControllerProvider} which it will use to obtain thecontroller "in scope" for that component. That controller is requested to handle the action, but if it cannot handle the action, the next controller up the chain is located and requested to process the action.
In this manner, a hierarchy of controllers (often just two: one application wide and one for whatever particular mode the application is in at the moment) can provide a set of services that are available to all user interface elements in the entire application and in a way that doesn't require tight connectedness between the UI elements and the controllers.
Methods on the GrammarReaderController interface is used for error reporting. @author Kohsuke KAWAGUCHI
The application can serve content both directly (by simple, direct reference to a JSP's URL), and indirectly, through this Controller.
Like almost all servlets, this class is safe for multi-threaded environments.
Validates user input and request parameters, interacts with a datastore, and places problem domain model objects in scope for eventual rendering by a JSP. Performs either a forward or a redirect, according to the instructions of the {@link Action}.
Emails are sent to the webmaster when :
This class is in a distinct package for two reasons :
There are key-names defined in this class (see below). Their names need to be long-winded (web4j_key_for_...), unfortunately, in order to avoid conflict with other tools, including your application.
The Controller is serially reusable, as required by JAXP: when one transformation or query is finished, it can be used to run another. However, there is no advantage in doing this rather than allocating a new Controller each time.
The Controller can also be used when running Java applications that use neither XSLT nor XQuery. A dummy Controller is created when running free-standing XPath expressions.
The Controller holds those parts of the dynamic context that do not vary during the course of a transformation or query, or that do not change once their value has been computed. This also includes those parts of the static context that are required at run-time.
Wherever possible XSLT applications should use the JAXP Transformer class directly, rather than relying on Saxon-specific methods in the Controller. However, some features are currently available only through this class. This applies especially to new features specific to XSLT 2.0, since the JAXP interface still supports only XSLT 1.0. Such methods may be superseded in the future by JAXP methods.
Many methods on the Controller are designed for internal use and should not be considered stable. From release 8.4 onwards, those methods that are considered sufficiently stable to constitute path of the Saxon public API are labelled with the JavaDoc tag "since": the value indicates the release at which the method was added to the public API. @author Michael H. Kay @since 8.4
Calls to {@link #process(Map,Class)} are thread-safe, although some care should begiven to initialization. Controller instance should be initialized (using any of the {@link #init()} methods) before other threads are allowed to see its instance.{@link #dispose()} should be called after all threads leave{@link #process(Map,Class)} and {@link #process(Map,Object)}.
Notice for {@link IProcessingComponent} developers: if data caching is used, values of{@link Output} attributes produced by the components whose output is to be cached(e.g., the {@link Document} instances in case {@link IDocumentSource} output is cached)may be accessed concurrently and therefore must be thread-safe.
@see ControllerFactoryMust implement the following methods:
getComponent
to get the controlled componentisComponentInstancied
to indicates whether the controller is instantiatedEvery instantiated controller is added to a pool of controllers. Through the pool, its possible reach any controller.
The state of permanent indicates that the controller can't be removed from the pool unless the parent has been removed.
Annotations:
ChildController
- defines that a controller can't be instantiated by constructor, only through method createChild
.Singleton
- defines a controller as singleton.Copyright (C) 2009-2013 Carlos Eduardo Leite de Andrade
This library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see www.gnu.org/licenses/
For more information, contact: www.japura.org
E @author Carlos Eduardo Leite de Andrade @param V controlled component class
The controller is the core component for keeping track of contexts to make sure the configuration and lifecycle are done in the correct order including dependencies and classloading considerations. @author Adrian Brock @version $Revision: 1.3 $
The Controller is serially reusable, as required by JAXP: when one transformation or query is finished, it can be used to run another. However, there is no advantage in doing this rather than allocating a new Controller each time.
The Controller can also be used when running Java applications that use neither XSLT nor XQuery. A dummy Controller is created when running free-standing XPath expressions.
The Controller holds those parts of the dynamic context that do not vary during the course of a transformation or query, or that do not change once their value has been computed. This also includes those parts of the static context that are required at run-time.
Wherever possible XSLT applications should use the JAXP Transformer class directly, rather than relying on Saxon-specific methods in the Controller. However, some features are currently available only through this class. This applies especially to new features specific to XSLT 2.0, since the JAXP interface still supports only XSLT 1.0. Such methods may be superseded in the future by JAXP methods.
Many methods on the Controller are designed for internal use and should not be considered stable. From release 8.4 onwards, those methods that are considered sufficiently stable to constitute path of the Saxon public API are labelled with the JavaDoc tag "since": the value indicates the release at which the method was added to the public API. @author Michael H. Kay @since 8.4
HttpServletRequest
and HttpServletResponse
instances just like a HttpServlet
but is able to participate in an MVC workflow. Controllers are comparable to the notion of a Struts Action
. Any implementation of the Controller interface should be a reusable, thread-safe class, capable of handling multiple HTTP requests throughout the lifecycle of an application. To be able to configure a Controller easily, Controller implementations are encouraged to be (and usually are) JavaBeans.
After a
So basically any direct implementation of the Controller interface just handles HttpServletRequests and should return a ModelAndView, to be further interpreted by the DispatcherServlet. Any additional functionality such as optional validation, form handling, etc should be obtained through extending one of the abstract controller classes mentioned above.
Notes on design and testing
The Controller interface is explicitly designed to operate on HttpServletRequest and HttpServletResponse objects, just like an HttpServlet. It does not aim to decouple itself from the Servlet API, in contrast to, for example, WebWork, JSF or Tapestry. Instead, the full power of the Servlet API is available, allowing Controllers to be general-purpose: a Controller is able to not only handle web user interface requests but also to process remoting protocols or to generate reports on demand.
Controllers can easily be tested by passing in mock objects for the HttpServletRequest and HttpServletResponse objects as parameters to the {@link #handleRequest(HttpServletRequest,HttpServletResponse) handleRequest}method. As a convenience, Spring ships with a set of Servlet API mocks that are suitable for testing any kind of web components, but are particularly suitable for testing Spring web controllers. In contrast to a Struts Action, there is no need to mock the ActionServlet or any other infrastructure; HttpServletRequest and HttpServletResponse are sufficient.
If Controllers need to be aware of specific environment references, they can choose to implement specific awareness interfaces, just like any other bean in a Spring (web) application context can do, for example:
org.springframework.context.ApplicationContextAware
org.springframework.context.ResourceLoaderAware
org.springframework.web.context.ServletContextAware
Such environment references can easily be passed in testing environments, through the corresponding setters defined in the respective awareness interfaces. In general, it is recommended to keep the dependencies as minimal as possible: for example, if all you need is resource loading, implement ResourceLoaderAware only. Alternatively, derive from the WebApplicationObjectSupport base class, which gives you all those references through convenient accessors - but requires an ApplicationContext reference on initialization.
Controllers can optionally implement the LastModified interface. @author Rod Johnson @author Juergen Hoeller @see LastModified @see SimpleControllerHandlerAdapter @see AbstractController @see AbstractCommandController @see SimpleFormController @see org.springframework.mock.web.MockHttpServletRequest @see org.springframework.mock.web.MockHttpServletResponse @see org.springframework.context.ApplicationContextAware @see org.springframework.context.ResourceLoaderAware @see org.springframework.web.context.ServletContextAware @see org.springframework.web.context.support.WebApplicationObjectSupport
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|