Package org.apache.aries.blueprint.mutable

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


        checkAndSetReference(context, element, envParamMetadata, ELEMENT_TRANSACTION_MANAGER, EnvironmentName.TRANSACTION_MANAGER, ATTRIBUTE_REF);
        checkAndSetReference(context, element, envParamMetadata, ELEMENT_GLOBALS, EnvironmentName.GLOBALS, ATTRIBUTE_REF);
        checkAndSetReference(context, element, envParamMetadata, ELEMENT_DATE_FORMATS, EnvironmentName.DATE_FORMATS, ATTRIBUTE_REF);
        checkAndSetReference(context, element, envParamMetadata, ELEMENT_CALENDARS, EnvironmentName.CALENDARS, ATTRIBUTE_REF);

        MutableCollectionMetadata strategiesCollectionMetadata = context.createMetadata(MutableCollectionMetadata.class);
        strategiesCollectionMetadata.setCollectionClass(ArrayList.class);
        NodeList nodeList = element.getElementsByTagName(element.getPrefix()+":"+ELEMENT_OBJECT_MARSHALLING_STRATEGIES);
        if (nodeList != null && nodeList.getLength() > 0){
            Node node = nodeList.item(0);
            if ( node instanceof Element ){
                Element strategiesElement = (Element)node;
                NodeList strategiesChildNodes = strategiesElement.getChildNodes();
                for ( int i=0; i < strategiesChildNodes.getLength(); i++){
                    Node childNode = strategiesChildNodes.item(i);
                    if ( childNode instanceof  Element) {
                        Element child = (Element) childNode;
                        String localName = child.getLocalName();

                        if (ELEMENT_SERIALIZABLE_PLACEHOLDER_RESOLVER_STRATEGY.equalsIgnoreCase(localName)) {
                            String ref = child.getAttribute(ATTRIBUTE_STRATEGY_ACCEPTOR_REF);
                            MutableBeanMetadata beanMetadata = context.createMetadata(MutableBeanMetadata.class);
                            beanMetadata.setClassName(SerializablePlaceholderResolverStrategy.class.getName());
                            beanMetadata.setActivation(MutableBeanMetadata.ACTIVATION_LAZY);

                            // BeanArgumentImpl argument = new BeanArgumentImpl();
                            // argument.setIndex(0);
                            if (!StringUtils.isEmpty(ref)) {
                                //argument.setValue(createRef(context, ref));
                                beanMetadata.addArgument(createRef(context, ref), null, 0);

                            } else {
                                MutableBeanMetadata defaultStrategyAcceptor = context.createMetadata(MutableBeanMetadata.class);
                                defaultStrategyAcceptor.setClassName(KieObjectsFactoryBean.class.getName());
                                defaultStrategyAcceptor.setFactoryMethod("createDefaultAcceptor");
                                beanMetadata.addArgument(defaultStrategyAcceptor, null, 0);

                                //argument.setValue(defaultStrategyAcceptor);
                            }
                            //beanMetadata.addArgument(argument);
                            strategiesCollectionMetadata.addValue(beanMetadata);
                        } else if (ELEMENT_IDENTITY_PLACEHOLDER_RESOLVER_STRATEGY.equalsIgnoreCase(localName)) {
                            String ref = child.getAttribute(ATTRIBUTE_STRATEGY_ACCEPTOR_REF);
                            MutableBeanMetadata beanMetadata = context.createMetadata(MutableBeanMetadata.class);
                            beanMetadata.setClassName(IdentityPlaceholderResolverStrategy.class.getName());
                            beanMetadata.setActivation(MutableBeanMetadata.ACTIVATION_LAZY);

                            //BeanArgumentImpl argument = new BeanArgumentImpl();
                            //argument.setIndex(0);
                            if (!StringUtils.isEmpty(ref)) {
                                //argument.setValue(createRef(context, ref));
                                beanMetadata.addArgument(createRef(context, ref), null, 0);

                            } else {
                                MutableBeanMetadata defaultStrategyAcceptor = context.createMetadata(MutableBeanMetadata.class);
                                defaultStrategyAcceptor.setClassName(KieObjectsFactoryBean.class.getName());
                                defaultStrategyAcceptor.setFactoryMethod("createDefaultAcceptor");
                                // argument.setValue(defaultStrategyAcceptor);
                                beanMetadata.addArgument(defaultStrategyAcceptor, null, 0);
                            }
                            //beanMetadata.addArgument(argument);
                            strategiesCollectionMetadata.addValue(beanMetadata);
                        } else if (ELEMENT_PROCESS_INSTANCE_RESOLVER_STRATEGY.equalsIgnoreCase(localName)) {
                            MutableBeanMetadata beanMetadata = context.createMetadata(MutableBeanMetadata.class);
                            beanMetadata.setClassName(ProcessInstanceResolverStrategy.class.getName());
                            beanMetadata.setActivation(MutableBeanMetadata.ACTIVATION_LAZY);
                            strategiesCollectionMetadata.addValue(beanMetadata);
                        } else if (ELEMENT_JPA_PLACEHOLDER_RESOLVER_STRATEGY.equalsIgnoreCase(localName)) {
                            MutableBeanMetadata beanMetadata = context.createMetadata(MutableBeanMetadata.class);
                            /*
                            JPAPlaceholderResolverStrategyHelper is required to be used because the original
                            JPAPlaceholderResolverStrategy takes a reference to a environment, and if it refers to the same environemnt
                            it causes a circular dependency.
                             */
                            beanMetadata.setClassName(JPAPlaceholderResolverStrategyHelper.class.getName());
                            beanMetadata.setActivation(MutableBeanMetadata.ACTIVATION_LAZY);
                            String ref = child.getAttribute(ATTRIBUTE_REF);
                            if (!StringUtils.isEmpty(ref)) {
                                /*BeanArgumentImpl argument = new BeanArgumentImpl();
                                argument.setIndex(0);
                                argument.setValue(createRef(context, id));
                                beanMetadata.addArgument(argument);*/
                                beanMetadata.addArgument(createRef(context, id), null, 0);
                            }
                            strategiesCollectionMetadata.addValue(beanMetadata);
                        } else if (ELEMENT_CUSTOM_MARSHALLING_STRATEGY.equalsIgnoreCase(localName)) {
                            String ref = child.getAttribute(ATTRIBUTE_REF);
                            if (!StringUtils.isEmpty(ref)) {
                                strategiesCollectionMetadata.addValue(createRef(context, ref));
                            } else {
                                throw new ComponentDefinitionException("'ref' attribute is missing for custom marshaller definition.");
                            }
                        }
                    }
View Full Code Here


        } else {
            Metadata metadata = checkForChildListeners(context, element);
            beanMetadata.addArgument(metadata, null, 2);
        }

        MutableCollectionMetadata collectionMetadata = KieSessionLoggerElementParser.parseConsoleLoggers(this, context, element);
        beanMetadata.addArgument(collectionMetadata, null, 3);

        collectionMetadata = KieSessionBatchElementParser.parseBatchElement(this, context, element);
        beanMetadata.addArgument(collectionMetadata, null, 4);
View Full Code Here

    public static final String LOGGER_ATTRIBUTE_LOGGER_TYPE = "loggerType";
    public static final String LOGGER_ATTRIBUTE_INTERVAL = "interval";

    public static MutableCollectionMetadata parseBatchElement(KieSessionElementParser kieSessionElementParser, ParserContext context, Element element){

        MutableCollectionMetadata collectionMetadata = context.createMetadata(MutableCollectionMetadata.class);
        collectionMetadata.setCollectionClass(ArrayList.class);
        String prefix = element.getPrefix();
        NodeList batchNodeList = element.getElementsByTagName(prefix+":batch");
        if ( batchNodeList != null && batchNodeList.getLength() > 0){
            //only one batch node allowed.
            Node batchNode = batchNodeList.item(0);

            for (int i=0; i < batchNode.getChildNodes().getLength(); i++){
                Node n = batchNode.getChildNodes().item(i);
                if (n instanceof Element) {
                    Element e = (Element) n;
                    MutableBeanMetadata componentMetadata = context.createMetadata(MutableBeanMetadata.class);
                    if ("insert-object".equals(e.getLocalName())) {
                        String ref = e.getAttribute("ref");
                        if (StringUtils.isEmpty(ref)){
                            throw new ComponentDefinitionException("'ref' attribute is missing for insert-object for bean definition ("+ kieSessionElementParser.getId(context, element)+")");
                        }
                        componentMetadata.setClassName(InsertObjectCommand.class.getName());
                        /*
                        BeanArgumentImpl argument = new BeanArgumentImpl();
                        argument.setIndex(0);
                        argument.setValue(kieSessionElementParser.createRef(context, ref));
                        componentMetadata.addArgument(argument);
                        */
                        componentMetadata.addArgument(kieSessionElementParser.createRef(context, ref), null, 0);
                    } else if ("set-global".equals(e.getLocalName())) {
                        String ref = e.getAttribute("ref");
                        if (StringUtils.isEmpty(ref)){
                            throw new ComponentDefinitionException("'ref' attribute is missing for set-global for bean definition ("+ kieSessionElementParser.getId(context, element)+")");
                        }
                        String identifier = e.getAttribute("identifier");
                        if (StringUtils.isEmpty(identifier)){
                            throw new ComponentDefinitionException("'identifier' attribute is missing for set-global for bean definition ("+ kieSessionElementParser.getId(context, element)+")");
                        }
                        componentMetadata.setClassName(SetGlobalCommand.class.getName());
                        /*
                        BeanArgumentImpl argument = new BeanArgumentImpl();
                        argument.setIndex(0);
                        argument.setValue(kieSessionElementParser.createValue(context, identifier));
                        componentMetadata.addArgument(argument);
                        */
                        componentMetadata.addArgument(kieSessionElementParser.createValue(context, identifier), null, 0);

                        //argument = new BeanArgumentImpl();
                        //argument.setIndex(1);
                        //argument.setValue(kieSessionElementParser.createRef(context, ref));
                        //componentMetadata.addArgument(argument);
                        componentMetadata.addArgument(kieSessionElementParser.createRef(context, ref), null, 1);


                    } else if ("fire-until-halt".equals(e.getLocalName())) {
                        componentMetadata.setClassName(FireUntilHaltCommand.class.getName());
                    } else if ("fire-all-rules".equals(e.getLocalName())) {
                        componentMetadata.setClassName(FireAllRulesCommand.class.getName());
                        String max = e.getAttribute("max");
                        if (!StringUtils.isEmpty(max)) {
                            try {
                                // BeanArgumentImpl argument = new BeanArgumentImpl();
                                // argument.setIndex(0);
                                // argument.setValue(kieSessionElementParser.createValue(context, Integer.parseInt(max)));
                                // componentMetadata.addArgument(argument);
                                componentMetadata.addArgument(kieSessionElementParser.createValue(context, Integer.parseInt(max)), null, 0);
                            }catch (NumberFormatException e1){
                                //xsd will prevent this from happening.
                            }
                        }

                    } else if ("start-process".equals(e.getLocalName())) {
//                        String processId = e.getAttribute("process-id");
//                        if (StringUtils.isEmpty(processId)) {
//                            throw new ComponentDefinitionException("start-process must specify a process-id for bean definition ("+ kieSessionElementParser.getId(context, element)+")");
//                        }
//                        BeanArgumentImpl argument = new BeanArgumentImpl();
//                        try{
//                            argument.setValue(kieSessionElementParser.createValue(context, Integer.parseInt(processId)));
//                        }catch (NumberFormatException e1){
//                            //xsd will prevent this from happening.
//                        }
//                        componentMetadata.addArgument(argument);
//
//                        List<Element> params = DomUtils.getChildElementsByTagName(e, "parameter");
                    } else if ("signal-event".equals(e.getLocalName())) {
                        componentMetadata.setClassName(SignalEventCommand.class.getName());
                        String processInstanceId = e.getAttribute("process-instance-id");
                        //BeanArgumentImpl argument = null;
                        int index = 0;
                        if (!StringUtils.isEmpty(processInstanceId)) {
                            //argument = new BeanArgumentImpl();
                            try{
                                // argument.setValue(kieSessionElementParser.createValue(context, Integer.parseInt(processInstanceId)));
                                componentMetadata.addArgument(kieSessionElementParser.createValue(context, Integer.parseInt(processInstanceId)), null, 0);
                            } catch (NumberFormatException e1){
                                //xsd will prevent this from happening.
                            }
                            // componentMetadata.addArgument(argument);
                            index++;
                        }
                        String ref = e.getAttribute("ref");
                        if (StringUtils.isEmpty(ref)){
                            throw new ComponentDefinitionException("'ref' attribute is missing for signal-event for bean definition ("+ kieSessionElementParser.getId(context, element)+")");
                        }
                        String eventType = e.getAttribute("event-type");
                        if (StringUtils.isEmpty(eventType)){
                            throw new ComponentDefinitionException("'event-type' attribute is missing for signal-event for bean definition ("+ kieSessionElementParser.getId(context, element)+")");
                        }

                        /*argument = new BeanArgumentImpl();
                        argument.setIndex(index++);
                        argument.setValue(kieSessionElementParser.createRef(context, ref)); */
                        componentMetadata.addArgument(kieSessionElementParser.createValue(context, ref), null, index++);

                        /*argument = new BeanArgumentImpl();
                        argument.setIndex(index++);
                        argument.setValue(kieSessionElementParser.createValue(context, eventType));
                        componentMetadata.addArgument(argument);*/
                        componentMetadata.addArgument(kieSessionElementParser.createValue(context, eventType), null, index++);
                    } else {
                        throw new ComponentDefinitionException("Unknown child element found in batch element.");
                    }
                    collectionMetadata.addValue(componentMetadata);
                }
            }
        }
        return collectionMetadata;
    }
View Full Code Here

    }

    protected Metadata parseListData(ParserContext context,
                                     ComponentMetadata enclosingComponent,
                                     Element element) {
        MutableCollectionMetadata m
            = (MutableCollectionMetadata) context.parseElement(CollectionMetadata.class,
                                                               enclosingComponent, element);
        m.setCollectionClass(List.class);
        return m;
    }
View Full Code Here

        Metadata metadata = context.parseElement(MapMetadata.class, context.getEnclosingComponent(), (Element) element);
        return metadata;
    }

    private Metadata parseCompleters(ParserContext context, ComponentMetadata enclosingComponent, Element element) {
        MutableCollectionMetadata collection = context.createMetadata(MutableCollectionMetadata.class);
        collection.setCollectionClass(List.class);
        NodeList children = element.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child = children.item(i);
            if (child instanceof Element) {
                Metadata metadata;
                if (nodeNameEquals(child, REF)) {
                    metadata = context.parseElement(RefMetadata.class, context.getEnclosingComponent(), (Element) child);
                } else if (nodeNameEquals(child, NULL)) {
                    metadata = context.parseElement(NullMetadata.class, context.getEnclosingComponent(), (Element) child);
                } else if (nodeNameEquals(child, BEAN)) {
                    metadata = context.parseElement(BeanMetadata.class, enclosingComponent, (Element) child);
                } else {
                    throw new IllegalStateException("Unexpected element " + child.getNodeName());
                }
                collection.addValue(metadata);
            }
        }
        return collection;
    }
