Package muntjac :: Package terminal :: Package gwt :: Package server :: Module abstract_application_servlet :: Class AbstractApplicationServlet
[hide private]
[frames] | no frames]

Class AbstractApplicationServlet

source code

                    object --+            
                             |            
paste.webkit.wkservlet.Servlet --+        
                                 |        
paste.webkit.wkservlet.HTTPServlet --+    
                                     |    
   paste_wsgi_servlet.PasteWsgiServlet --+
                                         |
                            object --+   |
                                     |   |
                   constants.Constants --+
                                         |
                                        AbstractApplicationServlet
Known Subclasses:

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.


Authors:
Vaadin Ltd., Richard Lincoln

Version: 1.1.2

Nested Classes [hide private]

Inherited from paste_wsgi_servlet.PasteWsgiServlet: EndResponse

Inherited from paste.webkit.wkservlet.Servlet: ReturnIterException

Instance Methods [hide private]
 
__init__(self, productionMode=False, debug=False, widgetset=None, resourceCacheTime=3600, disableXsrfProtection=False, *args, **kw_args)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
init(self)
Called by the servlet container to indicate to a servlet that the servlet is being placed into service.
source code
 
checkCrossSiteProtection(self) source code
 
checkWidgetsetVersion(self, request)
Checks that the version reported by the client (widgetset) matches that of the server.
source code
 
checkProductionMode(self)
Check if the application is in production mode.
source code
 
checkResourceCacheTime(self) source code
 
getApplicationProperty(self, parameterName)
Gets an application property value.
source code
 
getSystemProperty(self, parameterName)
Gets an system property value.
source code
 
getApplicationOrSystemProperty(self, parameterName, defaultValue)
Gets an application or system property value.
source code
 
isProductionMode(self)
Returns true if the servlet is running in production mode.
source code
 
getResourceCacheTime(self)
Returns the amount of milliseconds the browser should cache a file.
source code
 
service(self, request, response)
Receives standard HTTP requests from the public service method and dispatches them.
source code
 
ensureCookiesEnabled(self, requestType, request, response)
Check that cookie support is enabled in the browser.
source code
 
updateBrowserProperties(self, browser, request) source code
 
criticalNotification(self, request, response, caption, message, details, url)
Send a notification to client's application.
source code
 
writeResponse(self, response, contentType, output)
Writes the response in output using the contentType given in contentType to the provided HttpServletResponse
source code
 
findApplicationInstance(self, request, requestType)
Returns the application instance to be used for the request.
source code
 
requestCanCreateApplication(self, request, requestType)
Check if the request should create an application if an existing application is not found.
source code
 
handleDownload(self, stream, request, response)
Handles the requested URI.
source code
 
createApplication(self, request)
Creates a new application and registers it into WebApplicationContext (aka session).
source code
 
handleServiceException(self, request, response, application, e) source code
 
getThemeForWindow(self, request, window)
Returns the theme for given request/window
source code
 
handleURI(self, applicationManager, window, request, response)
Calls URI handlers for the request.
source code
 
handleServiceSessionExpired(self, request, response) source code
 
handleServiceSecurityException(self, request, response) source code
 
getNewApplication(self, request)
Creates a new application for the given request.
source code
 
startApplication(self, request, application, webApplicationContext)
Starts the application if it is not already running.
source code
 
serveStaticResources(self, request, response)
Check if this is a request for a static resource and, if it is, serve the resource to the client.
source code
 
serveStaticResourcesInVAADIN(self, filename, request, response)
Serve resources from VAADIN directory.
source code
 
isAllowedVAADINResourceUrl(self, request, resourceUrl)
Check whether a URL obtained from a classloader refers to a valid static resource in the directory VAADIN.
source code
 
browserHasNewestVersion(self, request, resourceLastModifiedTimestamp)
Checks if the browser has an up to date cached version of requested resource.
source code
 
getRequestType(self, request) source code
 
isApplicationRequest(self, request) source code
 
isStaticResourceRequest(self, request) source code
 
isUIDLRequest(self, request) source code
 
isFileUploadRequest(self, request) source code
 
isOnUnloadRequest(self, request) source code
 
getSystemMessages(self)
Get system messages from the current application class
source code
 
getApplicationClass(self) source code
 
getStaticFilesLocation(self, request)
Return the URL from where static files, e.g.
source code
 
getWebApplicationsStaticFileLocation(self, request)
The default method to fetch static files location (URL).
source code
 
