Java Doc for DispatcherPortlet.java in  » J2EE » spring-framework-2.0.6 » org » springframework » web » portlet » 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.portlet 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.springframework.web.portlet.GenericPortletBean
   org.springframework.web.portlet.FrameworkPortlet
      org.springframework.web.portlet.DispatcherPortlet

DispatcherPortlet
public class DispatcherPortlet extends FrameworkPortlet (Code)
Central dispatcher for use within the Portlet MVC framework, e.g. for web UI controllers. Dispatches to registered handlers for processing a portlet request.

This portlet is very flexible: It can be used with just about any workflow, with the installation of the appropriate adapter classes. It offers the following functionality that distinguishes it from other request-driven portlet MVC frameworks:

A web application can define any number of DispatcherPortlets. Each portlet will operate in its own namespace, loading its own application context with mappings, handlers, etc. Only the root application context as loaded by org.springframework.web.context.ContextLoaderListener , if any, will be shared.

Thanks to Rainer Schmitz and Nick Lothian for their suggestions!
author:
   William G. Thompson, Jr.
author:
   John A. Lewis
author:
   Juergen Hoeller
since:
   2.0
See Also:   org.springframework.web.portlet.mvc.Controller
See Also:   org.springframework.web.servlet.ViewRendererServlet
See Also:   org.springframework.web.context.ContextLoaderListener



Field Summary
final public static  StringACTION_EXCEPTION_RENDER_PARAMETER
     This render parameter is used to indicate forward to the render phase that an exception occurred during the action phase.
final public static  StringACTION_EXCEPTION_SESSION_ATTRIBUTE
     Unlike the Servlet version of this class, we have to deal with the two-phase nature of the portlet request.
final public static  StringDEFAULT_VIEW_RENDERER_URL
     Default URL to ViewRendererServlet.
final public static  StringHANDLER_ADAPTER_BEAN_NAME
     Well-known name for the HandlerAdapter object in the bean factory for this namespace.
final public static  StringHANDLER_EXCEPTION_RESOLVER_BEAN_NAME
     Well-known name for the HandlerExceptionResolver object in the bean factory for this namespace.
final public static  StringHANDLER_EXECUTION_CHAIN_ATTRIBUTE
     Request attribute to hold the currently chosen HandlerExecutionChain.
final public static  StringHANDLER_MAPPING_BEAN_NAME
     Well-known name for the HandlerMapping object in the bean factory for this namespace.
final public static  StringMULTIPART_RESOLVER_BEAN_NAME
     Well-known name for the PortletMultipartResolver object in the bean factory for this namespace.
final public static  StringPAGE_NOT_FOUND_LOG_CATEGORY
     Log category to use when no mapped handler is found for a request.
final public static  StringVIEW_RESOLVER_BEAN_NAME
     Well-known name for the ViewResolver object in the bean factory for this namespace.
final protected static  LogpageNotFoundLogger
     Additional logger to use when no mapped handler is found for a request.


Method Summary
protected  LocaleContextbuildLocaleContext(PortletRequest request)
     Build a LocaleContext for the given request, exposing the request's primary locale as current locale.
protected  ActionRequestcheckMultipart(ActionRequest request)
     Convert the request into a multipart request, and make multipart resolver available.
protected  ObjectcreateDefaultStrategy(ApplicationContext context, Class clazz)
     Create a default strategy.
protected  voiddoActionService(ActionRequest request, ActionResponse response)
     Processes the actual dispatching to the handler for action requests.
protected  voiddoRenderService(RenderRequest request, RenderResponse response)
     Processes the actual dispatching to the handler for render requests.
protected  ListgetDefaultStrategies(ApplicationContext context, Class strategyInterface)
     Create a List of default strategy objects for the given strategy interface.
protected  ObjectgetDefaultStrategy(ApplicationContext context, Class strategyInterface)
     Return the default strategy object for the given strategy interface.
protected  HandlerExecutionChaingetHandler(PortletRequest request, boolean cache)
     Return the HandlerExecutionChain for this request.
protected  HandlerAdaptergetHandlerAdapter(Object handler)
     Return the HandlerAdapter for this handler object.
public  PortletMultipartResolvergetMultipartResolver()
     Obtain this portlet's PortletMultipartResolver, if any.
protected  voidinitStrategies(ApplicationContext context)
     Refresh the strategy objects that this portlet uses.