View Full Code Here

    protected void mapAttribute(MutableBeanMetadata bean,
                                Element e, String name,
                                String val, ParserContext context) {
        if ("beanNames".equals(name)) {
            String[] values = StringUtils.split(val, " ");
            MutableCollectionMetadata tempFactories = context.createMetadata(MutableCollectionMetadata.class);
            for (String v : values) {
                String theValue = v.trim();
                if (theValue.length() > 0) {

                    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);
        } else if ("serviceName".equals(name)) {
            QName q = parseQName(e, val);
View Full Code Here

            bean.addProperty(name, this.parseListData(ctx, bean, el));
        else if ("serviceFactories".equals(name)) {
            bean.addProperty("resourceProviders", this.parseListData(ctx, bean, el));
        } 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

        if (rank != null && rank.length() > 0) {
            bean.addProperty("rank", createValue(context, rank));
        }
        NodeList childElements = element.getElementsByTagNameNS("http://karaf.apache.org/xmlns/jaas/v1.0.0", "module");
        if (childElements != null && childElements.getLength() > 0) {
            MutableCollectionMetadata children = context.createMetadata(MutableCollectionMetadata.class);
            for (int i = 0; i < childElements.getLength(); ++i) {
                Element childElement = (Element) childElements.item(i);
                MutableBeanMetadata md = context.createMetadata(MutableBeanMetadata.class);
                md.setRuntimeClass(Module.class);
                md.addProperty("className", createValue(context, childElement.getAttribute("className")));
                if (childElement.getAttribute("flags") != null) {
                    md.addProperty("flags", createValue(context, childElement.getAttribute("flags")));
                }
                String options = getTextValue(childElement);
                if (options != null && options.length() > 0) {
                    md.addProperty("options", createValue(context, options));
                }
                children.addValue(md);
            }
            bean.addProperty("modules", children);
        }
        // Publish Config
        MutableServiceMetadata service = context.createMetadata(MutableServiceMetadata.class);
View Full Code Here

        }
        return action;
    }

    private Metadata parseCompleters(ParserContext context, ComponentMetadata enclosingComponent, Element element) {
        MutableCollectionMetadata collection = context.createMetadata(MutableCollectionMetadata.class);
        collection.setCollectionClass(List.class);
        NodeList children = element.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            Node child  = children.item(i);
            if (child instanceof Element) {
                Metadata metadata;
                if (nodeNameEquals(child, REF)) {
                    metadata = context.parseElement(RefMetadata.class, context.getEnclosingComponent(), (Element) child);
                } else if (nodeNameEquals(child, NULL)) {
                    metadata = context.parseElement(NullMetadata.class, context.getEnclosingComponent(), (Element) child);
                } else if (nodeNameEquals(child, BEAN)) {
                    metadata = context.parseElement(BeanMetadata.class, enclosingComponent, (Element) child);
                } else {
                    throw new IllegalStateException("Unexpected element " + child.getNodeName());
                }
                collection.addValue(metadata);
            }
        }
        return collection;
    }
View Full Code Here

    protected void mapAttribute(MutableBeanMetadata bean,
                                Element e, String name,
                                String val, ParserContext context) {
        if ("beanNames".equals(name)) {
            String[] values = val.split(" ");
            MutableCollectionMetadata tempFactories = context.createMetadata(MutableCollectionMetadata.class);
            for (String v : values) {
                String theValue = v.trim();
                if (theValue.length() > 0) {

                    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);
        } else if ("serviceName".equals(name)) {
            QName q = parseQName(e, val);
View Full Code Here

TOP

Related Classes of org.apache.aries.blueprint.mutable.MutableCollectionMetadata

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.