redirectToApplication(self, request, response)
Write a redirect response to the main page of the application.
source code
 
writeAjaxPage(self, request, response, window, application)
This method writes the html host page (aka kickstart page) that starts the actual Muntjac application.
source code
 
getApplicationCSSClassName(self)
Returns the application class identifier for use in the application CSS class name in the root DIV.
source code
 
getThemeUri(self, themeName, request)
Get the URI for the application theme.
source code
 
writeAjaxPageHtmlMainDiv(self, page, appId, classNames, divStyle, request)
Method to write the div element into which that actual Muntjac application is rendered.
source code
 
writeAjaxPageHtmlMuntjacScripts(self, window, themeName, application, page, appUrl, themeUri, appId, request)
Method to write the script part of the page which loads needed Muntjac scripts and themes.
source code
 
isStandalone(self)
Returns: true if the served application is considered to be the only or main content of the host page.
source code
 
writeAjaxPageHtmlBodyStart(self, page, request)
Method to open the body tag of the html kickstart page.
source code
 
writeAjaxPageHtmlHeader(self, page, title, themeUri, request)
Method to write the contents of head element in html kickstart page.
source code
 
writeAjaxPageHtmlHeadStart(self, page, request)
Method to write the beginning of the html page.
source code
 
setAjaxPageHeaders(self, response)
Method to set http request headers for the Muntjac kickstart page.
source code
 
getNoScriptMessage(self)
Returns a message printed for browsers without scripting support or if browsers scripting support is disabled.
source code
 
getApplicationUrl(self, request)
Gets the current application URL from request.
source code
 
getExistingApplication(self, request, allowSessionCreation)
Gets the existing application for given request.
source code
 
endApplication(self, request, response, application)
Ends the application.
source code
 
getApplicationWindow(self, request, applicationManager, application)
Gets the existing application or create a new one.
source code
 
getRequestPathInfo(self, request)
Returns the path info; note that this _can_ be different than request.getPathInfo().
source code
 
getResourceLocation(self, theme, resource)
Gets relative location of a theme resource.
source code
 
isRepaintAll(self, request) source code
 
closeApplication(self, application, session) source code
 
getApplicationContext(self, session)
Gets the application context from an HttpSession.
source code
 
createCommunicationManager(self, application)
Override this method if you need to use a specialized communication mananger implementation.
source code

Inherited from paste_wsgi_servlet.PasteWsgiServlet: awake, getContentLength, getContentType, getContextPath, getHeader, getIfModifiedSince, getInputStream, getLocale, getMaxInactiveInterval, getOutputStream, getParameter, getParameters, getPathInfo, getRequestUri, getResource, getResourceAsStream, getResourcePath, getServerName, getServerPort, getServletPath, getSession, getSessionAttribute, getSessionId, getUrlPath, getUserAgent, invalidateSession, isSecure, isSessionNew, originalContextPath, redirect, respond, setHeader, setParameter, setSessionAttribute, setStatus, write

Inherited from paste.webkit.wkservlet.HTTPServlet: notImplemented, respondToHead

Inherited from paste.webkit.wkservlet.Servlet: __call__, canBeReused, canBeThreaded, name, runTransaction, sleep, wsgi_application

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods [hide private]
 
stripSpecialChars(cls, themeName)
A helper method to strip away characters that might somehow be used for XSS attacks.
 
getDefaultTheme(cls)
Returns the default theme.
 
removeHeadingOrTrailing(cls, string, what)
Remove any heading or trailing "what" from the "string".
 
safeEscapeForHtml(cls, unsafe)
Escapes characters to html entities.
 
isSafe(cls, c)
Class Variables [hide private]
  VERSION = '1.1.2'
The version number of this release.
  digits = ['1', '1', '2']
  VERSION_MAJOR = 1
Major version number.
  VERSION_MINOR = 1
Minor version number.
  VERSION_REVISION = 2
Version revision number.
  VERSION_BUILD = ''
Build identifier.
  REQUEST_FRAGMENT = ''
If the attribute is present in the request, a html fragment will be
  REQUEST_VAADIN_STATIC_FILE_PATH = ''
This request attribute forces widgetsets to be loaded from under the
  REQUEST_WIDGETSET = ''
This request attribute forces widgetset used; e.g for portlets that can
  REQUEST_SHARED_WIDGETSET = ''