protected  voidnoHandlerFound(PortletRequest request, PortletResponse response)
     No handler found -> throw appropriate exception.
public  voidonRefresh(ApplicationContext context)
     This implementation calls DispatcherPortlet.initStrategies .
protected  ModelAndViewprocessHandlerException(RenderRequest request, RenderResponse response, Object handler, Exception ex)
     Determine an error ModelAndView via the registered HandlerExceptionResolvers.
protected  voidrender(ModelAndView mv, RenderRequest request, RenderResponse response)
     Render the given ModelAndView.
protected  ViewresolveViewName(String viewName, Map model, RenderRequest request)
     Resolve the given view name into a View object (to be rendered).
public  voidsetDetectAllHandlerAdapters(boolean detectAllHandlerAdapters)
     Set whether to detect all HandlerAdapter beans in this portlet's context. Else, just a single bean with name "handlerAdapter" will be expected.

Default is "true".

public  voidsetDetectAllHandlerExceptionResolvers(boolean detectAllHandlerExceptionResolvers)
     Set whether to detect all HandlerExceptionResolver beans in this portlet's context. Else, just a single bean with name "handlerExceptionResolver" will be expected.

Default is true.

public  voidsetDetectAllHandlerMappings(boolean detectAllHandlerMappings)
     Set whether to detect all HandlerMapping beans in this portlet's context. Else, just a single bean with name "handlerMapping" will be expected.

Default is true.

public  voidsetDetectAllViewResolvers(boolean detectAllViewResolvers)
     Set whether to detect all ViewResolver beans in this portlet's context. Else, just a single bean with name "viewResolver" will be expected.

Default is true.

public  voidsetThreadContextInheritable(boolean threadContextInheritable)
     Set whether to expose the LocaleContext and RequestAttributes as inheritable for child threads (using an java.lang.InheritableThreadLocal ).

Default is "false", to avoid side effects on spawned background threads. Switch this to "true" to enable inheritance for custom child threads which are spawned during request processing and only used for this request (that is, ending after their initial task, without reuse of the thread).

