|
Eclipse Remote Application Platform | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.rap.rwt.SingletonUtil
public final class 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() ); } }
Constructor Summary | |
---|---|
SingletonUtil()
|
Method Summary | ||
---|---|---|
static
|
getSessionInstance(java.lang.Class<T> type)
Returns an instance of the specified type that is unique within the current UI session. |
|
static
|
getUniqueInstance(java.lang.Class<T> type,
ApplicationContext applicationContext)
Returns an instance of the specified type that is unique within the given UI session. |
|
static
|
getUniqueInstance(java.lang.Class<T> type,
UISession uiSession)
Returns an instance of the specified type that is unique within the given UI session. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SingletonUtil()
Method Detail |
---|
public static <T> T getSessionInstance(java.lang.Class<T> type)
This method is a shortcut for
getUniqueInstance( type, RWT.getUISession() )
.
type
- the type to obtain a singleton instance for
public static <T> T getUniqueInstance(java.lang.Class<T> type, UISession uiSession)
type
- the type to obtain a singleton instance foruiSession
- the UI session to store the singleton instance in
public static <T> T getUniqueInstance(java.lang.Class<T> type, ApplicationContext applicationContext)
type
- the type to obtain a singleton instance forapplicationContext
- the application context to store the singleton instance in
|
Eclipse Remote Application Platform | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright (c) EclipseSource and others 2002, 2013. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0