Java Examples for com.google.inject.Singleton

The following java examples will help you to understand the usage of com.google.inject.Singleton. These source code samples are taken from different open source projects.

Example 1
Project: groningen-master  File: GroningenServletModule.java View source code
@Override
protected void configureServlets() {
    bind(Pipelines.class).in(Singleton.class);
    bind(GroningenResourceServlet.class).in(Singleton.class);
    serve("/groningen/*").with(GuiceContainer.class, ImmutableMap.of(PackagesResourceConfig.PROPERTY_PACKAGES, Pipelines.class.getPackage().getName()));
    serve("/*").with(GroningenResourceServlet.class);
}
Example 2
Project: activityinfo-master  File: EmbedModule.java View source code
@Override
protected void configure() {
    bind(RemoteCommandServiceAsync.class).toProvider(RemoteServiceProvider.class).in(Singleton.class);
    bind(Dispatcher.class).to(RemoteDispatcher.class).in(Singleton.class);
    bind(EventBus.class).to(LoggingEventBus.class).in(Singleton.class);
    bind(StateProvider.class).to(GxtStateProvider.class);
}
Example 3
Project: degraphmalizer-master  File: CommonNeo4j.java View source code
@Provides
@Singleton
final TransactionalGraph provideGraph(@Neo4jDataDir String dataDir) throws IOException {
    // manually set the cache provider
    final Map<String, String> settings = new HashMap<String, String>();
    settings.put("cache_type", "soft");
    final Neo4jGraph graph = new Neo4jGraph(dataDir, settings);
    // quickly get vertices by ID
    final String[] props = new String[] { GraphUtilities.OWNER, GraphUtilities.SYMBOLIC_OWNER, GraphUtilities.IDENTIFIER, GraphUtilities.SYMBOLIC_IDENTIFER, GraphUtilities.KEY_INDEX, GraphUtilities.KEY_TYPE, GraphUtilities.KEY_ID, GraphUtilities.KEY_VERSION };
    for (String prop : props) {
        graph.createKeyIndex(prop, Vertex.class);
        graph.createKeyIndex(prop, Edge.class);
    }
    graph.stopTransaction(TransactionalGraph.Conclusion.SUCCESS);
    return graph;
}
Example 4
Project: guit-master  File: RequestFactoryModule.java View source code
@Provides
@Singleton
public ValidatorFactory getValidatorFactory(final Injector injector) {
    return Validation.byDefaultProvider().configure().constraintValidatorFactory(new ConstraintValidatorFactory() {

        @Override
        public <T extends ConstraintValidator<?, ?>> T getInstance(Class<T> key) {
            return injector.getInstance(key);
        }
    }).buildValidatorFactory();
}
Example 5
Project: ninja-appengine-master  File: ServletModule.java View source code
@Override
protected void configureServlets() {
    bind(NinjaServletDispatcher.class).asEagerSingleton();
    // Clean objectify instances with that filter:
    bind(ObjectifyFilter.class).in(Singleton.class);
    filter("/*").through(ObjectifyFilter.class);
    if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
        serve("/*").with(NinjaServletDispatcher.class);
    } else {
        // do not serve admin stuff like _ah and so on...
        // allows to call /_ah/admin and so on
        serveRegex("/(?!_ah).*").with(NinjaServletDispatcher.class);
    }
}
Example 6
Project: ovirt-engine-master  File: SystemModule.java View source code
void bindConfiguration() {
    bindConstant().annotatedWith(DefaultMainSectionPlace.class).to(UserPortalApplicationPlaces.DEFAULT_MAIN_SECTION_BASIC_PLACE);
    bindConstant().annotatedWith(DefaultMainSectionExtendedPlace.class).to(UserPortalApplicationPlaces.DEFAULT_MAIN_SECTION_EXTENDED_PLACE);
    bindConstant().annotatedWith(ClientStorageKeyPrefix.class).to(CLIENT_STORAGE_KEY_PREFIX);
    bindResourceConfiguration(ApplicationConstants.class, ApplicationMessages.class, ApplicationResources.class, ApplicationTemplates.class, ApplicationDynamicMessages.class);
    bind(ApplicationResourcesWithLookup.class).in(Singleton.class);
}
Example 7
Project: PortlandStateJava-master  File: BookStoreModule.java View source code
@Override
protected void configure() {
    bind(BookInventory.class).to(BookDatabase.class);
    bind(CreditCardService.class).to(FirstBankOfPSU.class).in(Singleton.class);
    bind(String.class).annotatedWith(Names.named("ServerHost")).toInstance("localhost");
    bind(Integer.class).annotatedWith(Names.named("ServerPort")).toInstance(8080);
//        String tmpdir = System.getProperty("java.io.tmpdir");
//        File directory = new File(tmpdir);
//        bind(File.class).annotatedWith(DataDirectory.class).toInstance(directory);
}
Example 8
Project: ballroom-master  File: ShowcaseModule.java View source code
protected void configure() {
    bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
    bind(PlaceManager.class).to(DefaultPlaceManager.class).in(Singleton.class);
    bind(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class);
    bind(RootPresenter.class).asEagerSingleton();
    // main layout
    bindPresenter(MainLayoutPresenter.class, MainLayoutPresenter.MainLayoutView.class, MainLayoutViewImpl.class, MainLayoutPresenter.MainLayoutProxy.class);
    bindPresenter(WidgetPresenter.class, WidgetPresenter.MyView.class, WidgetView.class, WidgetPresenter.MyProxy.class);
}
Example 9
Project: CausticSDK-master  File: CausticRuntimeModule.java View source code
@Override
protected void configure() {
    bind(ICaustkApplicationProvider.class).to(ApplicationProvider.class).in(Singleton.class);
    bind(IApplicationModel.class).to(ApplicationModel.class).in(Singleton.class);
    bind(IApplicationController.class).to(ApplicationController.class).in(Singleton.class);
    bind(IControllerProvider.class).to(ControllerProvider.class).in(Singleton.class);
    bind(IInjectorService.class).to(InjectorService.class).in(Singleton.class);
    bind(IScreenManager.class).to(ScreenManager.class).in(Singleton.class);
    configurePlatformRequirements();
    configureApplicationRequirements();
}
Example 10
Project: che-master  File: SshKeyGinModule.java View source code
@Override
protected void configure() {
    bind(SshKeyManagerView.class).to(SshKeyManagerViewImpl.class).in(Singleton.class);
    bind(UploadSshKeyView.class).to(UploadSshKeyViewImpl.class).in(Singleton.class);
    bind(ShowSshKeyView.class).to(ShowSshKeyViewImpl.class).in(Singleton.class);
    GinMultibinder<PreferencePagePresenter> prefBinder = GinMultibinder.newSetBinder(binder(), PreferencePagePresenter.class);
    prefBinder.addBinding().to(SshKeyManagerPresenter.class);
}
Example 11
Project: DevTools-master  File: SshKeyGinModule.java View source code
@Override
protected void configure() {
    bind(SshKeyManagerView.class).to(SshKeyManagerViewImpl.class).in(Singleton.class);
    bind(UploadSshKeyView.class).to(UploadSshKeyViewImpl.class).in(Singleton.class);
    bind(ShowSshKeyView.class).to(ShowSshKeyViewImpl.class).in(Singleton.class);
    GinMultibinder<PreferencePagePresenter> prefBinder = GinMultibinder.newSetBinder(binder(), PreferencePagePresenter.class);
    prefBinder.addBinding().to(SshKeyManagerPresenter.class);
}
Example 12
Project: guiceberry-master  File: PetStoreEnv4CanonicalSameJvmControllablePotm.java View source code
@Provides
@Singleton
MyPetStoreServer buildPetStoreServer() {
    MyPetStoreServer result = new MyPetStoreServer(8080) {

        @Override
        protected Module getPetStoreModule() {
            // !!! HERE !!!
            return icMaster.buildServerModule(new TestIdServerModule(), super.getPetStoreModule());
        }
    };
    return result;
}
Example 13
Project: kairos-carbon-master  File: CarbonServerModule.java View source code
@Override
protected void configure() {
    logger.info("Configuring module CarbonServerModule");
    String parserClassProp = m_properties.getProperty(TAG_PARSER_PROPERTY);
    if (parserClassProp != null) {
        try {
            Class<TagParser> parserClass = (Class<TagParser>) getClass().getClassLoader().loadClass(parserClassProp);
            bind(TagParser.class).to(parserClass).in(Singleton.class);
        } catch (ClassNotFoundException e) {
            addError(e);
        }
    } else {
        addError("No classs defined for " + TAG_PARSER_PROPERTY);
    }
    bind(CarbonTextServer.class).in(Singleton.class);
    bind(CarbonPickleServer.class).in(Singleton.class);
}
Example 14
Project: kairosdb-master  File: TelnetServerModule.java View source code
@Override
protected void configure() {
    logger.info("Configuring module TelnetServerModule");
    bind(TelnetServer.class).in(Singleton.class);
    bind(PutCommand.class).in(Singleton.class);
    bind(PutMillisecondCommand.class).in(Singleton.class);
    bind(VersionCommand.class).in(Singleton.class);
    bind(CommandProvider.class).to(GuiceCommandProvider.class);
}
Example 15
Project: klik-master  File: GuiceServerModule.java View source code
@Override
protected void configureHandlers() {
    bindHandler(RetrieveGreetingAction.class, RetrieveGreetingHandler.class);
    bindHandler(RetrieveSetupAction.class, RetrieveSetupHandler.class);
    bindHandler(SaveSetupAction.class, SaveSetupHandler.class);
    bindHandler(UnitEventAction.class, UnitEventHandler.class);
    bindHandler(RetrieveUnitStatusesAction.class, RetrieveUnitStatusesHandler.class);
    bindHandler(SendServerCommandAction.class, SendServerCommandHandler.class);
    bind(Log.class).toProvider(LogProvider.class).in(Singleton.class);
    requestStaticInjection(X10UnitEventHandler.class);
}
Example 16
Project: komma-master  File: CompositionTestCase.java View source code
protected Module createModule() {
    return new CompositionModule<String>() {

        @Override
        protected void configure() {
            super.configure();
            bind(new Key<ObjectFactory<String>>() {
            }).to(new TypeLiteral<DefaultObjectFactory<String>>() {
            });
            bind(new TypeLiteral<ClassResolver<String>>() {
            });
        }

        @Override
        protected void initRoleMapper(RoleMapper<String> roleMapper, TypeFactory<String> typeFactory) {
            CompositionTestCase.this.roleMapper = roleMapper;
            super.initRoleMapper(roleMapper, typeFactory);
            CompositionTestCase.this.initRoleMapper(roleMapper);
        }

        @Provides
        @Singleton
        protected TypeFactory<String> provideTypeFactory() {
            return new TypeFactory<String>() {

                @Override
                public String createType(String type) {
                    return type;
                }

                @Override
                public String toString(String type) {
                    return type;
                }
            };
        }
    };
}
Example 17
Project: mylyn-mantis-master  File: StandaloneMantisCorePluginModule.java View source code
@Override
protected void configure() {
    bind(StatusFactory.class);
    bind(MantisAttachmentHandler.class);
    bind(MantisTaskDataHandler.class);
    bind(IMantisClientManager.class).to(MantisClientManager.class);
    bind(MantisCommentMapper.class);
    bind(IPath.class).annotatedWith(RepositoryPersistencePath.class).toProvider(StandaloneRepositoryPersistencePathProvider.class);
    bind(MantisRepositoryConnector.class).toInstance(mantisRepositoryConnector);
    // we cannot support a core plugin related tracer here
    // so we have to skip tracing with a no-op implementation
    bind(Tracer.class).to(NoOpTracer.class).in(Singleton.class);
}
Example 18
Project: opensoc-streaming-master  File: DefaultServletModule.java View source code
@Override
protected void configureServlets() {
    ShiroWebModule.bindGuiceFilter(binder());
    bind(KafkaWebSocketCreator.class).in(Singleton.class);
    bind(HttpServletDispatcher.class).in(Singleton.class);
    serve("/rest/*").with(HttpServletDispatcher.class);
    bind(KafkaMessageSenderServlet.class).in(Singleton.class);
    serve("/ws/*").with(KafkaMessageSenderServlet.class);
    bind(LoginServlet.class).in(Singleton.class);
    serve("/login").with(LoginServlet.class);
    bind(LogoutServlet.class).in(Singleton.class);
    serve("/logout").with(LogoutServlet.class);
}
Example 19
Project: parroteer-master  File: Context.java View source code
private void bindBeansToScope() {
    bind(Main.class).in(Singleton.class);
    bind(DroneInputController.class).in(Singleton.class);
    bind(FxWindow.class).in(Singleton.class);
    bind(SocketController.class).in(Singleton.class);
    bind(SocketDataReceiver.class).in(Singleton.class);
    bind(SocketDataSender.class).in(Singleton.class);
    bind(SocketClient.class).in(Singleton.class);
    bind(RaceTimer.class).in(Singleton.class);
}
Example 20
Project: QMAClone-master  File: DatabaseModule.java View source code
@Provides
@Singleton
private DataSource provideDataSource() {
    BasicDataSource dataSource = new BasicDataSource();
    dataSource.setDriverClassName(DRIVER_CLASS_NAME);
    dataSource.setUsername(USERNAME);
    dataSource.setPassword(PASSWORD);
    dataSource.setUrl(URL);
    dataSource.setValidationQuery(VALIDATION_QUERY);
    return dataSource;
}
Example 21
Project: Rhegium-master  File: SecurityModule.java View source code
@Override
protected void configure() {
    bind(SecurityService.class).to(DefaultSecurityService.class).in(Singleton.class);
    bind(PermissionFactory.class).to(DefaultPermissionFactory.class).in(Singleton.class);
    bind(PrincipalFactory.class).to(DefaultPrincipalFactory.class).in(Singleton.class);
    bind(SecurityGroupFactory.class).to(DefaultSecurityGroupFactory.class).in(Singleton.class);
}
Example 22
Project: simplejavayoutubeuploader-master  File: PersistenceModule.java View source code
@Override
protected void configure() {
    install(new DaoModule());
    bind(IAccountService.class).to(AccountServiceImpl.class).in(Singleton.class);
    bind(IUploadService.class).to(UploadServiceImpl.class).in(Singleton.class);
    bind(IPlaylistService.class).to(PlaylistServiceImpl.class).in(Singleton.class);
    bind(ITemplateService.class).to(TemplateServiceImpl.class).in(Singleton.class);
}
Example 23
Project: smart-cms-master  File: TransactionImplModule.java View source code
@Override
protected void configure() {
    bind(TransactionInMemoryCache.class).to(TransactionInMemoryCacheImpl.class).in(Singleton.class);
    bind(TransactionService.class).to(TransactionServiceImpl.class).in(Singleton.class);
    bind(TransactionManager.class).to(TransactionManagerImpl.class).in(Singleton.class);
    install(new FactoryModuleBuilder().implement(TransactionStoreKey.class, TransactionStoreKeyImpl.class).implement(TransactionStoreValue.class, TransactionStoreValueImpl.class).implement(Transaction.class, TransactionImpl.class).build(TransactionFactory.class));
    TransactionalInterceptor interceptor = new TransactionalInterceptor();
    super.requestInjection(interceptor);
    bindInterceptor(Matchers.any(), Matchers.annotatedWith(Transactional.class), interceptor);
}
Example 24
Project: smart-user-master  File: UserCacheModule.java View source code
@Override
protected void configure() {
    bind(new TypeLiteral<CacheServiceProvider<Long, User>>() {
    }).to(new TypeLiteral<EhcacheCacheServiceProviderImpl<Long, User>>() {
    });
    bind(new TypeLiteral<BasicKey<Long>>() {
    }).toInstance(ImplServiceModule.<Long>getKeyInstance("User", prefixSeparator));
    bind(UserService.class).to(UserServiceCacheImpl.class).in(Singleton.class);
    binder().expose(UserService.class);
}
Example 25
Project: spark-jwt-auth-master  File: AppModule.java View source code
@Override
protected void configure() {
    bind(ITimeProvider.class).to(TimeProviderImpl.class).in(Singleton.class);
    bind(IKeyGenerator.class).to(IKeyGeneratorImpl.class).in(Singleton.class);
    bind(IJwtTokenService.class).to(JwtTokenServiceImpl.class).in(Singleton.class);
    bind(ITokenValidator.class).to(TokenValidator.class).in(Singleton.class);
    bind(IRedis.class).to(RedisImpl.class);
    bind(ISignupRepository.class).to(SignupRepositoryImpl.class).asEagerSingleton();
    bind(IUserRepository.class).to(UserRepositoryImpl.class).asEagerSingleton();
}
Example 26
Project: swellrt-master  File: NoOpFederationModule.java View source code
@Override
protected void configure() {
    bind(WaveletFederationProvider.class).annotatedWith(FederationRemoteBridge.class).to(NoOpFederationRemote.class).in(Singleton.class);
    bind(WaveletFederationListener.Factory.class).annotatedWith(FederationHostBridge.class).to(NoOpFederationHost.class).in(Singleton.class);
    bind(FederationTransport.class).to(NoOpFederationTransport.class).in(Singleton.class);
}
Example 27
Project: UsosApi4j-master  File: OAuthModule.java View source code
@Provides
@Singleton
public HttpRequestFactory provideHttpRequestFactory() {
    return new NetHttpTransport().createRequestFactory(new HttpRequestInitializer() {

        @Override
        public void initialize(HttpRequest request) throws IOException {
            request.setInterceptor(oAuthParameters);
            request.setParser(new JsonObjectParser(new JacksonFactory()));
        }
    });
}
Example 28
Project: AIR-master  File: DropwizardModule.java View source code
@Singleton
@Provides
protected ObjectMapper provideObjectMapper() {
    ObjectMapper mapper = environment.getObjectMapper();
    mapper.registerSubtypes(new NamedType(CSVPersistentOutput.class, "csv"), new NamedType(HiveTablePersistentOutput.class, "hive"));
    Rosetta.getMapper().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    Rosetta.getMapper().enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
    return mapper;
}
Example 29
Project: airpal-master  File: DropwizardModule.java View source code
@Singleton
@Provides
protected ObjectMapper provideObjectMapper() {
    ObjectMapper mapper = environment.getObjectMapper();
    mapper.registerSubtypes(new NamedType(CSVPersistentOutput.class, "csv"), new NamedType(HiveTablePersistentOutput.class, "hive"));
    Rosetta.getMapper().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
    Rosetta.getMapper().enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
    return mapper;
}
Example 30
Project: autobind-master  File: ImplementationBindingFeature.java View source code
@Override
public void process(final Class<Object> annotatedClass, final Map<String, Annotation> annotations) {
    final boolean asSingleton = (annotations.containsKey(com.google.inject.Singleton.class.getName()) || annotations.containsKey(javax.inject.Singleton.class.getName()));
    if (_logger.isLoggable(FINE)) {
        _logger.fine(format("Binding Class %s. Singleton? %s ", annotatedClass, asSingleton));
    }
    bind(annotatedClass, null, (asSingleton ? Singleton.class : null));
}
Example 31
Project: aXonix-master  File: AxonixModule.java View source code
@Override
protected void configure() {
    // Game
    bind(AxonixGame.class).in(Singleton.class);
    // Screens
    bind(StartScreen.class).in(Singleton.class);
    bind(LevelsScreen.class).in(Singleton.class);
    bind(GameScreen.class).in(Singleton.class);
    // Input Multiplexer
    bind(InputMultiplexer.class).in(Singleton.class);
    // Audio
    bind(SoundManager.class).in(Singleton.class);
    bind(MusicManager.class).in(Singleton.class);
    // Preferences
    bind(PreferencesWrapper.class).in(Singleton.class);
    // Event Bus
    bind(EventBus.class).in(Singleton.class);
}
Example 32
Project: bitcoin-exchange-master  File: TradeModule.java View source code
@Override
protected void configure() {
    bind(TradeManager.class).in(Singleton.class);
    bind(TradeStatisticsManager.class).in(Singleton.class);
    bind(ClosedTradableManager.class).in(Singleton.class);
    bind(FailedTradesManager.class).in(Singleton.class);
    bindConstant().annotatedWith(named(AppOptionKeys.DUMP_STATISTICS)).to(env.getRequiredProperty(AppOptionKeys.DUMP_STATISTICS));
}
Example 33
Project: bitsquare-master  File: TradeModule.java View source code
@Override
protected void configure() {
    bind(TradeManager.class).in(Singleton.class);
    bind(TradeStatisticsManager.class).in(Singleton.class);
    bind(ClosedTradableManager.class).in(Singleton.class);
    bind(FailedTradesManager.class).in(Singleton.class);
    bindConstant().annotatedWith(named(AppOptionKeys.DUMP_STATISTICS)).to(env.getRequiredProperty(AppOptionKeys.DUMP_STATISTICS));
}
Example 34
Project: cache4guice-master  File: JBossCacheModule.java View source code
@Override
protected void configure() {
    // load external properties
    Names.bindProperties(binder(), loadProperties());
    bind(new TypeLiteral<Cache<String, Object>>() {
    }).toProvider(CacheProvider.class).in(Singleton.class);
    bind(CacheAdapter.class).to(JBossCache.class).in(Singleton.class);
    CacheInterceptor cacheInterceptor = new CacheInterceptor();
    requestInjection(cacheInterceptor);
    bindInterceptor(Matchers.any(), Matchers.annotatedWith(Cached.class), cacheInterceptor);
}
Example 35
Project: candlepin-master  File: CacheTestFixture.java View source code
@Override
protected void configure() {
    /**
                 * Standard test uses mocked CandlepinCache. In this CacheTestFixture we gonna override it
                 * back to the standard cache implementation.
                 */
    bind(CandlepinCache.class);
    bind(CacheManager.class).toProvider(JCacheManagerProvider.class).in(Singleton.class);
}
Example 36
Project: cdap-master  File: DataFabricLocalModule.java View source code
@Override
public void configure() {
    install(Modules.override(new DataFabricLevelDBModule()).with(new AbstractModule() {

        @Override
        protected void configure() {
            bind(QueueClientFactory.class).to(LevelDBAndInMemoryQueueClientFactory.class).in(Singleton.class);
            bind(QueueAdmin.class).to(InMemoryQueueAdmin.class).in(Singleton.class);
        }
    }));
}
Example 37
Project: che-plugins-master  File: SshGinModule.java View source code
/** {@inheritDoc} */
@Override
protected void configure() {
    bind(SshKeyManagerView.class).to(SshKeyManagerViewImpl.class).in(Singleton.class);
    bind(UploadSshKeyView.class).to(UploadSshKeyViewImpl.class).in(Singleton.class);
    GinMultibinder<PreferencePagePresenter> prefBinder = GinMultibinder.newSetBinder(binder(), PreferencePagePresenter.class);
    prefBinder.addBinding().to(SshKeyManagerPresenter.class);
}
Example 38
Project: CSC-HCI-480-2013-repo-master  File: AppGinModule.java View source code
@Override
protected void configure() {
    bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
    bind(DoublePanelView.class).to(DoublePanelViewImpl.class).in(Singleton.class);
    //bind(RfParametersView.class).to(RfParametersViewImpl.class).in(Singleton.class);
    bind(PlaceController.class).toProvider(PlaceControllerProvider.class).in(Singleton.class);
    bind(H2OServiceAsync.class).toProvider(H2OServiceProvider.class).in(Singleton.class);
}
Example 39
Project: divide-master  File: MockBackendModule.java View source code
@Override
public void additionalConfig(Config<Backend> config) {
    // ORDER MATTER
    try {
        bind(KeyManager.class).toInstance(new MockKeyManager("someKey"));
    } catch (NoSuchAlgorithmException e) {
        throw new RuntimeException(e);
    }
    bind(new TypeLiteral<DAO<TransientObject, TransientObject>>() {
    }).to(new TypeLiteral<MockLocalStorage<TransientObject, TransientObject>>() {
    }).in(Singleton.class);
}
Example 40
Project: exo-training-master  File: ExplorerModule.java View source code
@Override
protected void configure() {
    bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
    bind(ActivityMapper.class).to(ExplorerActivityMapper.class);
    // bind up some data
    bind(ExampleModel.class).in(Singleton.class);
    // View implementation binding - if we build a mobile explorer, this would
    // be broken out into another module so it could be rebound
    bind(ExampleListView.class).to(ExampleListViewImpl.class).in(Singleton.class);
    bind(ExampleDetailView.class).to(ExampleDetailViewImpl.class).in(Singleton.class);
}
Example 41
Project: freedomotic-master  File: InjectorFeatures.java View source code
@Override
protected void configure() {
    bind(Autodiscovery.class).in(Singleton.class);
    bind(SynchManager.class).in(Singleton.class);
    bind(TopologyManager.class).in(Singleton.class);
    bind(JoinPlugin.class).in(Singleton.class);
    bind(TriggerCheck.class).in(Singleton.class);
    bind(BehaviorManager.class).in(Singleton.class);
    //TODO: bind(ResourcesManager.class).in(Singleton.class);
    // The ProcolRead event now needs the TriggerCheck class
    // It should be refactored in the future to avoid this dependency
    bind(ProtocolRead.class);
}
Example 42
Project: gengweibo-master  File: GuiceInit.java View source code
public void configure(Binder binder) {
    binder.bind(AccountAcction.class).in(Singleton.class);
    binder.bind(WeiboDao.class).to(WeiboDaoJdbcImpl.class).in(Singleton.class);
    binder.bind(DataSource.class).toProvider(C3P0Provider.class).in(Singleton.class);
    Properties properties = new Properties();
    try {
        properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("database.properties"));
    } catch (IOException e) {
        throw new ExceptionInInitializerError(e);
    }
    Names.bindProperties(binder, properties);
}
Example 43
Project: gerrit-master  File: MimeUtil2Module.java View source code
@Provides
@Singleton
MimeUtil2 provideMimeUtil2() {
    MimeUtil2 m = new MimeUtil2();
    m.registerMimeDetector(ExtensionMimeDetector.class.getName());
    m.registerMimeDetector(MagicMimeMimeDetector.class.getName());
    if (HostPlatform.isWin32()) {
        m.registerMimeDetector("eu.medsea.mimeutil.detector.WindowsRegistryMimeDetector");
    }
    m.registerMimeDetector(DefaultFileExtensionRegistry.class.getName());
    return m;
}
Example 44
Project: google-gin-master  File: MyAppGinModule.java View source code
protected void configure() {
    // Note that MyServiceImpl has @Singleton on itself
    bind(MyService.class).to(MyServiceImpl.class);
    bind(MyProvided.class).toProvider(MyProvidedProvider.class).in(Singleton.class);
    // SimpleObject (all three flavors) are singletons
    bind(SimpleObject.class).in(Singleton.class);
    bind(SimpleObject.class).annotatedWith(Names.named("red")).to(SimpleObject.class);
    bind(SimpleObject.class).annotatedWith(Names.named("blue")).to(SimpleObject.class);
    bind(EagerObject.class).asEagerSingleton();
    bindConstant().annotatedWith(MyBindingAnnotation.class).to(MyAppGinjector.ANNOTATED_STRING_VALUE);
}
Example 45
Project: google-guice-master  File: ExampleListener.java View source code
public Injector getInjector() {
    return Guice.createInjector(new Struts2GuicePluginModule(), new ServletModule() {

        @Override
        protected void configureServlets() {
            // Struts 2 setup
            bind(StrutsPrepareAndExecuteFilter.class).in(Singleton.class);
            filter("/*").through(StrutsPrepareAndExecuteFilter.class);
            // Our app-specific code
            bind(Service.class).to(ServiceImpl.class);
        }
    });
}
Example 46
Project: governator-master  File: CreateAllBoundSingletons.java View source code
public <T> Void visit(final Binding<T> binding) {
    // This takes care of bindings to concrete classes
    binding.acceptScopingVisitor(new DefaultBindingScopingVisitor<Void>() {

        @Override
        public Void visitScope(Scope scope) {
            if (scope.equals(Scopes.SINGLETON)) {
                binding.getProvider().get();
            }
            return null;
        }
    });
    // This takes care of the interface .to() bindings
    binding.acceptTargetVisitor(new DefaultBindingTargetVisitor<T, Void>() {

        public Void visit(LinkedKeyBinding<? extends T> linkedKeyBinding) {
            Key<?> key = linkedKeyBinding.getLinkedKey();
            Class<?> type = key.getTypeLiteral().getRawType();
            if (type.getAnnotation(Singleton.class) != null || type.getAnnotation(javax.inject.Singleton.class) != null) {
                binding.getProvider().get();
            }
            return null;
        }
    });
    return visitOther(binding);
}
Example 47
Project: guice-automatic-injection-master  File: ImplementationBindingFeature.java View source code
@Override
public void process(final Class<Object> annotatedClass, final Map<String, Annotation> annotations) {
    final boolean asSingleton = (annotations.containsKey(com.google.inject.Singleton.class.getName()) || annotations.containsKey(javax.inject.Singleton.class.getName()));
    if (_logger.isLoggable(Level.FINE)) {
        _logger.fine(String.format("Binding Class %s. Singleton? %s ", annotatedClass, asSingleton));
    }
    bind(annotatedClass, null, (asSingleton ? Singleton.class : null));
}
Example 48
Project: guice-master  File: Struts2FactoryTest.java View source code
@Override
protected Injector getInjector() {
    return Guice.createInjector(new Struts2GuicePluginModule(), new ServletModule() {

        @Override
        protected void configureServlets() {
            // Struts 2 setup
            bind(StrutsPrepareAndExecuteFilter.class).in(com.google.inject.Singleton.class);
            filter("/*").through(StrutsPrepareAndExecuteFilter.class);
        }
    }, module);
}
Example 49
Project: gwt-node-master  File: FeaturesModule.java View source code
@Override
protected void configure() {
    //modules
    bind(Process.class).toProvider(new Provider<Process>() {

        @Override
        public Process get() {
            return Process.get();
        }
    }.getClass());
    bind(Util.class).toProvider(new Provider<Util>() {

        @Override
        public Util get() {
            return Util.get();
        }
    }.getClass());
    //features
    bind(ClientBundleFeature.class).in(Singleton.class);
    bind(FormatFeature.class).in(Singleton.class);
    bind(HttpFeature.class).in(Singleton.class);
    bind(JsonpFeature.class).in(Singleton.class);
    bind(LoggingFeature.class).in(Singleton.class);
    bind(XmlFeature.class).in(Singleton.class);
}
Example 50
Project: gwtp-basicsample-maven-master  File: MyModule.java View source code
@Override
protected void configure() {
    bind(EventBus.class).to(DefaultEventBus.class).in(Singleton.class);
    bind(PlaceManager.class).to(MyPlaceManager.class).in(Singleton.class);
    bind(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class);
    bind(RootPresenter.class).asEagerSingleton();
    bind(ProxyFailureHandler.class).to(DefaultProxyFailureHandler.class).in(Singleton.class);
    // Presenters
    bindPresenter(MainPagePresenter.class, MainPagePresenter.MyView.class, MainPageView.class, MainPagePresenter.MyProxy.class);
    bindPresenter(ResponsePresenter.class, ResponsePresenter.MyView.class, ResponseView.class, ResponsePresenter.MyProxy.class);
}
Example 51
Project: HumBuch-master  File: TestModule.java View source code
@Override
protected void configure() {
    install(new JpaPersistModule("testPersistModule"));
    bind(new TypeLiteral<DAO<BorrowedMaterial>>() {
    }).to(new TypeLiteral<DAOImpl<BorrowedMaterial>>() {
    });
    bind(new TypeLiteral<DAO<Category>>() {
    }).to(new TypeLiteral<DAOImpl<Category>>() {
    });
    bind(new TypeLiteral<DAO<Dunning>>() {
    }).to(new TypeLiteral<DAOImpl<Dunning>>() {
    });
    bind(new TypeLiteral<DAO<Grade>>() {
    }).to(new TypeLiteral<DAOImpl<Grade>>() {
    });
    bind(new TypeLiteral<DAO<Parent>>() {
    }).to(new TypeLiteral<DAOImpl<Parent>>() {
    });
    bind(new TypeLiteral<DAO<SchoolYear>>() {
    }).to(new TypeLiteral<DAOImpl<SchoolYear>>() {
    });
    bind(new TypeLiteral<DAO<Student>>() {
    }).to(new TypeLiteral<DAOImpl<Student>>() {
    });
    bind(new TypeLiteral<DAO<TeachingMaterial>>() {
    }).to(new TypeLiteral<DAOImpl<TeachingMaterial>>() {
    });
    bind(new TypeLiteral<DAO<User>>() {
    }).to(new TypeLiteral<DAOImpl<User>>() {
    });
    bind(new TypeLiteral<DAO<SettingsEntry>>() {
    }).to(new TypeLiteral<DAOImpl<SettingsEntry>>() {
    });
    bind(Properties.class).in(Singleton.class);
    bind(ViewModelComposer.class).in(Singleton.class);
}
Example 52
Project: ide-master  File: SshGinModule.java View source code
/** {@inheritDoc} */
@Override
protected void configure() {
    bind(SshKeyService.class).to(SshKeyServiceImpl.class).in(Singleton.class);
    bind(SshKeyManagerView.class).to(SshKeyManagerViewImpl.class).in(Singleton.class);
    bind(UploadSshKeyView.class).to(UploadSshKeyViewImpl.class).in(Singleton.class);
    GinMultibinder<PreferencePagePresenter> prefBinder = GinMultibinder.newSetBinder(binder(), PreferencePagePresenter.class);
    prefBinder.addBinding().to(SshKeyManagerPresenter.class);
}
Example 53
Project: ImproveReading-master  File: MyModule.java View source code
@Override
protected void configure() {
    bind(EventBus.class).to(DefaultEventBus.class).in(Singleton.class);
    bind(PlaceManager.class).to(MyPlaceManager.class).in(Singleton.class);
    bind(TokenFormatter.class).to(ParameterTokenFormatter.class).in(Singleton.class);
    bind(RootPresenter.class).asEagerSingleton();
    bind(ProxyFailureHandler.class).to(DefaultProxyFailureHandler.class).in(Singleton.class);
    // Presenters
    bindPresenter(MainPagePresenter.class, MainPagePresenter.MyView.class, MainPageView.class, MainPagePresenter.MyProxy.class);
    bindPresenter(ResponsePresenter.class, ResponsePresenter.MyView.class, ResponseView.class, ResponsePresenter.MyProxy.class);
}
Example 54
Project: incubator-wave-master  File: NoOpFederationModule.java View source code
@Override
protected void configure() {
    bind(WaveletFederationProvider.class).annotatedWith(FederationRemoteBridge.class).to(NoOpFederationRemote.class).in(Singleton.class);
    bind(WaveletFederationListener.Factory.class).annotatedWith(FederationHostBridge.class).to(NoOpFederationHost.class).in(Singleton.class);
    bind(FederationTransport.class).to(NoOpFederationTransport.class).in(Singleton.class);
}
Example 55
Project: jciwebsite-master  File: ClientModule.java View source code
@Override
protected void configure() {
    install(new DefaultModule(PlaceManager.class));
    install(new ApplicationModule());
    install(new RestModule());
    bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.home);
    bind(CommonResource.class).in(Singleton.class);
    bind(ResourceLoader.class).asEagerSingleton();
}
Example 56
Project: jOOQ-master  File: Module.java View source code
@Override
protected void configure() {
    bind(Service.class).in(Singleton.class);
    TransactionalMethodInterceptor interceptor = new TransactionalMethodInterceptor();
    requestInjection(interceptor);
    bindInterceptor(annotatedWith(Transactional.class), any(), interceptor);
    bindInterceptor(any(), annotatedWith(Transactional.class), interceptor);
    install(new DataSources());
}
Example 57
Project: joyrest-master  File: GuiceApplicationModule.java View source code
@Override
protected void configure() {
    Multibinder<ControllerConfiguration> controllerBinder = newSetBinder(binder(), ControllerConfiguration.class);
    controllerBinder.addBinding().to(JokeController.class).in(Singleton.class);
    GsonReaderWriter readerWriter = new GsonReaderWriter();
    Multibinder<Writer> writerBinder = newSetBinder(binder(), Writer.class);
    writerBinder.addBinding().toInstance(readerWriter);
    Multibinder<Reader> readerBinder = newSetBinder(binder(), Reader.class);
    readerBinder.addBinding().toInstance(readerWriter);
    bind(JokeService.class).to(JokeServiceImpl.class).in(Singleton.class);
}
Example 58
Project: judochop-master  File: CustomShiroWebModule.java View source code
@Override
protected void configureShiroWeb() {
    addFilterChain("/logout", LOGOUT);
    addFilterChain("/VAADIN/*", AUTHC_BASIC);
    addFilterChain("/auth/**", Key.get(RestFilter.class));
    bindRealm().to(ShiroRealm.class).in(Singleton.class);
//        bindConstant().annotatedWith(Names.named("shiro.loginUrl")).to("/login.jsp");
//        bindConstant().annotatedWith(Names.named("shiro.globalSessionTimeout")).to(3600000L);//1 hour
//        bindConstant().annotatedWith(Names.named("shiro.usernameParam")).to("user");
//        bindConstant().annotatedWith(Names.named("shiro.passwordParam")).to("pass");
//        bindConstant().annotatedWith(Names.named("shiro.successUrl")).to("/index.jsp");
//        bindConstant().annotatedWith(Names.named("shiro.failureKeyAttribute")).to("shiroLoginFailure");
//        bindConstant().annotatedWith(Names.named("shiro.unauthorizedUrl")).to("/denied.jsp");
//        bindConstant().annotatedWith(Names.named("shiro.redirectUrl")).to("/login.jsp");
}
Example 59
Project: killbill-master  File: GlobalLockerModule.java View source code
@Provides
@Singleton
protected // Note: we need to inject the pooled DataSource here, not the (direct) one from EmbeddedDB
GlobalLocker provideGlobalLocker(final DataSource dataSource, final EmbeddedDB embeddedDB) throws IOException {
    if (EmbeddedDB.DBEngine.MYSQL.equals(embeddedDB.getDBEngine())) {
        return new MySqlGlobalLocker(dataSource);
    } else if (EmbeddedDB.DBEngine.POSTGRESQL.equals(embeddedDB.getDBEngine())) {
        return new PostgreSQLGlobalLocker(dataSource);
    } else {
        return new MemoryGlobalLocker();
    }
}
Example 60
Project: konto-master  File: CurrencyModule.java View source code
@Override
protected void configure() {
    bind(CurrencyView.class).to(CurrencyViewImpl.class).in(Singleton.class);
    bind(CurrencyActivity.class);
    bind(MonetaryUnitView.class).to(MonetaryUnitViewImpl.class).in(Singleton.class);
    bind(MonetaryUnitView.Presenter.class).to(MonetaryUnitPresenter.class);
    bind(CurrencyPairView.class).to(CurrencyPairViewImpl.class).in(Singleton.class);
    bind(CurrencyPairView.Presenter.class).to(CurrencyPairPresenter.class);
}
Example 61
Project: kune-master  File: MassmobGinModule.java View source code
@Override
protected void configure() {
    bind(I18nTranslationService.class).to(I18nTranslationServiceMocked.class).in(Singleton.class);
    bind(I18n.class).in(Singleton.class);
    requestStaticInjection(I18n.class);
    requestStaticInjection(EventBusInstance.class);
    bind(SimpleUserNotifierPopup.class).asEagerSingleton();
    requestStaticInjection(NotifyUser.class);
    // bind(EventBus.class).to(EventBusWithLogging.class).in(Singleton.class);
    bind(MassmobMainPanel.class).in(Singleton.class);
    bind(WaveUtils.class).in(Singleton.class);
    bind(StateManager.class).in(Singleton.class);
    bind(Images.class).in(Singleton.class);
    bind(UserSelfPreferences.class).to(CookiesUserSelfPreferences.class).in(Singleton.class);
    bind(DatePresenter.DateView.class).to(DatePanel.class);
    bind(DatePresenter.class);
    bind(GuiProvider.class).to(DefaultGuiProvider.class).in(Singleton.class);
    bind(GwtGuiProvider.class).in(Singleton.class);
    bind(GuiActionDescCollection.class).in(Singleton.class);
    bind(OptionsActions.class).in(Singleton.class);
}
Example 62
Project: legman-master  File: LegmanModuleTest.java View source code
@Test
public void testSomeMethod() {
    EventBus eventBus = new EventBus();
    Injector injector = Guice.createInjector(new LegmanModule(eventBus), new AbstractModule() {

        @Override
        protected void configure() {
            bind(SampleService.class).in(Singleton.class);
        }
    });
    SampleService service = injector.getInstance(SampleService.class);
    eventBus.post("event");
    assertEquals("event", service.event);
}
Example 63
Project: m2e-core-master  File: ExtensionModule.java View source code
public <T> void bind(Class<T> role, Class<? extends T> impl, String hint) {
    ScopedBindingBuilder builder;
    if (hint == null || hint.length() <= 0 || "default".equals(hint)) {
        //$NON-NLS-1$
        builder = bind(role).to(impl);
    } else {
        builder = bind(role).annotatedWith(Names.named(hint)).to(impl);
    }
    if (impl.getAnnotation(Singleton.class) != null) {
        builder.in(com.google.inject.Singleton.class);
    }
}
Example 64
Project: mobilitytestbed-master  File: NearestNodeInitModuleFactory.java View source code
@Override
public AbstractModule injectModule(Injector injector) {
    Collection<HighwayNode> allNetworkNodes = injector.getInstance(HighwayNetwork.class).getNetwork().getAllNodes();
    WGS84Convertor wgs84Convertor = WGS84Convertor.createConvertorFromWGS84ToSpatialRefSys(epsg);
    Map<Long, Coordinate> projectedNodeCoordinats = Maps.newHashMap();
    final KDTree kdTree = new KDTree(2);
    for (Node node : allNetworkNodes) {
        LatLon latLon = node.getLatLon();
        Coordinate coordinate = wgs84Convertor.convert(latLon.lon(), latLon.lat());
        projectedNodeCoordinats.put(node.getId(), coordinate);
        kdTree.insert(new double[] { coordinate.x, coordinate.y }, node.getId());
    }
    final NodeExtendedFunction nearestNodeFinder = new NodeExtendedFunction(projectedNodeCoordinats, kdTree, wgs84Convertor);
    return new AbstractModule() {

        @Override
        protected void configure() {
        // TODO Auto-generated method stub
        }

        @Singleton
        @Provides
        public NodeExtendedFunction provideNearestNodeFinder() {
            return nearestNodeFinder;
        }
    };
}
Example 65
Project: Moogle-Muice-master  File: ExampleListener.java View source code
public Injector getInjector() {
    return Guice.createInjector(new Struts2GuicePluginModule(), new ServletModule() {

        @Override
        protected void configureServlets() {
            // Struts 2 setup
            bind(StrutsPrepareAndExecuteFilter.class).in(Singleton.class);
            filter("/*").through(StrutsPrepareAndExecuteFilter.class);
            // Our app-specific code
            bind(Service.class).to(ServiceImpl.class);
        }
    });
}
Example 66
Project: Nin-master  File: NinjaBaseModule.java View source code
@Override
public void configure() {
    System.setProperty("file.encoding", "utf-8");
    // Lifecycle support
    install(LifecycleSupport.getModule());
    // Scheduling support
    install(SchedulerSupport.getModule());
    // Routing
    Multibinder.newSetBinder(binder(), ParamParser.class);
    bind(RouteBuilder.class).to(RouteBuilderImpl.class);
    bind(Router.class).to(RouterImpl.class).in(Singleton.class);
    // Logging
    bind(Logger.class).toProvider(LoggerProvider.class);
    // Bind the configuration into Guice
    ninjaProperties.bindProperties(binder());
    bind(NinjaProperties.class).toInstance(ninjaProperties);
}
Example 67
Project: Ninja-master  File: NinjaBaseModule.java View source code
@Override
public void configure() {
    System.setProperty("file.encoding", "utf-8");
    // Lifecycle support
    install(LifecycleSupport.getModule());
    // Routing
    Multibinder.newSetBinder(binder(), ParamParser.class);
    bind(RouteBuilder.class).to(RouteBuilderImpl.class);
    bind(Router.class).to(RouterImpl.class).in(Singleton.class);
    // Logging
    bind(Logger.class).toProvider(LoggerProvider.class);
    // Bind the configuration into Guice
    ninjaProperties.bindProperties(binder());
    bind(NinjaProperties.class).toInstance(ninjaProperties);
}
Example 68
Project: occurrence-master  File: OccurrenceDownloadServiceModule.java View source code
@Provides
@Singleton
@Named("oozie.default_properties")
Map<String, String> providesDefaultParameters(@Named("environment") String environment, @Named("ws.url") String wsUrl, @Named("hdfs.namenode") String nameNode) {
    return new ImmutableMap.Builder<String, String>().put(OozieClient.LIBPATH, String.format(DownloadWorkflowParameters.WORKFLOWS_LIB_PATH_FMT, environment)).put(OozieClient.APP_PATH, nameNode + String.format(DownloadWorkflowParameters.DOWNLOAD_WORKFLOW_PATH_FMT, environment)).put(OozieClient.WORKFLOW_NOTIFICATION_URL, DownloadUtils.concatUrlPaths(wsUrl, "occurrence/download/request/callback?job_id=$jobId&status=$status")).put(OozieClient.USER_NAME, Constants.OOZIE_USER).putAll(DownloadWorkflowParameters.CONSTANT_PARAMETERS).build();
}
Example 69
Project: open-data-service-master  File: DbModule.java View source code
@Override
protected void configure() {
    try {
        CouchDbInstance couchDbInstance = new StdCouchDbInstance(new StdHttpClient.Builder().url(couchDbConfig.getUrl()).username(couchDbConfig.getAdmin().getUsername()).password(couchDbConfig.getAdmin().getPassword()).maxConnections(couchDbConfig.getMaxConnections()).build());
        DbConnectorFactory connectorFactory = new DbConnectorFactory(couchDbInstance, couchDbConfig.getDbPrefix());
        CouchDbConnector dataSourceConnector = connectorFactory.createConnector(DataSourceRepository.DATABASE_NAME, true);
        bind(CouchDbConnector.class).annotatedWith(Names.named(DataSourceRepository.DATABASE_NAME)).toInstance(dataSourceConnector);
        CouchDbConnector userConnector = connectorFactory.createConnector(UserRepository.DATABASE_NAME, true);
        bind(CouchDbConnector.class).annotatedWith(Names.named(UserRepository.DATABASE_NAME)).toInstance(userConnector);
        bind(DbConnectorFactory.class).toInstance(connectorFactory);
        install(new FactoryModuleBuilder().build(RepositoryFactory.class));
        bind(DataSourceRepository.class).in(Singleton.class);
        bind(new TypeLiteral<Cache<DataViewRepository>>() {
        }).in(Singleton.class);
        bind(new TypeLiteral<Cache<ProcessorChainReferenceRepository>>() {
        }).in(Singleton.class);
        bind(new TypeLiteral<Cache<NotificationClientRepository>>() {
        }).in(Singleton.class);
        bind(new TypeLiteral<Cache<PluginMetaDataRepository>>() {
        }).in(Singleton.class);
        bind(new TypeLiteral<Cache<DataRepository>>() {
        }).in(Singleton.class);
    } catch (MalformedURLException mue) {
        throw new RuntimeException(mue);
    }
}
Example 70
Project: oxalis-master  File: PlatformModule.java View source code
@Override
protected void configure() {
    Multibinder<Platform> multibinder = Multibinder.newSetBinder(binder(), Platform.class);
    multibinder.addBinding().to(H2Platform.class);
    multibinder.addBinding().to(HSQLDBPlatform.class);
    multibinder.addBinding().to(MySQLPlatform.class);
    multibinder.addBinding().to(MsSQLPlatform.class);
    multibinder.addBinding().to(OraclePlatform.class);
    bind(Platform.class).toProvider(PlatformProvider.class).in(Singleton.class);
}
Example 71
Project: palava-concurrent-master  File: BackgroundSchedulerModule.java View source code
@Override
@SuppressWarnings("deprecation")
public void configure(Binder binder) {
    binder.install(new SchedulerModule(BackgroundScheduler.class, BackgroundScheduler.NAME));
    final Key<ScheduledExecutorService> key = Key.get(ScheduledExecutorService.class, BackgroundScheduler.class);
    binder.bind(Executor.class).annotatedWith(Background.class).to(key).in(Singleton.class);
    binder.bind(ExecutorService.class).annotatedWith(Background.class).to(key).in(Singleton.class);
    binder.bind(ScheduledExecutorService.class).annotatedWith(Background.class).to(key).in(Singleton.class);
}
Example 72
Project: palava-ipc-xml-rpc-master  File: AdapterModule.java View source code
@Override
protected void configure() {
    bind(BooleanAdapter.LITERAL).to(BooleanAdapter.class).in(Singleton.class);
    bind(DateAdapter.LITERAL).to(DateAdapter.class).in(Singleton.class);
    bind(DoubleAdapter.LITERAL).to(DoubleAdapter.class).in(Singleton.class);
    bind(EntryAdapter.LITERAL).to(EntryAdapter.class).in(Singleton.class);
    bind(InputStreamAdapter.LITERAL).to(InputStreamAdapter.class).in(Singleton.class);
    bind(IntegerAdapter.LITERAL).to(IntegerAdapter.class).in(Singleton.class);
    bind(ListAdapter.LITERAL).to(ListAdapter.class).in(Singleton.class);
    bind(MapAdapter.LITERAL).to(MapAdapter.class).in(Singleton.class);
    bind(NumberAdapter.LITERAL).to(NumberAdapter.class).in(Singleton.class);
    bind(ObjectAdapter.LITERAL).to(ObjectAdapter.class).in(Singleton.class);
    bind(StringAdapter.LITERAL).to(StringAdapter.class).in(Singleton.class);
    bind(ThrowableAdapter.LITERAL).to(ThrowableAdapter.class).in(Singleton.class);
}
Example 73
Project: palava-jpa-master  File: AnnotatedJpaModule.java View source code
@Override
public void configure(Binder binder) {
    binder.bind(PersistenceService.class).annotatedWith(annotation).to(DefaultPersistenceService.class).in(Singleton.class);
    binder.bind(EntityManagerFactory.class).annotatedWith(annotation).to(Key.get(PersistenceService.class, annotation)).in(Singleton.class);
    binder.bind(EntityManager.class).annotatedWith(annotation).toProvider(Key.get(PersistenceService.class, annotation)).in(UnitOfWork.class);
}
Example 74
Project: plugin-java-master  File: MavenGinModule.java View source code
/** {@inheritDoc} */
@Override
protected void configure() {
    bind(MavenBuildView.class).to(MavenBuildViewImpl.class).in(Singleton.class);
    install(new GinFactoryModuleBuilder().build(MavenNodeFactory.class));
    GinMultibinder.newSetBinder(binder(), TreeStructureProvider.class).addBinding().to(MavenProjectTreeStructureProvider.class);
    GinMultibinder.newSetBinder(binder(), ProjectWizardRegistrar.class).addBinding().to(MavenProjectWizardRegistrar.class);
}
Example 75
Project: prime-mvc-master  File: FreeMarkerModule.java View source code
@Override
protected void configure() {
    bind(TemplateLoader.class).to(OverridingTemplateLoader.class).in(Singleton.class);
    bind(Configuration.class).toProvider(FreeMarkerConfigurationProvider.class).in(Singleton.class);
    // Can't be a singleton because the Locale can change per request
    bind(FreeMarkerService.class).to(DefaultFreeMarkerService.class);
    bind(TemplateModelFactory.class);
    TemplateModelFactory.addSingletonModel(binder(), "function", "json_escape", JSONEscape.class);
    TemplateModelFactory.addModel(binder(), "function", "message", Message.class);
}
Example 76
Project: ratpack-master  File: TextTemplateModule.java View source code
@Provides
@Singleton
TextTemplateRenderingEngine provideGroovyTemplateRenderingEngine(ServerConfig serverConfig, ExecController execController, ByteBufAllocator bufferAllocator, Config config) {
    String templatesPath = config.getTemplatesPath();
    FileSystemBinding templateDir = serverConfig.getBaseDir().binding(templatesPath);
    if (templateDir == null) {
        throw new IllegalStateException("templatesPath '" + templatesPath + "' is outside the file system binding");
    }
    return new TextTemplateRenderingEngine(bufferAllocator, templateDir, serverConfig.isDevelopment(), config.staticallyCompile);
}
Example 77
Project: richfaces-cdk-master  File: ModelModule.java View source code
/*
     * (non-Javadoc)
     *
     * @see com.google.inject.AbstractModule#configure()
     */