WARNING: Do not use inheritance for child threads if you are accessing a thread pool which is configured to potentially add new threads on demand (e.g.

public  voidsetViewRendererUrl(String viewRendererUrl)
     Set the URL to the ViewRendererServlet.

Field Detail
ACTION_EXCEPTION_RENDER_PARAMETER
final public static String ACTION_EXCEPTION_RENDER_PARAMETER(Code)
This render parameter is used to indicate forward to the render phase that an exception occurred during the action phase.



ACTION_EXCEPTION_SESSION_ATTRIBUTE
final public static String ACTION_EXCEPTION_SESSION_ATTRIBUTE(Code)
Unlike the Servlet version of this class, we have to deal with the two-phase nature of the portlet request. To do this, we need to pass forward any exception that occurs during the action phase, so that it can be displayed in the render phase. The only direct way to pass things forward and preserve them for each render request is through render parameters, but these are limited to String objects and we need to pass the Exception itself. The only other way to do this is in the session. The bad thing about using the session is that we have no way of knowing when we are done re-rendering the request and so we don't know when we can remove the objects from the session. So we will end up polluting the session with an old exception when we finally leave the render phase of one request and move on to something else.



DEFAULT_VIEW_RENDERER_URL
final public static String DEFAULT_VIEW_RENDERER_URL(Code)
Default URL to ViewRendererServlet. This bridge servlet is used to convert portlet render requests to servlet requests in order to leverage the view support in the org.springframework.web.view package.



HANDLER_ADAPTER_BEAN_NAME
final public static String HANDLER_ADAPTER_BEAN_NAME(Code)
Well-known name for the HandlerAdapter object in the bean factory for this namespace. Only used when "detectAllHandlerAdapters" is turned off.
See Also:   DispatcherPortlet.setDetectAllHandlerAdapters



HANDLER_EXCEPTION_RESOLVER_BEAN_NAME
final public static String HANDLER_EXCEPTION_RESOLVER_BEAN_NAME(Code)
Well-known name for the HandlerExceptionResolver object in the bean factory for this namespace. Only used when "detectAllHandlerExceptionResolvers" is turned off.
See Also:   DispatcherPortlet.setDetectAllViewResolvers



HANDLER_EXECUTION_CHAIN_ATTRIBUTE
final public static String HANDLER_EXECUTION_CHAIN_ATTRIBUTE(Code)
Request attribute to hold the currently chosen HandlerExecutionChain. Only used for internal optimizations.



HANDLER_MAPPING_BEAN_NAME
final public static String HANDLER_MAPPING_BEAN_NAME(Code)
Well-known name for the HandlerMapping object in the bean factory for this namespace. Only used when "detectAllHandlerMappings" is turned off.
See Also:   DispatcherPortlet.setDetectAllViewResolvers



MULTIPART_RESOLVER_BEAN_NAME
final public static String MULTIPART_RESOLVER_BEAN_NAME(Code)
Well-known name for the PortletMultipartResolver object in the bean factory for this namespace.



PAGE_NOT_FOUND_LOG_CATEGORY
final public static String PAGE_NOT_FOUND_LOG_CATEGORY(Code)
Log category to use when no mapped handler is found for a request.



VIEW_RESOLVER_BEAN_NAME
final public static String VIEW_RESOLVER_BEAN_NAME(Code)
Well-known name for the ViewResolver object in the bean factory for this namespace.



pageNotFoundLogger
final protected static Log pageNotFoundLogger(Code)
Additional logger to use when no mapped handler is found for a request.





Method Detail
buildLocaleContext
protected LocaleContext buildLocaleContext(PortletRequest request)(Code)
Build a LocaleContext for the given request, exposing the request's primary locale as current locale.
Parameters:
  request - current HTTP request the corresponding LocaleContext



checkMultipart
protected ActionRequest checkMultipart(ActionRequest request) throws MultipartException(Code)
Convert the request into a multipart request, and make multipart resolver available. If no multipart resolver is set, simply use the existing request.
Parameters:
  request - current HTTP request the processed request (multipart wrapper if necessary)



createDefaultStrategy
protected Object createDefaultStrategy(ApplicationContext context, Class clazz) throws BeansException(Code)
Create a default strategy.

The default implementation uses org.springframework.beans.factory.config.AutowireCapableBeanFactory.createBean .
Parameters:
  context - the current Portlet ApplicationContext
Parameters:
  clazz - the strategy implementation class to instantiate the fully configured strategy instance
throws:
  BeansException - if initialization failed
See Also:   org.springframework.context.ApplicationContext.getAutowireCapableBeanFactory




doActionService
protected void doActionService(ActionRequest request, ActionResponse response) throws Exception(Code)
Processes the actual dispatching to the handler for action requests.

The handler will be obtained by applying the portlet's HandlerMappings in order. The HandlerAdapter will be obtained by querying the portlet's installed HandlerAdapters to find the first that supports the handler class.
Parameters:
  request - current portlet action request
Parameters:
  response - current portlet Action response
throws:
  Exception - in case of any kind of processing failure




doRenderService
protected void doRenderService(RenderRequest request, RenderResponse response) throws Exception(Code)
Processes the actual dispatching to the handler for render requests.

The handler will be obtained by applying the portlet's HandlerMappings in order. The HandlerAdapter will be obtained by querying the portlet's installed HandlerAdapters to find the first that supports the handler class.
Parameters:
  request - current portlet render request
Parameters:
  response - current portlet render response
throws:
  Exception - in case of any kind of processing failure




getDefaultStrategies
protected List getDefaultStrategies(ApplicationContext context, Class strategyInterface) throws BeansException(Code)
Create a List of default strategy objects for the given strategy interface.

The default implementation uses the "DispatcherPortlet.properties" file (in the same package as the DispatcherPortlet class) to determine the class names. It instantiates the strategy objects and satisifies ApplicationContextAware if necessary.
Parameters:
  context - the current Portlet ApplicationContext
Parameters:
  strategyInterface - the strategy interface the List of corresponding strategy objects
throws:
  BeansException - if initialization failed




getDefaultStrategy
protected Object getDefaultStrategy(ApplicationContext context, Class strategyInterface) throws BeansException(Code)
Return the default strategy object for the given strategy interface.

The default implementation delegates to DispatcherPortlet.getDefaultStrategies , expecting a single object in the list.
Parameters:
  context - the current Portlet ApplicationContext
Parameters:
  strategyInterface - the strategy interface the corresponding strategy object
throws:
  BeansException - if initialization failed
See Also:   DispatcherPortlet.getDefaultStrategies




getHandler
protected HandlerExecutionChain getHandler(PortletRequest request, boolean cache) throws Exception(Code)
Return the HandlerExecutionChain for this request. Try all handler mappings in order.
Parameters:
  request - current portlet request
Parameters:
  cache - whether to cache the HandlerExecutionChain in a request attribute the HandlerExceutionChain, or null if no handler could be found



getHandlerAdapter
protected HandlerAdapter getHandlerAdapter(Object handler) throws PortletException(Code)
Return the HandlerAdapter for this handler object.
Parameters:
  handler - the handler object to find an adapter for
throws:
  PortletException - if no HandlerAdapter can be found for the handler.This is a fatal error.



getMultipartResolver
public PortletMultipartResolver getMultipartResolver()(Code)
Obtain this portlet's PortletMultipartResolver, if any. the PortletMultipartResolver used by this portlet, or nullif none (indicating that no multipart support is available)



initStrategies
protected void initStrategies(ApplicationContext context)(Code)
Refresh the strategy objects that this portlet uses.

May be overridden in subclasses in order to initialize further strategy objects.




noHandlerFound
protected void noHandlerFound(PortletRequest request, PortletResponse response) throws PortletException(Code)
No handler found -> throw appropriate exception.
Parameters:
  request - current portlet request
Parameters:
  response - current portlet response



onRefresh
public void onRefresh(ApplicationContext context)(Code)
This implementation calls DispatcherPortlet.initStrategies .



processHandlerException
protected ModelAndView processHandlerException(RenderRequest request, RenderResponse response, Object handler, Exception ex) throws Exception(Code)
Determine an error ModelAndView via the registered HandlerExceptionResolvers.
Parameters:
  request - current portlet request
Parameters:
  response - current portlet response
Parameters:
  handler - the executed handler, or null if none chosen at the time ofthe exception (for example, if multipart resolution failed)
Parameters:
  ex - the exception that got thrown during handler execution a corresponding ModelAndView to forward to
throws:
  Exception - if no error ModelAndView found



render
protected void render(ModelAndView mv, RenderRequest request, RenderResponse response) throws Exception(Code)
Render the given ModelAndView. This is the last stage in handling a request. It may involve resolving the view by name.
Parameters:
  mv - the ModelAndView to render
Parameters:
  request - current portlet render request
Parameters:
  response - current portlet render response
throws:
  Exception - if there's a problem rendering the view



resolveViewName
protected View resolveViewName(String viewName, Map model, RenderRequest request) throws Exception(Code)
Resolve the given view name into a View object (to be rendered).

Default implementations asks all ViewResolvers of this dispatcher. Can be overridden for custom resolution strategies, potentially based on specific model attributes or request parameters.
Parameters:
  viewName - the name of the view to resolve
Parameters:
  model - the model to be passed to the view
Parameters:
  request - current portlet render request the View object, or null if none found
throws:
  Exception - if the view cannot be resolved(typically in case of problems creating an actual View object)
See Also:   ViewResolver.resolveViewName




setDetectAllHandlerAdapters
public void setDetectAllHandlerAdapters(boolean detectAllHandlerAdapters)(Code)
Set whether to detect all HandlerAdapter beans in this portlet's context. Else, just a single bean with name "handlerAdapter" will be expected.

Default is "true". Turn this off if you want this portlet to use a single HandlerAdapter, despite multiple HandlerAdapter beans being defined in the context.




setDetectAllHandlerExceptionResolvers
public void setDetectAllHandlerExceptionResolvers(boolean detectAllHandlerExceptionResolvers)(Code)
Set whether to detect all HandlerExceptionResolver beans in this portlet's context. Else, just a single bean with name "handlerExceptionResolver" will be expected.

Default is true. Turn this off if you want this portlet to use a single HandlerExceptionResolver, despite multiple HandlerExceptionResolver beans being defined in the context.




setDetectAllHandlerMappings
public void setDetectAllHandlerMappings(boolean detectAllHandlerMappings)(Code)
Set whether to detect all HandlerMapping beans in this portlet's context. Else, just a single bean with name "handlerMapping" will be expected.

Default is true. Turn this off if you want this portlet to use a single HandlerMapping, despite multiple HandlerMapping beans being defined in the context.




setDetectAllViewResolvers
public void setDetectAllViewResolvers(boolean detectAllViewResolvers)(Code)
Set whether to detect all ViewResolver beans in this portlet's context. Else, just a single bean with name "viewResolver" will be expected.

Default is true. Turn this off if you want this portlet to use a single ViewResolver, despite multiple ViewResolver beans being defined in the context.




setThreadContextInheritable
public void setThreadContextInheritable(boolean threadContextInheritable)(Code)
Set whether to expose the LocaleContext and RequestAttributes as inheritable for child threads (using an java.lang.InheritableThreadLocal ).

Default is "false", to avoid side effects on spawned background threads. Switch this to "true" to enable inheritance for custom child threads which are spawned during request processing and only used for this request (that is, ending after their initial task, without reuse of the thread).

WARNING: Do not use inheritance for child threads if you are accessing a thread pool which is configured to potentially add new threads on demand (e.g. a JDK java.util.concurrent.ThreadPoolExecutor ), since this will expose the inherited context to such a pooled thread.




setViewRendererUrl
public void setViewRendererUrl(String viewRendererUrl)(Code)
Set the URL to the ViewRendererServlet. That servlet is used to ultimately render all views in the portlet application.



Fields inherited from org.springframework.web.portlet.FrameworkPortlet
final public static Class DEFAULT_CONTEXT_CLASS(Code)(Java Doc)
final public static String DEFAULT_NAMESPACE_SUFFIX(Code)(Java Doc)
final public static String[] DEFAULT_USERINFO_ATTRIBUTE_NAMES(Code)(Java Doc)
final public static String PORTLET_CONTEXT_PREFIX(Code)(Java Doc)

Methods inherited from org.springframework.web.portlet.FrameworkPortlet
protected ApplicationContext createPortletApplicationContext(ApplicationContext parent) throws BeansException(Code)(Java Doc)
public void destroy()(Code)(Java Doc)
abstract protected void doActionService(ActionRequest request, ActionResponse response) throws Exception(Code)(Java Doc)
final protected void doDispatch(RenderRequest request, RenderResponse response) throws PortletException, IOException(Code)(Java Doc)
abstract protected void doRenderService(RenderRequest request, RenderResponse response) throws Exception(Code)(Java Doc)
public Class getContextClass()(Code)(Java Doc)
public String getContextConfigLocation()(Code)(Java Doc)
public String getNamespace()(Code)(Java Doc)
final public ApplicationContext getPortletApplicationContext()(Code)(Java Doc)
public String getPortletContextAttributeName()(Code)(Java Doc)
public String[] getUserinfoUsernameAttributes()(Code)(Java Doc)
protected String getUsernameForRequest(PortletRequest request)(Code)(Java Doc)
protected void initFrameworkPortlet() throws PortletException, BeansException(Code)(Java Doc)
protected ApplicationContext initPortletApplicationContext() throws BeansException(Code)(Java Doc)
final protected void initPortletBean() throws PortletException, BeansException(Code)(Java Doc)
public boolean isPublishContext()(Code)(Java Doc)
public boolean isPublishEvents()(Code)(Java Doc)
public void onApplicationEvent(ApplicationEvent event)(Code)(Java Doc)
protected void onRefresh(ApplicationContext context) throws BeansException(Code)(Java Doc)
protected void postProcessPortletApplicationContext(ConfigurableApplicationContext pac)(Code)(Java Doc)
final public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException(Code)(Java Doc)
final protected void processRequest(PortletRequest request, PortletResponse response) throws PortletException, IOException(Code)(Java Doc)
public void refresh() throws BeansException(Code)(Java Doc)
public void setContextClass(Class contextClass)(Code)(Java Doc)
public void setContextConfigLocation(String contextConfigLocation)(Code)(Java Doc)
public void setNamespace(String namespace)(Code)(Java Doc)
public void setPublishContext(boolean publishContext)(Code)(Java Doc)
public void setPublishEvents(boolean publishEvents)(Code)(Java Doc)
public void setUserinfoUsernameAttributes(String[] userinfoUsernameAttributes)(Code)(Java Doc)

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

Methods inherited from org.springframework.web.portlet.GenericPortletBean
final protected void addRequiredProperty(String property)(Code)(Java Doc)
final public PortletContext getPortletContext()(Code)(Java Doc)
final public String getPortletName()(Code)(Java Doc)
final public void init() throws PortletException(Code)(Java Doc)
protected void initBeanWrapper(BeanWrapper bw) throws BeansException(Code)(Java Doc)
protected void initPortletBean() throws PortletException(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.