com.vaadin.terminal.gwt.server.
Class AbstractWebApplicationContext
java.lang.Object
com.vaadin.terminal.gwt.server.AbstractWebApplicationContext
All Implemented Interfaces:
ApplicationContext, Serializable, EventListener, HttpSessionBindingListener
Direct Known Subclasses:
- extends Object
- implements ApplicationContext, HttpSessionBindingListener, Serializable
public abstract class AbstractWebApplicationContext
Base class for web application contexts (including portlet contexts) that handles the common tasks.
See Also:
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)
- Specified by:
addTransactionListener
in interfaceApplicationContext
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.
removeTransactionListener
public void removeTransactionListener(ApplicationContext.TransactionListener listener)
- Specified by:
removeTransactionListener
in interfaceApplicationContext
- Parameters:
listener
- the listener to be removed.- See Also:
ApplicationContext.TransactionListener
Description copied from interface: ApplicationContext
Removes a transaction listener from this context.
startTransaction
protected void startTransaction(Application application,
Object request)
- Parameters:
application
- The application associated with the transaction.request
- the HTTP or portlet request that triggered the transaction.
Sends a notification that a transaction is starting.
endTransaction
protected void endTransaction(Application application,
Object request)
- Parameters:
application
- The application associated with the transaction.request
- the HTTP or portlet request that triggered the transaction.
Sends a notification that a transaction has ended.
valueBound
public void valueBound(HttpSessionBindingEvent arg0)
- Specified by:
valueBound
in interfaceHttpSessionBindingListener
valueUnbound
public void valueUnbound(HttpSessionBindingEvent event)
- Specified by:
valueUnbound
in interfaceHttpSessionBindingListener
getBrowser
public WebBrowser getBrowser()
- Returns:
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.
getApplications
public Collection<Application> getApplications()
- Specified by:
getApplications
in interfaceApplicationContext
- Returns:
- A collection containing all the applications in this context.
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.
removeApplication
protected void removeApplication(Application application)
generateApplicationResourceURL
public String generateApplicationResourceURL(ApplicationResource resource,
String mapKey)
- Specified by:
generateApplicationResourceURL
in interfaceApplicationContext
mapKey
- a key for the resource that can later be extracted from a URL withApplicationContext.getURLKey(URL, String)
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.
isApplicationResourceURL
public boolean isApplicationResourceURL(URL context,
String relativeUri)
- Specified by:
isApplicationResourceURL
in interfaceApplicationContext
- Returns:
Description copied from interface: ApplicationContext
Tests if a URL is for an application resource (APP/...).
getURLKey
public String getURLKey(URL context,
String relativeUri)
- Specified by:
getURLKey
in interfaceApplicationContext
- Returns:
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.
getTotalSessionTime
public long getTotalSessionTime()
- Returns:
- The total time spent servicing requests in this session.
setLastRequestTime
public void setLastRequestTime(long time)
- Parameters:
time
- the time spent in the last request.
Sets the time spent servicing the last request in the session and updates the total time spent servicing requests in this session.
getLastRequestTime
public long getLastRequestTime()
- Returns:
- the time spent servicing the last request in this session.