use of com.google.inject.Singleton in project joynr by bmwcarit.
the class EhcacheModule method getCacheManager.
@Provides
@Singleton
CacheManager getCacheManager(@Named(BounceProxyEhcacheAdapter.PROPERTY_BP_CACHE_CONFIGURATION) String cacheConfigFileName) {
log.info("Using ehcache config file: {}", cacheConfigFileName);
URL cacheConfigFileUrl = getClass().getResource("/" + cacheConfigFileName);
if (cacheConfigFileUrl == null) {
log.error("No resource with filename found on classpath: {}. Using default CacheManager", cacheConfigFileName);
return CacheManager.newInstance();
} else {
return CacheManager.newInstance(cacheConfigFileUrl);
}
}
use of com.google.inject.Singleton in project incubator-myriad by apache.
the class MesosModule method providesSchedulerDriver.
@Provides
@Singleton
SchedulerDriver providesSchedulerDriver(MyriadScheduler scheduler, MyriadConfiguration cfg, SchedulerState schedulerState) {
Builder frameworkInfoBuilder = FrameworkInfo.newBuilder().setUser("").setName(cfg.getFrameworkName()).setCheckpoint(cfg.isCheckpoint()).setFailoverTimeout(cfg.getFrameworkFailoverTimeout());
frameworkInfoBuilder.setRole(cfg.getFrameworkRole());
Optional<FrameworkID> optFrameId = schedulerState.getFrameworkID();
if (optFrameId.isPresent()) {
FrameworkID frameworkId = optFrameId.get();
LOGGER.info("Attempting to re-register with frameworkId: {}", frameworkId.getValue());
frameworkInfoBuilder.setId(frameworkId);
}
String mesosAuthenticationPrincipal = cfg.getMesosAuthenticationPrincipal();
String mesosAuthenticationSecretFilename = cfg.getMesosAuthenticationSecretFilename();
if (StringUtils.isNotEmpty(mesosAuthenticationPrincipal)) {
frameworkInfoBuilder.setPrincipal(mesosAuthenticationPrincipal);
Credential.Builder credentialBuilder = Credential.newBuilder();
credentialBuilder.setPrincipal(mesosAuthenticationPrincipal);
if (StringUtils.isNotEmpty(mesosAuthenticationSecretFilename)) {
try {
credentialBuilder.setSecretBytes(ByteString.readFrom(new FileInputStream(mesosAuthenticationSecretFilename)));
} catch (FileNotFoundException ex) {
LOGGER.error("Mesos authentication secret file was not found", ex);
throw new RuntimeException(ex);
} catch (IOException ex) {
LOGGER.error("Error reading Mesos authentication secret file", ex);
throw new RuntimeException(ex);
}
}
return new MesosSchedulerDriver(scheduler, frameworkInfoBuilder.build(), cfg.getMesosMaster(), credentialBuilder.build());
} else {
return new MesosSchedulerDriver(scheduler, frameworkInfoBuilder.build(), cfg.getMesosMaster());
}
}
use of com.google.inject.Singleton in project ovirt-engine by oVirt.
the class StorageModule method getStorageDataCenterListProvider.
// Searchable Detail Models
@Provides
@Singleton
public SearchableDetailModelProvider<StorageDomain, StorageListModel, StorageDataCenterListModel> getStorageDataCenterListProvider(EventBus eventBus, Provider<DefaultConfirmationPopupPresenterWidget> defaultConfirmPopupProvider, final Provider<FindSingleDcPopupPresenterWidget> singlePopupProvider, final Provider<FindMultiDcPopupPresenterWidget> multiPopupProvider, final Provider<RemoveConfirmationPopupPresenterWidget> removeConfirmPopupProvider, final Provider<StorageListModel> mainModelProvider, final Provider<StorageDataCenterListModel> modelProvider) {
SearchableDetailTabModelProvider<StorageDomain, StorageListModel, StorageDataCenterListModel> result = new SearchableDetailTabModelProvider<StorageDomain, StorageListModel, StorageDataCenterListModel>(eventBus, defaultConfirmPopupProvider) {
@Override
public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> getModelPopup(StorageDataCenterListModel source, UICommand lastExecutedCommand, Model windowModel) {
StorageDataCenterListModel model = getModel();
if (lastExecutedCommand == model.getAttachCommand()) {
if (model.getAttachMultiple()) {
return multiPopupProvider.get();
} else {
return singlePopupProvider.get();
}
} else {
return super.getModelPopup(source, lastExecutedCommand, windowModel);
}
}
@Override
public AbstractModelBoundPopupPresenterWidget<? extends ConfirmationModel, ?> getConfirmModelPopup(StorageDataCenterListModel source, UICommand lastExecutedCommand) {
if (lastExecutedCommand == getModel().getDetachCommand() || lastExecutedCommand.getName().equals("OnAttach")) {
// $NON-NLS-1$) {
return removeConfirmPopupProvider.get();
} else if (lastExecutedCommand == getModel().getMaintenanceCommand() || lastExecutedCommand.getName().equals("OnMaintenance")) {
// $NON-NLS-1$) {
return removeConfirmPopupProvider.get();
} else {
return super.getConfirmModelPopup(source, lastExecutedCommand);
}
}
};
result.setMainModelProvider(mainModelProvider);
result.setModelProvider(modelProvider);
return result;
}
use of com.google.inject.Singleton in project ovirt-engine by oVirt.
the class TemplateModule method getTemplateListProvider.
// Main List Model
@Provides
@Singleton
public MainModelProvider<VmTemplate, TemplateListModel> getTemplateListProvider(EventBus eventBus, final Provider<DefaultConfirmationPopupPresenterWidget> defaultConfirmPopupProvider, final Provider<TemplateEditPresenterWidget> popupProvider, final Provider<VmExportPopupPresenterWidget> exportPopupProvider, final Provider<VmPopupPresenterWidget> createVmPopupProvider, final Provider<RemoveConfirmationPopupPresenterWidget> removeConfirmPopupProvider, final Provider<TemplateListModel> modelProvider, final Provider<VmDiskPopupPresenterWidget> newDiskPopupProvider, final Provider<SingleSelectionVmDiskAttachPopupPresenterWidget> attachDiskPopupProvider, final Provider<VmHighPerformanceConfigurationPresenterWidget> highPerformanceConfigurationProvider) {
MainViewModelProvider<VmTemplate, TemplateListModel> result = new MainViewModelProvider<VmTemplate, TemplateListModel>(eventBus, defaultConfirmPopupProvider) {
@Override
public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> getModelPopup(TemplateListModel source, UICommand lastExecutedCommand, Model windowModel) {
TemplateListModel model = getModel();
if (lastExecutedCommand == model.getEditCommand()) {
return popupProvider.get();
} else if (lastExecutedCommand == getModel().getExportCommand()) {
return exportPopupProvider.get();
} else if (lastExecutedCommand == getModel().getCreateVmFromTemplateCommand()) {
if (windowModel instanceof AttachDiskModel) {
return attachDiskPopupProvider.get();
} else if ((windowModel instanceof NewDiskModel) || (windowModel instanceof EditDiskModel)) {
return newDiskPopupProvider.get();
} else {
return createVmPopupProvider.get();
}
} else {
return super.getModelPopup(source, lastExecutedCommand, windowModel);
}
}
@Override
public AbstractModelBoundPopupPresenterWidget<? extends ConfirmationModel, ?> getConfirmModelPopup(TemplateListModel source, UICommand lastExecutedCommand) {
if (lastExecutedCommand == getModel().getRemoveCommand()) {
return removeConfirmPopupProvider.get();
} else if ("OnSave".equals(lastExecutedCommand.getName())) {
// $NON-NLS-1$
return defaultConfirmPopupProvider.get();
} else if (// $NON-NLS-1$
"OnSaveVm".equals(lastExecutedCommand.getName()) && source.getConfirmWindow() instanceof VmHighPerformanceConfigurationModel) {
return highPerformanceConfigurationProvider.get();
} else {
return super.getConfirmModelPopup(source, lastExecutedCommand);
}
}
};
result.setModelProvider(modelProvider);
return result;
}
use of com.google.inject.Singleton in project ovirt-engine by oVirt.
the class VirtualMachineModule method getVmInterfaceListProvider.
@Provides
@Singleton
public SearchableDetailModelProvider<VmNetworkInterface, VmListModel<Void>, VmInterfaceListModel> getVmInterfaceListProvider(EventBus eventBus, Provider<DefaultConfirmationPopupPresenterWidget> defaultConfirmPopupProvider, final Provider<VmInterfacePopupPresenterWidget> popupProvider, final Provider<RemoveConfirmationPopupPresenterWidget> removeConfirmPopupProvider, final Provider<VmListModel<Void>> mainModelProvider, final Provider<VmInterfaceListModel> modelProvider) {
SearchableDetailTabModelProvider<VmNetworkInterface, VmListModel<Void>, VmInterfaceListModel> result = new SearchableDetailTabModelProvider<VmNetworkInterface, VmListModel<Void>, VmInterfaceListModel>(eventBus, defaultConfirmPopupProvider) {
@Override
public AbstractModelBoundPopupPresenterWidget<? extends Model, ?> getModelPopup(VmInterfaceListModel source, UICommand lastExecutedCommand, Model windowModel) {
VmInterfaceListModel model = getModel();
if (lastExecutedCommand == model.getNewCommand() || lastExecutedCommand == model.getEditCommand()) {
return popupProvider.get();
} else {
return super.getModelPopup(source, lastExecutedCommand, windowModel);
}
}
@Override
public AbstractModelBoundPopupPresenterWidget<? extends ConfirmationModel, ?> getConfirmModelPopup(VmInterfaceListModel source, UICommand lastExecutedCommand) {
if (lastExecutedCommand == getModel().getRemoveCommand()) {
return removeConfirmPopupProvider.get();
} else {
return super.getConfirmModelPopup(source, lastExecutedCommand);
}
}
};
result.setMainModelProvider(mainModelProvider);
result.setModelProvider(modelProvider);
return result;
}
Aggregations