This request attribute indicates the shared widgetset (e.g.
  REQUEST_DEFAULT_THEME = ''
If set, do not load the default theme but assume that loading it is
  REQUEST_APPSTYLE = ''
This request attribute is used to add styles to the main element.
  UPLOAD_URL_PREFIX = 'APP/UPLOAD/'
  _CHAR_BLACKLIST = ['&', '"', '\'', '<', '>', '(', ')', ';']

Inherited from paste.webkit.wkservlet.Servlet: __traceback_supplement_hide_vars__

Inherited from constants.Constants: AJAX_UIDL_URI, DEFAULT_BUFFER_SIZE, DEFAULT_THEME_CACHETIME, DEFAULT_THEME_NAME, DEFAULT_WIDGETSET, ERROR_NO_WINDOW_FOUND, INVALID_SECURITY_KEY_MSG, MAX_BUFFER_SIZE, NOT_PRODUCTION_MODE_INFO, PARAMETER_VAADIN_RESOURCES, PARAMETER_WIDGETSET, PORTAL_PARAMETER_VAADIN_RESOURCE_PATH, PORTAL_PARAMETER_VAADIN_THEME, PORTAL_PARAMETER_VAADIN_WIDGETSET, SERVLET_PARAMETER_DEBUG, SERVLET_PARAMETER_DISABLE_XSRF_PROTECTION, SERVLET_PARAMETER_PRODUCTION_MODE, SERVLET_PARAMETER_RESOURCE_CACHE_TIME, THEME_DIRECTORY_PATH, URL_PARAMETER_CLOSE_APPLICATION, URL_PARAMETER_REPAINT_ALL, URL_PARAMETER_RESTART_APPLICATION, URL_PARAMETER_THEME, WARNING_RESOURCE_CACHING_TIME_NOT_NUMERIC, WARNING_XSRF_PROTECTION_DISABLED, WIDGETSET_DIRECTORY_PATH, WIDGETSET_MISMATCH_INFO

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, productionMode=False, debug=False, widgetset=None, resourceCacheTime=3600, disableXsrfProtection=False, *args, **kw_args)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

init(self)

source code 

Called by the servlet container to indicate to a servlet that the servlet is being placed into service.

Overrides: paste_wsgi_servlet.PasteWsgiServlet.init

getApplicationProperty(self, parameterName)

source code 

Gets an application property value.

Parameters:
  • parameterName - the Name or the parameter.
Returns:
String value or None if not found

getSystemProperty(self, parameterName)

source code 

Gets an system property value.

Parameters:
  • parameterName - the Name or the parameter.
Returns:
String value or None if not found

getApplicationOrSystemProperty(self, parameterName, defaultValue)

source code 

Gets an application or system property value.

Parameters:
  • parameterName - the Name or the parameter.
  • defaultValue - the Default to be used.
Returns:
String value or default if not found

isProductionMode(self)

source code 

Returns true if the servlet is running in production mode. Production mode disables all debug facilities.

Returns:
true if in production mode, false if in debug mode

getResourceCacheTime(self)

source code 

Returns the amount of milliseconds the browser should cache a file. Default is 1 hour (3600 ms).

Returns:
The amount of milliseconds files are cached in the browser

service(self, request, response)

source code 

Receives standard HTTP requests from the public service method and dispatches them.

Overrides: paste_wsgi_servlet.PasteWsgiServlet.service

ensureCookiesEnabled(self, requestType, request, response)

source code 

Check that cookie support is enabled in the browser. Only checks UIDL requests.

Parameters:
  • requestType - Type of the request as returned by getRequestType
  • request - The request from the browser
  • response - The response to which an error can be written
Returns:
false if cookies are disabled, true otherwise
Raises:
  • IOException

criticalNotification(self, request, response, caption, message, details, url)

source code 

Send a notification to client's application. Used to notify client of critical errors, session expiration and more. Server has no knowledge of what application client refers to.

Parameters:
  • request - the HTTP request instance.
  • response - the HTTP response to write to.
  • caption - the notification caption
  • message - to notification body
  • details - 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.
Raises:
  • IOException - if the writing failed due to input/output error.

writeResponse(self, response, contentType, output)

source code 

Writes the response in output using the contentType given in contentType to the provided HttpServletResponse

Parameters:
  • response
  • contentType
  • output - Output to write (UTF-8 encoded)
Raises:
  • IOException

findApplicationInstance(self, request, requestType)

source code 

Returns the application instance to be used for the request. If an existing instance is not found a new one is created or null is returned to indicate that the application is not available.

Raises:

requestCanCreateApplication(self, request, requestType)

source code 

