Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 324077

Summary: Provide support for singleton creation/management regarding to RCP and RAP
Product: [RT] Riena Reporter: Stefan Liebig <Stefan.Liebig>
Component: CoreAssignee: Project Inbox <riena.core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: achilles.sabine, christian.campo, ekke, florian.pirchner
Version: 2.1.0   
Target Milestone: 3.0.0.M7   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
SingletonProvider none

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