use of org.platformlayer.xaas.discovery.JerseyAnnotationDiscovery in project platformlayer by platformlayer.
the class GuiceXaasConfig method configure.
@Override
protected void configure() {
bind(EncryptionStore.class).toProvider(EncryptionStoreProvider.class);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
FreemarkerTemplateEngine freemarker = new FreemarkerTemplateEngine(classLoader);
bind(TemplateEngine.class).toInstance(freemarker);
bind(ItemService.class).to(ItemServiceImpl.class);
bind(ISshContext.class).to(MinaSshContext.class);
bind(OpsSystem.class);
bind(OpsContext.class).toProvider(OpsContextProvider.class);
bind(JobRegistry.class).to(PersistentJobRegistry.class).asEagerSingleton();
File jobLogStoreBaseDir = new File("jobs");
jobLogStoreBaseDir.mkdirs();
bind(JobLogStore.class).toInstance(new FilesystemJobLogStore(jobLogStoreBaseDir));
// TODO: Split off scheduler
bind(ResultSetMappersProvider.class).asEagerSingleton();
bind(ResultSetMappers.class).toProvider(ResultSetMappersProvider.class).in(Scopes.SINGLETON);
bind(DataSource.class).toProvider(GuiceDataSourceProvider.bind("platformlayer.jdbc.")).asEagerSingleton();
URLClassLoader urlClassLoader = (URLClassLoader) Thread.currentThread().getContextClassLoader();
JerseyAnnotationDiscovery discovery = new JerseyAnnotationDiscovery();
discovery.scan(urlClassLoader);
bind(AnnotationDiscovery.class).toInstance(discovery);
for (AnnotatedClass annotatedClass : discovery.findAnnotatedClasses(org.platformlayer.xaas.Module.class)) {
Class<?> moduleClass = annotatedClass.getSubjectClass();
log.info("Installing extension module: " + moduleClass);
com.google.inject.Module module;
try {
module = (com.google.inject.Module) moduleClass.newInstance();
} catch (InstantiationException e) {
throw new IllegalStateException("Error creating class: " + moduleClass, e);
} catch (IllegalAccessException e) {
throw new IllegalStateException("Error creating class: " + moduleClass, e);
}
this.install(module);
}
HttpStrategy httpStrategy = new InstrumentedApacheHttpStrategy();
bind(HttpStrategy.class).toInstance(httpStrategy);
bind(AuthenticationTokenValidator.class).toProvider(PlatformLayerAuthAdminClient.Provider.class).in(Scopes.SINGLETON);
// boolean isMultitenant = !Strings.isNullOrEmpty(configuration.lookup("multitenant.keys", null));
if (true) {
// isMultitenant) {
bind(PlatformLayerAuthenticationClient.class).toProvider(PlatformLayerAuthenticationClientProvider.class).asEagerSingleton();
bind(AuthenticationService.class).to(PlatformlayerAuthenticationService.class).asEagerSingleton();
}
bind(BackupContextFactory.class).to(StubBackupContextFactory.class);
bind(ExecutorService.class).toInstance(Executors.newCachedThreadPool());
bind(ServiceProviderDictionary.class).to(AnnotationServiceProviderDictionary.class).in(Scopes.SINGLETON);
bind(JaxbContextHelper.class).asEagerSingleton();
bind(JAXBContext.class).toProvider(JaxbContextHelper.class);
bind(OperationQueue.class).to(SimpleOperationQueue.class).asEagerSingleton();
bind(ObjectInjector.class).to(GuiceObjectInjector.class);
bind(OpsKeyStore.class).to(SimpleOpsKeyStore.class).in(Scopes.SINGLETON);
bind(JobRepository.class).to(JdbcJobRepository.class);
bind(ManagedItemRepository.class).to(JdbcManagedItemRepository.class);
bind(ServiceAuthorizationRepository.class).to(JdbcServiceAuthorizationRepository.class);
bind(ChangeQueue.class).to(InProcessChangeQueue.class);
bind(PlatformLayerClient.class).toProvider(PlatformLayerClientProvider.class);
}
Aggregations