Search in sources :

Example 1 with DefaultComponentDependency

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);
    }
}
Also used : DefaultComponentDependency(org.xwiki.component.descriptor.DefaultComponentDependency) EntityReferenceResolver(org.xwiki.model.reference.EntityReferenceResolver) BinEntityResourceReferenceResolver(org.xwiki.url.internal.standard.entity.BinEntityResourceReferenceResolver) ResourceReferenceResolver(org.xwiki.resource.ResourceReferenceResolver) WikiEntityResourceReferenceResolver(org.xwiki.url.internal.standard.entity.WikiEntityResourceReferenceResolver) ComponentRepositoryException(org.xwiki.component.manager.ComponentRepositoryException) ExtendedURL(org.xwiki.url.ExtendedURL) InitializationException(org.xwiki.component.phase.InitializationException) EntityResourceActionLister(org.xwiki.resource.internal.entity.EntityResourceActionLister) DefaultComponentDescriptor(org.xwiki.component.descriptor.DefaultComponentDescriptor) EntityReference(org.xwiki.model.reference.EntityReference) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType)

Aggregations

DefaultComponentDependency (org.xwiki.component.descriptor.DefaultComponentDependency)1 DefaultComponentDescriptor (org.xwiki.component.descriptor.DefaultComponentDescriptor)1 ComponentRepositoryException (org.xwiki.component.manager.ComponentRepositoryException)1 InitializationException (org.xwiki.component.phase.InitializationException)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 EntityReference (org.xwiki.model.reference.EntityReference)1 EntityReferenceResolver (org.xwiki.model.reference.EntityReferenceResolver)1 ResourceReferenceResolver (org.xwiki.resource.ResourceReferenceResolver)1 EntityResourceActionLister (org.xwiki.resource.internal.entity.EntityResourceActionLister)1 ExtendedURL (org.xwiki.url.ExtendedURL)1 BinEntityResourceReferenceResolver (org.xwiki.url.internal.standard.entity.BinEntityResourceReferenceResolver)1 WikiEntityResourceReferenceResolver (org.xwiki.url.internal.standard.entity.WikiEntityResourceReferenceResolver)1