Examples of ComponentMetadata


Examples of org.osgi.service.blueprint.reflect.ComponentMetadata

        return cm;
    }

    private static ComponentMetadata getComponentResolverReference(ParserContext context, String component) {
        ComponentDefinitionRegistry componentDefinitionRegistry = context.getComponentDefinitionRegistry();
        ComponentMetadata cm = componentDefinitionRegistry.getComponentDefinition(".camelBlueprint.componentResolver." + component);
        if (cm == null) {
            MutableReferenceMetadata svc = context.createMetadata(MutableReferenceMetadata.class);
            svc.setId(".camelBlueprint.componentResolver." + component);
            svc.setFilter("(component=" + component + ")");
            svc.setAvailability(componentDefinitionRegistry.containsComponentDefinition(component) ? AVAILABILITY_OPTIONAL : AVAILABILITY_MANDATORY);
View Full Code Here

Examples of org.osgi.service.blueprint.reflect.ComponentMetadata

        public void afterDestroy(Object bean, String beanName) {
        }

        @Override
        protected boolean isSingleton(Object bean, String beanName) {
            ComponentMetadata meta = blueprintContainer.getComponentMetadata(beanName);
            if (meta != null && meta instanceof BeanMetadata) {
                String scope = ((BeanMetadata) meta).getScope();
                if (scope != null) {
                    return BeanMetadata.SCOPE_SINGLETON.equals(scope);
                }
View Full Code Here

Examples of org.osgi.service.blueprint.reflect.ComponentMetadata

    public String[] lookupPropertyPlaceholderIds() {
        List<String> ids = new ArrayList<String>();

        for (Object componentId : container.getComponentIds()) {
            String id = (String) componentId;
            ComponentMetadata meta = container.getComponentMetadata(id);
            if (meta instanceof ExtendedBeanMetadata) {
                Class<?> clazz = ((ExtendedBeanMetadata) meta).getRuntimeClass();
                if (clazz != null && AbstractPropertyPlaceholder.class.isAssignableFrom(clazz)) {
                    ids.add(id);
                }
View Full Code Here

Examples of org.osgi.service.blueprint.reflect.ComponentMetadata

                findInputComponents(rd.getInputs(), components, languages, dataformats);
                findOutputComponents(rd.getOutputs(), components, languages, dataformats);
            }
            try {
                for (String component : components) {
                    ComponentMetadata cm = componentDefinitionRegistry.getComponentDefinition(".camelBlueprint.componentResolver." + component);
                    if (cm == null) {
                        MutableReferenceMetadata svc = createMetadata(MutableReferenceMetadata.class);
                        svc.setId(".camelBlueprint.componentResolver." + component);
                        svc.setFilter("(component=" + component + ")");
                        svc.setAvailability(componentDefinitionRegistry.containsComponentDefinition(component) ? AVAILABILITY_OPTIONAL : AVAILABILITY_MANDATORY);
                        try {
                            // Try to set the runtime interface (only with aries blueprint > 0.1
                            svc.getClass().getMethod("setRuntimeInterface", Class.class).invoke(svc, ComponentResolver.class);
                        } catch (Throwable t) {
                            // Check if the bundle can see the class
                            try {
                                PassThroughMetadata ptm = (PassThroughMetadata) componentDefinitionRegistry.getComponentDefinition("blueprintBundle");
                                Bundle b = (Bundle) ptm.getObject();
                                if (b.loadClass(ComponentResolver.class.getName()) != ComponentResolver.class) {
                                    throw new UnsupportedOperationException();
                                }
                                svc.setInterface(ComponentResolver.class.getName());
                            } catch (Throwable t2) {
                                throw new UnsupportedOperationException();
                            }
                        }
                        componentDefinitionRegistry.registerComponentDefinition(svc);
                        dependsOn.add(svc.getId());
                    }
                }
                for (String language : languages) {
                    ComponentMetadata cm = componentDefinitionRegistry.getComponentDefinition(".camelBlueprint.languageResolver." + language);
                    if (cm == null) {
                        MutableReferenceMetadata svc = createMetadata(MutableReferenceMetadata.class);
                        svc.setId(".camelBlueprint.languageResolver." + language);
                        svc.setFilter("(language=" + language + ")");
                        svc.setAvailability(componentDefinitionRegistry.containsComponentDefinition(language) ? AVAILABILITY_OPTIONAL : AVAILABILITY_MANDATORY);
                        try {
                            // Try to set the runtime interface (only with aries blueprint > 0.1
                            svc.getClass().getMethod("setRuntimeInterface", Class.class).invoke(svc, LanguageResolver.class);
                        } catch (Throwable t) {
                            // Check if the bundle can see the class
                            try {
                                PassThroughMetadata ptm = (PassThroughMetadata) componentDefinitionRegistry.getComponentDefinition("blueprintBundle");
                                Bundle b = (Bundle) ptm.getObject();
                                if (b.loadClass(LanguageResolver.class.getName()) != LanguageResolver.class) {
                                    throw new UnsupportedOperationException();
                                }
                                svc.setInterface(LanguageResolver.class.getName());
                            } catch (Throwable t2) {
                                throw new UnsupportedOperationException();
                            }
                        }
                        componentDefinitionRegistry.registerComponentDefinition(svc);
                        dependsOn.add(svc.getId());
                    }
                }
                for (String dataformat : dataformats) {
                    ComponentMetadata cm = componentDefinitionRegistry.getComponentDefinition(".camelBlueprint.dataformatResolver." + dataformat);
                    if (cm == null) {
                        MutableReferenceMetadata svc = createMetadata(MutableReferenceMetadata.class);
                        svc.setId(".camelBlueprint.dataformatResolver." + dataformat);
                        svc.setFilter("(dataformat=" + dataformat + ")");
                        svc.setAvailability(componentDefinitionRegistry.containsComponentDefinition(dataformat) ? AVAILABILITY_OPTIONAL : AVAILABILITY_MANDATORY);
View Full Code Here

Examples of org.osgi.service.blueprint.reflect.ComponentMetadata

        return ids;
    }

    public CompositeData getComponentMetadata(long containerServiceId, String componentId) {
        BlueprintContainer container = getBlueprintContainer(containerServiceId);
        ComponentMetadata componentMetadata = container.getComponentMetadata(componentId);
        BPMetadata metadata = Util.metadata2BPMetadata(componentMetadata);
        return metadata.asCompositeData();
    }
View Full Code Here

Examples of org.osgi.service.blueprint.reflect.ComponentMetadata

        }
        components.put(id, component);
    }

    public void removeComponentDefinition(String name) {
        ComponentMetadata removed = components.remove(name);
        if(removed!=null){
            interceptors.remove(removed);
        }
    }
View Full Code Here

Examples of org.osgi.service.blueprint.reflect.ComponentMetadata

    }

    public void testParseComponent() throws Exception {
        ComponentDefinitionRegistry registry = parse("/test-simple-component.xml");
        assertNotNull(registry);
        ComponentMetadata component = registry.getComponentDefinition("pojoA");
        assertNotNull(component);
        assertEquals("pojoA", component.getId());
        assertTrue(component instanceof BeanMetadata);
        BeanMetadata local = (BeanMetadata) component;
        List<String> deps = local.getDependsOn();
        assertNotNull(deps);
        assertEquals(2, deps.size());
        assertTrue(deps.contains("pojoB"));
        assertTrue(deps.contains("pojoC"));
        assertEquals("org.apache.aries.blueprint.pojos.PojoA", local.getClassName());
        List<BeanArgument> params = local.getArguments();
        assertNotNull(params);
        assertEquals(6, params.size());
        BeanArgument param = params.get(0);
        assertNotNull(param);
        assertEquals(-1, param.getIndex());
        assertNull(param.getValueType());
        assertNotNull(param.getValue());
        assertTrue(param.getValue() instanceof ValueMetadata);
        assertEquals("val0", ((ValueMetadata) param.getValue()).getStringValue());
        assertNull(((ValueMetadata) param.getValue()).getType());
        param = params.get(1);
        assertNotNull(param);
        assertEquals(-1, param.getIndex());
        assertNull(param.getValueType());
        assertNotNull(param.getValue());
        assertTrue(param.getValue() instanceof RefMetadata);
        assertEquals("val1", ((RefMetadata) param.getValue()).getComponentId());
        param = params.get(2);
        assertNotNull(param);
        assertEquals(-1, param.getIndex());
        assertNull(param.getValueType());
        assertNotNull(param.getValue());
        assertTrue(param.getValue() instanceof NullMetadata);
        param = params.get(3);
        assertNotNull(param);
        assertEquals(-1, param.getIndex());
        assertEquals("java.lang.String", param.getValueType());
        assertNotNull(param.getValue());
        assertTrue(param.getValue() instanceof ValueMetadata);
        assertEquals("val3", ((ValueMetadata) param.getValue()).getStringValue());
        assertNull(((ValueMetadata) param.getValue()).getType());
        param = params.get(4);
        assertNotNull(param);
        assertEquals(-1, param.getIndex());
        assertNull(param.getValueType());
        assertNotNull(param.getValue());
        assertTrue(param.getValue() instanceof CollectionMetadata);
        CollectionMetadata array = (CollectionMetadata) param.getValue();
        assertNull(array.getValueType());
        assertNotNull(array.getValues());
        assertEquals(3, array.getValues().size());
        assertTrue(array.getValues().get(0) instanceof ValueMetadata);
        assertTrue(array.getValues().get(1) instanceof ComponentMetadata);
        assertTrue(array.getValues().get(2) instanceof NullMetadata);
        param = params.get(5);
        assertNotNull(param);
        assertEquals(-1, param.getIndex());
        assertNull(param.getValueType());
        assertNotNull(param.getValue());
        assertTrue(param.getValue() instanceof RefMetadata);
        assertEquals("pojoB", ((RefMetadata) param.getValue()).getComponentId());
       
        assertEquals(null, local.getInitMethod());
        assertEquals(null, local.getDestroyMethod());
               
        // test pojoB
        ComponentMetadata pojoB = registry.getComponentDefinition("pojoB");
        assertNotNull(pojoB);
        assertEquals("pojoB", pojoB.getId());
        assertTrue(pojoB instanceof BeanMetadata);
        BeanMetadata pojoBLocal = (BeanMetadata) pojoB;
        assertEquals("initPojo", pojoBLocal.getInitMethod());
//        assertEquals("", pojoBLocal.getDestroyMethod());
       
View Full Code Here

Examples of org.osgi.service.blueprint.reflect.ComponentMetadata


    public void testCustomNodes() throws Exception {
        ComponentDefinitionRegistry registry = parse("/test-custom-nodes.xml", new TestNamespaceHandlerSet());
       
        ComponentMetadata metadata;
       
        metadata = registry.getComponentDefinition("fooService");
        assertNotNull(metadata);
        assertTrue(metadata instanceof MyLocalComponentMetadata);
        MyLocalComponentMetadata comp1 = (MyLocalComponentMetadata) metadata;
View Full Code Here

Examples of org.osgi.service.blueprint.reflect.ComponentMetadata

        if (nodeNameEquals(element, DESCRIPTION_ELEMENT)) {
            // Ignore description
        } else if (nodeNameEquals(element, TYPE_CONVERTERS_ELEMENT)) {
            parseTypeConverters(element);
        } else if (nodeNameEquals(element, BEAN_ELEMENT)) {
            ComponentMetadata component = parseBeanMetadata(element, true);
            registry.registerComponentDefinition(component);
        } else if (nodeNameEquals(element, SERVICE_ELEMENT)) {
            ComponentMetadata service = parseService(element, true);
            registry.registerComponentDefinition(service);
        } else if (nodeNameEquals(element, REFERENCE_ELEMENT)) {
            ComponentMetadata reference = parseReference(element, true);
            registry.registerComponentDefinition(reference);
        } else if (nodeNameEquals(element, REFERENCE_LIST_ELEMENT) ) {
            ComponentMetadata references = parseRefList(element, true);
            registry.registerComponentDefinition(references);
        } else {
            throw new ComponentDefinitionException("Unknown element " + element.getNodeName() + " in namespace " + BLUEPRINT_NAMESPACE);
        }
    }
View Full Code Here

Examples of org.osgi.service.blueprint.reflect.ComponentMetadata

            }
        }

        MetadataUtil.validateBeanArguments(metadata.getArguments());
       
        ComponentMetadata m = metadata;
       
        // Parse custom scopes
        m = handleCustomScope(element.getAttributeNode(SCOPE_ATTRIBUTE), element, m);
       
        // Parse custom attributes
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.