@Override protected void configure() { bind(BeanFactory.class).toInstance(SpringContextHolder.getApplicationContext()); bind(UserDao.class).toProvider(SpringIntegration.fromSpring(UserDao.class, "UserDao")); bind(WorkspaceDao.class).toProvider(SpringIntegration.fromSpring(AdaptiveWorkspaceDao.class,"adaptiveWorkspaceDao")); bind(UserProfileDao.class).toProvider(SpringIntegration.fromSpring(AdaptiveProfileDao.class,"adaptiveProfileDao")); bind(PreferenceDao.class).toProvider(SpringIntegration.fromSpring(AdaptivePreferenceDao.class, "adaptivePreferenceDao")); //TODO find a batter way Multibinder<SubscriptionService> multiBinder = Multibinder.newSetBinder(binder(), SubscriptionService.class); Map<String, SubscriptionService> services = SpringContextHolder.getApplicationContext().getBeansOfType(SubscriptionService.class); services.entrySet().forEach(entry -> multiBinder.addBinding().toInstance(entry.getValue())); bind(MemberDao.class).toProvider(SpringIntegration.fromSpring(WorkspaceMemberDao.class, "workspaceMemberDao")); bind(ResourcesManager.class).toProvider(SpringIntegration.fromSpring(AdaptiveResourcesManager.class, "adaptiveResourcesManager")); bind(PlanDao.class).toProvider(SpringIntegration.fromSpring(AdaptivePlanDao.class, "adaptivePlanDao")); bind(AccountDao.class).toProvider(SpringIntegration.fromSpring(AccountDao.class, "AccountDao")); bind(AuthenticationDao.class).toProvider(SpringIntegration.fromSpring(AdaptiveAuthenticationDao.class,"adaptiveAuthenticationDao")); bind(FactoryStore.class).to(InMemoryFactoryStore.class); bind(TokenValidator.class).toProvider(SpringIntegration.fromSpring(AdaptiveTokenValidator.class, "adaptiveTokenValidator")); SpringIntegration.bindAll(binder(), SpringContextHolder.getApplicationContext()); }
/** * This method is provided to execute some custom plugin configuration stuff. Is is the place * to execute Google Guice bindings,etc if needed. */ @Override protected void configurePlugin() { ClassPathXmlApplicationContext ctx = getApplicationContext(); //Make all instances managed by Spring known to Guice SpringIntegration.bindAll(binder(), ctx.getBeanFactory()); //Make Spring's ApplicationContext known to Guice bind(ApplicationContext.class).toInstance(ctx); //Tell Guice to inject into the StartCallback instance, which is managed by Spring requestInjection(ctx.getBeanFactory().getBean("startCallback")); }
@Override protected void configure() { bind(BeanFactory.class).toInstance(appContext.getAutowireCapableBeanFactory()); bind(AccountService.class).toProvider(SpringIntegration.fromSpring(AccountService.class, "httpInvokerProxy")); }
@Override protected void configure() { bind(ApiExceptionMapper.class); bind(ApiInfoService.class); bind(AuthenticationService.class); bind(WorkspaceService.class); bind(ProjectService.class); bind(AccountService.class); //TODO Implement Account/Subscription/Plan bind(ETagResponseFilter.class); bind(UserService.class); bind(UserRegistrationService.class).toProvider(SpringIntegration.fromSpring(UserRegistrationService.class, "userRegistrationService")); bind(RegistrationService.class); bind(MetricsModule.class); bind(UserProfileService.class); bind(VirtualFileSystemRegistry.class).to(AutoMountVirtualFileSystemRegistry.class); //Important it will create automatically a workspace folder upon workspace creation bind(LocalFSMountStrategy.class).toProvider(SpringIntegration.fromSpring(WorkspaceIdLocalFSMountStrategy.class, "workspaceIdLocalFSMountStrategy")); //bind(WorkspaceToDirectoryMappingService.class); bind(BuilderSelectionStrategy.class).to(LastInUseBuilderSelectionStrategy.class); bind(BuilderService.class); bind(BuildQueue.class).to(AdaptiveBuildQueue.class); //bind(BuilderAdminService.class); //bind(SlaveBuilderService.class); //bind(RunnerSelectionStrategy.class).to(LastInUseRunnerSelectionStrategy.class); //bind(RunnerService.class); //bind(RunnerAdminService.class); //bind(SlaveRunnerService.class); //bind(DebuggerService.class); //bind(FormatService.class); //bind(KeyService.class); //bind(SshKeyStore.class).to(UserProfileSshKeyStore.class); //bind(OAuthAuthenticationService.class); //bind(OAuthTokenProvider.class).to(OAuthAuthenticatorTokenProvider.class); //bind(OAuthAuthenticatorProvider.class).to(OAuthAuthenticatorProviderImpl.class); //bind(RestNameEnvironment.class); //bind(JavadocService.class); //bind(JavaNavigationService.class); bind(AsynchronousJobPool.class).to(CodenvyAsynchronousJobPool.class); bind(new PathKey<>(AsynchronousJobService.class, "/async/{ws-id}")).to(AsynchronousJobService.class); //install(new ArchetypeGeneratorModule()); install(new CoreRestModule()); install(new AnalyticsModule()); install(new BaseProjectModule()); install(new BuilderModule()); install(new RunnerModule()); install(new VirtualFileSystemModule()); install(new VirtualFileSystemFSModule()); install(new FactoryModule()); install(new DocsModule()); }
@Override protected void configureServlets() { getServletContext().addListener(new WSConnectionTracker()); bind(AdaptiveEnvironmentFilter.class) .toProvider(SpringIntegration.fromSpring(AdaptiveEnvironmentFilter.class, "adaptiveEnvironmentFilter")) .in(Singleton.class); Filter corsFilter = getCORSFilter(); filter("/*").through(corsFilter); //TODO remove this filter in PRODUCTION filter("/*").through(AdaptiveEnvironmentFilter.class); serve("/api/ws/*").with(CodenvyEverrestWebSocketServlet.class); serve("/api/*").with(GuiceEverrestServlet.class); }
@Override protected void configure() { //bind the application context to our guice instance final BeanFactory beanFactory = applicationContext.getAutowireCapableBeanFactory(); bind( BeanFactory.class).toInstance( beanFactory); //create our bridge and put the EMF into guice. Ultimately all spring needs removed and we need to just use guice final Provider<EntityManagerFactory> emfProvider = SpringIntegration.fromSpring( EntityManagerFactory.class, "entityManagerFactory" ); bind( EntityManagerFactory.class ).toProvider( emfProvider ); final Provider<QueueManagerFactory> qmfProvider = SpringIntegration.fromSpring( QueueManagerFactory.class, "queueManagerFactory" ); bind( QueueManagerFactory.class ).toProvider( qmfProvider ); }