Java Doc for FrameworkServlet.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » servlet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » spring framework 2.0.6 » org.springframework.web.servlet 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.web.servlet.HttpServletBean
   org.springframework.web.servlet.FrameworkServlet

All known Subclasses:   org.springframework.web.servlet.DispatcherServlet,
FrameworkServlet
abstract public class FrameworkServlet extends HttpServletBean implements ApplicationListener(Code)
Base servlet for Spring's web framework. Provides integration with a Spring application context, in a JavaBean-based overall solution.

This class offers the following functionality:

Subclasses must implement FrameworkServlet.doService to handle requests. Because this extends HttpServletBean rather than HttpServlet directly, bean properties are automatically mapped onto it. Subclasses can override FrameworkServlet.initFrameworkServlet() for custom initialization.

Detects a "contextClass" parameter at the servlet init-param level, falling back to the default context class, org.springframework.web.context.support.XmlWebApplicationContext , if not found. Note that, with the default FrameworkServlet, a custom context class needs to implement the org.springframework.web.context.ConfigurableWebApplicationContext SPI.

Passes a "contextConfigLocation" servlet init-param to the context instance, parsing it into potentially multiple file paths which can be separated by any number of commas and spaces, like "test-servlet.xml, myServlet.xml". If not explicitly specified, the context implementation is supposed to build a default location from the namespace of the servlet.

Note: In case of multiple config locations, later bean definitions will override ones defined in earlier loaded files, at least when using Spring's default ApplicationContext implementation. This can be leveraged to deliberately override certain bean definitions via an extra XML file.

The default namespace is "'servlet-name'-servlet", e.g. "test-servlet" for a servlet-name "test" (leading to a "/WEB-INF/test-servlet.xml" default location with XmlWebApplicationContext). The namespace can also be set explicitly via the "namespace" servlet init-param.
author:
   Rod Johnson
author:
   Juergen Hoeller
See Also:   FrameworkServlet.doService
See Also:   FrameworkServlet.setContextClass
See Also:   FrameworkServlet.setContextConfigLocation
See Also:   FrameworkServlet.setNamespace



Field Summary
final public static  ClassDEFAULT_CONTEXT_CLASS
     Default context class for FrameworkServlet.
final public static  StringDEFAULT_NAMESPACE_SUFFIX
     Suffix for WebApplicationContext namespaces.
final public static  StringSERVLET_CONTEXT_PREFIX
     Prefix for the ServletContext attribute for the WebApplicationContext.


Method Summary
protected  WebApplicationContextcreateWebApplicationContext(WebApplicationContext parent)
     Instantiate the WebApplicationContext for this servlet, either a default org.springframework.web.context.support.XmlWebApplicationContext or a FrameworkServlet.setContextClass custom context class , if set.

This implementation expects custom contexts to implement the org.springframework.web.context.ConfigurableWebApplicationContext interface.

public  voiddestroy()
     Close the WebApplicationContext of this servlet.
final protected  voiddoDelete(HttpServletRequest request, HttpServletResponse response)
     Delegate DELETE requests to FrameworkServlet.processRequest .
final protected  voiddoGet(HttpServletRequest request, HttpServletResponse response)
     Delegate GET requests to processRequest/doService.
final protected  voiddoPost(HttpServletRequest request, HttpServletResponse response)
     Delegate POST requests to FrameworkServlet.processRequest .
final protected  voiddoPut(HttpServletRequest request, HttpServletResponse response)
     Delegate PUT requests to FrameworkServlet.processRequest .
abstract protected  voiddoService(HttpServletRequest request, HttpServletResponse response)
     Subclasses must implement this method to do the work of request handling, receiving a centralized callback for GET, POST, PUT and DELETE.
public  ClassgetContextClass()
     Return the custom context class.
public  StringgetContextConfigLocation()
     Return the explicit context config location, if any.
public  StringgetNamespace()
     Return the namespace for this servlet, falling back to default scheme if no custom namespace was set: e.g.
public  StringgetServletContextAttributeName()
     Return the ServletContext attribute name for this servlet's WebApplicationContext.
protected  StringgetUsernameForRequest(HttpServletRequest request)
     Determine the username for the given request.
final public  WebApplicationContextgetWebApplicationContext()
     Return this servlet's WebApplicationContext.
protected  voidinitFrameworkServlet()
     This method will be invoked after any bean properties have been set and the WebApplicationContext has been loaded.
final protected  voidinitServletBean()
     Overridden method of HttpServletBean , invoked after any bean properties have been set.
protected  WebApplicationContextinitWebApplicationContext()
     Initialize and publish the WebApplicationContext for this servlet.

Delegates to FrameworkServlet.createWebApplicationContext for actual creation of the context.

public  booleanisPublishContext()
     Return whether to publish this servlet's context as a ServletContext attribute.
public  booleanisPublishEvents()
     Return whether this servlet should publish a ServletRequestHandledEvent at the end of each request.
public  voidonApplicationEvent(ApplicationEvent event)
     ApplicationListener endpoint that receives events from this servlet's WebApplicationContext.
protected  voidonRefresh(ApplicationContext context)
     Template method which can be overridden to add servlet-specific refresh work.
