Interface ApplicationContext
RWT.getApplicationContext(). It can be used to store any data that is shared between all
UI sessions of an application, and to acquire application-scoped instances of framework services
such as the resource manager.
The application context is bound to the servlet context of the hosting web application. It is
destroyed when the web application ends (i.e. the servlet context is destroyed) or when the
application is explicitly stopped by calling ApplicationRunner.stop().
The application context is thread safe, it can be accessed concurrently from different threads.
- Since:
- 2.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds anApplicationContextListenerto this application context.voidaddUIThreadListener(UIThreadListener listener) Adds aUIThreadListenerto this application context.getAttribute(String name) Returns the value which is stored under the given name in this application context.Returns the instance of the resource manager for this application context.Returns the instance of the service manager for this application context.booleanRemoves anApplicationContextListenerfrom this application context.voidremoveAttribute(String name) Removes the object which is stored under the given name in this application context.voidremoveUIThreadListener(UIThreadListener listener) Removes aUIThreadListenerfrom this application context.voidsetAttribute(String name, Object value) Stores the given value in this application context, associated with the given name.
-
Method Details
-
setAttribute
Stores the given value in this application context, associated with the given name. If another value has already been stored with the given name, the old value is overwritten.- Parameters:
name- the name to associate the value withvalue- the object to be stored
-
getAttribute
Returns the value which is stored under the given name in this application context.- Parameters:
name- the name whose associated value is requested- Returns:
- the object that is stored, or
nullif no object has been stored by that name
-
removeAttribute
Removes the object which is stored under the given name in this application context. If no value object was stored under the given name, this method does nothing. -
addUIThreadListener
Adds aUIThreadListenerto this application context. UIThreadListeners are used to receive a notification before the UIThread is entered and after it is left. If the given listener was already added the method has no effect.- Parameters:
listener- the listener to be added- Since:
- 3.1
-
removeUIThreadListener
Removes aUIThreadListenerfrom this application context. UIThreadListeners are used to receive a notification before the UIThread is entered and after it is left. If the given listener was not added to this application context before, this method has no effect.- Parameters:
listener- the listener to be removed- Since:
- 3.1
-
addApplicationContextListener
Adds anApplicationContextListenerto this application context. ApplicationContextListeners are used to receive a notification before the application context is destroyed. If the given listener was already added the method has no effect.If the ApplicationContext is already deactivated or is about to be deactivated, the listener will not be added and this method will return
false. A return value oftrueasserts that this listener is registered and will be called on destroy.- Parameters:
listener- the listener to be added- Returns:
trueif the listener is registered,falseif not- Since:
- 2.2
-
removeApplicationContextListener
Removes anApplicationContextListenerfrom this application context. ApplicationContextListeners are used to receive a notification before the application context is destroyed. If the given listener was not added to this application context before, this method has no effect.If the ApplicationContext is already deactivated or is about to be deactivated, the listener will not be removed and this method will return
false. A return value oftrueasserts that this listener is not registered and will not be called anymore.- Parameters:
listener- the listener to be removed- Returns:
trueif the listener was removed,falseif not- Since:
- 2.2
-
getResourceManager
ResourceManager getResourceManager()Returns the instance of the resource manager for this application context. The resource manager is used to register static resources such as images of JavaScript files.- Returns:
- the resource manager for this application context
- See Also:
-
getServiceManager
ServiceManager getServiceManager()Returns the instance of the service manager for this application context. The service manager is used to register and unregister service handlers.- Returns:
- the service manager instance for this application context
- See Also:
-