Search in sources :

Example 1 with JerseyAnnotationDiscovery

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);
}
Also used : JaxbContextHelper(org.platformlayer.xaas.web.jaxrs.JaxbContextHelper) HttpStrategy(org.platformlayer.http.HttpStrategy) InstrumentedApacheHttpStrategy(org.platformlayer.http.apache.InstrumentedApacheHttpStrategy) PlatformlayerAuthenticationService(org.platformlayer.auth.system.PlatformlayerAuthenticationService) JAXBContext(javax.xml.bind.JAXBContext) ManagedItemRepository(org.platformlayer.xaas.repository.ManagedItemRepository) JdbcManagedItemRepository(org.platformlayer.guice.xaas.JdbcManagedItemRepository) OpsContext(org.platformlayer.ops.OpsContext) AnnotationServiceProviderDictionary(org.platformlayer.xaas.services.AnnotationServiceProviderDictionary) JobRepository(org.platformlayer.xaas.repository.JobRepository) JdbcJobRepository(org.platformlayer.ops.jobstore.jdbc.JdbcJobRepository) PlatformLayerClient(org.platformlayer.PlatformLayerClient) FreemarkerTemplateEngine(org.platformlayer.ops.templates.FreemarkerTemplateEngine) TemplateEngine(org.platformlayer.ops.templates.TemplateEngine) ResultSetMappersProvider(com.fathomdb.jpa.impl.ResultSetMappersProvider) PlatformLayerAuthenticationClientProvider(org.platformlayer.auth.client.PlatformLayerAuthenticationClientProvider) AnnotatedClass(org.platformlayer.xaas.discovery.AnnotatedClass) ItemService(org.platformlayer.ops.ItemService) SimpleOpsKeyStore(org.platformlayer.ops.crypto.SimpleOpsKeyStore) URLClassLoader(java.net.URLClassLoader) ISshContext(org.platformlayer.ops.ssh.ISshContext) EncryptionStore(com.fathomdb.crypto.EncryptionStore) JobLogStore(org.platformlayer.ops.jobstore.JobLogStore) FilesystemJobLogStore(org.platformlayer.ops.jobstore.FilesystemJobLogStore) ChangeQueue(org.platformlayer.xaas.services.ChangeQueue) InProcessChangeQueue(org.platformlayer.xaas.ops.InProcessChangeQueue) SimpleOperationQueue(org.platformlayer.ops.jobstore.SimpleOperationQueue) FilesystemJobLogStore(org.platformlayer.ops.jobstore.FilesystemJobLogStore) EncryptionStoreProvider(org.platformlayer.crypto.EncryptionStoreProvider) OpsContextProvider(org.platformlayer.ops.guice.OpsContextProvider) PlatformLayerAuthenticationClientProvider(org.platformlayer.auth.client.PlatformLayerAuthenticationClientProvider) ResultSetMappersProvider(com.fathomdb.jpa.impl.ResultSetMappersProvider) GuiceDataSourceProvider(org.platformlayer.jdbc.GuiceDataSourceProvider) JerseyAnnotationDiscovery(org.platformlayer.xaas.discovery.JerseyAnnotationDiscovery) AnnotationDiscovery(org.platformlayer.xaas.discovery.AnnotationDiscovery) PersistentJobRegistry(org.platformlayer.ops.jobstore.PersistentJobRegistry) JerseyAnnotationDiscovery(org.platformlayer.xaas.discovery.JerseyAnnotationDiscovery) URLClassLoader(java.net.URLClassLoader) ExecutorService(java.util.concurrent.ExecutorService) InstrumentedApacheHttpStrategy(org.platformlayer.http.apache.InstrumentedApacheHttpStrategy) BackupContextFactory(org.platformlayer.ops.backups.BackupContextFactory) StubBackupContextFactory(org.platformlayer.ops.backups.StubBackupContextFactory) File(java.io.File) GuiceObjectInjector(org.platformlayer.inject.GuiceObjectInjector) ObjectInjector(org.platformlayer.inject.ObjectInjector) FreemarkerTemplateEngine(org.platformlayer.ops.templates.FreemarkerTemplateEngine) JdbcServiceAuthorizationRepository(org.platformlayer.guice.xaas.JdbcServiceAuthorizationRepository) ServiceAuthorizationRepository(org.platformlayer.xaas.repository.ServiceAuthorizationRepository)

Aggregations

EncryptionStore (com.fathomdb.crypto.EncryptionStore)1 ResultSetMappersProvider (com.fathomdb.jpa.impl.ResultSetMappersProvider)1 File (java.io.File)1 URLClassLoader (java.net.URLClassLoader)1 ExecutorService (java.util.concurrent.ExecutorService)1 JAXBContext (javax.xml.bind.JAXBContext)1 PlatformLayerClient (org.platformlayer.PlatformLayerClient)1 PlatformLayerAuthenticationClientProvider (org.platformlayer.auth.client.PlatformLayerAuthenticationClientProvider)1 PlatformlayerAuthenticationService (org.platformlayer.auth.system.PlatformlayerAuthenticationService)1 EncryptionStoreProvider (org.platformlayer.crypto.EncryptionStoreProvider)1 JdbcManagedItemRepository (org.platformlayer.guice.xaas.JdbcManagedItemRepository)1 JdbcServiceAuthorizationRepository (org.platformlayer.guice.xaas.JdbcServiceAuthorizationRepository)1 HttpStrategy (org.platformlayer.http.HttpStrategy)1 InstrumentedApacheHttpStrategy (org.platformlayer.http.apache.InstrumentedApacheHttpStrategy)1 GuiceObjectInjector (org.platformlayer.inject.GuiceObjectInjector)1 ObjectInjector (org.platformlayer.inject.ObjectInjector)1 GuiceDataSourceProvider (org.platformlayer.jdbc.GuiceDataSourceProvider)1 ItemService (org.platformlayer.ops.ItemService)1 OpsContext (org.platformlayer.ops.OpsContext)1 BackupContextFactory (org.platformlayer.ops.backups.BackupContextFactory)1