use of com.google.inject.Singleton in project ovirt-engine by oVirt.
the class BaseSystemModule method getGenericApiGWTService.
@Provides
@Singleton
public GenericApiGWTServiceAsync getGenericApiGWTService(final XsrfRpcRequestBuilder requestBuilder) {
// no need to use GenericApiGWTServiceAsync.Util as this is GIN-managed singleton anyway
GenericApiGWTServiceAsync service = GWT.create(GenericApiGWTService.class);
// cast to ServiceDefTarget and set RPC request builder as needed
((ServiceDefTarget) service).setRpcRequestBuilder(requestBuilder);
return service;
}
use of com.google.inject.Singleton in project n4js by eclipse.
the class GHOLD_180_CheckInjectedSharedSingletons_PluginUITest method testInjectorsSharingSameSingleton.
/**
* Checks whether the same instance is provided by different injector instances when the class of the provided
* instance is annotated with {@code @Singleton}.
*/
@Test
public void testInjectorsSharingSameSingleton() throws Exception {
final Class<N4JSTypeSystem> testedType = N4JSTypeSystem.class;
final Singleton[] singletons = testedType.getAnnotationsByType(Singleton.class);
assertTrue(testedType.getSimpleName() + " is not annotated with " + Singleton.class.getName() + ".", !Arrays2.isEmpty(singletons));
final String injectorId = N4JSActivator.ORG_ECLIPSE_N4JS_N4JS;
final Injector parentInjector = N4JSActivator.getInstance().getInjector(injectorId);
final MockUIPlugin mockBundle = new MockUIPlugin();
try {
mockBundle.start(/* context */
null);
assertTrue("Mock bundle is not running yet.", Bundle.ACTIVE == mockBundle.getBundle().getState());
final Injector childInjector = mockBundle.getN4JSChildInjector();
final N4JSTypeSystem instanceFromParent = parentInjector.getInstance(testedType);
final N4JSTypeSystem instanceFromChild = childInjector.getInstance(testedType);
assertTrue("Expected the same instance of " + testedType.getSimpleName() + " from parent and child injectors.", instanceFromChild == instanceFromParent);
} finally {
mockBundle.stop(/* context */
null);
}
}
use of com.google.inject.Singleton in project airpal by airbnb.
the class AirpalModule method provideSchemaCache.
@Singleton
@Provides
public SchemaCache provideSchemaCache(QueryRunnerFactory queryRunnerFactory, @Named("presto") ExecutorService executorService) {
final SchemaCache cache = new SchemaCache(queryRunnerFactory, executorService);
cache.populateCache(config.getPrestoCatalog());
return cache;
}
use of com.google.inject.Singleton in project airpal by airbnb.
the class AirpalModule method provideDBI.
@Singleton
@Provides
public DBI provideDBI(ObjectMapper objectMapper) throws ClassNotFoundException {
final DBIFactory factory = new DBIFactory();
final DBI dbi = factory.build(environment, config.getDataSourceFactory(), provideDbType().name());
dbi.registerMapper(new TableRow.TableRowMapper(objectMapper));
dbi.registerMapper(new QueryStoreMapper(objectMapper));
dbi.registerArgumentFactory(new UUIDArgumentFactory());
dbi.registerArgumentFactory(new URIArgumentFactory());
return dbi;
}
use of com.google.inject.Singleton in project joynr by bmwcarit.
the class AccessControlClientModule method provideCacheManager.
@Provides
@Singleton
public CacheManager provideCacheManager() {
Configuration configuration = new Configuration();
configuration.setName("LDACEhCacheManager");
configuration.setUpdateCheck(false);
return CacheManager.create(configuration);
}
Aggregations