Search in sources :

Example 1 with PrivateModule

use of com.google.inject.PrivateModule in project guice by google.

the class ModuleAnnotatedMethodScannerTest method testPrivateModule_skipSourcesForPrivateModule.

public void testPrivateModule_skipSourcesForPrivateModule() {
    Injector injector = Guice.createInjector(NamedMunger.module(), new AbstractModule() {

        @Override
        protected void configure() {
            binder().skipSources(getClass()).install(new PrivateModule() {

                @Override
                protected void configure() {
                }

                @Exposed
                @TestProvides
                @Named("foo")
                String foo() {
                    return "foo";
                }
            });
        }
    });
    assertMungedBinding(injector, String.class, "foo", "foo");
}
Also used : Injector(com.google.inject.Injector) PrivateModule(com.google.inject.PrivateModule) AbstractModule(com.google.inject.AbstractModule)

Example 2 with PrivateModule

use of com.google.inject.PrivateModule in project guice by google.

the class ModuleAnnotatedMethodScannerTest method testPrivateModule_skipSourcesWithinPrivateModule.

public void testPrivateModule_skipSourcesWithinPrivateModule() {
    Injector injector = Guice.createInjector(NamedMunger.module(), new PrivateModule() {

        @Override
        protected void configure() {
            binder().skipSources(getClass()).install(new AbstractModule() {

                @Override
                protected void configure() {
                }

                @Exposed
                @TestProvides
                @Named("foo")
                String foo() {
                    return "foo";
                }
            });
        }
    });
    assertMungedBinding(injector, String.class, "foo", "foo");
}
Also used : Injector(com.google.inject.Injector) PrivateModule(com.google.inject.PrivateModule) AbstractModule(com.google.inject.AbstractModule)

Example 3 with PrivateModule

use of com.google.inject.PrivateModule in project guice by google.

the class ModuleAnnotatedMethodScannerTest method testPrivateModuleInheritScanner_usingPrivateModule.

public void testPrivateModuleInheritScanner_usingPrivateModule() {
    Injector injector = Guice.createInjector(NamedMunger.module(), new PrivateModule() {

        @Override
        protected void configure() {
        }

        @Exposed
        @TestProvides
        @Named("foo")
        String foo() {
            return "foo";
        }
    });
    assertMungedBinding(injector, String.class, "foo", "foo");
}
Also used : Exposed(com.google.inject.Exposed) Named(com.google.inject.name.Named) Injector(com.google.inject.Injector) PrivateModule(com.google.inject.PrivateModule)

Example 4 with PrivateModule

use of com.google.inject.PrivateModule in project guice by google.

the class ModuleAnnotatedMethodScannerTest method testPrivateModuleScannersDontImpactSiblings_usingPrivateModule.

public void testPrivateModuleScannersDontImpactSiblings_usingPrivateModule() {
    Injector injector = Guice.createInjector(new PrivateModule() {

        @Override
        protected void configure() {
            install(NamedMunger.module());
        }

        @Exposed
        @TestProvides
        @Named("foo")
        String foo() {
            return "foo";
        }
    }, new PrivateModule() {

        @Override
        protected void configure() {
        }

        // ignored! (because the scanner doesn't run over this module)
        @Exposed
        @TestProvides
        @Named("foo")
        String foo() {
            return "foo";
        }
    });
    assertMungedBinding(injector, String.class, "foo", "foo");
}
Also used : Exposed(com.google.inject.Exposed) Named(com.google.inject.name.Named) Injector(com.google.inject.Injector) PrivateModule(com.google.inject.PrivateModule)

Example 5 with PrivateModule

use of com.google.inject.PrivateModule in project xtext-eclipse by eclipse.

the class SharedModule method configure.

