Examples of MutableBeanMetadata


Examples of org.apache.aries.blueprint.mutable.MutableBeanMetadata

    }

    private ComponentMetadata parseManagedServiceFactory(ParserContext context, Element element) {
        String id = getId(context, element);

        MutableBeanMetadata factoryMetadata = context.createMetadata(MutableBeanMetadata.class);
        generateIdIfNeeded(context, factoryMetadata);
        factoryMetadata.addProperty("id", createValue(context, factoryMetadata.getId()));
        factoryMetadata.setScope(BeanMetadata.SCOPE_SINGLETON);
        factoryMetadata.setRuntimeClass(CmManagedServiceFactory.class);
        factoryMetadata.setInitMethod("init");
        factoryMetadata.setDestroyMethod("destroy");
        factoryMetadata.addArgument(createRef(context, "blueprintContainer"), null, 0);
        factoryMetadata.addProperty("factoryPid", createValue(context, element.getAttribute(FACTORY_PID_ATTRIBUTE)));
        String autoExport = element.hasAttribute(AUTO_EXPORT_ATTRIBUTE) ? element.getAttribute(AUTO_EXPORT_ATTRIBUTE) : AUTO_EXPORT_DEFAULT;
        if (AUTO_EXPORT_DISABLED.equals(autoExport)) {
            autoExport = Integer.toString(ServiceMetadata.AUTO_EXPORT_DISABLED);
        } else if (AUTO_EXPORT_INTERFACES.equals(autoExport)) {
            autoExport = Integer.toString(ServiceMetadata.AUTO_EXPORT_INTERFACES);
        } else if (AUTO_EXPORT_CLASS_HIERARCHY.equals(autoExport)) {
            autoExport = Integer.toString(ServiceMetadata.AUTO_EXPORT_CLASS_HIERARCHY);
        } else if (AUTO_EXPORT_ALL.equals(autoExport)) {
            autoExport = Integer.toString(ServiceMetadata.AUTO_EXPORT_ALL_CLASSES);
        } else {
            throw new ComponentDefinitionException("Illegal value (" + autoExport + ") for " + AUTO_EXPORT_ATTRIBUTE + " attribute");
        }
        factoryMetadata.addProperty("autoExport", createValue(context, autoExport));
        String ranking = element.hasAttribute(RANKING_ATTRIBUTE) ? element.getAttribute(RANKING_ATTRIBUTE) : RANKING_DEFAULT;
        factoryMetadata.addProperty("ranking", createValue(context, ranking));

        List<String> interfaces = null;
        if (element.hasAttribute(INTERFACE_ATTRIBUTE)) {
            interfaces = Collections.singletonList(element.getAttribute(INTERFACE_ATTRIBUTE));
            factoryMetadata.addProperty("interfaces", createList(context, interfaces));
        }
      
        // Parse elements
        List<RegistrationListener> listeners = new ArrayList<RegistrationListener>();
        NodeList nl = element.getChildNodes();
        for (int i = 0; i < nl.getLength(); i++) {
            Node node = nl.item(i);
            if (node instanceof Element) {
                Element e = (Element) node;
                if (isBlueprintNamespace(e.getNamespaceURI())) {
                    if (nodeNameEquals(e, INTERFACES_ELEMENT)) {
                        if (interfaces != null) {
                            throw new ComponentDefinitionException("Only one of " + INTERFACE_ATTRIBUTE + " attribute or " + INTERFACES_ELEMENT + " element must be used");
                        }
                        interfaces = parseInterfaceNames(e);
                        factoryMetadata.addProperty("interfaces", createList(context, interfaces));                   
                    } else if (nodeNameEquals(e, SERVICE_PROPERTIES_ELEMENT)) {
                        MapMetadata map = context.parseElement(MapMetadata.class,
                            factoryMetadata, e);
                        factoryMetadata.addProperty("serviceProperties", map);
                        NodeList enl = e.getChildNodes();
                        for (int j = 0; j < enl.getLength(); j++) {
                            Node enode = enl.item(j);
                            if (enode instanceof Element) {
                                if (isCmNamespace(enode.getNamespaceURI()) && nodeNameEquals(enode, CM_PROPERTIES_ELEMENT)) {
                                    decorateCmProperties(context, (Element) enode, factoryMetadata);
                                }
                            }
                        }
                    } else if (nodeNameEquals(e, REGISTRATION_LISTENER_ELEMENT)) {
                        listeners.add(context.parseElement(RegistrationListener.class,
                            factoryMetadata, e));
                    }
                } else if (isCmNamespace(e.getNamespaceURI())) {
                    if (nodeNameEquals(e, MANAGED_COMPONENT_ELEMENT)) {
                        MutableBeanMetadata managedComponent = context.parseElement(MutableBeanMetadata.class, null, e);
                        generateIdIfNeeded(context, managedComponent);
                        managedComponent.setScope(BeanMetadata.SCOPE_PROTOTYPE);
                        // destroy-method on managed-component has different signature than on regular beans
                        // so we'll handle it differently
                        String destroyMethod = managedComponent.getDestroyMethod();
                        if (destroyMethod != null) {
                            factoryMetadata.addProperty("componentDestroyMethod", createValue(context, destroyMethod));
                            managedComponent.setDestroyMethod(null);
                        }
                        context.getComponentDefinitionRegistry().registerComponentDefinition(managedComponent);
                        factoryMetadata.addProperty("managedComponentName", createIdRef(context, managedComponent.getId()));
                    }
                }
            }
        }

        MutableCollectionMetadata listenerCollection = context.createMetadata(MutableCollectionMetadata.class);
        listenerCollection.setCollectionClass(List.class);
        for (RegistrationListener listener : listeners) {
            MutableBeanMetadata bean = context.createMetadata(MutableBeanMetadata.class);
            bean.setRuntimeClass(ServiceListener.class);
            bean.addProperty("listener", listener.getListenerComponent());
            bean.addProperty("registerMethod", createValue(context, listener.getRegistrationMethod()));
            bean.addProperty("unregisterMethod", createValue(context, listener.getUnregistrationMethod()));
            listenerCollection.addValue(bean);
        }
        factoryMetadata.addProperty("listeners", listenerCollection);
       
        context.getComponentDefinitionRegistry().registerComponentDefinition(factoryMetadata);
       
        MutableBeanMetadata mapMetadata = context.createMetadata(MutableBeanMetadata.class);
        mapMetadata.setScope(BeanMetadata.SCOPE_SINGLETON);
        mapMetadata.setId(id);
        mapMetadata.setFactoryComponent(createRef(context, factoryMetadata.getId()));
        mapMetadata.setFactoryMethod("getServiceMap");
        return mapMetadata;
    }
