Search in sources :

Example 1 with ComponentDefinitionRegistryImpl

use of org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl 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 2 with ComponentDefinitionRegistryImpl

use of org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl 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)

Example 3 with ComponentDefinitionRegistryImpl

use of org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl in project aries by apache.

the class AbstractBlueprintTest method parse.

protected ComponentDefinitionRegistryImpl parse(String name, NamespaceHandlerSet handlers) throws Exception {
    ComponentDefinitionRegistryImpl registry = new ComponentDefinitionRegistryImpl();
    Parser parser = new Parser();
    parser.parse(Collections.singletonList(getClass().getResource(name)));
    parser.populate(handlers, registry);
    return registry;
}
Also used : ComponentDefinitionRegistryImpl(org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl) Parser(org.apache.aries.blueprint.parser.Parser)

Example 4 with ComponentDefinitionRegistryImpl

use of org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl in project aries by apache.

the class ExtPlaceholderTest method testStaticValues.

@Test
public void testStaticValues() throws Exception {
    ComponentDefinitionRegistryImpl registry = parse("/test-staticvalues.xml");
    Repository repository = new TestBlueprintContainer(registry).getRepository();
    Object obj1 = repository.create("beanD");
    assertNotNull(obj1);
    assertTrue(obj1 instanceof BeanD);
    BeanD beanD = (BeanD) obj1;
    assertEquals(ExtNamespaceHandler.BLUEPRINT_EXT_NAMESPACE_V1_5, beanD.getName());
}
Also used : Repository(org.apache.aries.blueprint.di.Repository) BeanD(org.apache.aries.blueprint.pojos.BeanD) ComponentDefinitionRegistryImpl(org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl) Test(org.junit.Test)

Example 5 with ComponentDefinitionRegistryImpl

use of org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl in project aries by apache.

the class ReferencesTest method testWiring.

public void testWiring() throws Exception {
    ComponentDefinitionRegistryImpl registry = parse("/test-references.xml");
    ProxyManager proxyManager = new AbstractProxyManager() {

        @Override
        protected Object createNewProxy(Bundle bundle, Collection<Class<?>> classes, Callable<Object> objectCallable, InvocationListener invocationListener) throws UnableToProxyException {
            return new Object();
        }

        @Override
        protected InvocationHandler getInvocationHandler(Object o) {
            return null;
        }

        @Override
        protected boolean isProxyClass(Class<?> aClass) {
            return false;
        }
    };
    Repository repository = new TestBlueprintContainer(registry, proxyManager).getRepository();
    repository.create("refItf");
    try {
        repository.create("refClsErr");
        fail("Should have failed");
    } catch (ComponentDefinitionException e) {
    }
    repository.create("refClsOk");
}
Also used : Repository(org.apache.aries.blueprint.di.Repository) AbstractProxyManager(org.apache.aries.proxy.impl.AbstractProxyManager) ComponentDefinitionException(org.osgi.service.blueprint.container.ComponentDefinitionException) Bundle(org.osgi.framework.Bundle) InvocationListener(org.apache.aries.proxy.InvocationListener) AbstractProxyManager(org.apache.aries.proxy.impl.AbstractProxyManager) ProxyManager(org.apache.aries.proxy.ProxyManager) Collection(java.util.Collection) ComponentDefinitionRegistryImpl(org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl) Callable(java.util.concurrent.Callable)

Aggregations

ComponentDefinitionRegistryImpl (org.apache.aries.blueprint.parser.ComponentDefinitionRegistryImpl)16 Repository (org.apache.aries.blueprint.di.Repository)12 BlueprintRepository (org.apache.aries.blueprint.container.BlueprintRepository)8 MyObject (org.apache.aries.blueprint.pojos.PojoGenerics2.MyObject)6 HashMap (java.util.HashMap)4 BigInteger (java.math.BigInteger)3 Map (java.util.Map)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 ComponentDefinitionRegistry (org.apache.aries.blueprint.ComponentDefinitionRegistry)2 NamespaceHandlerSet (org.apache.aries.blueprint.parser.NamespaceHandlerSet)2 Parser (org.apache.aries.blueprint.parser.Parser)2 BeanD (org.apache.aries.blueprint.pojos.BeanD)2 PojoA (org.apache.aries.blueprint.pojos.PojoA)2 PojoB (org.apache.aries.blueprint.pojos.PojoB)2 SimpleBean (org.apache.aries.blueprint.pojos.SimpleBean)2 ComponentDefinitionException (org.osgi.service.blueprint.container.ComponentDefinitionException)2 URL (java.net.URL)1 Calendar (java.util.Calendar)1 Collection (java.util.Collection)1