/** * Returns with the service instance associated with the passed in service interface. * May throw runtime exception if the service associated with the passed in interface is not registered or {@code null}. * @param serviceInterface the interface of the required service. Should not be {@code null}. * @return the available registered service instance. * @param <T> type of the service. */ public <T> T getServiceChecked(final Class<T> serviceInterface) { Preconditions.checkNotNull(serviceInterface, "Service interface argument cannot be null."); final T service = getService(serviceInterface); Preconditions.checkNotNull(service, "Service for " + serviceInterface.getSimpleName() + " service cannot be null."); return service; }
@Override public <T> T getServiceImplementation(final Class<T> serviceInterface) { return ApplicationContext.getInstance().getService(serviceInterface); } }
private ICDORepositoryManager getRepositoryManager() { return ApplicationContext.getInstance().getService(ICDORepositoryManager.class); } }
private IEventBus getEventBus() { return ApplicationContext.getInstance().getService(IEventBus.class); }
private ICDOConnectionManager getConnectionManager() { return ApplicationContext.getInstance().getService(ICDOConnectionManager.class); } }
/**Returns with the service registered for the class argument key from the shared application context.*/ public static <T> T getServiceForClass(final Class<T> clazz) { return getInstance().getService(clazz); }
protected <T> T getService(Class<T> type) { return checkNotNull(ApplicationContext.getInstance().getService(type), "%s service should not be null. Use @Provides instead of direct member injection", type.getSimpleName()); }
public SnowowlSessionManager() { this(ApplicationContext.getInstance().getService(IApplicationSessionManager.class)); }
private static ICDOConnectionManager getConnectionManager() { return ApplicationContext.getInstance().getService(ICDOConnectionManager.class); }
public VersionProcessor() { this(ApplicationContext.getInstance().getService(PreferencesService.class)); }
protected IEventBus getEventBus() { return ApplicationContext.getInstance().getService(IEventBus.class); }
private static ICDOConnectionManager getConnectionManager() { return ApplicationContext.getInstance().getService(ICDOConnectionManager.class); }
private static ICDORepository getRepository(final String nsUri) { Preconditions.checkNotNull(nsUri, "Namespace URI argument cannot be null."); final ICDORepositoryManager repositoryManager = ApplicationContext.getInstance().getService(ICDORepositoryManager.class); return repositoryManager.get(nsUri); }
private List<ExtendedLocale> getLocales() { return ApplicationContext.getInstance().getService(LanguageSetting.class).getLanguagePreference(); }
/** * Calculates the CDO change set between two branch points in all repositories. * @param sourceBranchPath the source branch path. * @param sourceTimestamp the source timestamp. * @param targetBranchPath the target branch path. * @param targetTimestamp the target timestamp. * @return a map of change set data where the keys are the repository unique IDs and the values are the actual change set. */ public Map<String, CDOChangeSetData> getChangeSetData(final IBranchPath sourceBranchPath, final long sourceTimestamp, final IBranchPath targetBranchPath, final long targetTimestamp) { final ICDOConnectionManager manager = ApplicationContext.getInstance().getService(ICDOConnectionManager.class); final Iterable<Pair<String, CDOChangeSetData>> itr = Iterables.transform(manager, new GetChangeSetDataFunction(sourceBranchPath, sourceTimestamp, targetBranchPath, targetTimestamp)); final Map<String, CDOChangeSetData> $ = Maps.newHashMap(); for (final Pair<String, CDOChangeSetData> pair : itr) { $.put(pair.getA(), pair.getB()); } return Collections.unmodifiableMap($); }
public DelegateCDOServerChangeManager(final ICDOCommitChangeSet commitChangeSet, final Collection<CDOChangeProcessorFactory> factories, final boolean copySession, boolean isCommitNotificationEnabled) { this.isCommitNotificationEnabled = isCommitNotificationEnabled; this.commitChangeSet = Preconditions.checkNotNull(commitChangeSet, "Commit change set data argument cannot be null."); final CDOView view = commitChangeSet.getView(); this.repositoryUuid = ApplicationContext.getInstance().getService(ICDOConnectionManager.class).get(view).getUuid(); this.branchPath = BranchPathUtils.createPath(view); this.factories = Preconditions.checkNotNull(factories, "CDO change processor factories argument cannot be null."); }
/** * Returns with the {@link EClass} of an object identified by its unique {@link CDOID}. May return with {@code null}. * @param branchPath the branch path. * @param cdoId the unique CDO ID. * @return the {@link EClass} of an object. */ @Nullable public EClass getEClass(final IBranchPath branchPath, final long storageKey) { Preconditions.checkNotNull(branchPath, "Branch path argument cannot be null."); final ICDOConnection connection = ApplicationContext.getInstance().getService(ICDOConnectionManager.class).get(storageKey); final String repositoryUuid = connection.getUuid(); for (final IEClassProvider provider : getProviders().get(repositoryUuid)) { final EClass eClass = provider.getEClass(branchPath, storageKey); if (null != eClass) { return eClass; } } return null; }
private Multimap<String, CDORemoteSession> getRemoteSessions() { LifecycleUtil.checkActive(this); final HashMultimap<String, CDORemoteSession> $ = HashMultimap.create(); for (final ICDORepository repository : this) { final String uuid = repository.getUuid(); final ICDOConnection connection = ApplicationContext.getInstance().getService(ICDOConnectionManager.class).getByUuid(uuid); final CDORemoteSessionManager remoteSessionManager = connection.getSession().getRemoteSessionManager(); for (final CDORemoteSession session : remoteSessionManager.getElements()) { $.put(session.getUserID(), session); } } return Multimaps.unmodifiableMultimap($); }
public static Connection createConnection(final EPackage ePackage, final RepositoryConfiguration configuration) { Preconditions.checkNotNull(ePackage, "EClass argument cannot be null."); final String driverName = configuration.getDatabaseConfiguration().getDriverClass(); final JdbcUrl jdbcUrl = configuration.getDatabaseUrl(); final String username = configuration.getDatabaseConfiguration().getUsername(); final String password = configuration.getDatabaseConfiguration().getPassword(); final ICDORepositoryManager repositoryManager = ApplicationContext.getInstance().getService(ICDORepositoryManager.class); final String repositoryUuid = repositoryManager.get(ePackage).getUuid(); final String localDbUrl = jdbcUrl.build(repositoryUuid); return JdbcUtils.createConnection(driverName, localDbUrl, username, password); }
public static long getClassMetaID(final EClass eClass) { final ICDORepositoryManager repositoryManager = ApplicationContext.getInstance().getService(ICDORepositoryManager.class); final ICDORepository cdoRepository = repositoryManager.get(eClass); final IDBStore dbStore = cdoRepository.getDbStore(); final IRepository repository = cdoRepository.getRepository(); final ISession session = repository.getSessionManager().getSessions()[0]; StoreThreadLocal.setSession((InternalSession) session); final long lastCommitTime = dbStore.getLastCommitTime(); return CDOIDUtil.getLong(dbStore.getMetaDataManager().getMetaID(eClass, lastCommitTime)); }