private PatientAccessHelper getHelper() { try { return this.componentManager.get().getInstance(PatientAccessHelper.class); } catch (ComponentLookupException ex) { this.logger.error("Mandatory component [PatientAccessHelper] missing: {}", ex.getMessage(), ex); } return null; }
/** * {@inheritDoc} * * @see org.xwiki.component.manager.ComponentManager#lookup(Class) */ @SuppressWarnings("unchecked") public <T> T lookup(Class<T> role) throws ComponentLookupException { T result; try { result = (T) this.plexusContainer.lookup(role.getName()); } catch (org.codehaus.plexus.component.repository.exception.ComponentLookupException e) { throw new ComponentLookupException("Failed to lookup component role [" + role + "]", e); } return result; }
@Override public List<RecordConfigurationModule> get() { try { List<RecordConfigurationModule> modules = new LinkedList<>(); modules.addAll(this.cm.<RecordConfigurationModule>getInstanceList(RecordConfigurationModule.class)); Collections.sort(modules, ModulePriorityComparator.INSTANCE); return modules; } catch (ComponentLookupException ex) { throw new RuntimeException("Failed to look up record configuration modules: " + ex.getMessage(), ex); } }
/** * {@inheritDoc} * * @see org.xwiki.component.manager.ComponentManager#lookup(Class, String) */ @SuppressWarnings("unchecked") public <T> T lookup(Class<T> role, String roleHint) throws ComponentLookupException { T result; try { result = (T) this.plexusContainer.lookup(role.getName(), roleHint); } catch (org.codehaus.plexus.component.repository.exception.ComponentLookupException e) { throw new ComponentLookupException("Failed to lookup component role [" + role + "] for hint [" + roleHint + "]", e); } return result; }
private EntityAccessHelper getHelper() { try { return this.componentManager.get().getInstance(EntityAccessHelper.class); } catch (ComponentLookupException ex) { this.logger.error("Mandatory component [EntityAccessHelper] missing: {}", ex.getMessage(), ex); } return null; }
/** * {@inheritDoc} * * @see org.xwiki.component.manager.ComponentManager#lookupMap(Class) */ @SuppressWarnings("unchecked") public <T> Map<String, T> lookupMap(Class<T> role) throws ComponentLookupException { Map<String, T> result; try { result = this.plexusContainer.lookupMap(role.getName()); } catch (org.codehaus.plexus.component.repository.exception.ComponentLookupException e) { throw new ComponentLookupException("Failed to lookup components for role [" + role + "]", e); } return result; }
public DataToCellConverter() { try { this.translationManager = ComponentManagerRegistry.getContextComponentManager().getInstance( TranslationManager.class); } catch (ComponentLookupException ex) { LoggerFactory.getLogger(getClass()).warn("Failed to lookup TranslationManager component: [{}]", ex.getMessage()); } }
/** * {@inheritDoc} * * @see org.xwiki.component.manager.ComponentManager#lookupList(Class) */ @SuppressWarnings("unchecked") public <T> List<T> lookupList(Class<T> role) throws ComponentLookupException { List<T> result; try { result = this.plexusContainer.lookupList(role.getName()); } catch (org.codehaus.plexus.component.repository.exception.ComponentLookupException e) { throw new ComponentLookupException("Failed to lookup components for role [" + role + "]", e); } return result; }
public DataToCellConverter() { try { this.translationManager = ComponentManagerRegistry.getContextComponentManager().getInstance( TranslationManager.class); } catch (ComponentLookupException ex) { LoggerFactory.getLogger(getClass()).warn("Failed to lookup TranslationManager component: [{}]", ex.getMessage()); } }
@Override @SuppressWarnings("unchecked") public <T> Map<String, T> getInstanceMap(Type roleType) throws ComponentLookupException { Map<String, T> components = new HashMap<>(); Map<String, ComponentEntry<?>> entries = this.componentEntries.get(roleType); // Add local components if (entries != null) { for (Map.Entry<String, ComponentEntry<?>> entry : entries.entrySet()) { try { components.put(entry.getKey(), getComponentInstance((ComponentEntry<T>) entry.getValue())); } catch (Exception e) { throw new ComponentLookupException( "Failed to lookup component with type [" + roleType + "] and hint [" + entry.getKey() + "]", e); } } } // Add parent components if (getParent() != null) { // If the hint already exists in the children Component Manager then don't add the one from the parent. for (Map.Entry<String, T> entry : getParent().<T>getInstanceMap(roleType).entrySet()) { if (!components.containsKey(entry.getKey())) { components.put(entry.getKey(), entry.getValue()); } } } return components; }
/** * Gets all the available {@link PrimaryEntityManager}s. * * @return all available {@link PrimaryEntityManager}s */ @Nonnull private List<PrimaryEntityManager> getAvailableManagers() { try { // Returns a list of all primary entity managers. final List<PrimaryEntityManager> mgrs = this.cmProvider.get().getInstanceList(PrimaryEntityManager.class); // Filter out the managers with the wrong name. return mgrs.stream() .filter(this::isValidManager) .collect(Collectors.toList()); } catch (ComponentLookupException e) { this.logger.debug("Unable to retrieve primary entity managers: [{}].", e.getMessage()); return Collections.emptyList(); } }
@Override public <T> T getInstance(Type roleType, String roleHint) throws ComponentLookupException { T instance; ComponentEntry<T> componentEntry = (ComponentEntry<T>) getComponentEntry(roleType, roleHint); if (componentEntry != null) { try { instance = getComponentInstance(componentEntry); } catch (Throwable e) { throw new ComponentLookupException( String.format("Failed to lookup component [%s] identified by type [%s] and hint [%s]", componentEntry.descriptor.getImplementation().getName(), roleType, roleHint), e); } } else { if (getParent() != null) { instance = getParent().getInstance(roleType, roleHint); } else { throw new ComponentLookupException( "Can't find descriptor for the component with type [" + roleType + "] and hint [" + roleHint + "]"); } } return instance; }
protected QueryManager getQueryManager() { try { return ComponentManagerRegistry.getContextComponentManager().getInstance(QueryManager.class); } catch (ComponentLookupException ex) { this.logger.error("Failed to access the query manager: {}", ex.getMessage(), ex); } return null; }
private Vocabulary getHGNCVocabulary() { try { VocabularyManager vm = ComponentManagerRegistry.getContextComponentManager().getInstance(VocabularyManager.class); return vm.getVocabulary(HGNC); } catch (ComponentLookupException ex) { this.logger.error("Error loading component [{}]", ex.getMessage(), ex); } return null; }
/** * {@inheritDoc} */ public void initializeApplicationContext(ApplicationContext applicationContext) { try { List<ApplicationContextListener> initializers = this.componentManager.lookupList(ApplicationContextListener.class); for (ApplicationContextListener initializer : initializers) { initializer.initializeApplicationContext(applicationContext); } } catch (ComponentLookupException ex) { getLogger().error(ex.getMessage(), ex); } }
/** * {@inheritDoc} */ public void destroyApplicationContext(ApplicationContext applicationContext) { try { List<ApplicationContextListener> initializers = this.componentManager.lookupList(ApplicationContextListener.class); for (ApplicationContextListener initializer : initializers) { initializer.destroyApplicationContext(applicationContext); } } catch (ComponentLookupException ex) { getLogger().error(ex.getMessage(), ex); } } }