Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324077 - Provide support for singleton creation/management regarding to RCP and RAP
Summary: Provide support for singleton creation/management regarding to RCP and RAP
Status: RESOLVED FIXED
Alias: None
Product: Riena
Classification: RT
Component: Core (show other bugs)
Version: 2.1.0   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: 3.0.0.M7   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-31 07:49 EDT by Stefan Liebig CLA
Modified: 2011-05-03 10:26 EDT (History)
4 users (show)

See Also:


Attachments
SingletonProvider (5.20 KB, text/x-java)
2010-08-31 07:49 EDT, Stefan Liebig CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Liebig CLA 2010-08-31 07:49:04 EDT
Created attachment 177824 [details]
SingletonProvider

We have decided to enable Riena for running under RAP. See: http://wiki.eclipse.org/Riena_on_RAP

One challenge when using RAP is that singletons need to be session dependent. When running under RCP they can stay global.
To ease handling of singletons we have created a generic SingletonProvider located in riena.core that detects whether it is running in RAP or RCP.
When running in RAP it uses the SessionSingeltonBase.getInstance() for correct handling of session dependent singletons. Otherwise singletons will be created globally.
In both cases the SingletonProvider ensures that the singletons get wired (Rienas dependency injection).

It's usage is (just an example):

public class SwtViewProvider {

	private final Map<INavigationNode<?>, SwtViewId> views;
	private final Map<String, Integer> viewCounter;
	private final HashMap<String, Boolean> viewShared;

	private static final SingletonProvider<SwtViewProvider> SVP = new SingletonProvider<SwtViewProvider>(
			SwtViewProvider.class);

	/**
	 * Gets the singleton SwtViewProvider.
	 * 
	 * @return
	 * @since 1.2
	 */
	public static SwtViewProvider getInstance() {
		return SVP.getInstance();
	}

	/**
	 * Create new instance and initialize
	 */
	protected SwtViewProvider() {

...
Comment 1 Stefan Liebig CLA 2010-09-03 02:50:04 EDT
The SingletonProvider has been refactored into a:
- SingletonProvider - creating "true" singletons
- SessionSingletonProvider - it is a sub class of the SingletonProvider and behaves as the old SingletonProvider

Detecting the existence of RAP has also been extracted into the utility class RAPDetector.
Comment 2 Stefan Liebig CLA 2011-04-01 02:23:47 EDT
Fixed