protected  voidpostProcessWebApplicationContext(ConfigurableWebApplicationContext wac)
     Post-process the given WebApplicationContext before it is refreshed and activated as context for this servlet.

The default implementation is empty.

final protected  voidprocessRequest(HttpServletRequest request, HttpServletResponse response)
     Process this request, publishing an event regardless of the outcome.
public  voidrefresh()
     Refresh this servlet's application context, as well as the dependent state of the servlet.
public  voidsetContextClass(Class contextClass)
     Set a custom context class.
public  voidsetContextConfigLocation(String contextConfigLocation)
     Set the context config location explicitly, instead of relying on the default location built from the namespace.
public  voidsetNamespace(String namespace)
     Set a custom namespace for this servlet, to be used for building a default context config location.
public  voidsetPublishContext(boolean publishContext)
     Set whether to publish this servlet's context as a ServletContext attribute, available to all objects in the web container.
public  voidsetPublishEvents(boolean publishEvents)
     Set whether this servlet should publish a ServletRequestHandledEvent at the end of each request.

Field Detail
DEFAULT_CONTEXT_CLASS
final public static Class DEFAULT_CONTEXT_CLASS(Code)
Default context class for FrameworkServlet.
See Also:   org.springframework.web.context.support.XmlWebApplicationContext



DEFAULT_NAMESPACE_SUFFIX
final public static String DEFAULT_NAMESPACE_SUFFIX(Code)
Suffix for WebApplicationContext namespaces. If a servlet of this class is given the name "test" in a context, the namespace used by the servlet will resolve to "test-servlet".



SERVLET_CONTEXT_PREFIX
final public static String SERVLET_CONTEXT_PREFIX(Code)
Prefix for the ServletContext attribute for the WebApplicationContext. The completion is the servlet name.





Method Detail
createWebApplicationContext
protected WebApplicationContext createWebApplicationContext(WebApplicationContext parent) throws BeansException(Code)
Instantiate the WebApplicationContext for this servlet, either a default org.springframework.web.context.support.XmlWebApplicationContext or a FrameworkServlet.setContextClass custom context class , if set.

This implementation expects custom contexts to implement the org.springframework.web.context.ConfigurableWebApplicationContext interface. Can be overridden in subclasses.