@SuppressWarnings("deprecation")
@Override
protected void configure() {
    // binder().requireExplicitBindings();
    if (context != null)
        bind(BundleContext.class).toInstance(context);
    bind(IBuilderState.class).to(ClusteringBuilderState.class).in(Scopes.SINGLETON);
    bind(IResourceDescriptions.class).to(DirtyStateAwareResourceDescriptions.class).in(Scopes.SINGLETON);
    bind(IResourceServiceProvider.Registry.class).toInstance(IResourceServiceProvider.Registry.INSTANCE);
    binder().install(new PrivateModule() {

        @Override
        protected void configure() {
            bind(IResourceSetProvider.class).to(XtextResourceSetProvider.class);
            bind(XtextResourceSet.class).to(SynchronizedXtextResourceSet.class);
            expose(IResourceSetProvider.class);
        }
    });
    bind(IExtensionRegistry.class).toInstance(Platform.getExtensionRegistry());
    bind(BuildScheduler.class);
    bind(ToBeBuiltComputer.class);
    bind(IExternalContentSupport.IExternalContentProvider.class).to(IDirtyStateManager.class).in(Scopes.SINGLETON);
    bind(IDirtyStateManager.class).to(DirtyStateManager.class).in(Scopes.SINGLETON);
    bind(IStateChangeEventBroker.class).to(StateChangeEventBroker.class).in(Scopes.SINGLETON);
    bind(IncrementalProjectBuilder.class).to(XtextBuilder.class);
    bind(IStorage2UriMapper.class).to(IStorage2UriMapperExtension.class);
    bind(IStorage2UriMapperExtension.class).to(Storage2UriMapperImpl.class).in(Scopes.SINGLETON);
    binder().install(new PrivateModule() {

        @Override
        protected void configure() {
            bind(ITraceForURIProvider.class).to(ITraceForStorageProvider.class);
            bind(ITraceForStorageProvider.class).to(TraceForStorageProvider.class);
            bind(ITraceURIConverter.class).to(DefaultTraceURIConverter.class);
            bind(TraceFileNameProvider.class);
            bind(TraceMarkers.class);
            bind(TraceRegionSerializer.class);
            bind(StorageAwareTrace.class);
            expose(TraceFileNameProvider.class);
            expose(ITraceForURIProvider.class);
            expose(ITraceURIConverter.class);
            expose(ITraceForStorageProvider.class);
            expose(StorageAwareTrace.class);
        }
    });
    bind(EclipseProjectConfigProvider.class);
    bind(IWorkbench.class).toProvider(new Provider<IWorkbench>() {

        @Override
        public IWorkbench get() {
            if (PlatformUI.isWorkbenchRunning())
                return PlatformUI.getWorkbench();
            return null;
        }
    });
    bind(IWorkspace.class).toProvider(new Provider<IWorkspace>() {

        @Override
        public IWorkspace get() {
            return ResourcesPlugin.getWorkspace();
        }
    });
    bind(IJdtHelper.class).to(JdtHelper.class).asEagerSingleton();
    bind(WorkspaceProjectsStateHelper.class);
    bind(QueuedBuildData.class);
    bind(UriValidator.class);
    bind(ISharedStateContributionRegistry.class).to(SharedStateContributionRegistryImpl.class);
    boolean parallel = false;
    if (parallel) {
        bind(IResourceLoader.class).toProvider(ResourceLoaderProviders.getParallelLoader());
        bind(IResourceLoader.class).annotatedWith(Names.named(ClusteringBuilderState.RESOURCELOADER_GLOBAL_INDEX)).toProvider(ResourceLoaderProviders.getParallelLoader());
        bind(IResourceLoader.class).annotatedWith(Names.named(ClusteringBuilderState.RESOURCELOADER_CROSS_LINKING)).toProvider(ResourceLoaderProviders.getParallelLoader());
    } else {
        bind(IResourceLoader.class).toProvider(ResourceLoaderProviders.getSerialLoader());
        bind(IResourceLoader.class).annotatedWith(Names.named(ClusteringBuilderState.RESOURCELOADER_GLOBAL_INDEX)).toProvider(ResourceLoaderProviders.getSerialLoader());
        bind(IResourceLoader.class).annotatedWith(Names.named(ClusteringBuilderState.RESOURCELOADER_CROSS_LINKING)).toProvider(ResourceLoaderProviders.getSerialLoader());
    }
    bind(IMarkerUpdater.class);
    bind(PersistedStateProvider.class);
    bind(org.eclipse.xtext.resource.clustering.IResourceClusteringPolicy.class).to(org.eclipse.xtext.builder.clustering.IResourceClusteringPolicy.class);
    bind(org.eclipse.xtext.builder.clustering.IResourceClusteringPolicy.class);
    bind(CompilerPhases.class);
    bind(RegistryBuilderParticipant.class);
    bind(IResourceLoader.Sorter.class);
    bind(IURIEditorOpener.class);
    bind(OpenXtextElementHandler.class);
    bind(GlobalDescriptionLabelProvider.class);
    bind(IXtextEObjectSearch.class);
    binder().install(new PrivateModule() {

        @Override
        protected void configure() {
            bind(ReferenceSearchViewPage.class);
            bind(ReferenceSearchResultLabelProvider.class);
            bind(ReferenceSearchResultContentProvider.class);
            bind(ReferenceSearchViewSorter.class);
            expose(ReferenceSearchViewPage.class);
        }
    });
}
Also used : ReferenceSearchResultLabelProvider(org.eclipse.xtext.ui.editor.findrefs.ReferenceSearchResultLabelProvider) JdtHelper(org.eclipse.xtext.ui.shared.JdtHelper) IJdtHelper(org.eclipse.xtext.ui.util.IJdtHelper) ReferenceSearchResultContentProvider(org.eclipse.xtext.ui.editor.findrefs.ReferenceSearchResultContentProvider) IExternalContentSupport(org.eclipse.xtext.resource.IExternalContentSupport) ReferenceSearchViewPage(org.eclipse.xtext.ui.editor.findrefs.ReferenceSearchViewPage) DirtyStateAwareResourceDescriptions(org.eclipse.xtext.builder.impl.DirtyStateAwareResourceDescriptions) IDirtyStateManager(org.eclipse.xtext.ui.editor.IDirtyStateManager) TraceFileNameProvider(org.eclipse.xtext.generator.trace.TraceFileNameProvider) DirtyStateManager(org.eclipse.xtext.ui.editor.DirtyStateManager) IDirtyStateManager(org.eclipse.xtext.ui.editor.IDirtyStateManager) ClusteringBuilderState(org.eclipse.xtext.builder.clustering.ClusteringBuilderState) TraceMarkers(org.eclipse.xtext.ui.generator.trace.TraceMarkers) IStorage2UriMapper(org.eclipse.xtext.ui.resource.IStorage2UriMapper) ITraceForStorageProvider(org.eclipse.xtext.ui.generator.trace.ITraceForStorageProvider) TraceRegionSerializer(org.eclipse.xtext.generator.trace.TraceRegionSerializer) IResourceLoader(org.eclipse.xtext.builder.resourceloader.IResourceLoader) ITraceURIConverter(org.eclipse.xtext.generator.trace.ITraceURIConverter) PrivateModule(com.google.inject.PrivateModule) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) ITraceForStorageProvider(org.eclipse.xtext.ui.generator.trace.ITraceForStorageProvider) TraceForStorageProvider(org.eclipse.xtext.ui.generator.trace.TraceForStorageProvider) IncrementalProjectBuilder(org.eclipse.core.resources.IncrementalProjectBuilder) DefaultTraceURIConverter(org.eclipse.xtext.generator.trace.DefaultTraceURIConverter) ISharedStateContributionRegistry(org.eclipse.xtext.ui.shared.contribution.ISharedStateContributionRegistry) XtextResourceSetProvider(org.eclipse.xtext.ui.resource.XtextResourceSetProvider) SynchronizedXtextResourceSet(org.eclipse.xtext.resource.SynchronizedXtextResourceSet) StorageAwareTrace(org.eclipse.xtext.ui.generator.trace.StorageAwareTrace) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) ISharedStateContributionRegistry(org.eclipse.xtext.ui.shared.contribution.ISharedStateContributionRegistry) IWorkbench(org.eclipse.ui.IWorkbench) IStateChangeEventBroker(org.eclipse.xtext.ui.notification.IStateChangeEventBroker) StateChangeEventBroker(org.eclipse.xtext.ui.notification.StateChangeEventBroker) ITraceForURIProvider(org.eclipse.xtext.generator.trace.ITraceForURIProvider) Storage2UriMapperImpl(org.eclipse.xtext.ui.resource.Storage2UriMapperImpl) IWorkspace(org.eclipse.core.resources.IWorkspace) ReferenceSearchViewSorter(org.eclipse.xtext.ui.editor.findrefs.ReferenceSearchViewSorter) IResourceSetProvider(org.eclipse.xtext.ui.resource.IResourceSetProvider)