@Override
protected void configure() {
    bind(ComponentLibrary.class).in(Singleton.class);
    bind(ComponentLibraryHolder.class).in(Singleton.class);
    LibraryProxyInterceptor interceptor = new LibraryProxyInterceptor();
    requestInjection(interceptor);
    bindInterceptor(Matchers.subclassesOf(ComponentLibrary.class), Matchers.any(), interceptor);
}
Example 78
Project: roboguice-master  File: ExampleListener.java View source code
public Injector getInjector() {
    return Guice.createInjector(new Struts2GuicePluginModule(), new ServletModule() {

        @Override
        protected void configureServlets() {
            // Struts 2 setup
            bind(StrutsPrepareAndExecuteFilter.class).in(Singleton.class);
            filter("/*").through(StrutsPrepareAndExecuteFilter.class);
            // Our app-specific code
            bind(Service.class).to(ServiceImpl.class);
        }
    });
}
Example 79
Project: sarl-master  File: NoNetworkModule.java View source code
@Override
protected void configure() {
    bind(NetworkService.class).to(NoNetworkService.class).in(Singleton.class);
    // Complete the binding for: Set<Service>
    // (This set is given to the service manager to launch the services).
    final Multibinder<Service> serviceSetBinder = Multibinder.newSetBinder(binder(), Service.class);
    serviceSetBinder.addBinding().to(NoNetworkService.class);
}
Example 80
Project: seda-proto-master  File: WebsocketModule.java View source code
@Override
protected void configure() {
    bind(SedaServer.class).in(Singleton.class);
    bind(Server.class).toProvider(ServerProvider.class).in(Singleton.class);
    bind(Connector.class).toProvider(ConnectorProvider.class);
    bind(HandlerList.class).toProvider(HandlerListProvider.class);
    bind(ContextHandler.class).annotatedWith(WebSocketContext.class).toProvider(WebsocketContextProvider.class).in(Singleton.class);
    bind(ContextHandler.class).annotatedWith(ResourceContext.class).toProvider(ResourceContextProvider.class).in(Singleton.class);
    bind(SessionManager.class).to(SessionManagerImpl.class).in(Singleton.class);
}
Example 81
Project: service-discovery-master  File: GalaxyAnnouncementModule.java View source code
@Provides
@Singleton
AnnouncementConfig getAnnouncementConfig(final Config config) {
    final AnnouncementConfig baseConfig = config.getBean(AnnouncementConfig.class);
    return new AnnouncementConfig(baseConfig) {

        @Override
        public String getServiceName() {
            return ObjectUtils.toString(super.getServiceName(), serviceName);
        }

        @Override
        public String getServiceType() {
            return ObjectUtils.toString(super.getServiceType(), serviceType);
        }
    };
}
Example 82
Project: sisu-guice-master  File: Struts2FactoryTest.java View source code
@Override
protected Injector getInjector() {
    return Guice.createInjector(new Struts2GuicePluginModule(), new ServletModule() {

        @Override
        protected void configureServlets() {
            // Struts 2 setup
            bind(StrutsPrepareAndExecuteFilter.class).in(com.google.inject.Singleton.class);
            filter("/*").through(StrutsPrepareAndExecuteFilter.class);
        }
    }, module);
}
Example 83
Project: SmartMonitoring-master  File: MongoDbModule.java View source code
@Override
protected void configure() {
    bindInterceptor(Matchers.subclassesOf(IPersistenceService.class), Matchers.any(), new PersistenceInterceptor(mongoConfig));
    bind(IPersistenceService.class).to(MongoDbPersitenceService.class).in(Singleton.class);
    // bind session and install DAOs
    if (mongoConfig.getEnabled()) {
        bind(MongoSessionFactory.class).asEagerSingleton();
        install(new MongoDbDaoModule());
    }
}
Example 84
Project: swing-on-steroids-master  File: GuiceMessageBusTest.java View source code
@Override
protected void configure() {
    bind(String.class).annotatedWith(Names.named(WorkQueue.NAME)).toInstance("MessageBusTest");
    bind(Integer.class).annotatedWith(Names.named(WorkQueue.SIZE)).toInstance(2);
    bind(WorkQueue.class).to(DefaultWorkQueue.class).in(Singleton.class);
    bind(MessageBus.class).to(SingleThreadDeliveryMessageBus.class).in(Singleton.class);
}
Example 85
Project: torodb-master  File: ReplCommandImplementionsModule.java View source code
@Override
protected void configure() {
    bind(CommandsExecutorClassifier.class).in(Singleton.class);
    bind(ConnectionCommandsExecutor.class).in(Singleton.class);
    bind(GeneralTransactionImplementations.class).in(Singleton.class);
    bind(WriteTransactionImplementations.class).to(ReplWriteTransactionImplementations.class).in(Singleton.class);
    bind(ExclusiveWriteTransactionImplementations.class).to(ReplExclusiveWriteTransactionImplementations.class).in(Singleton.class);
}
Example 86
Project: TurkServer-master  File: DataModule.java View source code
@Provides
@Singleton
RequesterServiceExt getRequesterService() {
    // Create AWS Requester, if any
    RequesterServiceExt req = null;
    try {
        ClientConfig reqConf = TSConfig.getClientConfig(conf);
        req = new RequesterServiceExt(reqConf);
    } catch (RuntimeException e) {
        e.printStackTrace();
        System.out.println("Bad configuration for MTurk requester service. MTurk functions will be unavailable.");
    }
    return req;
}
Example 87
Project: universal-analytics-master  File: ServerAnalyticsModule.java View source code
@Override
protected void configureServlets() {
    bindConstant().annotatedWith(GaAccount.class).to(userAccount);
    bind(ServerOptionsCallback.class).toProvider(ServerOptionsCallbackProvider.class).in(RequestScoped.class);
    bind(Analytics.class).to(ServerAnalytics.class).in(Singleton.class);
    filter("/*").through(ServerOptionsCallbackProvider.class);
}
Example 88
Project: user-master  File: CustomShiroWebModule.java View source code
@Override
protected void configureShiroWeb() {
    addFilterChain("/logout", LOGOUT);
    addFilterChain("/VAADIN/*");
    addFilterChain("/auth/**", Key.get(RestFilter.class));
    bindRealm().to(ShiroRealm.class).in(Singleton.class);
//        bindConstant().annotatedWith(Names.named("shiro.loginUrl")).to("/login.jsp");
//        bindConstant().annotatedWith(Names.named("shiro.globalSessionTimeout")).to(3600000L);//1 hour
//        bindConstant().annotatedWith(Names.named("shiro.usernameParam")).to("user");
//        bindConstant().annotatedWith(Names.named("shiro.passwordParam")).to("pass");
//        bindConstant().annotatedWith(Names.named("shiro.successUrl")).to("/index.jsp");
//        bindConstant().annotatedWith(Names.named("shiro.failureKeyAttribute")).to("shiroLoginFailure");
//        bindConstant().annotatedWith(Names.named("shiro.unauthorizedUrl")).to("/denied.jsp");
//        bindConstant().annotatedWith(Names.named("shiro.redirectUrl")).to("/login.jsp");
}
Example 89
Project: usergrid-master  File: CustomShiroWebModule.java View source code
@Override
protected void configureShiroWeb() {
    addFilterChain("/logout", LOGOUT);
    addFilterChain("/VAADIN/*");
    addFilterChain("/auth/**", Key.get(RestFilter.class));
    bindRealm().to(ShiroRealm.class).in(Singleton.class);
//        bindConstant().annotatedWith(Names.named("shiro.loginUrl")).to("/login.jsp");
//        bindConstant().annotatedWith(Names.named("shiro.globalSessionTimeout")).to(3600000L);//1 hour
//        bindConstant().annotatedWith(Names.named("shiro.usernameParam")).to("user");
//        bindConstant().annotatedWith(Names.named("shiro.passwordParam")).to("pass");
//        bindConstant().annotatedWith(Names.named("shiro.successUrl")).to("/index.jsp");
//        bindConstant().annotatedWith(Names.named("shiro.failureKeyAttribute")).to("shiroLoginFailure");
//        bindConstant().annotatedWith(Names.named("shiro.unauthorizedUrl")).to("/denied.jsp");
//        bindConstant().annotatedWith(Names.named("shiro.redirectUrl")).to("/login.jsp");
}
Example 90
Project: volinfoman-master  File: VolinfomanGuiceModule.java View source code
/* (non-Javadoc)
	 * @see com.google.inject.AbstractModule#configure()
	 */
