SingletonDecorator

Last edit April 30, 2012
A DecoratorPattern on SingletonDecorator.

public class SingletonDecorator implements Singleton {

	private Singleton singleton;
	private static String DEFAULT = "ConcreteSingleton1";

private static String getDefault() { return DEFAULT; }

public SingletonDecorator() { this(getDefault()); }

public SingletonDecorator(final String which) { this(SingletonRegistry.getSingleton(which)); }

public SingletonDecorator(final Singleton singleton) { this.singleton = singleton; }

public Singleton getInstance() { return singleton; }

// decorator interfaced methods.
}

SingletonRegistry is just a facade for Singleton creation.