View Full Code Here

Examples of org.apache.aries.blueprint.mutable.MutableBeanMetadata

        return mapMetadata;
    }

    private ComponentMetadata decorateCmProperties(ParserContext context, Element element, ComponentMetadata component) {
        generateIdIfNeeded(context, ((MutableComponentMetadata) component));
        MutableBeanMetadata metadata = context.createMetadata(MutableBeanMetadata.class);
        metadata.setProcessor(true);
        metadata.setId(getId(context, element));
        metadata.setRuntimeClass(CmProperties.class);
        String persistentId = element.getAttribute(PERSISTENT_ID_ATTRIBUTE);
        // if persistentId is "" the cm-properties element in nested in managed-service-factory
        // and the configuration object will come from the factory. So we only really need to register
        // ManagedService if the persistentId is not an empty string.
        if (persistentId.length() > 0) {
            metadata.setInitMethod("init");
            metadata.setDestroyMethod("destroy");
        }
        metadata.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
        metadata.addProperty("configAdmin", createConfigurationAdminRef(context));
        metadata.addProperty("managedObjectManager", createRef(context, MANAGED_OBJECT_MANAGER_NAME));
        metadata.addProperty("persistentId", createValue(context, persistentId));
        if (element.hasAttribute(UPDATE_ATTRIBUTE)) {
            metadata.addProperty("update", createValue(context, element.getAttribute(UPDATE_ATTRIBUTE)));
        }
        metadata.addProperty("serviceId", createIdRef(context, component.getId()));
        context.getComponentDefinitionRegistry().registerComponentDefinition(metadata);
        return component;
    }
View Full Code Here