Do not forget to register this servlet instance as application listener on the created context (for triggering its FrameworkServlet.onRefresh callback , and to call org.springframework.context.ConfigurableApplicationContext.refresh before returning the context instance.
Parameters:
  parent - the parent ApplicationContext to use, or null if none the WebApplicationContext for this servlet
throws:
  BeansException - if the context couldn't be initialized
See Also:   org.springframework.web.context.support.XmlWebApplicationContext




destroy
public void destroy()(Code)
Close the WebApplicationContext of this servlet.
See Also:   org.springframework.context.ConfigurableApplicationContext.close



doDelete
final protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException(Code)
Delegate DELETE requests to FrameworkServlet.processRequest .
See Also:   FrameworkServlet.doService



doGet
final protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException(Code)
Delegate GET requests to processRequest/doService.

Will also be invoked by HttpServlet's default implementation of doHead, with a NoBodyResponse that just captures the content length.
See Also:   FrameworkServlet.doService
See Also:   FrameworkServlet.doHead




doPost
final protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException(Code)
Delegate POST requests to FrameworkServlet.processRequest .
See Also:   FrameworkServlet.doService



doPut
final protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException(Code)
Delegate PUT requests to FrameworkServlet.processRequest .
See Also:   FrameworkServlet.doService



doService
abstract protected void doService(HttpServletRequest request, HttpServletResponse response) throws Exception(Code)
Subclasses must implement this method to do the work of request handling, receiving a centralized callback for GET, POST, PUT and DELETE.

The contract is essentially the same as that for the commonly overridden doGet or doPost methods of HttpServlet.

This class intercepts calls to ensure that exception handling and event publication takes place.
Parameters:
  request - current HTTP request
Parameters:
  response - current HTTP response
throws:
  Exception - in case of any kind of processing failure
See Also:   javax.servlet.http.HttpServlet.doGet
See Also:   javax.servlet.http.HttpServlet.doPost




getContextClass
public Class getContextClass()(Code)
Return the custom context class.



getContextConfigLocation
public String getContextConfigLocation()(Code)
Return the explicit context config location, if any.



getNamespace
public String getNamespace()(Code)
Return the namespace for this servlet, falling back to default scheme if no custom namespace was set: e.g. "test-servlet" for a servlet named "test".



getServletContextAttributeName
public String getServletContextAttributeName()(Code)
Return the ServletContext attribute name for this servlet's WebApplicationContext.

The default implementation returns SERVLET_CONTEXT_PREFIX + servlet name.
See Also:   FrameworkServlet.SERVLET_CONTEXT_PREFIX
See Also:   FrameworkServlet.getServletName




getUsernameForRequest
protected String getUsernameForRequest(HttpServletRequest request)(Code)
Determine the username for the given request.

The default implementation takes the name of the UserPrincipal, if any. Can be overridden in subclasses.
Parameters:
  request - current HTTP request the username, or null if none found
See Also:   javax.servlet.http.HttpServletRequest.getUserPrincipal




getWebApplicationContext
final public WebApplicationContext getWebApplicationContext()(Code)
Return this servlet's WebApplicationContext.



initFrameworkServlet
protected void initFrameworkServlet() throws ServletException, BeansException(Code)
This method will be invoked after any bean properties have been set and the WebApplicationContext has been loaded. The default implementation is empty; subclasses may override this method to perform any initialization they require.
throws:
  ServletException - in case of an initialization exception
throws:
  BeansException - if thrown by ApplicationContext methods



initServletBean
final protected void initServletBean() throws ServletException, BeansException(Code)
Overridden method of HttpServletBean , invoked after any bean properties have been set. Creates this servlet's WebApplicationContext.



initWebApplicationContext
protected WebApplicationContext initWebApplicationContext() throws BeansException(Code)
Initialize and publish the WebApplicationContext for this servlet.

Delegates to FrameworkServlet.createWebApplicationContext for actual creation of the context. Can be overridden in subclasses. the WebApplicationContext instance
throws:
  BeansException - if the context couldn't be initialized
See Also:   FrameworkServlet.setContextClass
See Also:   FrameworkServlet.setContextConfigLocation




isPublishContext
public boolean isPublishContext()(Code)
Return whether to publish this servlet's context as a ServletContext attribute.



isPublishEvents
public boolean isPublishEvents()(Code)
Return whether this servlet should publish a ServletRequestHandledEvent at the end of each request.



onApplicationEvent
public void onApplicationEvent(ApplicationEvent event)(Code)
ApplicationListener endpoint that receives events from this servlet's WebApplicationContext.

The default implementation calls FrameworkServlet.onRefresh in case of a org.springframework.context.event.ContextRefreshedEvent , triggering a refresh of this servlet's context-dependent state.
Parameters:
  event - the incoming ApplicationContext event




onRefresh
protected void onRefresh(ApplicationContext context) throws BeansException(Code)
Template method which can be overridden to add servlet-specific refresh work. Called after successful context refresh.

This implementation is empty.
Parameters:
  context - the current WebApplicationContext
throws:
  BeansException - in case of errors
See Also:   FrameworkServlet.refresh()




postProcessWebApplicationContext
protected void postProcessWebApplicationContext(ConfigurableWebApplicationContext wac)(Code)
Post-process the given WebApplicationContext before it is refreshed and activated as context for this servlet.

The default implementation is empty. refresh() will be called automatically after this method returns.
Parameters:
  wac - the configured WebApplicationContext (not refreshed yet)
See Also:   FrameworkServlet.createWebApplicationContext
See Also:   ConfigurableWebApplicationContext.refresh




processRequest
final protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException(Code)
Process this request, publishing an event regardless of the outcome.

The actual event handling is performed by the abstract FrameworkServlet.doService template method.




refresh
public void refresh() throws BeansException(Code)
Refresh this servlet's application context, as well as the dependent state of the servlet.
throws:
  BeansException - in case of errors
See Also:   FrameworkServlet.getWebApplicationContext()
See Also:   org.springframework.context.ConfigurableApplicationContext.refresh



setContextClass
public void setContextClass(Class contextClass)(Code)
Set a custom context class. This class must be of type org.springframework.web.context.WebApplicationContext .

When using the default FrameworkServlet implementation, the context class must also implement the org.springframework.web.context.ConfigurableWebApplicationContext interface.
See Also:   FrameworkServlet.createWebApplicationContext




setContextConfigLocation
public void setContextConfigLocation(String contextConfigLocation)(Code)
Set the context config location explicitly, instead of relying on the default location built from the namespace. This location string can consist of multiple locations separated by any number of commas and spaces.



setNamespace
public void setNamespace(String namespace)(Code)
Set a custom namespace for this servlet, to be used for building a default context config location.



setPublishContext
public void setPublishContext(boolean publishContext)(Code)
Set whether to publish this servlet's context as a ServletContext attribute, available to all objects in the web container. Default is "true".

This is especially handy during testing, although it is debatable whether it's good practice to let other application objects access the context this way.




setPublishEvents
public void setPublishEvents(boolean publishEvents)(Code)
Set whether this servlet should publish a ServletRequestHandledEvent at the end of each request. Default is "true"; can be turned off for a slight performance improvement, provided that no ApplicationListeners rely on such events.
See Also:   org.springframework.web.context.support.ServletRequestHandledEvent



Fields inherited from org.springframework.web.servlet.HttpServletBean
final protected Log logger(Code)(Java Doc)

Methods inherited from org.springframework.web.servlet.HttpServletBean
final protected void addRequiredProperty(String property)(Code)(Java Doc)
final public ServletContext getServletContext()(Code)(Java Doc)
final public String getServletName()(Code)(Java Doc)
final public void init() throws ServletException(Code)(Java Doc)
protected void initBeanWrapper(BeanWrapper bw) throws BeansException(Code)(Java Doc)
protected void initServletBean() throws ServletException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.