use of com.google.inject.Provider in project camel by apache.
the class JndiContext method lookup.
public Object lookup(String name) throws NamingException {
if (name.length() == 0) {
return this;
}
Object result = treeBindings.get(name);
if (result == null) {
result = bindings.get(name);
}
if (result == null) {
int pos = name.indexOf(':');
if (pos > 0) {
String scheme = name.substring(0, pos);
Context ctx = NamingManager.getURLContext(scheme, environment);
if (ctx == null) {
throw new NamingException("scheme " + scheme + " not recognized");
}
return ctx.lookup(name);
} else {
// Split out the first name of the path
// and look for it in the bindings map.
CompositeName path = new CompositeName(name);
if (path.size() == 0) {
return this;
} else {
String first = path.get(0);
Object value = bindings.get(first);
if (value == null) {
throw new NameNotFoundException(name);
} else if (value instanceof Context && path.size() > 1) {
Context subContext = (Context) value;
value = subContext.lookup(path.getSuffix(1));
}
return value;
}
}
}
if (result instanceof Provider) {
Provider provider = (Provider) result;
result = provider.get();
}
if (result instanceof LinkRef) {
LinkRef ref = (LinkRef) result;
result = lookup(ref.getLinkName());
}
if (result instanceof Reference) {
try {
result = NamingManager.getObjectInstance(result, null, null, this.environment);
} catch (NamingException e) {
throw e;
} catch (Exception e) {
throw (NamingException) new NamingException("could not look up : " + name).initCause(e);
}
}
if (result instanceof JndiContext) {
String prefix = getNameInNamespace();
if (prefix.length() > 0) {
prefix = prefix + SEPARATOR;
}
result = new JndiContext((JndiContext) result, environment, prefix + name);
}
return result;
}
use of com.google.inject.Provider in project che by eclipse.
the class BootstrapController method startComponents.
private void startComponents(final Iterator<Map.Entry<String, Provider<Component>>> componentIterator) {
if (componentIterator.hasNext()) {
Map.Entry<String, Provider<Component>> entry = componentIterator.next();
final String componentName = entry.getKey();
try {
Provider<Component> componentProvider = entry.getValue();
final Component component = componentProvider.get();
component.start(new Callback<Component, Exception>() {
@Override
public void onSuccess(Component result) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
startComponents(componentIterator);
}
});
}
@Override
public void onFailure(Exception reason) {
Log.error(getClass(), "Unable to start " + componentName, reason);
initializationFailed(reason.getMessage());
}
});
} catch (Exception e) {
Log.error(getClass(), "Unable to start " + componentName, e);
initializationFailed(e.getMessage());
}
} else {
startExtensionsAndDisplayUI();
}
}
use of com.google.inject.Provider in project che by eclipse.
the class ImportProjectWizardPresenter method getWizardForImporter.
/** Creates or returns import wizard for the specified importer. */
private ImportWizard getWizardForImporter(@NotNull ProjectImporterDescriptor importer) {
if (wizardsCache.containsKey(importer)) {
return wizardsCache.get(importer);
}
final ImportWizardRegistrar wizardRegistrar = wizardRegistry.getWizardRegistrar(importer.getId());
if (wizardRegistrar == null) {
// should never occur
throw new IllegalStateException("WizardRegistrar for the importer " + importer.getId() + " isn't registered.");
}
List<Provider<? extends WizardPage<MutableProjectConfig>>> pageProviders = wizardRegistrar.getWizardPages();
final ImportWizard importWizard = createDefaultWizard();
for (Provider<? extends WizardPage<MutableProjectConfig>> provider : pageProviders) {
importWizard.addPage(provider.get(), 1, false);
}
wizardsCache.put(importer, importWizard);
return importWizard;
}
use of com.google.inject.Provider in project che by eclipse.
the class PomReconcilerTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
when(projectRegistryProvider.get()).thenReturn(projectRegistry);
MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
MavenTerminal terminal = new MavenTerminal() {
@Override
public void print(int level, String message, Throwable throwable) throws RemoteException {
System.out.println(message);
if (throwable != null) {
throwable.printStackTrace();
}
}
};
File localRepository = new File(new File("target/localRepo").getAbsolutePath());
localRepository.mkdirs();
mavenServerManager.setLocalRepository(localRepository);
MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
projectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
ClasspathManager classpathManager = new ClasspathManager(root.getAbsolutePath(), wrapperManager, projectManager, terminal, mavenNotifier);
mavenWorkspace = new MavenWorkspace(projectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {
@Override
public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
}
@Override
public void sendNotification(NotificationMessage message) {
System.out.println(message.toString());
}
@Override
public void send(JsonObject object, MessageType type) {
}
}, classpathManager, eventService, new EclipseWorkspaceProvider());
}
use of com.google.inject.Provider in project che by eclipse.
the class WorkspaceTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
when(projectRegistryProvider.get()).thenReturn(projectRegistry);
MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
MavenTerminal terminal = new MavenTerminal() {
@Override
public void print(int level, String message, Throwable throwable) throws RemoteException {
System.out.println(message);
if (throwable != null) {
throwable.printStackTrace();
}
}
};
MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
mavenProjectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
mavenWorkspace = new MavenWorkspace(mavenProjectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {
@Override
public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
}
@Override
public void sendNotification(NotificationMessage message) {
System.out.println(message.toString());
}
@Override
public void send(JsonObject object, MessageType type) {
}
}, new ClasspathManager(root.getAbsolutePath(), wrapperManager, mavenProjectManager, terminal, mavenNotifier), eventService, new EclipseWorkspaceProvider());
}
Aggregations