All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.inject.SingletonScope Maven / Gradle / Ivy

The newest version!
package com.google.inject;


public class SingletonScope implements Scope {
	public  Provider scope(final Key key, final Provider creator) {
		return new Provider() {
			private volatile Object instance;

			public Object get() {
				if (instance == null) {
					synchronized (Injector.class) {
						if (instance == null) {
							instance = creator.get();
							GuiceComponentReloader.registerSingleton(key.getRawType(), instance);
						}
					}
				}
				return instance;
			}

			public String toString() {
				return creator.toString();
			}
		};
	}

	public String toString() {
		return "Scopes.SINGLETON";
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy