Package org.osgi.service.blueprint.reflect

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


        return v;
    }

    protected MutableBeanMetadata getBus(ParserContext context, String name) {
        ComponentDefinitionRegistry cdr = context.getComponentDefinitionRegistry();
        ComponentMetadata meta = cdr.getComponentDefinition("blueprintBundle");

        Bundle blueprintBundle = null;
        if (meta instanceof PassThroughMetadata) {
            blueprintBundle = (Bundle) ((PassThroughMetadata) meta).getObject();
        }
View Full Code Here


        }
    }
   
    public <T> T getBeanOfType(String name, Class<T> type) {
       
        ComponentMetadata cmd = getComponentMetadata(name);
        Class<?> cls = getClassForMetaData(cmd);
        if (cls != null && type.isAssignableFrom(cls)) {
            return type.cast(container.getComponentInstance(name));
        }
        return orig.getBeanOfType(name, type);
View Full Code Here

    }
    /** {@inheritDoc}*/
    public List<String> getBeanNamesOfType(Class<?> type) {
        Set<String> names = new LinkedHashSet<String>();
        for (String s : container.getComponentIds()) {
            ComponentMetadata cmd = container.getComponentMetadata(s);
            Class<?> cls = getClassForMetaData(cmd);
            if (cls != null && type.isAssignableFrom(cls)) {
                names.add(s);
            }
        }
View Full Code Here

    /** {@inheritDoc}*/
    public <T> Collection<? extends T> getBeansOfType(Class<T> type) {
        List<T> list = new ArrayList<T>();
       
        for (String s : container.getComponentIds()) {
            ComponentMetadata cmd = container.getComponentMetadata(s);
            Class<?> cls = getClassForMetaData(cmd);
            if (cls != null && type.isAssignableFrom(cls)) {
                list.add(type.cast(container.getComponentInstance(s)));
            }
        }
View Full Code Here

    /** {@inheritDoc}*/
    public <T> boolean loadBeansOfType(Class<T> type, BeanLoaderListener<T> listener) {
        List<String> names = new ArrayList<String>();
        boolean loaded = false;
        for (String s : container.getComponentIds()) {
            ComponentMetadata cmd = container.getComponentMetadata(s);
            Class<?> cls = getClassForMetaData(cmd);
            if (cls != null && type.isAssignableFrom(cls)) {
                names.add(s);
            }
        }
        Collections.reverse(names);
        for (String s : names) {
            ComponentMetadata cmd = container.getComponentMetadata(s);
            Class<?> beanType = getClassForMetaData(cmd);
            Class<? extends T> t = beanType.asSubclass(type);
            if (listener.loadBean(s, t)) {
                Object o = container.getComponentInstance(s);
                if (listener.beanLoaded(s, type.cast(o))) {
View Full Code Here

        }
        return loaded || orig.loadBeansOfType(type, listener);
    }

    public boolean hasConfiguredPropertyValue(String beanName, String propertyName, String value) {
        ComponentMetadata cmd = getComponentMetadata(beanName);
        if (cmd instanceof BeanMetadata) {
            BeanMetadata br = (BeanMetadata)cmd;
            for (BeanProperty s : br.getProperties()) {
                if (propertyName.equals(s.getName())) {
                    return true;
View Full Code Here

        }
        return orig.hasConfiguredPropertyValue(beanName, propertyName, value);
    }

    public boolean hasBeanOfName(String name) {
        ComponentMetadata cmd = getComponentMetadata(name);
        if (cmd instanceof BeanMetadata) {
            return true;
        }       
        return orig.hasBeanOfName(name);
    }
View Full Code Here

        Bundle bundle = (Bundle) blueprintContainer.getComponentInstance("blueprintBundle");
        Map<String, T> objects = new LinkedHashMap<String, T>();
        Set<String> ids = blueprintContainer.getComponentIds();
        for (String id : ids) {
            try {
                ComponentMetadata metadata = blueprintContainer.getComponentMetadata(id);
                Class<?> cl = null;
                if (metadata instanceof BeanMetadata) {
                    BeanMetadata beanMetadata = (BeanMetadata)metadata;
                    cl = bundle.loadClass(beanMetadata.getClassName());
                } else if (metadata instanceof ReferenceMetadata) {
                    ReferenceMetadata referenceMetadata = (ReferenceMetadata)metadata;
                    cl = bundle.loadClass(referenceMetadata.getInterface());
                }
                if (cl != null && type.isAssignableFrom(cl)) {
                    Object o = blueprintContainer.getComponentInstance(metadata.getId());
                    objects.put(metadata.getId(), type.cast(o));
                }
            } catch (Throwable t) {
                // ignore
            }
        }
View Full Code Here

    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

     * @return a set with the ids of the {@link BlueprintCamelContext}, never <tt>null</tt>, but can be empty set.
     */
    public static Set<String> lookupBlueprintCamelContext(BlueprintContainer container) {
        Set<String> ids = new LinkedHashSet<String>();
        for (Object id : container.getComponentIds()) {
            ComponentMetadata meta = container.getComponentMetadata(id.toString());

            // must be extended meta, to see if its the blueprint camel context
            if (meta instanceof ExtendedBeanMetadata) {
                Class<?> clazz = ((ExtendedBeanMetadata) meta).getRuntimeClass();
                if (clazz != null && BlueprintCamelContext.class.isAssignableFrom(clazz)) {
                    // okay we found a BlueprintCamelContext
                    ids.add(meta.getId());
                }
            }
        }
        return ids;
    }
View Full Code Here

TOP

Related Classes of org.osgi.service.blueprint.reflect.ComponentMetadata

Copyright © 2018 www.massapicom. 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.