Check if the request should create an application if an existing application is not found.

Returns:
true if an application should be created, false otherwise

handleDownload(self, stream, request, response)

source code 

Handles the requested URI. An application can add handlers to do special processing, when a certain URI is requested. The handlers are invoked before any windows URIs are processed and if a DownloadStream is returned it is sent to the client.

Parameters:
  • stream - the download stream.
  • request - the HTTP request instance.
  • response - the HTTP response to write to.
Raises:
  • IOException

See Also: URIHandler

createApplication(self, request)

source code 

Creates a new application and registers it into WebApplicationContext (aka session). This is not meant to be overridden. Override getNewApplication to create the application instance in a custom way.

Raises:

stripSpecialChars(cls, themeName)
Class Method

 

A helper method to strip away characters that might somehow be used for XSS attacks. Leaves at least alphanumeric characters intact. Also removes eg. ( and ), so values should be safe in javascript too.

getDefaultTheme(cls)
Class Method

 

Returns the default theme. Must never return None.

handleURI(self, applicationManager, window, request, response)

source code 

Calls URI handlers for the request. If an URI handler returns a DownloadStream the stream is passed to the client for downloading.

Returns:
true if an DownloadStream was sent to the client @raise IOException

getNewApplication(self, request)

source code 

Creates a new application for the given request.

Parameters:
  • request - the HTTP request.
Returns:
A new Application instance.
Raises:

startApplication(self, request, application, webApplicationContext)

source code 

Starts the application if it is not already running.

Raises:

serveStaticResources(self, request, response)

source code 

Check if this is a request for a static resource and, if it is, serve the resource to the client.

Returns:
true if a file was served and the request has been handled, false otherwise.
Raises:

serveStaticResourcesInVAADIN(self, filename, request, response)

source code 

Serve resources from VAADIN directory.

Parameters:
  • filename - The filename to serve. Should always start with /VAADIN/.
  • request
  • response
Raises:

isAllowedVAADINResourceUrl(self, request, resourceUrl)

source code 

Check whether a URL obtained from a classloader refers to a valid static resource in the directory VAADIN.

Warning: Overriding of this method is not recommended, but is possible to support non-default classloaders or servers that may produce URLs different from the normal ones. The method prototype may change in the future. Care should be taken not to expose class files or other resources outside the VAADIN directory if the method is overridden.

browserHasNewestVersion(self, request, resourceLastModifiedTimestamp)

source code 

Checks if the browser has an up to date cached version of requested resource. Currently the check is performed using the "If-Modified-Since" header. Could be expanded if needed.

Parameters:
  • request - The HttpServletRequest from the browser.
  • resourceLastModifiedTimestamp - The timestamp when the resource was last modified. 0 if the last modification time is unknown.
Returns:
true if the If-Modified-Since header tells the cached version in the browser is up to date, false otherwise

getStaticFilesLocation(self, request)

source code 

Return the URL from where static files, e.g. the widgetset and the theme, are served. In a standard configuration the VAADIN folder inside the returned folder is what is used for widgetsets and themes.

The returned folder is usually the same as the context path and independent of the application.

Returns:
The location of static resources (should contain the VAADIN directory). Never ends with a slash (/).

getWebApplicationsStaticFileLocation(self, request)

source code 

The default method to fetch static files location (URL). This method does not check for request attribute REQUEST_VAADIN_STATIC_FILE_PATH.

redirectToApplication(self, request, response)

source code 

Write a redirect response to the main page of the application.

Raises:
  • IOException - if sending the redirect fails due to an input/output error or a bad application URL

writeAjaxPage(self, request, response, window, application)

source code 

This method writes the html host page (aka kickstart page) that starts the actual Muntjac application.

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:

Parameters:
  • request - the HTTP request.
  • response - the HTTP response to write to.
  • window
  • application
Raises:
  • 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.

getApplicationCSSClassName(self)

source code 

Returns the application class identifier for use in the application CSS class name in the root DIV. The application CSS class name is of form "v-app-"+getApplicationCSSClassName().

This method should normally not be overridden.

Returns:
The CSS class name to use in combination with "v-app-".

getThemeUri(self, themeName, request)

source code 

Get the URI for the application theme.

A portal-wide default theme is fetched from the portal shared resource directory (if any), other themes from the portlet.

writeAjaxPageHtmlMainDiv(self, page, appId, classNames, divStyle, request)

source code 

Method to write the div element into which that actual Muntjac application is rendered.

