private SnomedBrowserService getBrowserService() { if (browserService == null) { browserService = (SnomedBrowserService) ApplicationContext.getInstance().getServiceChecked(ISnomedBrowserService.class); } return Preconditions.checkNotNull(browserService, "browserService cannot be null!"); }
private IEventBus getBus() { if (bus == null) { bus = ApplicationContext.getInstance().getServiceChecked(IEventBus.class); } return Preconditions.checkNotNull(bus, "bus cannot be null!"); }
/** * Returns the {@link PreferencesService} from the * {@link ApplicationContext}. * * @return */ public PreferencesService preferences() { return services().getServiceChecked(PreferencesService.class); }
@Bean public FileRegistry fileRegistry() { return com.b2international.snowowl.core.ApplicationContext.getInstance().getServiceChecked(FileRegistry.class); }
@Bean @Scope(value=ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode=ScopedProxyMode.TARGET_CLASS) public IEventBus eventBus() { return com.b2international.snowowl.core.ApplicationContext.getInstance().getServiceChecked(IEventBus.class); }
private IEventBus getBus() { return ApplicationContext.getInstance().getServiceChecked(IEventBus.class); }
@Override public <T> T service(final Class<T> type) { return services().getServiceChecked(type); }
public FetchUsersIndication(SignalProtocol<?> protocol) { super(protocol, Net4jProtocolConstants.FETCH_USERS_SIGNAL); manager = ApplicationContext.getInstance().getServiceChecked(IUserManager.class); }
private IDatastoreOperationLockManager getLockManager() { return getContext().getServiceChecked(IDatastoreOperationLockManager.class); }
private SnowOwlConfiguration getSnowOwlConfiguration() { return ApplicationContext.getInstance().getServiceChecked(SnowOwlConfiguration.class); }
@PreDestroy protected void shutdown() { if (null != remoteJobSubscription) { remoteJobSubscription.dispose(); remoteJobSubscription = null; } if (null != executorService) { executorService.shutdown(); executorService = null; } if (null != indexService) { ApplicationContext.getInstance().getServiceChecked(SingleDirectoryIndexManager.class).unregisterIndex(indexService); try { Closeables.close(indexService, true); } catch (IOException e) { throw new RuntimeException(e); } indexService = null; } LOG.info("Classification service shut down."); }
final IDatastoreOperationLockManager lockManager = ApplicationContext.getInstance().getServiceChecked(IDatastoreOperationLockManager.class);
private Integer getMaxReasonerRuns() { if (maxReasonerRuns == null) { maxReasonerRuns = ApplicationContext.getInstance().getServiceChecked(SnowOwlConfiguration.class) .getModuleConfig(SnomedCoreConfiguration.class).getClassificationConfig().getMaxReasonerRuns(); } return Preconditions.checkNotNull(maxReasonerRuns, "maximum number of reasoner runs must be configured"); }
@Bean public Integer maxReasonerRuns() { return com.b2international.snowowl.core.ApplicationContext.getInstance() .getServiceChecked(SnowOwlConfiguration.class) .getModuleConfig(SnomedCoreConfiguration.class) .getClassificationConfig() .getMaxReasonerRuns(); }
@PostConstruct protected void init() { LOG.info("Initializing classification service; keeping indexed data for {} recent run(s).", getMaxReasonerRuns()); final File dir = new File(new File(SnowOwlApplication.INSTANCE.getEnviroment().getDataDirectory(), "indexes"), "classification_runs"); indexService = new ClassificationRunIndex(dir); ApplicationContext.getInstance().getServiceChecked(SingleDirectoryIndexManager.class).registerIndex(indexService); try { indexService.trimIndex(getMaxReasonerRuns()); indexService.invalidateClassificationRuns(); } catch (final IOException e) { LOG.error("Failed to run housekeeping tasks for the classification index.", e); } // TODO: common ExecutorService for asynchronous work? executorService = Executors.newCachedThreadPool(); remoteJobSubscription = getNotifications() .ofType(RemoteJobNotification.class) .subscribe(this::onRemoteJobNotification); initialized = true; }