Package org.eclipse.rap.rwt
Class SingletonUtil
java.lang.Object
org.eclipse.rap.rwt.SingletonUtil
Creates and maintains a unique instance of a given type for the given scope. The scope is either
 a UI session or an application context. Within the context of this scope,
 
getUniqueInstance(...) will always return the same object, but for different scopes
 the returned instances will be different.
 This utility class can be used to adjust classic singletons to the appropriate scope in RAP. Example:
 public class FooSingleton {
   private FooSingleton() {
   }
   public static FooSingleton getInstance() {
     return SingletonUtil.getUniqueInstance( FooSingleton.class, RWT.getUISession() );
   }
 }
 - Since:
- 2.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic <T> TgetSessionInstance(Class<T> type) Returns an instance of the specified type that is unique within the current UI session.static <T> TgetUniqueInstance(Class<T> type, ApplicationContext applicationContext) Returns an instance of the specified type that is unique within the given UI session.static <T> TgetUniqueInstance(Class<T> type, UISession uiSession) Returns an instance of the specified type that is unique within the given UI session.
- 
Constructor Details- 
SingletonUtilpublic SingletonUtil()
 
- 
- 
Method Details- 
getSessionInstanceReturns an instance of the specified type that is unique within the current UI session. If no such instance exists yet, a new one will be created. The specified type must have a parameterless constructor.This method is a shortcut for getUniqueInstance( type, RWT.getUISession() ).- Parameters:
- type- the type to obtain a singleton instance for
- Returns:
- the unique instance of the specified type that is associated with the current UI session
 
- 
getUniqueInstanceReturns an instance of the specified type that is unique within the given UI session. If no such instance exists yet, a new one will be created. The specified type must have a parameterless constructor.- Parameters:
- type- the type to obtain a singleton instance for
- uiSession- the UI session to store the singleton instance in
- Returns:
- the unique instance of the specified type that is associated with the given UI session
- Since:
- 2.3
 
- 
getUniqueInstanceReturns an instance of the specified type that is unique within the given UI session. If no such instance exists yet, a new one will be created. The specified type must have a parameterless constructor.- Parameters:
- type- the type to obtain a singleton instance for
- applicationContext- the application context to store the singleton instance in
- Returns:
- the unique instance of the specified type that is associated with the given application context
- Since:
- 2.3
 
 
-