Search in sources :

Example 51 with Provides

use of com.google.inject.Provides in project OpenAM by OpenRock.

the class CoreRestGuiceModule method getServerAttributeSyntax.

@Provides
@Singleton
@Named("ServerAttributeSyntax")
public Properties getServerAttributeSyntax() throws IOException {
    Properties syntaxProperties = new Properties();
    syntaxProperties.load(getClass().getClassLoader().getResourceAsStream("validserverconfig.properties"));
    return syntaxProperties;
}
Also used : SystemProperties(com.iplanet.am.util.SystemProperties) Properties(java.util.Properties) Named(javax.inject.Named) Singleton(javax.inject.Singleton) Provides(com.google.inject.Provides)

Example 52 with Provides

use of com.google.inject.Provides in project OpenAM by OpenRock.

the class CoreRestGuiceModule method getAuthenticateHandler.

@Provides
@Named("AuthenticateHandler")
@Inject
Handler getAuthenticateHandler(@Named("InvalidRealmNames") Set<String> invalidRealms, HttpAccessAuditFilterFactory httpAuditFactory) {
    invalidRealms.add(firstPathSegment("authenticate"));
    org.forgerock.http.routing.Router authenticateVersionRouter = new org.forgerock.http.routing.Router();
    Handler authenticateHandlerV1 = Endpoints.from(AuthenticationServiceV1.class);
    Handler authenticateHandlerV2 = Endpoints.from(AuthenticationServiceV2.class);
    authenticateVersionRouter.addRoute(RouteMatchers.requestResourceApiVersionMatcher(version(1, 1)), authenticateHandlerV1);
    authenticateVersionRouter.addRoute(RouteMatchers.requestResourceApiVersionMatcher(version(2)), authenticateHandlerV2);
    return chainOf(authenticateVersionRouter, httpAuditFactory.createFilter(AUTHENTICATION));
}
Also used : ConsoleConfigHandler(org.forgerock.openam.sm.config.ConsoleConfigHandler) SmsRequestHandler(org.forgerock.openam.core.rest.sms.SmsRequestHandler) Handler(org.forgerock.http.Handler) Inject(javax.inject.Inject) Named(javax.inject.Named) Provides(com.google.inject.Provides)

Example 53 with Provides

use of com.google.inject.Provides in project gerrit by GerritCodeReview.

the class MimeUtil2Module method provideMimeUtil2.

@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;
}
Also used : ExtensionMimeDetector(eu.medsea.mimeutil.detector.ExtensionMimeDetector) MagicMimeMimeDetector(eu.medsea.mimeutil.detector.MagicMimeMimeDetector) MimeUtil2(eu.medsea.mimeutil.MimeUtil2) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 54 with Provides

use of com.google.inject.Provides in project ratpack by ratpack.

the class ThymeleafModule method provideTemplateResolver.

@Provides
@Singleton
ITemplateResolver provideTemplateResolver(ServerConfig serverConfig, Config config) {
    IResourceResolver resourceResolver = new FileSystemBindingThymeleafResourceResolver(serverConfig.getBaseDir());
    TemplateResolver templateResolver = new TemplateResolver();
    templateResolver.setResourceResolver(resourceResolver);
    templateResolver.setTemplateMode(getTemplatesModeSetting(config));
    templateResolver.setPrefix(getTemplatesPrefixSetting(config));
    templateResolver.setSuffix(getTemplatesSuffixSetting(config));
    templateResolver.setCacheable(getCacheSizeSetting(config) > 0);
    // Never use TTL expiration
    templateResolver.setCacheTTLMs(null);
    return templateResolver;
}
Also used : IResourceResolver(org.thymeleaf.resourceresolver.IResourceResolver) FileSystemBindingThymeleafResourceResolver(ratpack.thymeleaf.internal.FileSystemBindingThymeleafResourceResolver) TemplateResolver(org.thymeleaf.templateresolver.TemplateResolver) ITemplateResolver(org.thymeleaf.templateresolver.ITemplateResolver) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 55 with Provides

use of com.google.inject.Provides in project ratpack by ratpack.

the class ThymeleafModule method provideTemplateEngine.

@Provides
@Singleton
TemplateEngine provideTemplateEngine(ITemplateResolver templateResolver, ICacheManager cacheManager, Set<IDialect> dialects) {
    final TemplateEngine templateEngine = new TemplateEngine();
    templateEngine.setTemplateResolver(templateResolver);
    templateEngine.setCacheManager(cacheManager);
    dialects.stream().forEach(templateEngine::addDialect);
    return templateEngine;
}
Also used : TemplateEngine(org.thymeleaf.TemplateEngine) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)126 Singleton (javax.inject.Singleton)36 AbstractModule (com.google.inject.AbstractModule)26 Singleton (com.google.inject.Singleton)24 Injector (com.google.inject.Injector)22 Named (javax.inject.Named)17 LazySingleton (io.druid.guice.LazySingleton)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 Named (com.google.inject.name.Named)8 IOException (java.io.IOException)7 File (java.io.File)6 ArrayList (java.util.ArrayList)6 Inject (javax.inject.Inject)6 Properties (java.util.Properties)5 Client (javax.ws.rs.client.Client)5 Test (org.junit.Test)5 Key (com.google.inject.Key)4 ExecutorService (java.util.concurrent.ExecutorService)4 ConfigModule (co.cask.cdap.common.guice.ConfigModule)3 Binder (com.google.inject.Binder)3