Override this method if you want to add some custom html around around the div element into which the actual Muntjac application will be rendered.

Raises:
  • IOException

writeAjaxPageHtmlMuntjacScripts(self, window, themeName, application, page, appUrl, themeUri, appId, request)

source code 

Method to write the script part of the page which loads needed Muntjac scripts and themes.

Override this method if you want to add some custom html around scripts.

Raises:

isStandalone(self)

source code 
Returns:
true if the served application is considered to be the only or main content of the host page. E.g. various embedding solutions should override this to false.

writeAjaxPageHtmlBodyStart(self, page, request)

source code 

Method to open the body tag of the html kickstart page.

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.

Raises:
  • IOException

writeAjaxPageHtmlHeader(self, page, title, themeUri, request)

source code 

Method to write the contents of head element in html kickstart page.

Override this method if you want to add some custom html to the header of the page.

Raises:
  • IOException

writeAjaxPageHtmlHeadStart(self, page, request)

source code 

Method to write the beginning of the html page.

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.

Raises:
  • IOException

setAjaxPageHeaders(self, response)

source code 

Method to set http request headers for the Muntjac kickstart page.

Override this method if you need to customize http headers of the page.

getApplicationUrl(self, request)

source code 

Gets the current application URL from request.

Parameters:
  • request - the HTTP request.
Raises:
  • MalformedURLException - if the application is denied access to the persistent data store represented by the given URL.

getExistingApplication(self, request, allowSessionCreation)

source code 

Gets the existing application for given request. Looks for application instance for given request based on the requested URL.

Parameters:
  • request - the HTTP request.
  • allowSessionCreation - true if a session should be created if no session exists, false if no session should be created
Returns:
Application instance, or null if the URL does not map to valid application.
Raises:
  • MalformedURLException - if the application is denied access to the persistent data store represented by the given URL.
  • SessionExpiredException

endApplication(self, request, response, application)

source code 

Ends the application.

Parameters:
  • request - the HTTP request.
  • response - the HTTP response to write to.
  • application - the application to end.
Raises:
  • IOException - if the writing failed due to input/output error.

getApplicationWindow(self, request, applicationManager, application)

source code 

Gets the existing application or create a new one. Get a window within an application based on the requested URI.

Parameters:
  • request - the HTTP Request.
  • application - the Application to query for window.
Returns:
Window matching the given URI or null if not found.
Raises:
  • ServletException - if an exception has occurred that interferes with the servlet's normal operation.

getRequestPathInfo(self, request)

source code 

Returns the path info; note that this _can_ be different than request.getPathInfo(). Examples where this might be useful:

  • An application runner servlet that runs different Muntjac applications based on an identifier.
  • Providing a REST interface in the context root, while serving a Muntjac UI on a sub-URI using only one servlet (e.g. REST on http://example.com/foo, UI on http://example.com/foo/vaadin)

getResourceLocation(self, theme, resource)

source code 

Gets relative location of a theme resource.

Parameters:
  • theme - the Theme name.
  • resource - the Theme resource.
Returns:
External URI specifying the resource

getApplicationContext(self, session)

source code 

Gets the application context from an HttpSession. If no context is currently stored in a session a new context is created and stored in the session.

Parameters:
  • session - the HTTP session.
Returns:
the application context for HttpSession.

createCommunicationManager(self, application)

source code 

Override this method if you need to use a specialized communication mananger implementation.

Deprecated: Instead of overriding this method, override WebApplicationContext implementation via getApplicationContext method and in that customized implementation return your CommunicationManager in WebApplicationContext.getApplicationManager method.

safeEscapeForHtml(cls, unsafe)
Class Method

 

Escapes characters to html entities. An exception is made for some "safe characters" to keep the text somewhat readable.

Returns:
a safe string to be added inside an html tag

Class Variable Details [hide private]

VERSION

The version number of this release. For example "6.2.0". Always in the

Value:
'1.1.2'

VERSION_MAJOR

Major version number. For example 6 in 6.2.0.

Value:
1

VERSION_MINOR

Minor version number. For example 2 in 6.2.0.

Value:
1

VERSION_REVISION

Version revision number. For example 0 in 6.2.0.

Value:
2

VERSION_BUILD

Build identifier. For example "nightly-20091123-c9963" in

Value:
''

REQUEST_SHARED_WIDGETSET

This request attribute indicates the shared widgetset (e.g. portal-wide

Value:
''

REQUEST_APPSTYLE

This request attribute is used to add styles to the main element. E.g

Value:
''