@Override
protected void configure() {
    // Servlets are Singletons
    bind(UserServiceImpl.class).in(Singleton.class);
    bind(Register.class).in(Singleton.class);
    bind(ConfirmationCodeChecker.class).in(Singleton.class);
    bind(Login.class).in(Singleton.class);
    // Data providers
    bind(Dao.class).to(DaoGaeDatastore.class).in(Singleton.class);
}
Example 91
Project: Wave-master  File: XmppFederationModule.java View source code
@Override
protected void configure() {
    // Request history and submit deltas to the outside world *from* our local
    // Wave Server.
    bind(WaveletFederationProvider.class).annotatedWith(FederationRemoteBridge.class).to(XmppFederationRemote.class).in(Singleton.class);
    // Serve updates to the outside world about local waves.
    bind(WaveletFederationListener.Factory.class).annotatedWith(FederationHostBridge.class).to(XmppFederationHost.class).in(Singleton.class);
    bind(XmppDisco.class).in(Singleton.class);
    bind(XmppFederationRemote.class).in(Singleton.class);
    bind(XmppFederationHost.class).in(Singleton.class);
    bind(XmppManager.class).in(Singleton.class);
    bind(IncomingPacketHandler.class).to(XmppManager.class);
    bind(ComponentPacketTransport.class).in(Singleton.class);
    bind(OutgoingPacketTransport.class).to(ComponentPacketTransport.class);
    bind(FederationTransport.class).to(XmppFederationTransport.class).in(Singleton.class);
}
Example 92
Project: wave-protocol-master  File: XmppFederationModule.java View source code
@Override
protected void configure() {
    // Request history and submit deltas to the outside world *from* our local
    // Wave Server.
    bind(WaveletFederationProvider.class).annotatedWith(FederationRemoteBridge.class).to(XmppFederationRemote.class).in(Singleton.class);
    // Serve updates to the outside world about local waves.
    bind(WaveletFederationListener.Factory.class).annotatedWith(FederationHostBridge.class).to(XmppFederationHost.class).in(Singleton.class);
    bind(XmppDisco.class).in(Singleton.class);
    bind(XmppFederationRemote.class).in(Singleton.class);
    bind(XmppFederationHost.class).in(Singleton.class);
    bind(XmppManager.class).in(Singleton.class);
    bind(IncomingPacketHandler.class).to(XmppManager.class);
    bind(ComponentPacketTransport.class).in(Singleton.class);
    bind(OutgoingPacketTransport.class).to(ComponentPacketTransport.class);
    bind(FederationTransport.class).to(XmppFederationTransport.class).in(Singleton.class);
}
Example 93
Project: WaveInCloud-master  File: XmppFederationModule.java View source code
@Override
protected void configure() {
    // Request history and submit deltas to the outside world *from* our local
    // Wave Server.
    bind(WaveletFederationProvider.class).annotatedWith(FederationRemoteBridge.class).to(XmppFederationRemote.class).in(Singleton.class);
    // Serve updates to the outside world about local waves.
    bind(WaveletFederationListener.Factory.class).annotatedWith(FederationHostBridge.class).to(XmppFederationHost.class).in(Singleton.class);
    bind(XmppDisco.class).in(Singleton.class);
    bind(XmppFederationRemote.class).in(Singleton.class);
    bind(XmppFederationHost.class).in(Singleton.class);
    bind(XmppManager.class).in(Singleton.class);
    bind(IncomingPacketHandler.class).to(XmppManager.class);
    bind(ComponentPacketTransport.class).in(Singleton.class);
    bind(OutgoingPacketTransport.class).to(ComponentPacketTransport.class);
    bind(FederationTransport.class).to(XmppFederationTransport.class).in(Singleton.class);
}
Example 94
Project: WebGatherer---Scraper-and-Analyzer-master  File: DependencyBindingModule.java View source code
@Override
protected void configure() {
    bind(HtmlParser.class).to(HtmlParserImpl.class).in(Singleton.class);
    bind(WebDriverFactory.class).in(Singleton.class);
    bind(PageRetrieverThreadManager.class).in(Singleton.class);
    bind(PageRetrieverThreadManagerScraper.class).in(Singleton.class);
    bind(ThreadCommunication.class).to(ThreadCommunicationImpl.class);
    bind(EmailExtractor.class);
    bind(ThreadRetrievePageIndeed.class);
    bind(EmailSendReceive.class);
    bind(ReadFiles.class);
    bind(PersistenceImpl_WriteToFile.class);
    bind(RandomSelector.class).in(Singleton.class);
    bind(GoogleExtractUrls.class);
    bind(ThreadRetrievePageEmailExtraction.class);
    bind(PageRetrieverThreadManagerEmailExtraction.class).in(Singleton.class);
    bind(WriterOutputQueueToFile.class).in(Singleton.class);
    bind(ScraperIndeed.class);
    bind(ScraperGeneric.class);
}
Example 95
Project: wsn-device-drivers-master  File: MockModule.java View source code
@Override
protected void configure() {
    MockOperationInterceptor interceptor = new MockOperationInterceptor();
    requestInjection(interceptor);
    bindInterceptor(Matchers.any(), Matchers.annotatedWith(SerialPortProgrammingMode.class), interceptor);
    final TypeLiteral<Map<String, String>> mapLiteral = new TypeLiteral<Map<String, String>>() {
    };
    bind(mapLiteral).annotatedWith(Names.named("configuration")).toInstance(configuration != null ? configuration : Maps.<String, String>newHashMap());
    bind(Device.class).to(MockDevice.class);
    bind(MockConfiguration.class).in(Singleton.class);
    install(new FactoryModuleBuilder().implement(EraseFlashOperation.class, MockEraseFlashOperation.class).implement(GetChipTypeOperation.class, MockGetChipTypeOperation.class).implement(IsNodeAliveOperation.class, DefaultIsNodeAliveOperation.class).implement(ProgramOperation.class, MockProgramOperation.class).implement(ReadFlashOperation.class, MockReadFlashOperation.class).implement(ReadMacAddressOperation.class, MockReadMacAddressOperation.class).implement(ResetOperation.class, MockResetOperation.class).implement(WriteFlashOperation.class, MockWriteFlashOperation.class).implement(WriteMacAddressOperation.class, MockWriteMacAddressOperation.class).build(OperationFactory.class));
}
Example 96
Project: Jnario-master  File: AnnotationsSpec.java View source code
@Test
@Named("should support class annotations for \\\'describe\\\'")
@Order(1)
public void _shouldSupportClassAnnotationsForDescribe() throws Exception {
    final String spec = "\r\n\t\t\tpackage bootstrap\r\n\t\t\timport static org.hamcrest.CoreMatchers.*\t\t\t\r\n\t\t\timport com.google.inject.Singleton\r\n\r\n\t\t\t@Singleton\t\t\t\r\n\t\t\tdescribe \"Annotations\" {\r\n\t\t\t\r\n\t\t\tfact \"should support class annotations for describe\"{\r\n\t\t\t\t\tval annotation = typeof(AnnotationsSpec).getAnnotation(typeof(Singleton))\r\n\t\t\t\t\tannotation should not be null\r\n\t\t\t\t} \r\n\t\t\t\t\t\t\r\n\t\t\t}\r\n\t\t";
    this._behaviorExecutor.executesSuccessfully(spec);
}
Example 97
Project: adaptive-services-dashbar-master  File: ApiServletModule.java View source code
@Override
protected void configureServlets() {
    getServletContext().addListener(new WSConnectionTracker());
    bind(AdaptiveEnvironmentFilter.class).toProvider(SpringIntegration.fromSpring(AdaptiveEnvironmentFilter.class, "adaptiveEnvironmentFilter")).in(Singleton.class);
    Filter corsFilter = getCORSFilter();
    //TODO remove this filter in PRODUCTION
    filter("/*").through(corsFilter);
    filter("/*").through(AdaptiveEnvironmentFilter.class);
    serve("/api/ws/*").with(CodenvyEverrestWebSocketServlet.class);
    serve("/api/*").with(GuiceEverrestServlet.class);
}
Example 98
Project: Aion-unique-master  File: IDFactoriesInjectionModule.java View source code
@Provides
@IDFactoryAionObject
@Singleton
IDFactory provideAionObjectIdFactory() {
    IDFactory idFactory = new IDFactory();
    idFactory.lockIds(0);
    // Here should be calls to all IDFactoryAwareDAO implementations to initialize
    // used values in IDFactory
    idFactory.lockIds(DAOManager.getDAO(PlayerDAO.class).getUsedIDs());
    idFactory.lockIds(DAOManager.getDAO(InventoryDAO.class).getUsedIDs());
    idFactory.lockIds(DAOManager.getDAO(LegionDAO.class).getUsedIDs());
    idFactory.lockIds(DAOManager.getDAO(MailDAO.class).getUsedIDs());
    return idFactory;
}
Example 99
Project: AisAbnormal-master  File: WebAppModule.java View source code
@Provides
@Singleton
WebServer provideWebServer() {
    WebServer webServer = null;
    try {
        webServer = new WebServer(port, repositoryName, pathToEventDatabase, eventRepositoryType, eventDataDbHost, eventDataDbPort, eventDataDbName, eventDataDbUsername, eventDataDbPassword);
    } catch (Exception e) {
        LOG.error(e.getMessage(), e);
    }
    return webServer;
}
Example 100
Project: android-arscblamer-master  File: ArscModule.java View source code
/** Provides the resources.arsc resource table in the {@code apk}. */
@Provides
@Singleton
ResourceTableChunk providesResourceTableChunk(@Nullable @ApkPath File apk) throws IOException {
    Preconditions.checkNotNull(apk, "APK is required. Did you forget --apk=/my/app.apk?");
    byte[] resourceBytes = ApkUtils.getFile(apk, RESOURCES_ARSC);
    if (resourceBytes == null) {
        throw new IOException(String.format("Unable to find %s in APK.", RESOURCES_ARSC));
    }
    List<Chunk> chunks = new ResourceFile(resourceBytes).getChunks();
    Preconditions.checkState(chunks.size() == 1, "%s should only have one root chunk.", RESOURCES_ARSC);
    Chunk resourceTable = chunks.get(0);
    Preconditions.checkState(resourceTable instanceof ResourceTableChunk, "%s root chunk must be a ResourceTableChunk.", RESOURCES_ARSC);
    return (ResourceTableChunk) resourceTable;
}
Example 101
Project: aokp-gerrit-master  File: ReceiveCommitsExecutorModule.java View source code
@Provides
@Singleton
@ChangeUpdateExecutor
public ListeningExecutorService createChangeUpdateExecutor(@GerritServerConfig Config config) {
    int poolSize = config.getInt("receive", null, "changeUpdateThreads", 1);
    if (poolSize <= 1) {
        return MoreExecutors.sameThreadExecutor();
    }
    return MoreExecutors.listeningDecorator(MoreExecutors.getExitingExecutorService(new ThreadPoolExecutor(1, poolSize, 10, TimeUnit.MINUTES, new ArrayBlockingQueue<Runnable>(poolSize), new ThreadFactoryBuilder().setNameFormat("ChangeUpdate-%d").setDaemon(true).build(), new ThreadPoolExecutor.CallerRunsPolicy())));
}