本文整理匯總了Java中com.google.inject.Injector.getInstance方法的典型用法代碼示例。如果您正苦於以下問題:Java Injector.getInstance方法的具體用法?Java Injector.getInstance怎麽用?Java Injector.getInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.inject.Injector
的用法示例。
在下文中一共展示了Injector.getInstance方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: SatisfyBaseStepListener
import com.google.inject.Injector; //導入方法依賴的package包/類
public SatisfyBaseStepListener(final File outputDirectory, Injector
injector) {
super(outputDirectory, injector);
this.proxyFactory = WebdriverProxyFactory.getFactory();
this.testOutcomes = Lists.newArrayList();
this.currentStepStack = new Stack<TestStep>();
this.currentGroupStack = new Stack<TestStep>();
this.outputDirectory = outputDirectory;
this.inFluentStepSequence = false;
this.storywideIssues = Lists.newArrayList();
this.storywideTags = Lists.newArrayList();
this.webdriverManager = injector.getInstance(WebdriverManager.class);
this.clock = injector.getInstance(SystemClock.class);
this.configuration = injector.getInstance(Configuration.class);
this.screenshotProcessor = injector.getInstance(ScreenshotProcessor
.class);
}
示例2: convertERDSLtoXMI
import com.google.inject.Injector; //導入方法依賴的package包/類
public static void convertERDSLtoXMI(String inputM, String outputM) {
Injector injector = new QueryITStandaloneSetup().createInjectorAndDoEMFRegistration();
XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
URI uri = URI.createURI(inputM);
Resource xtextResource = resourceSet.getResource(uri, true);
EcoreUtil.resolveAll(xtextResource);
Resource xmiResource = resourceSet.createResource(URI.createURI(outputM));
xmiResource.getContents().add(xtextResource.getContents().get(0));
try {
xmiResource.save(null);
System.out.println("Saved " + outputM);
System.out.println("QueryIT file converted successfully to XMI");
System.out.println("-------------------------------------");
} catch (IOException e) {
e.printStackTrace();
}
}
示例3: runTest
import com.google.inject.Injector; //導入方法依賴的package包/類
@Override
public void runTest() throws IOException {
/**
* record
* -d ./bromium-chrome/bromium-chrome-base/src/test/resources/chromedriver
* -a /home/hvrigazov/bromium-data/demo-app/configurations/demo.json
* -u http://localhost:3000
* -o bromium-core/src/test/resources/dynamic-testCase.json
*/
File outputFile = createTempFile(pathToTestCase);
opts.put(DRIVER, chromedriverFile.getAbsolutePath());
opts.put(APPLICATION, configurationFile.getAbsolutePath());
opts.put(URL, demoApp.getBaseUrl());
opts.put(OUTPUT, outputFile.getAbsolutePath());
opts.put(BROWSER, CHROME);
opts.put(TIMEOUT, String.valueOf(10));
opts.put(SCREEN, screen);
Module defaultModule = new DefaultModule(RECORD, opts);
Injector originalInjector = Guice.createInjector(defaultModule);
RecordingSimulatorModule recordingSimulatorModule = new RecordingSimulatorModule(originalInjector);
recordingSimulatorModule.whenPromptedForRecordingRunnable(this);
Injector injector = Guice.createInjector(Modules.override(defaultModule).with(recordingSimulatorModule));
stepsReader = injector.getInstance(Key.get(new TypeLiteral<IOProvider<StepsReader>>() {})).get();
RecordCommand recordCommand = injector.getInstance(RecordCommand.class);
recordCommand.run();
verifyAssertions();
}
示例4: register
import com.google.inject.Injector; //導入方法依賴的package包/類
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.eclipse.gw4e/dsl/DSLPolicies")) {
EPackage.Registry.INSTANCE.put("http://www.eclipse.gw4e/dsl/DSLPolicies", DSLPoliciesPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("policies", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("policies", serviceProvider);
}
示例5: createCompilerWithProperties
import com.google.inject.Injector; //導入方法依賴的package包/類
/**
* Construct a {@link N4HeadlessCompiler} with configuration based on the provided properties.
*
* @param properties
* preferences.
*/
public static N4HeadlessCompiler createCompilerWithProperties(Properties properties) {
Injector localinjector = new N4JSHeadlessStandaloneSetup(properties).createInjectorAndDoEMFRegistration();
N4HeadlessCompiler instance = localinjector.getInstance(N4HeadlessCompiler.class);
HeadlessExtensionRegistrationHelper headlessExtensionRegistrationHelper = localinjector
.getInstance(HeadlessExtensionRegistrationHelper.class);
headlessExtensionRegistrationHelper.registerExtensions();
return instance;
}
示例6: initUIPane
import com.google.inject.Injector; //導入方法依賴的package包/類
@PostConstruct
void initUIPane(BorderPane pane){
// configure application
Injector injector = Guice.createInjector(createModule());
domain = injector.getInstance(IDomain.class);
viewer = domain.getAdapter(AdapterKey.get(IViewer.class, IDomain.CONTENT_VIEWER_ROLE));
InfiniteCanvas canvas = (InfiniteCanvas)viewer.getCanvas();
pane.setCenter(canvas);
canvas.sceneProperty().addListener((observable, oldValue, newValue) -> {
if (canvas.getScene() != null) {
domain.activate();
}
});
}
示例7: updateControllerServiceTest
import com.google.inject.Injector; //導入方法依賴的package包/類
@Test
public void updateControllerServiceTest() throws InterruptedException {
Injector injector = Guice.createInjector(new AbstractModule() {
protected void configure() {
bind(ControllerServicesApi.class).toInstance(controllerServicesApiMock);
bind(Integer.class).annotatedWith(Names.named("timeout")).toInstance(1);
bind(Integer.class).annotatedWith(Names.named("interval")).toInstance(1);
bind(Boolean.class).annotatedWith(Names.named("forceMode")).toInstance(false);
}
});
ControllerServiceEntity controllerServiceDisabled = TestUtils.createControllerServiceEntity("id","name");
controllerServiceDisabled.getComponent().setState(ControllerServiceDTO.StateEnum.DISABLED);
ControllerServiceEntity controllerServiceEnabled = TestUtils.createControllerServiceEntity("id","name");
controllerServiceEnabled.getComponent().setState(ControllerServiceDTO.StateEnum.ENABLED);
ControllerServiceEntity controllerService = TestUtils.createControllerServiceEntity("id","name");
when(controllerServicesApiMock.getControllerService("id")).thenReturn(controllerServiceDisabled).thenReturn(controllerServiceEnabled);
when(controllerServicesApiMock.updateControllerService(eq("id"), any()))
.thenReturn(controllerServiceDisabled)
.thenReturn(controllerService)
.thenReturn(controllerServiceEnabled);
ControllerServicesService controllerServicesService = injector.getInstance(ControllerServicesService.class);
ControllerServiceDTO component = new ControllerServiceDTO();
component.getProperties().put("key", "value");
controllerServicesService.updateControllerService(component, controllerService, false);
ArgumentCaptor<ControllerServiceEntity> controllerServiceCapture = ArgumentCaptor.forClass(ControllerServiceEntity.class);
verify(controllerServicesApiMock, times(1)).updateControllerService(eq("id"),controllerServiceCapture.capture());
// assertEquals("id", controllerServiceCapture.getAllValues().get(0).getComponent().getId());
// assertEquals(ControllerServiceDTO.StateEnum.DISABLED, controllerServiceCapture.getAllValues().get(0).getComponent().getState());
assertEquals("id", controllerServiceCapture.getAllValues().get(0).getComponent().getId());
assertEquals("value", controllerServiceCapture.getAllValues().get(0).getComponent().getProperties().get("key"));
// assertEquals("id", controllerServiceCapture.getAllValues().get(2).getComponent().getId());
// assertEquals(ControllerServiceDTO.StateEnum.ENABLED, controllerServiceCapture.getAllValues().get(2).getComponent().getState());
}
示例8: getEurekaClient
import com.google.inject.Injector; //導入方法依賴的package包/類
private EurekaClient getEurekaClient(){
if (eurekaClient==null){
LifecycleInjectorBuilder builder = LifecycleInjector.builder();
Injector injector = builder.build().createInjector();
eurekaClient = injector.getInstance(EurekaClient.class);
}
return eurekaClient;
}
示例9: register
import com.google.inject.Injector; //導入方法依賴的package包/類
public void register(Injector injector) {
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("n4js", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("n4js", serviceProvider);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("n4jsx", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("n4jsx", serviceProvider);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("js", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("js", serviceProvider);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("jsx", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("jsx", serviceProvider);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("n4jsd", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("n4jsd", serviceProvider);
}
示例10: register
import com.google.inject.Injector; //導入方法依賴的package包/類
public void register(Injector injector) {
if (!EPackage.Registry.INSTANCE.containsKey("http://www.xtext.org/example/mydsl/MyDsl")) {
EPackage.Registry.INSTANCE.put("http://www.xtext.org/example/mydsl/MyDsl", MyDslPackage.eINSTANCE);
}
IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("mensa", resourceFactory);
IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("mensa", serviceProvider);
}
示例11: testControllerIndex
import com.google.inject.Injector; //導入方法依賴的package包/類
@Test
public void testControllerIndex() {
Injector injector = WebAppTests.createMockInjector(TestRMWebApp.class,
this, new Module() {
@Override
public void configure(Binder binder) {
binder.bind(ApplicationACLsManager.class).toInstance(
new ApplicationACLsManager(new Configuration()));
}
});
RmController c = injector.getInstance(RmController.class);
c.index();
assertEquals("Applications", c.get(TITLE, "unknown"));
}
示例12: runGUIMode
import com.google.inject.Injector; //導入方法依賴的package包/類
/**
* Run Marathon in GUI mode with all bells and whistles.
*
* @param licensee
*/
private static void runGUIMode() {
showSplash();
String projectDir = getProjectDirectory(argProcessor.getProjectDirectory());
if (projectDir == null) {
System.exit(0);
}
processMPF(projectDir, false);
initializeInjector();
OSUtils.setLogConfiguration(projectDir);
Injector injector = GuiceInjector.get();
final DisplayWindow display = injector.getInstance(DisplayWindow.class);
display.setVisible(true);
}
示例13: waitEmptyQueueForceTest
import com.google.inject.Injector; //導入方法依賴的package包/類
@Test
public void waitEmptyQueueForceTest() throws ApiException, IOException, URISyntaxException {
Injector injector = Guice.createInjector(new AbstractModule() {
protected void configure() {
bind(ConnectionsApi.class).toInstance(connectionsApiMock);
bind(FlowfileQueuesApi.class).toInstance(flowfileQueuesApiMock);
bind(Integer.class).annotatedWith(Names.named("timeout")).toInstance(1);
bind(Integer.class).annotatedWith(Names.named("interval")).toInstance(1);
bind(Boolean.class).annotatedWith(Names.named("forceMode")).toInstance(true);
}
});
ConnectionService connectionService = injector.getInstance(ConnectionService.class);
ConnectionEntity connection = TestUtils.createConnectionEntity("id","sourceId","destinationId");
connection.setStatus(new ConnectionStatusDTO());
connection.getStatus().setAggregateSnapshot(new ConnectionStatusSnapshotDTO());
connection.getStatus().getAggregateSnapshot().setQueuedCount("1");
connection.getStatus().getAggregateSnapshot().setQueuedSize("0");
when(connectionsApiMock.getConnection("id")).thenReturn(connection);
DropRequestEntity dropRequest = new DropRequestEntity();
dropRequest.setDropRequest(new DropRequestDTO());
dropRequest.getDropRequest().setId("idDrop");
dropRequest.getDropRequest().setFinished(true);
when(flowfileQueuesApiMock.createDropRequest("id")).thenReturn(dropRequest);
when(flowfileQueuesApiMock.getDropRequest("id", dropRequest.getDropRequest().getId())).thenReturn(dropRequest);
when(flowfileQueuesApiMock.removeDropRequest("id", dropRequest.getDropRequest().getId())).thenReturn(dropRequest);
connectionService.waitEmptyQueue(connection);
}
示例14: initApplicationScoped
import com.google.inject.Injector; //導入方法依賴的package包/類
private static void initApplicationScoped()
{
Injector injector = getInjector();
for (Key<?> key : DwrScopes.APPLICATION.getKeysInScope())
{
// Eagerly create application-scoped object.
injector.getInstance(key);
}
}
示例15: testRollback
import com.google.inject.Injector; //導入方法依賴的package包/類
public void testRollback() throws Exception {
Injector injector = Guice.createInjector(new TestModule());
TestDao2 dao = injector.getInstance(TestDao2.class);
try {
dao.getCount();
fail();
} catch(RuntimeException ignored){
}
verify(session, times(1)).begin();
verify(session, times(1)).rollback();
verify(session, never()).commit();
}