com.vaadin.terminal.gwt.server
Class AbstractWebApplicationContext

java.lang.Object
  extended by com.vaadin.terminal.gwt.server.AbstractWebApplicationContext
All Implemented Interfaces:
ApplicationContext, Serializable, EventListener, HttpSessionBindingListener
Direct Known Subclasses:
PortletApplicationContext2, WebApplicationContext

public abstract class AbstractWebApplicationContext
extends Object
implements ApplicationContext, HttpSessionBindingListener, Serializable

Base class for web application contexts (including portlet contexts) that handles the common tasks.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.service.ApplicationContext
ApplicationContext.TransactionListener
 
Field Summary
protected  HashSet<Application> applications
           
protected  HashMap<Application,AbstractCommunicationManager> applicationToAjaxAppMgrMap
           
protected  WebBrowser browser
           
protected  Collection<ApplicationContext.TransactionListener> listeners
           
 
Constructor Summary
AbstractWebApplicationContext()
           
 
Method Summary
 void addTransactionListener(ApplicationContext.TransactionListener listener)
          Adds a transaction listener to this context.
protected  void endTransaction(Application application, Object request)
          Sends a notification that a transaction has ended.
 String generateApplicationResourceURL(ApplicationResource resource, String mapKey)
          Generate a URL that can be used as the relative location of e.g.
 Collection<Application> getApplications()
          Returns a collection of all the applications in this context.
 WebBrowser getBrowser()
          Get the web browser associated with this application context.
 long getLastRequestTime()
           
 long getTotalSessionTime()
           
 String getURLKey(URL context, String relativeUri)
          Gets the identifier (key) from an application resource URL.
 boolean isApplicationResourceURL(URL context, String relativeUri)
          Tests if a URL is for an application resource (APP/...).
protected  void removeApplication(Application application)
           
 void removeTransactionListener(ApplicationContext.TransactionListener listener)
          Removes a transaction listener from this context.
 void setLastRequestTime(long time)
          Sets the time spent servicing the last request in the session and updates the total time spent servicing requests in this session.
protected  void startTransaction(Application application, Object request)
          Sends a notification that a transaction is starting.
 void valueBound(HttpSessionBindingEvent arg0)
           
 void valueUnbound(HttpSessionBindingEvent event)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.service.ApplicationContext
getBaseDirectory
 

Field Detail

listeners

protected Collection<ApplicationContext.TransactionListener> listeners

applications

protected final HashSet<Application> applications

browser

protected WebBrowser browser

applicationToAjaxAppMgrMap

protected HashMap<Application,AbstractCommunicationManager> applicationToAjaxAppMgrMap
Constructor Detail

AbstractWebApplicationContext

public AbstractWebApplicationContext()
Method Detail

addTransactionListener

public void addTransactionListener(ApplicationContext.TransactionListener listener)
Description copied from interface: ApplicationContext
Adds a transaction listener to this context. The transaction listener is called before and after each each request related to this session except when serving static resources. The transaction listener must not be null.

Specified by:
addTransactionListener in interface ApplicationContext
See Also:
ApplicationContext.addTransactionListener(com.vaadin.service.ApplicationContext.TransactionListener)

removeTransactionListener

public void removeTransactionListener(ApplicationContext.TransactionListener listener)
Description copied from interface: ApplicationContext
Removes a transaction listener from this context.

Specified by:
removeTransactionListener in interface ApplicationContext
Parameters:
listener - the listener to be removed.
See Also:
ApplicationContext.TransactionListener

startTransaction

protected void startTransaction(Application application,
                                Object request)
Sends a notification that a transaction is starting.

Parameters:
application - The application associated with the transaction.
request - the HTTP or portlet request that triggered the transaction.

endTransaction

protected void endTransaction(Application application,
                              Object request)
Sends a notification that a transaction has ended.

Parameters:
application - The application associated with the transaction.
request - the HTTP or portlet request that triggered the transaction.

valueBound

public void valueBound(HttpSessionBindingEvent arg0)
Specified by:
valueBound in interface HttpSessionBindingListener
See Also:
HttpSessionBindingListener.valueBound(HttpSessionBindingEvent)

valueUnbound

public void valueUnbound(HttpSessionBindingEvent event)
Specified by:
valueUnbound in interface HttpSessionBindingListener
See Also:
HttpSessionBindingListener.valueUnbound(HttpSessionBindingEvent)

getBrowser

public WebBrowser getBrowser()
Get the web browser associated with this application context. Because application context is related to the http session and server maintains one session per browser-instance, each context has exactly one web browser associated with it.

Returns:

getApplications

public Collection<Application> getApplications()
Description copied from interface: ApplicationContext
Returns a collection of all the applications in this context. Each application context contains all active applications for one user.

Specified by:
getApplications in interface ApplicationContext
Returns:
A collection containing all the applications in this context.

removeApplication

protected void removeApplication(Application application)

generateApplicationResourceURL

public String generateApplicationResourceURL(ApplicationResource resource,
                                             String mapKey)
Description copied from interface: ApplicationContext
Generate a URL that can be used as the relative location of e.g. an ApplicationResource. This method should only be called from the processing of a UIDL request, not from a background thread. The return value is null if used outside a suitable request.

Specified by:
generateApplicationResourceURL in interface ApplicationContext
mapKey - a key for the resource that can later be extracted from a URL with ApplicationContext.getURLKey(URL, String)

isApplicationResourceURL

public boolean isApplicationResourceURL(URL context,
                                        String relativeUri)
Description copied from interface: ApplicationContext
Tests if a URL is for an application resource (APP/...).

Specified by:
isApplicationResourceURL in interface ApplicationContext
Returns:

getURLKey

public String getURLKey(URL context,
                        String relativeUri)
Description copied from interface: ApplicationContext
Gets the identifier (key) from an application resource URL. This key is the one that was given to ApplicationContext.generateApplicationResourceURL(ApplicationResource, String) when creating the URL.

Specified by:
getURLKey in interface ApplicationContext
Returns:

getTotalSessionTime

public long getTotalSessionTime()
Returns:
The total time spent servicing requests in this session.

setLastRequestTime

public void setLastRequestTime(long time)
Sets the time spent servicing the last request in the session and updates the total time spent servicing requests in this session.

Parameters:
time - the time spent in the last request.

getLastRequestTime

public long getLastRequestTime()
Returns:
the time spent servicing the last request in this session.


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.