@Override public <T> void registerComponent(ComponentDescriptor<T> componentDescriptor, T componentInstance) throws ComponentRepositoryException { getComponentManager().registerComponent(componentDescriptor, componentInstance); }
@Override public <T> void registerComponent(ComponentDescriptor<T> componentDescriptor) throws ComponentRepositoryException { getComponentManager().registerComponent(componentDescriptor); }
@Override public <T> void registerComponent(ComponentDescriptor<T> componentDescriptor, T componentInstance) throws ComponentRepositoryException { synchronized (this) { // Make sure the ComponentManager associated to the current key exists ComponentManager componentManager = this.componentManagerManager.getComponentManager(getKey(), true); if (componentInstance == null) { componentManager.registerComponent(componentDescriptor); } else { componentManager.registerComponent(componentDescriptor, componentInstance); } } }
/** * Register components associated to the provided class. * * @param componentImplementation the implementation of the component * @param componentManager the component manager against which to register the components * @throws Exception in case of an error during registration * @since 5.2M1 */ public void registerComponent(Class<?> componentImplementation, ComponentManager componentManager) throws Exception { List<ComponentDescriptor> descriptors = this.loader.getComponentsDescriptors(componentImplementation); for (ComponentDescriptor descriptor : descriptors) { componentManager.registerComponent(descriptor); } }
/** * Register in-memory data source for the default, "xwikiproperties" and "all" configuration sources. * * @param componentManager the component manager against which to register the configuration sources * @return the in-memory configuration source used for default, "xwikiproperties" and "all" component hints * @throws Exception in case the registration fails */ public MemoryConfigurationSource registerMemoryConfigurationSource(ComponentManager componentManager) throws Exception { MockConfigurationSource configurationSource = new MockConfigurationSource(); componentManager.registerComponent(MockConfigurationSource.getDescriptor(null), configurationSource); componentManager.registerComponent(MockConfigurationSource.getDescriptor("xwikiproperties"), configurationSource); componentManager.registerComponent(MockConfigurationSource.getDescriptor("all"), configurationSource); return configurationSource; } }
/** * @param extension the uninstalled extension * @param namespace the namespace from where the extension has been uninstalled */ private void extensionAdded(InstalledExtension extension, String namespace) { try { File jarFile = new File(extension.getFile().getAbsolutePath()); ComponentManager componentManager = this.componentManagerManager.getComponentManager(namespace, false); if (componentManager == null) { componentManager = this.rootComponentManager; } JARFileTranslationBundle bundle = new JARFileTranslationBundle(jarFile, componentManager, this.translationParser); ComponentDescriptor<TranslationBundle> descriptor = createComponentDescriptor(jarFile.toURI().toURL()); componentManager.registerComponent(descriptor, bundle); } catch (Exception e) { this.logger.error("Failed to register a TranslationBundle component for extension [{}] on namespace [{}]", extension, namespace, e); } } }
/** * Registers a component. * * @param roleType the type of the component role to register * @param roleHint the role hint of the component to register * @param instance the instance to register * @param componentManager the component manager against which to register the component * @throws Exception in case of an error during registration */ public void registerComponent(Type roleType, String roleHint, Object instance, ComponentManager componentManager) throws Exception { DefaultComponentDescriptor descriptor = new DefaultComponentDescriptor(); descriptor.setRoleType(roleType); if (roleHint != null) { descriptor.setRoleHint(roleHint); } componentManager.registerComponent(descriptor, instance); }
manager.registerComponent(descriptor);
/** * Register components associated to the provided class if there is not already one. * * @param componentImplementation the implementation of the component * @param componentManager the component manager against which to register the components * @throws Exception in case of an error during registration * @since 7.2M2 */ public void registerComponentIfDontExist(Class<?> componentImplementation, ComponentManager componentManager) throws Exception { List<ComponentDescriptor> descriptors = this.loader.getComponentsDescriptors(componentImplementation); for (ComponentDescriptor descriptor : descriptors) { if (!componentManager.hasComponent(descriptor.getRoleType(), descriptor.getRoleHint())) { componentManager.registerComponent(descriptor); } } }
/** * @param document the translation document * @throws TranslationBundleDoesNotExistsException when no translation bundle could be created from the provided * document * @throws ComponentRepositoryException when the actual registration of the document bundle failed * @throws AccessDeniedException when the document author does not have enough right to register the translation * bundle */ private void registerTranslationBundle(XWikiDocument document) throws TranslationBundleDoesNotExistsException, ComponentRepositoryException, AccessDeniedException { Scope scope = getScope(document); if (scope != null && scope != Scope.ON_DEMAND) { checkRegistrationAuthorization(document, scope); ComponentDescriptor<TranslationBundle> descriptor = createComponentDescriptor(document.getDocumentReference()); ComponentDocumentTranslationBundle bundle = createComponentDocumentBundle(document, descriptor); getComponentManager(document, scope, true).registerComponent(descriptor, bundle); } }
getComponentManager(component.getScope()).registerComponent(componentDescriptor, roleTypeClass.cast(component));
private void registerDBIFactoryComponent(Environment environment, MayocatShopSettings configuration) throws ClassNotFoundException, ComponentRepositoryException { final DBIFactory factory = new DBIFactory(); final DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "jdbi"); jdbi.registerArgumentFactory(new PostgresUUIDArgumentFactory()); jdbi.registerArgumentFactory(new PostgresUUIDArrayArgumentFactory()); if (configuration.getDevelopmentEnvironment().isEnabled() && configuration.getDevelopmentEnvironment().isLogDatabaseRequests()) { jdbi.setSQLLog(new PrintStreamLog()); } final DBIProvider dbi = new DBIProvider() { @Override public DBI get() { return jdbi; } }; DefaultComponentDescriptor<DBIProvider> cd = new DefaultComponentDescriptor<DBIProvider>(); cd.setRoleType(DBIProvider.class); getComponentManager().registerComponent(cd, dbi); }