/**
* TODO Document me!
- *
+ *
* @author peholmst
*/
public abstract class AbstractApplicationPortlet extends GenericPortlet
/**
* Gets an application property value.
- *
+ *
* @param parameterName
* the Name or the parameter.
* @return String value or null if not found
/**
* Gets an system property value.
- *
+ *
* @param parameterName
* the Name or the parameter.
* @return String value or null if not found
/**
* Gets an application or system property value.
- *
+ *
* @param parameterName
* the Name or the parameter.
* @param defaultValue
* 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.
- *
+ *
* @param request
* @return The location of static resources (inside which there should be a
* VAADIN directory). Does not end with a slash (/).
/**
* Returns true if the servlet is running in production mode. Production
* mode disables all debug facilities.
- *
+ *
* @return true if in production mode, false if in debug mode
*/
public boolean isProductionMode() {
updateBrowserProperties(applicationContext.getBrowser(),
request);
+ /*
+ * Call application requestStart before Application.init() is
+ * called (bypasses the limitation in TransactionListener)
+ */
+ if (application instanceof PortletRequestListener) {
+ ((PortletRequestListener) application).onRequestStart(
+ request, response);
+ }
+
/* Start the newly created application */
startApplication(request, application, applicationContext);
// TODO Should this happen before or after the transaction
// starts?
-
if (request instanceof RenderRequest) {
applicationContext.firePortletRenderRequest(application,
(RenderRequest) request, (RenderResponse) response);
if (application != null) {
((PortletApplicationContext2) application.getContext())
.endTransaction(application, request);
+
+ if (application instanceof PortletRequestListener) {
+ ((PortletRequestListener) application).onRequestEnd(
+ request, response);
+ }
+
}
}
}
protected String getWidgetsetURL(String widgetset, PortletRequest request) {
return getStaticFilesLocation(request) + "/" + WIDGETSET_DIRECTORY_PATH
- + widgetset + "/"
- + widgetset + ".nocache.js?" + new Date().getTime();
+ + widgetset + "/" + widgetset + ".nocache.js?"
+ + new Date().getTime();
}
protected String getThemeURI(String themeName, PortletRequest request) {
/**
* Returns the theme for given request/window
- *
+ *
* @param request
* @param window
* @return
/**
* Get system messages from the current application class
- *
+ *
* @return
*/
protected SystemMessages getSystemMessages() {
* Send notification to client's application. Used to notify client of
* critical errors and session expiration due to long inactivity. Server has
* no knowledge of what application client refers to.
- *
+ *
* @param request
* the Portlet request instance.
* @param response
/**
* 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.
- *
- *
+ *
+ *
* @author IT Mill Ltd.
* @version
* @VERSION@
*/
@SuppressWarnings("serial")
-public abstract class AbstractApplicationServlet extends HttpServlet implements Constants {
+public abstract class AbstractApplicationServlet extends HttpServlet implements
+ Constants {
- // TODO Move some (all?) of the constants to a separate interface (shared with portlet)
+ // TODO Move some (all?) of the constants to a separate interface (shared
+ // with portlet)
/**
* The version number of this release. For example "6.2.0". Always in the
/**
* If the attribute is present in the request, a html fragment will be
* written instead of a whole page.
- *
+ *
* It is set to "true" by the {@link ApplicationPortlet} (Portlet 1.0) and
* read by {@link AbstractApplicationServlet}.
*/
/**
* This request attribute forces widgetsets to be loaded from under the
* specified base path; e.g shared widgetset for all portlets in a portal.
- *
+ *
* It is set by the {@link ApplicationPortlet} (Portlet 1.0) based on
* {@link Constants.PORTAL_PARAMETER_VAADIN_RESOURCE_PATH} and read by
* {@link AbstractApplicationServlet}.
/**
* This request attribute forces widgetset used; e.g for portlets that can
* not have different widgetsets.
- *
+ *
* It is set by the {@link ApplicationPortlet} (Portlet 1.0) based on
* {@link ApplicationPortlet.PORTLET_PARAMETER_WIDGETSET} and read by
* {@link AbstractApplicationServlet}.
/**
* This request attribute indicates the shared widgetset (e.g. portal-wide
* default widgetset).
- *
+ *
* It is set by the {@link ApplicationPortlet} (Portlet 1.0) based on
* {@link Constants.PORTAL_PARAMETER_VAADIN_WIDGETSET} and read by
* {@link AbstractApplicationServlet}.
/**
* If set, do not load the default theme but assume that loading it is
* handled e.g. by ApplicationPortlet.
- *
+ *
* It is set by the {@link ApplicationPortlet} (Portlet 1.0) based on
* {@link Constants.PORTAL_PARAMETER_VAADIN_THEME} and read by
* {@link AbstractApplicationServlet}.
* This request attribute is used to add styles to the main element. E.g
* "height:500px" generates a style="height:500px" to the main element,
* useful from some embedding situations (e.g portlet include.)
- *
+ *
* It is typically set by the {@link ApplicationPortlet} (Portlet 1.0) based
* on {@link ApplicationPortlet.PORTLET_PARAMETER_STYLE} and read by
* {@link AbstractApplicationServlet}.
/**
* Called by the servlet container to indicate to a servlet that the servlet
* is being placed into service.
- *
+ *
* @param servletConfig
* the object containing the servlet's configuration and
* initialization parameters
/**
* Gets an application property value.
- *
+ *
* @param parameterName
* the Name or the parameter.
* @return String value or null if not found
/**
* Gets an system property value.
- *
+ *
* @param parameterName
* the Name or the parameter.
* @return String value or null if not found
/**
* Gets an application or system property value.
- *
+ *
* @param parameterName
* the Name or the parameter.
* @param defaultValue
/**
* Returns true if the servlet is running in production mode. Production
* mode disables all debug facilities.
- *
+ *
* @return true if in production mode, false if in debug mode
*/
public boolean isProductionMode() {
/**
* Receives standard HTTP requests from the public service method and
* dispatches them.
- *
+ *
* @param request
* the object that contains the request the client made of the
* servlet.
/* Update browser information from the request */
updateBrowserProperties(webApplicationContext.getBrowser(), request);
+ /*
+ * Call application requestStart before Application.init() is called
+ * (bypasses the limitation in TransactionListener)
+ */
+ if (application instanceof HttpServletRequestListener) {
+ ((HttpServletRequestListener) application).onRequestStart(
+ request, response);
+ }
+
// Start the newly created application
startApplication(request, application, webApplicationContext);
if (application != null) {
((WebApplicationContext) application.getContext())
.endTransaction(application, request);
+
+ if (application instanceof HttpServletRequestListener) {
+ ((HttpServletRequestListener) application).onRequestEnd(
+ request, response);
+ }
}
}
* Send notification to client's application. Used to notify client of
* critical errors and session expiration due to long inactivity. Server has
* no knowledge of what application client refers to.
- *
+ *
* @param request
* the HTTP request instance.
* @param response
* 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.
- *
+ *
* @param request
* @param requestType
* @return
/**
* Check if the request should create an application if an existing
* application is not found.
- *
+ *
* @param request
* @param requestType
* @return true if an application should be created, false otherwise
* Gets resource path using different implementations. Required to
* supporting different servlet container implementations (application
* servers).
- *
+ *
* @param servletContext
* @param path
* the resource path.
* 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.
- *
+ *
* @param stream
* the download stream.
- *
+ *
* @param request
* the HTTP request instance.
* @param response
* the HTTP response to write to.
* @throws IOException
- *
+ *
* @see com.vaadin.terminal.URIHandler
*/
@SuppressWarnings("unchecked")
* 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.
- *
+ *
* @param request
* @return
* @throws ServletException
/**
* Returns the theme for given request/window
- *
+ *
* @param request
* @param window
* @return
/**
* Returns the default theme. Must never return null.
- *
+ *
* @return
*/
public static String getDefaultTheme() {
/**
* Calls URI handlers for the request. If an URI handler returns a
* DownloadStream the stream is passed to the client for downloading.
- *
+ *
* @param applicationManager
* @param window
* @param request
* Invalidate session (weird to have session if we're saying
* that it's expired, and worse: portal integration will fail
* since the session is not created by the portal.
- *
+ *
* Session must be invalidated before criticalNotification as it
* commits the response.
*/
/**
* Creates a new application for the given request.
- *
+ *
* @param request
* the HTTP request.
* @return A new Application instance.
/**
* Starts the application if it is not already running.
- *
+ *
* @param request
* @param application
* @param webApplicationContext
* 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.
- *
+ *
* @param request
* @param response
* @return
/**
* Serve resources from VAADIN directory.
- *
+ *
* @param request
* @param response
* @throws IOException
/**
* Get system messages from the current application class
- *
+ *
* @return
*/
protected SystemMessages getSystemMessages() {
* 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.
- *
+ *
* @param request
* @return The location of static resources (should contain the VAADIN
* directory). Never ends with a slash (/).
/**
* The default method to fetch static files location. This method does not
* check for request attribute {@value #REQUEST_VAADIN_STATIC_FILE_PATH}.
- *
+ *
* @param request
* @return
*/
/**
* Remove any heading or trailing "what" from the "string".
- *
+ *
* @param string
* @param what
* @return
/**
* Write a redirect response to the main page of the application.
- *
+ *
* @param request
* @param response
* @throws IOException
* {@link #writeAjaxPageHtmlMainDiv(BufferedWriter, String, String, String)}
* <li> {@link #writeAjaxPageHtmlBodyEnd(BufferedWriter)}
* </ul>
- *
+ *
* @param request
* the HTTP request.
* @param response
* 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.
- *
+ *
* @return The CSS class name to use in combination with "v-app-".
*/
protected String getApplicationCSSClassName() {
/**
* 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.
- *
+ *
* @param themeName
* @param request
* @return
* 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.
- *
+ *
* @param page
* @param appId
* @param classNames
}
/**
- *
+ *
* * Method to write the script part of the page which loads needed vaadin
* scripts and themes.
* <p>
* Override this method if you want to add some custom html around scripts.
- *
+ *
* @param window
* @param themeName
* @param application
}
/**
- *
+ *
* Method to open the body tag of the html kickstart page.
* <p>
* This method is responsible for closing the head tag and opening the body
* tag.
* <p>
* Override this method if you want to add some custom html to the page.
- *
+ *
* @param page
* @throws IOException
*/
* <p>
* Override this method if you want to add some custom html to the header of
* the page.
- *
+ *
* @param page
* @param title
* @param themeUri
* <p>
* Override this method if you want to add some custom html to the very
* beginning of the page.
- *
+ *
* @param page
* @throws IOException
*/
* Method to set http request headers for the Vaadin kickstart page.
* <p>
* Override this method if you need to customize http headers of the page.
- *
+ *
* @param response
*/
protected void setAjaxPageHeaders(HttpServletResponse response) {
/**
* Gets the current application URL from request.
- *
+ *
* @param request
* the HTTP request.
* @throws MalformedURLException
/**
* Gets the existing application for given request. Looks for application
* instance for given request based on the requested URL.
- *
+ *
* @param request
* the HTTP request.
* @param allowSessionCreation
/**
* Ends the application.
- *
+ *
* @param request
* the HTTP request.
* @param response
/**
* Gets the existing application or create a new one. Get a window within an
* application based on the requested URI.
- *
+ *
* @param request
* the HTTP Request.
* @param application
/**
* Returns the path info; note that this _can_ be different than
* request.getPathInfo() (e.g application runner).
- *
+ *
* @param request
* @return
*/
/**
* Gets relative location of a theme resource.
- *
+ *
* @param theme
* the Theme name.
* @param resource
/**
* Gets the contained throwable.
- *
+ *
* @see com.vaadin.terminal.Terminal.ErrorEvent#getThrowable()
*/
public Throwable getThrowable() {
/**
* Gets the source ParameterHandler.
- *
+ *
* @see com.vaadin.terminal.ParameterHandler.ErrorEvent#getParameterHandler()
*/
public ParameterHandler getParameterHandler() {
private final Throwable throwable;
/**
- *
+ *
* @param owner
* @param throwable
*/
/**
* Gets the contained throwable.
- *
+ *
* @see com.vaadin.terminal.Terminal.ErrorEvent#getThrowable()
*/
public Throwable getThrowable() {
/**
* Gets the source URIHandler.
- *
+ *
* @see com.vaadin.terminal.URIHandler.ErrorEvent#getURIHandler()
*/
public URIHandler getURIHandler() {