Package org.apache.aries.blueprint.mutable

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


        m.setComponentId(value);
        return m;
    }

    private static CollectionMetadata createList(ParserContext context, List<String> list) {
        MutableCollectionMetadata m = context.createMetadata(MutableCollectionMetadata.class);
        m.setCollectionClass(List.class);
        m.setValueType(String.class.getName());
        for (String v : list) {
            m.addValue(createValue(context, v, String.class.getName()));
        }
        return m;
    }
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

    }

    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

        m.setComponentId(value);
        return m;
    }

    private static CollectionMetadata createList(ParserContext context, List<String> list) {
        MutableCollectionMetadata m = context.createMetadata(MutableCollectionMetadata.class);
        m.setCollectionClass(List.class);
        m.setValueType(String.class.getName());
        for (String v : list) {
            m.addValue(createValue(context, v, String.class.getName()));
        }
        return m;
    }
View Full Code Here

                    }
                }
            }
        }

        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);
       
View Full Code Here

        m.setComponentId(value);
        return m;
    }

    private static CollectionMetadata createList(ParserContext context, List<String> list) {
        MutableCollectionMetadata m = context.createMetadata(MutableCollectionMetadata.class);
        m.setCollectionClass(List.class);
        m.setValueType(String.class.getName());
        for (String v : list) {
            m.addValue(createValue(context, v, String.class.getName()));
        }
        return m;
    }
