@Override public void initialize() throws InitializationException { // Try to find a WikiModel implementation and set it if it can be found. If not it means we're in // non wiki mode (i.e. no attachment in wiki documents and no links to documents for example). try { this.wikiModel = this.componentManager.getInstance(WikiModel.class); } catch (ComponentLookupException e) { // There's no WikiModel implementation available. this.wikiModel stays null. } }
private XarObjectPropertySerializer getInstance(String type, ComponentManager componentManager) throws ComponentLookupException { return componentManager.getInstance(XarObjectPropertySerializer.class, type); } }
public static void initializeComponent(ComponentManager componentManager) throws Exception { TestUtils.componentManager = componentManager; TestUtils.relativeReferenceResolver = TestUtils.componentManager.getInstance(EntityReferenceResolver.TYPE_STRING, "relative"); TestUtils.referenceResolver = TestUtils.componentManager.getInstance(EntityReferenceResolver.TYPE_STRING); TestUtils.referenceSerializer = TestUtils.componentManager.getInstance(EntityReferenceSerializer.TYPE_STRING); }
/** * Lookup the cache creation component with provided hint return it. * * @param cacheHint the role hint to lookup. * @return a cache creation service. * @throws ComponentLookupException error when searching for cache component. */ public CacheFactory getCacheFactory(String cacheHint) throws ComponentLookupException { return this.componentManager.getInstance(CacheFactory.class, cacheHint); }
private AsymmetricKeyFactory getKeyFactory(String hint) { try { return manager.getInstance(AsymmetricKeyFactory.class, hint); } catch (ComponentLookupException e) { throw new UnsupportedOperationException("Asymmetric key algorithm not found.", e); } }
@Override public AccessLevel resolveAccessLevel(String name) { try { if (StringUtils.isNotBlank(name)) { return this.componentManager.get().getInstance(AccessLevel.class, name); } } catch (ComponentLookupException ex) { this.logger.warn("Invalid patient access level requested: {}", name); } return null; }
@Override public <T> T getInstance(Type roleType) throws ComponentLookupException { return getComponentManager().getInstance(roleType); }
@Override public <T> T getInstance(Type roleType, String roleHint) throws ComponentLookupException { return getComponentManager().getInstance(roleType, roleHint); }
/** * Get the handler corresponding to the provided extension. * * @param localExtension the extension to handler * @return the handler * @throws ComponentLookupException failed to find a proper handler for the provided extension */ private ExtensionHandler getExtensionHandler(LocalExtension localExtension) throws ComponentLookupException { return this.componentManager.getInstance(ExtensionHandler.class, localExtension.getType().toLowerCase()); }
protected XWikiContext getXContext() { try { Provider<XWikiContext> xcontextProvider = ComponentManagerRegistry.getContextComponentManager().getInstance(XWikiContext.TYPE_PROVIDER); return xcontextProvider.get(); } catch (Exception ex) { this.logger.error("Unexpected exception while getting the current context: {}", ex.getMessage()); } return null; }
private <T> QuestionRecorder<T> getQuestionRecorder(T question) { ParameterizedType questionRecorderType = new DefaultParameterizedType(null, QuestionRecorder.class, question.getClass()); try { return this.contextComponentManagerProvider.get().getInstance(questionRecorderType); } catch (ComponentLookupException e) { return null; } }
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; }
@Override public void setRuntimeServices(RuntimeServices runtimeServices) { ComponentManager componentManager = (ComponentManager) runtimeServices.getApplicationAttribute(ComponentManager.class.getName()); try { this.converterManager = componentManager.getInstance(ConverterManager.class); } catch (ComponentLookupException e) { this.log.warn("Failed to initialize " + this.getClass().getSimpleName(), e); } }
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 public void initialize() throws InitializationException { String settlerHint = authorizationManagerConfiguration.getAuthorizationSettler(); try { authorizationSettler = componentManager.getInstance(AuthorizationSettler.class, settlerHint); } catch (ComponentLookupException e) { throw new InitializationException( String.format("Unable to lookup the authorization settler hinted [%s].", settlerHint), e); } }
@Override public void initialize() throws InitializationException { String type = this.configuration.getServerType(); try { this.configuredInstance = this.componentManager.getInstance(SolrInstance.class, type); } catch (ComponentLookupException e) { throw new InitializationException( String.format("Failed to lookup configured Solr instance type [%s]", type), e); } }
private XDOM getTransformedXDOM(String content, String sourceSyntaxId) throws ParseException, org.xwiki.component.manager.ComponentLookupException, TransformationException { Parser parser = componentManager.getInstance(Parser.class, sourceSyntaxId); XDOM xdom = parser.parse(new StringReader(content)); // run transformations TransformationContext txContext = new TransformationContext(xdom, Syntax.valueOf(sourceSyntaxId)); TransformationManager transformationManager = componentManager.getInstance(TransformationManager.class); transformationManager.performTransformations(xdom, txContext); return xdom; }
private Patient resolvePatient(String serializedReference) { try { PatientRepository resolver = ComponentManagerRegistry.getContextComponentManager().getInstance(PatientRepository.class); return resolver.get(serializedReference); } catch (ComponentLookupException ex) { // This really shouldn't happen... } return null; } }
private static Patient getPatient(String patientId) { PatientRepository patientRepository = null; try { ComponentManager ccm = ComponentManagerRegistry.getContextComponentManager(); patientRepository = ccm.getInstance(PatientRepository.class); } catch (ComponentLookupException e) { return null; } return patientRepository.get(patientId); } }
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; }