Examples of org.apache.aries.blueprint.mutable.MutableBeanMetadata

    private ComponentMetadata decorateManagedProperties(ParserContext context, Element element, ComponentMetadata component) {
        if (!(component instanceof MutableBeanMetadata)) {
            throw new ComponentDefinitionException("Element " + MANAGED_PROPERTIES_ELEMENT + " must be used inside a <bp:bean> element");
        }
        generateIdIfNeeded(context, ((MutableBeanMetadata) component));
        MutableBeanMetadata metadata = context.createMetadata(MutableBeanMetadata.class);
        metadata.setProcessor(true);
        metadata.setId(getId(context, element));
        metadata.setRuntimeClass(CmManagedProperties.class);
        String persistentId = element.getAttribute(PERSISTENT_ID_ATTRIBUTE);
        // if persistentId is "" the managed properties element in nested in managed-service-factory
        // and the configuration object will come from the factory. So we only really need to register
        // ManagedService if the persistentId is not an empty string.
        if (persistentId.length() > 0) {
            metadata.setInitMethod("init");
            metadata.setDestroyMethod("destroy");
        }
        metadata.addProperty("blueprintContainer", createRef(context, "blueprintContainer"));
        metadata.addProperty("configAdmin", createConfigurationAdminRef(context));
        metadata.addProperty("managedObjectManager", createRef(context, MANAGED_OBJECT_MANAGER_NAME));
        metadata.addProperty("persistentId", createValue(context, persistentId));
        String updateStrategy = element.getAttribute(UPDATE_STRATEGY_ATTRIBUTE);
        if (updateStrategy != null) {
            metadata.addProperty("updateStrategy", createValue(context, updateStrategy));
        }
        if (element.hasAttribute(UPDATE_METHOD_ATTRIBUTE)) {
            metadata.addProperty("updateMethod", createValue(context, element.getAttribute(UPDATE_METHOD_ATTRIBUTE)));
        } else if ("component-managed".equals(updateStrategy)) {
            throw new ComponentDefinitionException(UPDATE_METHOD_ATTRIBUTE + " attribute must be set when " + UPDATE_STRATEGY_ATTRIBUTE + " is set to 'component-managed'");
        }
        metadata.addProperty("beanName", createIdRef(context, component.getId()));
        context.getComponentDefinitionRegistry().registerComponentDefinition(metadata);
        return component;
    }
View Full Code Here

Examples of org.apache.aries.blueprint.mutable.MutableBeanMetadata

        return component;
    }

    private void registerManagedObjectManager(ParserContext context, ComponentDefinitionRegistry registry) {
        if (registry.getComponentDefinition(MANAGED_OBJECT_MANAGER_NAME) == null) {
            MutableBeanMetadata beanMetadata = context.createMetadata(MutableBeanMetadata.class);
            beanMetadata.setScope(BeanMetadata.SCOPE_SINGLETON);
            beanMetadata.setId(MANAGED_OBJECT_MANAGER_NAME);
            beanMetadata.setRuntimeClass(ManagedObjectManager.class);           
            registry.registerComponentDefinition(beanMetadata);
        }
    }
View Full Code Here

Examples of org.apache.aries.blueprint.mutable.MutableBeanMetadata

                    MutablePassThroughMetadata factory
                        = context.createMetadata(MutablePassThroughMetadata.class);
                    factory.setObject(new PassThroughCallable<Object>(new BlueprintResourceFactory(v)));

                    MutableBeanMetadata resourceBean = context.createMetadata(MutableBeanMetadata.class);
                    resourceBean.setRuntimeClass(BlueprintResourceFactory.class);
                    resourceBean.setFactoryComponent(factory);
                    resourceBean.setFactoryMethod("call");
                    resourceBean.setInitMethod("init");

                    tempFactories.addValue(resourceBean);
                }
            }
            bean.addProperty("tempFactories", tempFactories);
View Full Code Here

Examples of org.apache.aries.blueprint.mutable.MutableBeanMetadata

        } else if ("resourceClasses".equals(name)) {
            List<String> resources = getResourceClassesFromElement(el);
            MutableCollectionMetadata list = ctx.createMetadata(MutableCollectionMetadata.class);
            list.setCollectionClass(List.class);
            for (String res : resources) {
                MutableBeanMetadata objectOfClass = createObjectOfClass(ctx, res);
                list.addValue(objectOfClass);
            }
            bean.addProperty("serviceBeans", list);
        } else if ("model".equals(name)) {
            List<UserResource> resources = ResourceUtils.getResourcesFromElement(el);
            MutableCollectionMetadata list = ctx.createMetadata(MutableCollectionMetadata.class);
            list.setCollectionClass(List.class);
            for (UserResource res : resources) {
                MutablePassThroughMetadata factory = ctx.createMetadata(MutablePassThroughMetadata.class);
                factory.setObject(new PassThroughCallable<Object>(res));

                MutableBeanMetadata resourceBean = ctx.createMetadata(MutableBeanMetadata.class);
                resourceBean.setFactoryComponent(factory);
                resourceBean.setFactoryMethod("call");
                list.addValue(resourceBean);
            }
            bean.addProperty("modelBeans", list);
        } else {
            setFirstChildAsProperty(el, ctx, bean, name);           
View Full Code Here

Examples of org.apache.aries.blueprint.mutable.MutableBeanMetadata

    }
   

    @Override
    public Metadata parse(Element element, ParserContext context) {
        MutableBeanMetadata bean = (MutableBeanMetadata)super.parse(element, context);
        bean.setInitMethod("init");

        // We don't really want to delay the registration of our Server
        bean.setActivation(MutableBeanMetadata.ACTIVATION_EAGER);
        return bean;
    }
