Search in sources :

Example 6 with ComponentDefinitionRegistry

use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.

the class ParserServiceImportXSDsBetweenNamespaceHandlersTest method testXSDImports.

@Test
public void testXSDImports() throws Exception {
    waitForConfig();
    ParserService parserService = context().getService(ParserService.class);
    URL blueprintXML = context().getBundleByName(TEST_BUNDLE).getEntry("OSGI-INF/blueprint/ImportNamespacesTest.xml");
    ComponentDefinitionRegistry cdr = parserService.parse(blueprintXML, context().getBundleByName(TEST_BUNDLE));
    assertNotNull(cdr.getComponentDefinition("aries-1503"));
}
Also used : ComponentDefinitionRegistry(org.apache.aries.blueprint.ComponentDefinitionRegistry) URL(java.net.URL) ParserService(org.apache.aries.blueprint.services.ParserService) Test(org.junit.Test)

Example 7 with ComponentDefinitionRegistry

use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.

the class AnnotationEnablingNameSpaceHandlerTest method testAnnotationDisabled.

@Test
public void testAnnotationDisabled() throws Exception {
    ComponentDefinitionRegistry cdr = parseCDR("enable-annotations2.xml");
    checkCompTop(cdr);
    BeanMetadata pmd = (BeanMetadata) cdr.getComponentDefinition(TxNamespaceHandler.ANNOTATION_PARSER_BEAN_NAME);
    assertNull(pmd);
}
Also used : ComponentDefinitionRegistry(org.apache.aries.blueprint.ComponentDefinitionRegistry) BeanMetadata(org.osgi.service.blueprint.reflect.BeanMetadata) Test(org.junit.Test)

Example 8 with ComponentDefinitionRegistry

use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.

the class BaseNameSpaceHandlerSetup method parseCDR.

protected ComponentDefinitionRegistry parseCDR(String name) throws Exception {
    Parser p = new Parser();
    URL bpxml = this.getClass().getResource(name);
    p.parse(Arrays.asList(bpxml));
    Set<URI> nsuris = p.getNamespaces();
    NamespaceHandlerSet nshandlers = nhri.getNamespaceHandlers(nsuris, b);
    ComponentDefinitionRegistry cdr = new ComponentDefinitionRegistryImpl();
    cdr.registerComponentDefinition(new PassThroughMetadataImpl("blueprintBundle", b));
    p.populate(nshandlers, cdr);
    return cdr;
}
Also used : NamespaceHandlerSet(org.apache.aries.blueprint.parser.NamespaceHandlerSet) ComponentDefinitionRegistry(org.apache.aries.blueprint.ComponentDefinitionRegistry) PassThroughMetadataImpl(org.apache.aries.blueprint.reflect.PassThroughMetadataImpl) URI(java.net.URI) ComponentDefinitionRegistryImpl(org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl) URL(java.net.URL) Parser(org.apache.aries.blueprint.parser.Parser)

Example 9 with ComponentDefinitionRegistry

use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.

the class TxNamespaceHandler method createAnnotationParserBean.

private MutableBeanMetadata createAnnotationParserBean(ParserContext pc, ComponentDefinitionRegistry cdr) {
    MutableBeanMetadata meta = pc.createMetadata(MutableBeanMetadata.class);
    meta.setId(ANNOTATION_PARSER_BEAN_NAME);
    meta.setRuntimeClass(AnnotationProcessor.class);
    meta.setProcessor(true);
    meta.addArgument(passThrough(pc, cdr), ComponentDefinitionRegistry.class.getName(), 0);
    meta.addArgument(passThrough(pc, tm), TransactionManager.class.getName(), 1);
    meta.addArgument(passThrough(pc, coordinator), Coordinator.class.getName(), 1);
    return meta;
}
Also used : MutableBeanMetadata(org.apache.aries.blueprint.mutable.MutableBeanMetadata) ComponentDefinitionRegistry(org.apache.aries.blueprint.ComponentDefinitionRegistry) TransactionManager(javax.transaction.TransactionManager) Coordinator(org.osgi.service.coordinator.Coordinator)

Example 10 with ComponentDefinitionRegistry

use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.

the class ParserServiceImpl method validateAndPopulate.

private ComponentDefinitionRegistry validateAndPopulate(Parser parser, Bundle clientBundle, boolean validate) throws IOException, SAXException {
    Set<URI> nsuris = parser.getNamespaces();
    ComponentDefinitionRegistry cdr;
    NamespaceHandlerSet nshandlers = _namespaceHandlerRegistry.getNamespaceHandlers(nsuris, clientBundle);
    try {
        if (validate) {
            parser.validate(nshandlers.getSchema());
        }
        cdr = new ComponentDefinitionRegistryImpl();
        parser.populate(nshandlers, cdr);
    } finally {
        nshandlers.destroy();
    }
    return cdr;
}
Also used : NamespaceHandlerSet(org.apache.aries.blueprint.parser.NamespaceHandlerSet) ComponentDefinitionRegistry(org.apache.aries.blueprint.ComponentDefinitionRegistry) URI(java.net.URI) ComponentDefinitionRegistryImpl(org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl)

Aggregations

ComponentDefinitionRegistry (org.apache.aries.blueprint.ComponentDefinitionRegistry)21 Test (org.junit.Test)5 ComponentMetadata (org.osgi.service.blueprint.reflect.ComponentMetadata)5 URL (java.net.URL)4 PassThroughMetadata (org.apache.aries.blueprint.PassThroughMetadata)3 MutableBeanMetadata (org.apache.aries.blueprint.mutable.MutableBeanMetadata)3 MutablePassThroughMetadata (org.apache.aries.blueprint.mutable.MutablePassThroughMetadata)3 MutableReferenceMetadata (org.apache.aries.blueprint.mutable.MutableReferenceMetadata)3 ParserService (org.apache.aries.blueprint.services.ParserService)3 Bundle (org.osgi.framework.Bundle)3 ComponentDefinitionException (org.osgi.service.blueprint.container.ComponentDefinitionException)3 URI (java.net.URI)2 ComponentDefinitionRegistryImpl (org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl)2 NamespaceHandlerSet (org.apache.aries.blueprint.parser.NamespaceHandlerSet)2 BeanMetadata (org.osgi.service.blueprint.reflect.BeanMetadata)2 TransactionManager (javax.transaction.TransactionManager)1 ExportedService (org.apache.aries.application.modelling.ExportedService)1 ImportedService (org.apache.aries.application.modelling.ImportedService)1 ParsedServiceElements (org.apache.aries.application.modelling.ParsedServiceElements)1 Interceptor (org.apache.aries.blueprint.Interceptor)1