Aggregations

PrivateModule (com.google.inject.PrivateModule)39 Injector (com.google.inject.Injector)26 AbstractModule (com.google.inject.AbstractModule)21 Module (com.google.inject.Module)11 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)10 Test (org.junit.Test)9 Named (com.google.inject.name.Named)8 Guice.createInjector (com.google.inject.Guice.createInjector)6 DatasetDefinitionRegistry (co.cask.cdap.api.dataset.module.DatasetDefinitionRegistry)5 ConfigModule (co.cask.cdap.common.guice.ConfigModule)5 DefaultDatasetDefinitionRegistry (co.cask.cdap.data2.dataset2.DefaultDatasetDefinitionRegistry)5 Exposed (com.google.inject.Exposed)5 Key (com.google.inject.Key)5 DatasetFramework (co.cask.cdap.data2.dataset2.DatasetFramework)4 Binding (com.google.inject.Binding)4 Singleton (com.google.inject.Singleton)4 Element (com.google.inject.spi.Element)4 CConfiguration (co.cask.cdap.common.conf.CConfiguration)3 AuthorizationDatasetTypeService (co.cask.cdap.data2.datafabric.dataset.service.AuthorizationDatasetTypeService)3 DatasetService (co.cask.cdap.data2.datafabric.dataset.service.DatasetService)3