public class SpringMvcTinyProcessor extends AbstractTinyProcessor implements org.springframework.context.ApplicationContextAware
Modifier and Type | Field and Description |
---|---|
static String |
LOCALE_RESOLVER_ATTRIBUTE
Request attribute to hold the current LocaleResolver, retrievable by
views.
|
static String |
REQUEST_URI |
static String |
THEME_RESOLVER_ATTRIBUTE
Request attribute to hold the current ThemeResolver, retrievable by
views.
|
static String |
THEME_SOURCE_ATTRIBUTE
Request attribute to hold the current ThemeSource, retrievable by views.
|
static String |
WEB_APPLICATION_CONTEXT_ATTRIBUTE
Request attribute to hold the current web application context.
|
logger, processorName, tinyProcessorConfig
TINY_PROCESSOR
DEFAULT_PRECEDENCE, HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
SpringMvcTinyProcessor() |
Modifier and Type | Method and Description |
---|---|
protected org.springframework.context.i18n.LocaleContext |
buildLocaleContext(javax.servlet.http.HttpServletRequest request)
Build a LocaleContext
|
protected javax.servlet.http.HttpServletRequest |
checkMultipart(javax.servlet.http.HttpServletRequest request)
Return the HandlerExecutionChain for this request.
|
protected void |
cleanupMultipart(javax.servlet.http.HttpServletRequest request)
Clean up any resources used by the given multipart request (if any).
|
protected org.springframework.web.context.WebApplicationContext |
createWebApplicationContext(org.springframework.context.ApplicationContext parent) |
protected void |
customInit() |
void |
destroy()
处理器的销毁方法
|
String |
getContextAttribute() |
String |
getContextConfigLocation() |
protected String |
getDefaultViewName(javax.servlet.http.HttpServletRequest request)
Translate the supplied request into a default view name.
|
protected org.springframework.web.servlet.HandlerExecutionChain |
getHandler(javax.servlet.http.HttpServletRequest request) |
protected org.springframework.web.servlet.HandlerAdapter |
getHandlerAdapter(Object handler)
Return the HandlerAdapter for this handler object.
|
int |
getOrder()
Return the order value of this object, with a
higher value meaning greater in terms of sorting.
|
protected javax.servlet.ServletContext |
getServletContext() |
org.springframework.ui.context.ThemeSource |
getThemeSource() |
protected String |
getUsernameForRequest(javax.servlet.http.HttpServletRequest request)
Determine the username for the given request.
|
protected org.springframework.web.context.WebApplicationContext |
initWebApplicationContext()
Initialize and publish the WebApplicationContext for this servlet.
|
protected void |
noHandlerFound(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
No handler found -> set appropriate HTTP response status.
|
void |
onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
Callback that receives refresh events from this servlet's
WebApplicationContext.
|
protected void |
onRefresh(org.springframework.context.ApplicationContext context) |
protected void |
postProcessWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext wac) |
protected org.springframework.web.servlet.ModelAndView |
processHandlerException(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Object handler,
Exception ex)
Determine an error ModelAndView via the registered
HandlerExceptionResolvers.
|
void |
reallyProcess(String urlString,
WebContext context)
tinyprocessor的逻辑处理方法,由子类来完成
|
protected void |
render(org.springframework.web.servlet.ModelAndView mv,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Render the given ModelAndView.
|
protected org.springframework.web.servlet.View |
resolveViewName(String viewName,
Map<String,Object> model,
Locale locale,
javax.servlet.http.HttpServletRequest request)
Resolve the given view name into a View object (to be rendered).
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setCleanupAfterInclude(boolean cleanupAfterInclude) |
void |
setContextAttribute(String contextAttribute) |
void |
setContextConfigLocation(String contextConfigLocation) |
void |
setExtensionMappingInstanceResolver(ExtensionMappingInstanceResolver extensionMappingInstanceResolver) |
void |
setPublishContext(boolean publishContext) |
void |
setPublishEvents(boolean publishEvents) |
void |
setSpringMVCAdapter(SpringMVCAdapter springMVCAdapter) |
get, getInitParamMap, getProcessorName, init, isMatch, process, setProcessorName
public static final String WEB_APPLICATION_CONTEXT_ATTRIBUTE
RequestContextUtils.getWebApplicationContext(javax.servlet.ServletRequest)
public static final String LOCALE_RESOLVER_ATTRIBUTE
RequestContextUtils.getLocaleResolver(javax.servlet.http.HttpServletRequest)
public static final String THEME_RESOLVER_ATTRIBUTE
RequestContextUtils.getThemeResolver(javax.servlet.http.HttpServletRequest)
public static final String THEME_SOURCE_ATTRIBUTE
RequestContextUtils.getThemeSource(javax.servlet.http.HttpServletRequest)
public static final String REQUEST_URI
public void setExtensionMappingInstanceResolver(ExtensionMappingInstanceResolver extensionMappingInstanceResolver)
public void setCleanupAfterInclude(boolean cleanupAfterInclude)
public void setSpringMVCAdapter(SpringMVCAdapter springMVCAdapter)
public String getContextAttribute()
public void setContextAttribute(String contextAttribute)
public String getContextConfigLocation()
public void setContextConfigLocation(String contextConfigLocation)
public void setPublishEvents(boolean publishEvents)
public void setPublishContext(boolean publishContext)
public void reallyProcess(String urlString, WebContext context) throws javax.servlet.ServletException, IOException
AbstractTinyProcessor
reallyProcess
in class AbstractTinyProcessor
javax.servlet.ServletException
IOException
public final org.springframework.ui.context.ThemeSource getThemeSource()
protected javax.servlet.http.HttpServletRequest checkMultipart(javax.servlet.http.HttpServletRequest request) throws Exception
Tries all handler mappings in order.
request
- current HTTP requestnull
if no handler
could be foundException
protected void cleanupMultipart(javax.servlet.http.HttpServletRequest request)
request
- current HTTP requestMultipartResolver.cleanupMultipart(org.springframework.web.multipart.MultipartHttpServletRequest)
protected void noHandlerFound(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception
request
- current HTTP requestresponse
- current HTTP responseException
- if preparing the response failedprotected org.springframework.web.servlet.HandlerAdapter getHandlerAdapter(Object handler) throws javax.servlet.ServletException
handler
- the handler object to find an adapter forjavax.servlet.ServletException
- if no HandlerAdapter can be found for the handler. This is a
fatal error.protected org.springframework.web.servlet.HandlerExecutionChain getHandler(javax.servlet.http.HttpServletRequest request) throws Exception
Exception
protected String getDefaultViewName(javax.servlet.http.HttpServletRequest request) throws Exception
request
- current HTTP servlet requestnull
if no default found)Exception
- if view name translation failedprotected org.springframework.web.servlet.ModelAndView processHandlerException(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, Exception ex) throws Exception
request
- current HTTP requestresponse
- current HTTP responsehandler
- the executed handler, or null
if none chosen at
the time of the exception (for example, if multipart
resolution failed)ex
- the exception that got thrown during handler executionException
- if no error ModelAndView foundprotected void render(org.springframework.web.servlet.ModelAndView mv, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception
This is the last stage in handling a request. It may involve resolving the view by name.
mv
- the ModelAndView to renderrequest
- current HTTP servlet requestresponse
- current HTTP servlet responsejavax.servlet.ServletException
- if view is missing or cannot be resolvedException
- if there's a problem rendering the viewprotected org.springframework.web.servlet.View resolveViewName(String viewName, Map<String,Object> model, Locale locale, javax.servlet.http.HttpServletRequest request) throws Exception
The default implementations asks all ViewResolvers of this dispatcher. Can be overridden for custom resolution strategies, potentially based on specific model attributes or request parameters.
viewName
- the name of the view to resolvemodel
- the model to be passed to the viewlocale
- the current localerequest
- current HTTP servlet requestnull
if none foundException
- if the view cannot be resolved (typically in case of problems
creating an actual View object)ViewResolver.resolveViewName(java.lang.String, java.util.Locale)
protected org.springframework.context.i18n.LocaleContext buildLocaleContext(javax.servlet.http.HttpServletRequest request)
request
- current HTTP requestprotected String getUsernameForRequest(javax.servlet.http.HttpServletRequest request)
The default implementation takes the name of the UserPrincipal, if any. Can be overridden in subclasses.
request
- current HTTP requestnull
if none foundHttpServletRequest.getUserPrincipal()
protected void customInit() throws javax.servlet.ServletException
customInit
in class AbstractTinyProcessor
javax.servlet.ServletException
protected org.springframework.web.context.WebApplicationContext initWebApplicationContext()
Delegates to createWebApplicationContext(org.springframework.context.ApplicationContext)
for actual creation of
the context. Can be overridden in subclasses.
#setContextClass
,
setContextConfigLocation(java.lang.String)
protected javax.servlet.ServletContext getServletContext()
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
org.springframework.beans.BeansException
protected org.springframework.web.context.WebApplicationContext createWebApplicationContext(org.springframework.context.ApplicationContext parent)
protected void postProcessWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext wac)
public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
The default implementation calls onRefresh(org.springframework.context.ApplicationContext)
, triggering a refresh
of this servlet's context-dependent state.
event
- the incoming ApplicationContext eventprotected void onRefresh(org.springframework.context.ApplicationContext context)
public void destroy()
TinyProcessor
destroy
in interface TinyProcessor
destroy
in class AbstractTinyProcessor
public int getOrder()
Ordered
Normally starting with 0 or 1, with Ordered.LOWEST_PRECEDENCE
indicating greatest. Same order values will result in arbitrary
positions for the affected objects.
Higher value can be interpreted as lower priority, consequently the first object has highest priority (somewhat analogous to Servlet "load-on-startup" values).
Note that order values below 0 are reserved for framework purposes. Application-specified values should always be 0 or greater, with only framework components (internal or third-party) supposed to use lower values.
getOrder
in interface Ordered
getOrder
in class AbstractTinyProcessor
Ordered.LOWEST_PRECEDENCE
Copyright © 2006–2018 TinyGroup. All rights reserved.