use of org.xwiki.component.descriptor.DefaultComponentDependency in project xwiki-platform by xwiki.
the class StandardExtendedURLResourceTypeResolver method registerEntityResourceReferenceResolver.
private void registerEntityResourceReferenceResolver(String registrationHint, Class<? extends ResourceReferenceResolver<ExtendedURL>> registrationImplementation, String wikiExtractorHint) throws InitializationException {
DefaultComponentDescriptor<ResourceReferenceResolver<ExtendedURL>> resolverDescriptor = new DefaultComponentDescriptor<>();
resolverDescriptor.setImplementation(registrationImplementation);
resolverDescriptor.setInstantiationStrategy(ComponentInstantiationStrategy.SINGLETON);
String hint = computeHint(registrationHint);
resolverDescriptor.setRoleHint(hint);
resolverDescriptor.setRoleType(new DefaultParameterizedType(null, ResourceReferenceResolver.class, ExtendedURL.class));
// Register dependencies
DefaultComponentDependency<WikiReferenceExtractor> wikiReferenceExtractorDependency = new DefaultComponentDependency<>();
wikiReferenceExtractorDependency.setRoleType(WikiReferenceExtractor.class);
wikiReferenceExtractorDependency.setRoleHint(wikiExtractorHint);
wikiReferenceExtractorDependency.setName("wikiExtractor");
resolverDescriptor.addComponentDependency(wikiReferenceExtractorDependency);
DefaultComponentDependency<EntityReferenceResolver<EntityReference>> entityReferenceResolverDependency = new DefaultComponentDependency<>();
entityReferenceResolverDependency.setRoleType(new DefaultParameterizedType(null, EntityReferenceResolver.class, EntityReference.class));
entityReferenceResolverDependency.setName("defaultReferenceEntityReferenceResolver");
resolverDescriptor.addComponentDependency(entityReferenceResolverDependency);
DefaultComponentDependency<StandardURLConfiguration> standardURLConfigurationDependency = new DefaultComponentDependency<>();
standardURLConfigurationDependency.setRoleType(StandardURLConfiguration.class);
standardURLConfigurationDependency.setName("configuration");
resolverDescriptor.addComponentDependency(standardURLConfigurationDependency);
DefaultComponentDependency<EntityResourceActionLister> entityResourceActionListerDependency = new DefaultComponentDependency<>();
entityResourceActionListerDependency.setRoleType(EntityResourceActionLister.class);
entityResourceActionListerDependency.setName("entityResourceActionLister");
resolverDescriptor.addComponentDependency(entityResourceActionListerDependency);
try {
this.rootComponentManager.registerComponent(resolverDescriptor);
} catch (ComponentRepositoryException e) {
throw new InitializationException(String.format("Failed to dynamically register Resource Reference Resolver for hint [%s]", hint), e);
}
}
Aggregations