|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.vaadin.terminal.gwt.server.AbstractApplicationServlet
public abstract class AbstractApplicationServlet
Abstract implementation of the ApplicationServlet which handles all communication between the client and the server. It is possible to extend this class to provide own functionality but in most cases this is unnecessary.
Nested Class Summary | |
---|---|
class |
AbstractApplicationServlet.ParameterHandlerErrorImpl
Implementation of ParameterHandler.ErrorEvent interface. |
class |
AbstractApplicationServlet.RequestError
|
protected static class |
AbstractApplicationServlet.RequestType
|
class |
AbstractApplicationServlet.URIHandlerErrorImpl
Implementation of URIHandler.ErrorEvent interface. |
Field Summary | |
---|---|
static String |
REQUEST_APPSTYLE
This request attribute is used to add styles to the main element. |
static String |
REQUEST_DEFAULT_THEME
If set, do not load the default theme but assume that loading it is handled e.g. |
static String |
REQUEST_FRAGMENT
If the attribute is present in the request, a html fragment will be written instead of a whole page. |
static String |
REQUEST_SHARED_WIDGETSET
This request attribute indicates the shared widgetset (e.g. |
static String |
REQUEST_VAADIN_STATIC_FILE_PATH
This request attribute forces widgetsets to be loaded from under the specified base path; e.g shared widgetset for all portlets in a portal. |
static String |
REQUEST_WIDGETSET
This request attribute forces widgetset used; e.g for portlets that can not have different widgetsets. |
static String |
VERSION
The version number of this release. |
static String |
VERSION_BUILD
Build identifier. |
static int |
VERSION_MAJOR
Major version number. |
static int |
VERSION_MINOR
Minor version number. |
static int |
VERSION_REVISION
Version revision number. |
Constructor Summary | |
---|---|
AbstractApplicationServlet()
|
Method Summary | |
---|---|
CommunicationManager |
createCommunicationManager(Application application)
Deprecated. Instead of overriding this method, override WebApplicationContext implementation via
getApplicationContext(HttpSession)
method and in that customized implementation return your
CommunicationManager in
WebApplicationContext.getApplicationManager(Application, AbstractApplicationServlet)
method. |
protected String |
createPreventCachingQueryString()
To ensure the GWT kickstart scritp is downloaded each time (even if server caching is not set up right), we add a unique query parameter to the end of the script file. |
protected void |
criticalNotification(HttpServletRequest request,
HttpServletResponse response,
String caption,
String message,
String details,
String url)
Send a notification to client's application. |
protected abstract Class<? extends Application> |
getApplicationClass()
|
protected WebApplicationContext |
getApplicationContext(HttpSession session)
Gets the application context from an HttpSession. |
protected String |
getApplicationCSSClassName()
Returns the application class identifier for use in the application CSS class name in the root DIV. |
protected String |
getApplicationProperty(String parameterName)
Gets an application property value. |
protected URL |
getApplicationUrl(HttpServletRequest request)
Gets the current application URL from request. |
protected Window |
getApplicationWindow(HttpServletRequest request,
CommunicationManager applicationManager,
Application application)
Gets the existing application or create a new one. |
protected ClassLoader |
getClassLoader()
|
static String |
getDefaultTheme()
Returns the default theme. |
protected Application |
getExistingApplication(HttpServletRequest request,
boolean allowSessionCreation)
Gets the existing application for given request. |
protected abstract Application |
getNewApplication(HttpServletRequest request)
Creates a new application for the given request. |
protected String |
getNoScriptMessage()
Returns a message printed for browsers without scripting support or if browsers scripting support is disabled. |
protected String |
getRequestPathInfo(HttpServletRequest request)
Returns the path info; note that this _can_ be different than request.getPathInfo(). |
protected AbstractApplicationServlet.RequestType |
getRequestType(HttpServletRequest request)
|
int |
getResourceCacheTime()
Returns the number of seconds the browser should cache a file. |
String |
getResourceLocation(String theme,
ThemeResource resource)
Gets relative location of a theme resource. |
protected static String |
getResourcePath(ServletContext servletContext,
String path)
Gets resource path using different implementations. |
protected String |
getStaticFilesLocation(HttpServletRequest request)
Return the URL from where static files, e.g. |
protected Application.SystemMessages |
getSystemMessages()
Get system messages from the current application class |
protected String |
getSystemProperty(String parameterName)
Gets an system property value. |
protected boolean |
handleURI(CommunicationManager applicationManager,
Window window,
HttpServletRequest request,
HttpServletResponse response)
Calls URI handlers for the request. |
void |
init(ServletConfig servletConfig)
Called by the servlet container to indicate to a servlet that the servlet is being placed into service. |
protected boolean |
isAllowedVAADINResourceUrl(HttpServletRequest request,
URL resourceUrl)
Check whether a URL obtained from a classloader refers to a valid static resource in the directory VAADIN. |
boolean |
isProductionMode()
Returns true if the servlet is running in production mode. |
protected boolean |
isStandalone()
|
static String |
safeEscapeForHtml(String unsafe)
Escapes characters to html entities. |
protected void |
service(HttpServletRequest request,
HttpServletResponse response)
Receives standard HTTP requests from the public service method and dispatches them. |
protected void |
setAjaxPageHeaders(HttpServletResponse response)
Method to set http request headers for the Vaadin kickstart page. |
protected static String |
stripSpecialChars(String themeName)
A helper method to strip away characters that might somehow be used for XSS attacs. |
protected void |
writeAjaxPage(HttpServletRequest request,
HttpServletResponse response,
Window window,
Application application)
This method writes the html host page (aka kickstart page) that starts the actual Vaadin application. |
protected void |
writeAjaxPageHtmlBodyStart(BufferedWriter page,
HttpServletRequest request)
Method to open the body tag of the html kickstart page. |
protected void |
writeAjaxPageHtmlHeader(BufferedWriter page,
String title,
String themeUri,
HttpServletRequest request)
Method to write the contents of head element in html kickstart page. |
protected void |
writeAjaxPageHtmlHeadStart(BufferedWriter page,
HttpServletRequest request)
Method to write the beginning of the html page. |
protected void |
writeAjaxPageHtmlMainDiv(BufferedWriter page,
String appId,
String classNames,
String divStyle,
HttpServletRequest request)
Method to write the div element into which that actual Vaadin application is rendered. |
protected void |
writeAjaxPageHtmlVaadinScripts(Window window,
String themeName,
Application application,
BufferedWriter page,
String appUrl,
String themeUri,
String appId,
HttpServletRequest request)
Method to write the script part of the page which loads needed Vaadin scripts and themes. |
protected void |
writeStaticResourceResponse(HttpServletRequest request,
HttpServletResponse response,
URL resourceUrl)
Writes the contents of the given resourceUrl in the response. |
Methods inherited from class javax.servlet.http.HttpServlet |
---|
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service |
Methods inherited from class javax.servlet.GenericServlet |
---|
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String VERSION
public static final int VERSION_MAJOR
public static final int VERSION_MINOR
public static final int VERSION_REVISION
public static final String VERSION_BUILD
public static final String REQUEST_FRAGMENT
ApplicationPortlet
(Portlet 1.0) and
read by AbstractApplicationServlet
.
public static final String REQUEST_VAADIN_STATIC_FILE_PATH
ApplicationPortlet
(Portlet 1.0) based on
Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH
and read by
AbstractApplicationServlet
.
public static final String REQUEST_WIDGETSET
ApplicationPortlet
(Portlet 1.0) based on
ApplicationPortlet.PORTLET_PARAMETER_WIDGETSET
and read by
AbstractApplicationServlet
.
public static final String REQUEST_SHARED_WIDGETSET
ApplicationPortlet
(Portlet 1.0) based on
Constants.PORTAL_PARAMETER_VAADIN_WIDGETSET
and read by
AbstractApplicationServlet
.
public static final String REQUEST_DEFAULT_THEME
ApplicationPortlet
(Portlet 1.0) based on
Constants.PORTAL_PARAMETER_VAADIN_THEME
and read by
AbstractApplicationServlet
.
public static final String REQUEST_APPSTYLE
ApplicationPortlet
(Portlet 1.0) based
on ApplicationPortlet.PORTLET_PARAMETER_STYLE
and read by
AbstractApplicationServlet
.
Constructor Detail |
---|
public AbstractApplicationServlet()
Method Detail |
---|
public void init(ServletConfig servletConfig) throws ServletException
init
in interface Servlet
init
in class GenericServlet
servletConfig
- the object containing the servlet's configuration and
initialization parameters
ServletException
- if an exception has occurred that interferes with the
servlet's normal operation.protected String getApplicationProperty(String parameterName)
parameterName
- the Name or the parameter.
protected String getSystemProperty(String parameterName)
parameterName
- the Name or the parameter.
public boolean isProductionMode()
public int getResourceCacheTime()
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
service
in class HttpServlet
request
- the object that contains the request the client made of the
servlet.response
- the object that contains the response the servlet returns to
the client.
ServletException
- if an input or output error occurs while the servlet is
handling the TRACE request.
IOException
- if the request for the TRACE cannot be handled.protected ClassLoader getClassLoader() throws ServletException
ServletException
protected void criticalNotification(HttpServletRequest request, HttpServletResponse response, String caption, String message, String details, String url) throws IOException
request
- the HTTP request instance.response
- the HTTP response to write to.caption
- the notification captionmessage
- to notification bodydetails
- a detail message to show in addition to the message. Currently
shown directly below the message but could be hidden behind a
details drop down in the future. Mainly used to give
additional information not necessarily useful to the end user.url
- url to load when the message is dismissed. Null will reload
the current page.
IOException
- if the writing failed due to input/output error.protected static String getResourcePath(ServletContext servletContext, String path)
servletContext
- path
- the resource path.
protected static String stripSpecialChars(String themeName)
themeName
-
public static String getDefaultTheme()
protected boolean handleURI(CommunicationManager applicationManager, Window window, HttpServletRequest request, HttpServletResponse response) throws IOException
applicationManager
- window
- request
- response
-
IOException
protected abstract Application getNewApplication(HttpServletRequest request) throws ServletException
request
- the HTTP request.
ServletException
protected void writeStaticResourceResponse(HttpServletRequest request, HttpServletResponse response, URL resourceUrl) throws IOException
request
- The request for the resourceresponse
- The responseresourceUrl
- The url to send
IOException
protected boolean isAllowedVAADINResourceUrl(HttpServletRequest request, URL resourceUrl)
request
- resourceUrl
-
protected AbstractApplicationServlet.RequestType getRequestType(HttpServletRequest request)
protected Application.SystemMessages getSystemMessages()
protected abstract Class<? extends Application> getApplicationClass() throws ClassNotFoundException
ClassNotFoundException
protected String getStaticFilesLocation(HttpServletRequest request)
request
-
protected void writeAjaxPage(HttpServletRequest request, HttpServletResponse response, Window window, Application application) throws IOException, MalformedURLException, ServletException
If one needs to override parts of the host page, it is suggested that one overrides on of several submethods which are called by this method:
setAjaxPageHeaders(HttpServletResponse)
writeAjaxPageHtmlHeadStart(BufferedWriter, HttpServletRequest)
writeAjaxPageHtmlHeader(BufferedWriter, String, String, HttpServletRequest)
writeAjaxPageHtmlBodyStart(BufferedWriter, HttpServletRequest)
writeAjaxPageHtmlVaadinScripts(Window, String, Application, BufferedWriter, String, String, String, HttpServletRequest)
writeAjaxPageHtmlMainDiv(BufferedWriter, String, String, String, HttpServletRequest)
#writeAjaxPageHtmlBodyEnd(BufferedWriter)
request
- the HTTP request.response
- the HTTP response to write to.out
- unhandledParameters
- window
- terminalType
- theme
-
IOException
- if the writing failed due to input/output error.
MalformedURLException
- if the application is denied access the persistent data store
represented by the given URL.
ServletException
protected String getApplicationCSSClassName()
protected void writeAjaxPageHtmlMainDiv(BufferedWriter page, String appId, String classNames, String divStyle, HttpServletRequest request) throws IOException
Override this method if you want to add some custom html around around the div element into which the actual Vaadin application will be rendered.
page
- appId
- classNames
- divStyle
- request
-
IOException
protected void writeAjaxPageHtmlVaadinScripts(Window window, String themeName, Application application, BufferedWriter page, String appUrl, String themeUri, String appId, HttpServletRequest request) throws ServletException, IOException
Override this method if you want to add some custom html around scripts.
window
- themeName
- application
- page
- appUrl
- themeUri
- appId
- request
-
ServletException
IOException
protected String createPreventCachingQueryString()
protected boolean isStandalone()
protected void writeAjaxPageHtmlBodyStart(BufferedWriter page, HttpServletRequest request) throws IOException
This method is responsible for closing the head tag and opening the body tag.
Override this method if you want to add some custom html to the page.
page
- request
-
IOException
protected void writeAjaxPageHtmlHeader(BufferedWriter page, String title, String themeUri, HttpServletRequest request) throws IOException
Override this method if you want to add some custom html to the header of the page.
page
- title
- themeUri
- request
-
IOException
protected void writeAjaxPageHtmlHeadStart(BufferedWriter page, HttpServletRequest request) throws IOException
This method is responsible for writing appropriate doc type declarations and to open html and head tags.
Override this method if you want to add some custom html to the very beginning of the page.
page
- request
-
IOException
protected void setAjaxPageHeaders(HttpServletResponse response)
Override this method if you need to customize http headers of the page.
response
- protected String getNoScriptMessage()
protected URL getApplicationUrl(HttpServletRequest request) throws MalformedURLException
request
- the HTTP request.
MalformedURLException
- if the application is denied access to the persistent data
store represented by the given URL.protected Application getExistingApplication(HttpServletRequest request, boolean allowSessionCreation) throws MalformedURLException, SessionExpiredException
request
- the HTTP request.allowSessionCreation
- true if a session should be created if no session exists,
false if no session should be created
MalformedURLException
- if the application is denied access to the persistent data
store represented by the given URL.
IllegalAccessException
InstantiationException
SessionExpiredException
protected Window getApplicationWindow(HttpServletRequest request, CommunicationManager applicationManager, Application application) throws ServletException
request
- the HTTP Request.application
- the Application to query for window.
ServletException
- if an exception has occurred that interferes with the
servlet's normal operation.protected String getRequestPathInfo(HttpServletRequest request)
request
-
public String getResourceLocation(String theme, ThemeResource resource)
theme
- the Theme name.resource
- the Theme resource.
protected WebApplicationContext getApplicationContext(HttpSession session)
session
- the HTTP session.
@Deprecated public CommunicationManager createCommunicationManager(Application application)
WebApplicationContext
implementation via
getApplicationContext(HttpSession)
method and in that customized implementation return your
CommunicationManager in
WebApplicationContext.getApplicationManager(Application, AbstractApplicationServlet)
method.
application
-
public static final String safeEscapeForHtml(String unsafe)
unsafe
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |