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");
}
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");
}
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");
}
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");
}
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);
}
});
}
Aggregations