View Full Code Here

        } else if ("features".equals(name) || "providers".equals(name)
                   || "schemaLocations".equals(name) || "modelBeans".equals(name)) {
            bean.addProperty(name, 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

    }

    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

        return componentMetadata;
    }

    protected static MutableBeanMetadata getBeanMetadata(ParserContext context, Element element) {
        NodeList nodeList = element.getChildNodes();
        MutableCollectionMetadata collectionMetadata = context.createMetadata(MutableCollectionMetadata.class);
        collectionMetadata.setCollectionClass(ArrayList.class);
        for (int i=0; i < nodeList.getLength(); i++){
            Node node = nodeList.item(i);
            String localName = node.getLocalName();
            if ( localName == null) {
                continue;
            }
            MutableBeanMetadata beanMetadata = context.createMetadata(MutableBeanMetadata.class);
            beanMetadata.setClassName(KieListenerAdaptor.class.getName());
            beanMetadata.setActivation(ComponentMetadata.ACTIVATION_LAZY);

            Node refValue = node.getAttributes().getNamedItem("ref");
            String type="";
            if ("ruleRuntimeEventListener".equalsIgnoreCase(localName) ){
                type = RuleRuntimeEventListener.class.getName();
            } else  if ("processEventListener".equalsIgnoreCase(localName)){
                type = ProcessEventListener.class.getName();
            } else if ("agendaEventListener".equalsIgnoreCase(localName)){
                type = AgendaEventListener.class.getName();
            }

            beanMetadata.addArgument(createValue(context, type), null, 0);

            beanMetadata.addArgument(createRef(context, refValue.getTextContent()), null, 1);

            collectionMetadata.addValue(beanMetadata);
        }

        MutableBeanMetadata componentMetadata = context.createMetadata(MutableBeanMetadata.class);
        componentMetadata.setClassName("java.util.ArrayList");
        componentMetadata.addArgument(collectionMetadata, null, 0);
View Full Code Here

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

    public static MutableCollectionMetadata parseConsoleLoggers(KieSessionElementParser kieLoggerElementParser, ParserContext context, Element element){

        MutableCollectionMetadata collectionMetadata = context.createMetadata(MutableCollectionMetadata.class);
        collectionMetadata.setCollectionClass(ArrayList.class);
        String prefix = element.getPrefix();
        NodeList consoleLoggerList = element.getElementsByTagName(prefix+":consoleLogger");
        if ( consoleLoggerList != null && consoleLoggerList.getLength() > 0){
            for (int i=0; i < consoleLoggerList.getLength(); i++){
                Node loggerNode = consoleLoggerList.item(i);
                MutableBeanMetadata componentMetadata = context.createMetadata(MutableBeanMetadata.class);
                componentMetadata.setId(kieLoggerElementParser.getId(context, loggerNode));
                kieLoggerElementParser.generateIdIfNeeded(context, componentMetadata);
                componentMetadata.setClassName(KieLoggerAdaptor.class.getName());
                context.getComponentDefinitionRegistry().registerComponentDefinition(componentMetadata);

                MutableRefMetadata refMetadata = context.createMetadata(MutableRefMetadata.class);
                refMetadata.setComponentId(componentMetadata.getId());
                collectionMetadata.addValue(refMetadata);
            }
        }

        NodeList fileLoggerList = element.getElementsByTagName(prefix+":fileLogger");
        if ( fileLoggerList != null && fileLoggerList.getLength() > 0){
            for (int i=0; i < fileLoggerList.getLength(); i++){
                Node loggerNode = fileLoggerList.item(i);
                MutableBeanMetadata componentMetadata = context.createMetadata(MutableBeanMetadata.class);
                String id = kieLoggerElementParser.getId(context, loggerNode);
                if ( id != null) {
                    componentMetadata.setId(id);
                }
                kieLoggerElementParser.generateIdIfNeeded(context, componentMetadata);
                context.getComponentDefinitionRegistry().registerComponentDefinition(componentMetadata);

                componentMetadata.setClassName(KieLoggerAdaptor.class.getName());

                String fileName = kieLoggerElementParser.getAttributeValue(loggerNode, LOGGER_ATTRIBUTE_FILE);
                if (StringUtils.isEmpty(LOGGER_ATTRIBUTE_FILE)){
                    throw new ComponentDefinitionException(LOGGER_ATTRIBUTE_FILE+" attribute is missing for logger ("+ kieLoggerElementParser.getId(context, element)+")");
                }
                fileName =  ExpressionUtils.resolveExpressionInPath(fileName);
                componentMetadata.addProperty("file", kieLoggerElementParser.createValue(context, fileName));

                String threaded = kieLoggerElementParser.getAttributeValue(loggerNode, LOGGER_ATTRIBUTE_THREADED);
                if (!StringUtils.isEmpty(LOGGER_ATTRIBUTE_FILE) && "true".equalsIgnoreCase(threaded)){
                    componentMetadata.addProperty("loggerType", kieLoggerElementParser.createValue(context, KieLoggerAdaptor.KNOWLEDGE_LOGGER_TYPE.LOGGER_TYPE_THREADED_FILE.toString()));
                    String interval = kieLoggerElementParser.getAttributeValue(loggerNode, LOGGER_ATTRIBUTE_INTERVAL);
                    if ( !StringUtils.isEmpty(interval)){
                        try{
                            int nInterval = Integer.parseInt(interval);
                            componentMetadata.addProperty("interval", kieLoggerElementParser.createValue(context, nInterval));
                        }catch (Exception e){
                            //should never happen, the XSD would prevent non-integers coming this far.
                        }
                    }
                    if (StringUtils.isEmpty(LOGGER_ATTRIBUTE_FILE)){
                        throw new ComponentDefinitionException(LOGGER_ATTRIBUTE_FILE+" attribute is missing for logger ("+ kieLoggerElementParser.getId(context, element)+")");
                    }

                } else{
                    componentMetadata.addProperty("loggerType", kieLoggerElementParser.createValue(context, KieLoggerAdaptor.KNOWLEDGE_LOGGER_TYPE.LOGGER_TYPE_FILE.toString()));
                }

                MutableRefMetadata refMetadata = context.createMetadata(MutableRefMetadata.class);
                refMetadata.setComponentId(componentMetadata.getId());
                collectionMetadata.addValue(refMetadata);
            }
        }
        return collectionMetadata;
    }
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.