View Full Code Here

Examples of org.apache.aries.blueprint.mutable.MutableBeanMetadata


public class RsClientDefinitionParser extends AbstractBeanDefinitionParser {

    public Metadata parse(Element element, ParserContext context) {
        MutableBeanMetadata beanMetadata = createBeanMetadata(element, context, RsClientBlueprintBean.class);
        NamedNodeMap atts = element.getAttributes();

        String bus = null;
        for (int i = 0; i < atts.getLength(); i++) {
            Attr node = (Attr) atts.item(i);
            String val = node.getValue();
            String pre = node.getPrefix();
            String name = node.getLocalName();
            if ("bus".equals(name)) {
                bus = val;
            } else if (isAttribute(pre, name)) {
                if ("depends-on".equals(name)) {
                    beanMetadata.addDependsOn(val);
                } else if (!"name".equals(name)) {
                    beanMetadata.addProperty(name, AbstractBPBeanDefinitionParser.createValue(context, val));
                }
            }
        }

        Element elem = DOMUtils.getFirstElement(element);
        while (elem != null) {
            String name = elem.getLocalName();
            if ("properties".equals(name) || "headers".equals(name)) {
                Metadata map = parseMapData(context, beanMetadata, elem);
                beanMetadata.addProperty(name, map);
            } else if ("binding".equals(name)) {
                setFirstChildAsProperty(element, context, beanMetadata, "bindingConfig");
            } else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name)
                || "outFaultInterceptors".equals(name) || "features".equals(name) || "schemaLocations".equals(name) || "handlers".equals(name)) {
                Metadata list = parseListData(context, beanMetadata, elem);
                beanMetadata.addProperty(name, list);
            } else if ("features".equals(name) || "providers".equals(name)
                || "schemaLocations".equals(name) || "modelBeans".equals(name)
                || "serviceBeans".equals(name)) {
                Metadata list = parseListData(context, beanMetadata, elem);
                beanMetadata.addProperty(name, list);
            } else if ("model".equals(name)) {
                List<UserResource> resources = ResourceUtils.getResourcesFromElement(elem);
                MutablePassThroughMetadata value = context.createMetadata(MutablePassThroughMetadata.class);
                value.setObject(resources);
                beanMetadata.addProperty(name, value);
            } else {
                setFirstChildAsProperty(element, context, beanMetadata, name);
            }
        }
        if (StringUtils.isEmpty(bus)) {
            bus = "cxf";
        }
        //Will create a bus if needed...

        beanMetadata.addProperty("bus", getBusRef(context, bus));
        return beanMetadata;
    }
View Full Code Here

Examples of org.apache.aries.blueprint.mutable.MutableBeanMetadata


public class EndpointDefinitionParser extends AbstractBeanDefinitionParser {
   
    public Metadata parse(Element element, ParserContext context) {
        MutableBeanMetadata endpointConfig = createBeanMetadata(element, context, CxfBlueprintEndpoint.class);
        NamedNodeMap atts = element.getAttributes();

        String bus = null;
        String address = null;

        for (int i = 0; i < atts.getLength(); i++) {
            Attr node = (Attr) atts.item(i);
            String val = node.getValue();
            String pre = node.getPrefix();
            String name = node.getLocalName();
            if ("bus".equals(name)) {
                bus = val;
            } else if ("address".equals(name)) {
                address = val;
            } else if (isAttribute(pre, name)) {
                if ("endpointName".equals(name) || "serviceName".equals(name)) {
                    if (isPlaceHolder(val)) {
                        endpointConfig.addProperty(name + "String", createValue(context, val));
                    } else {
                        QName q = parseQName(element, val);
                        endpointConfig.addProperty(name, createValue(context, q));
                    }
                } else if ("depends-on".equals(name)) {
                    endpointConfig.addDependsOn(val);
                } else if (!"name".equals(name)) {
                    endpointConfig.addProperty(name, createValue(context, val));
                }
            }
        }

        Element elem = DOMUtils.getFirstElement(element);
        while (elem != null) {
            String name = elem.getLocalName();
            if ("properties".equals(name)) {
                Metadata map = parseMapData(context, endpointConfig, elem);
                endpointConfig.addProperty(name, map);
            } else if ("binding".equals(name)) {
                setFirstChildAsProperty(element, context, endpointConfig, "bindingConfig");
            } else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name)
                || "outFaultInterceptors".equals(name) || "features".equals(name) || "schemaLocations".equals(name) || "handlers".equals(name)) {
                Metadata list = parseListData(context, endpointConfig, elem);
                endpointConfig.addProperty(name, list);
            } else {
                setFirstChildAsProperty(element, context, endpointConfig, name);
            }

            elem = DOMUtils.getNextElement(elem);
        }
        if (StringUtils.isEmpty(bus)) {
            bus = "cxf";
        }
        //Will create a bus if needed...

        endpointConfig.addProperty("bus", getBusRef(context, bus));
        endpointConfig.setDestroyMethod("destroy");
        endpointConfig.addArgument(createValue(context, address), String.class.getName(), 0);
        endpointConfig.addArgument(createRef(context, "blueprintBundleContext"),
                                   BundleContext.class.getName(), 1);

        return endpointConfig;
    }
View Full Code Here

Examples of org.apache.aries.blueprint.mutable.MutableBeanMetadata

import org.osgi.service.blueprint.reflect.Metadata;

public class RsServerDefinitionParser extends AbstractBeanDefinitionParser {
   
    public Metadata parse(Element element, ParserContext context) {
        MutableBeanMetadata beanMetadata = createBeanMetadata(element, context, RsServerBlueprintBean.class);
        NamedNodeMap atts = element.getAttributes();

        String bus = null;
        for (int i = 0; i < atts.getLength(); i++) {
            Attr node = (Attr) atts.item(i);
            String val = node.getValue();
            String pre = node.getPrefix();
            String name = node.getLocalName();
            if ("bus".equals(name)) {
                bus = val;
            } else if (isAttribute(pre, name)) {
                if ("depends-on".equals(name)) {
                    beanMetadata.addDependsOn(val);
                } else if (!"name".equals(name)) {
                    beanMetadata.addProperty(name, AbstractBPBeanDefinitionParser.createValue(context, val));
                }
            }
        }

        Element elem = DOMUtils.getFirstElement(element);
        while (elem != null) {
            String name = elem.getLocalName();
            if ("properties".equals(name)
                || "extensionMappings".equals(name)
                || "languageMappings".equals(name)) {
                Metadata map = parseMapData(context, beanMetadata, elem);
                beanMetadata.addProperty(name, map);
            } else if ("binding".equals(name)) {
                setFirstChildAsProperty(element, context, beanMetadata, "bindingConfig");
            } else if ("inInterceptors".equals(name) || "inFaultInterceptors".equals(name) || "outInterceptors".equals(name)
                || "outFaultInterceptors".equals(name) || "features".equals(name) || "schemaLocations".equals(name) || "handlers".equals(name)) {
                Metadata list = parseListData(context, beanMetadata, elem);
                beanMetadata.addProperty(name, list);
            } else if ("features".equals(name) || "providers".equals(name)
                || "schemaLocations".equals(name) || "modelBeans".equals(name)) {
                Metadata list = parseListData(context, beanMetadata, elem);
                beanMetadata.addProperty(name, list);
            } else if ("model".equals(name)) {
                List<UserResource> resources = ResourceUtils.getResourcesFromElement(elem);
                MutablePassThroughMetadata value = context.createMetadata(MutablePassThroughMetadata.class);
                value.setObject(resources);
                beanMetadata.addProperty(name, value);
            } else {
                setFirstChildAsProperty(element, context, beanMetadata, name);
            }
        }
        if (StringUtils.isEmpty(bus)) {
            bus = "cxf";
        }
        //Will create a bus if needed...

        beanMetadata.addProperty("bus", getBusRef(context, bus));
        return beanMetadata;
    }
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.