Package org.wso2.carbon.rulecep.commons.descriptions

Examples of org.wso2.carbon.rulecep.commons.descriptions.QNameFactory


                    "The configuration cannot be null.", log);
        }

        InputOutputAdaptersConfiguration configuration = new InputOutputAdaptersConfiguration();
        QName tagQName = configurationXML.getQName();
        QNameFactory qNameFactory = QNameFactory.getInstance();
        // registers fact adapters
        QName factAdapterQName = qNameFactory.createQName(AdaptersConstants.INPUT_ADAPTER, tagQName);
        QName adapterQName = qNameFactory.createQName(AdaptersConstants.INPUT_ADAPTER, tagQName);
        OMElement factAdapterElement = configurationXML.getFirstChildWithName(factAdapterQName);
        if (factAdapterElement != null) {
            Iterator factAdapters = factAdapterElement.getChildrenWithName(adapterQName);
            while (factAdapters.hasNext()) {
                OMElement child = (OMElement) factAdapters.next();
                ResourceDescription factDescription =
                        ResourceDescriptionFactory.createResourceDescription(child, xPathFactory);
                if (factDescription != null) {
                    configuration.addFactAdapterDescription(factDescription);
                }
            }
        }
        // registers results adapters
        QName resultAdapterQName = qNameFactory.createQName(AdaptersConstants.OUTPUT_ADAPTER,
                tagQName);
        OMElement resultAdapterElement = configurationXML.getFirstChildWithName(resultAdapterQName);
        if (resultAdapterElement != null) {
            Iterator resultAdapters = resultAdapterElement.getChildrenWithName(adapterQName);
            while (resultAdapters.hasNext()) {
View Full Code Here


                                                    ExtensionBuilder extensionBuilder) {

        final List<OperationDescription> operationList =
                new ArrayList<OperationDescription>();
        QName parentQName = configuration.getQName();
        QNameFactory qNameFactory = QNameFactory.getInstance();
        // operations
        QName operationQName = qNameFactory.createQName(CommonsConstants.ELE_OPERATION,
                parentQName);
        Iterator operations = configuration.getChildrenWithName(operationQName);
        while (operations.hasNext()) {
            OMElement operation = (OMElement) operations.next();
            if (operation == null) {
View Full Code Here

     * @return <code>OperationDescription</code>  instance
     */
    private static OperationDescription create(OMElement operation,
                                               XPathFactory xPathFactory,
                                               QName parentQName) {
        QNameFactory qNameFactory = QNameFactory.getInstance();
        OperationDescription operationDescription =
                new OperationDescription();
        String name = operation.getAttributeValue(CommonsConstants.ATT_NAME_Q);
        if (name != null && !"".equals(name)) {
            operationDescription.setName(qNameFactory.createQName(name, parentQName));
        }


        QName inputQName = qNameFactory.createQName(CommonsConstants.ELE_WITH_PARAM,
                parentQName);
        Iterator inputs = operation.getChildrenWithName(inputQName);
        while (inputs.hasNext()) {
            OMElement inputElem = (OMElement) inputs.next();
            ResourceDescription input =
                    ResourceDescriptionFactory.createResourceDescription(inputElem,
                            xPathFactory);
            if (input != null) {
                operationDescription.addFactDescription(input);
            }
        }

        QName resultsQName = qNameFactory.createQName("result", parentQName);
        OMElement resultsElement = operation.getFirstChildWithName(resultsQName);
        if (resultsElement != null) {
            ResourceDescription resultWrapper = new ResourceDescription();
            resultWrapper.setType("omelement");//todo
            String wrapperName = resultsElement.getAttributeValue(CommonsConstants.ATT_NAME_Q);
            if (wrapperName != null && !"".equals(wrapperName)) {
                resultWrapper.setName(wrapperName);// TODO setting QName
            } else {
                resultWrapper.setName(CommonsConstants.DEFAULT_WRAPPER_NAME);
            }
            QName outputQName = qNameFactory.createQName(CommonsConstants.ELE_ELEMENT,
                    parentQName);
            Iterator outputs = resultsElement.getChildrenWithName(outputQName);
            while (outputs.hasNext()) {
                OMElement outputElem = (OMElement) outputs.next();
                ResourceDescription output =
View Full Code Here

                                            ExtensionBuilder extensionBuilder) {

        RuleSetDescription description = new RuleSetDescription();
        extensionBuilder.build(description, ruleSet, xPathFactory);
        QName parentQName = ruleSet.getQName();
        QNameFactory qNameFactory = QNameFactory.getInstance();
        QName creationQName = qNameFactory.createQName(CommonsConstants.ELE_CREATION,
                parentQName);
        QName registrationQName = qNameFactory.createQName(CommonsConstants.ELE_REGISTRATION,
                parentQName);
        QName deregistrationQName = qNameFactory.createQName(CommonsConstants.ELE_DEREGISTRATION,
                parentQName);

        String uri = ruleSet.getAttributeValue(CommonsConstants.ATT_URI_Q);
        if (uri != null) {
            description.setBindURI(uri.trim());
View Full Code Here

     */
    public static OMElement serializeToServiceXML(ServiceDescription description,
                                                  OMElement parent, XPathSerializer xPathSerializer) {

        OMElement serviceElement;
        QNameFactory qNameFactory = QNameFactory.getInstance();
        OMNamespaceFactory omNamespaceFactory = OMNamespaceFactory.getInstance();
        OMElementHelper omElementHelper = OMElementHelper.getInstance();
        if (parent != null) {
            // removes existing rule config information in the service.xml
            serviceElement = parent;
            Iterator iterator = serviceElement.getChildElements();
            while (iterator.hasNext()) {
                Object o = iterator.next();
                if (!(o instanceof OMElement)) {
                    continue;
                }
                OMElement child = (OMElement) o;
                if (CommonsConstants.ELE_DESCRIPTION.equals(child.getLocalName())) {
                    omElementHelper.detachChildren(child);
                    String des = description.getDescription();
                    if (des != null && !"".equals(des.trim())) {
                        child.setText(des);
                    }
                }
            }
        } else {
            String name = description.getName();
            if (name != null && !"".equals(name.trim())) {
                serviceElement = OM_FACTORY.createOMElement(CommonsConstants.ELE_SERVICE,
                        omNamespaceFactory.createOMNamespace(new QName(name)));
                serviceElement.addAttribute(OM_FACTORY.createOMAttribute("name", NULL_NS,
                        name.trim()));
            } else {
                throw new LoggedRuntimeException("Service name missing", log);
            }
            // set description
            OMNamespace omNamespace = omNamespaceFactory.createOMNamespace(
                    serviceElement.getQName());

            String des = description.getDescription();
            if (des != null && !"".equals(des.trim())) {
                OMElement desElement = OM_FACTORY.createOMElement(CommonsConstants.ELE_DESCRIPTION,
                        omNamespace);
                desElement.setText(des.trim());
                serviceElement.addChild(desElement);
            }
        }

        // updating existing operations
        final List<String> addedOpNames = new ArrayList<String>();
        Iterator iterator = serviceElement.getChildrenWithName(
                qNameFactory.createQName(CommonsConstants.ELE_OPERATION, serviceElement.getQName()));
        while (iterator.hasNext()) {
            Object o = iterator.next();
            if (!(o instanceof OMElement)) {
                continue;
            }
View Full Code Here

        }

        public void run() {
            try {
                MessageContext msgCtx = ((Axis2MessageContext) synCtx).getAxis2MessageContext();
                Event<MessageContext> event = new Event(msgCtx);
                subscriptions = subscriptionManager.getMatchingSubscriptions(event);
            } catch (EventException e) {
                handleException("Matching subscriptions fetching error", e);
            }
View Full Code Here

     * @throws EventException event
     */
    private void processGetStatusRequest(MessageContext mc,
                                         ResponseMessageBuilder messageBuilder)
            throws AxisFault, EventException {
        Subscription subscription =
                SubscriptionMessageBuilder.createGetStatusMessage(mc);
        if (log.isDebugEnabled()) {
            log.debug("GetStatus request recived for SynapseSubscription ID : " +
                    subscription.getId());
        }
        subscription = subscriptionManager.getSubscription(subscription.getId());
        if (subscription != null) {
            if (log.isDebugEnabled()) {
                log.debug("Sending GetStatus responce for SynapseSubscription ID : " +
                        subscription.getId());
            }
            //send the responce
            SOAPEnvelope soapEnvelope = messageBuilder.genGetStatusResponse(subscription);
            dispatchResponse(soapEnvelope, EventingConstants.WSE_GET_STATUS_RESPONSE,
                    mc, false);
View Full Code Here

            // Adding static subscriptions
            List<Subscription> staticSubscriptionList =
                    eventSource.getSubscriptionManager().getStaticSubscriptions();
            for (Iterator<Subscription> iterator = staticSubscriptionList.iterator();
                 iterator.hasNext();) {
                Subscription staticSubscription = iterator.next();
                OMElement staticSubElem =
                        fac.createOMElement("subscription", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                staticSubElem.addAttribute(
                        fac.createOMAttribute("id", nullNS, staticSubscription.getId()));
                OMElement filterElem =
                        fac.createOMElement("filter", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                filterElem.addAttribute(fac.createOMAttribute("source", nullNS,
                        (String) staticSubscription.getFilterValue()));
                filterElem.addAttribute(fac.createOMAttribute("dialect", nullNS,
                        (String) staticSubscription.getFilterDialect()));
                staticSubElem.addChild(filterElem);
                OMElement endpointElem =
                        fac.createOMElement("endpoint", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                OMElement addressElem =
                        fac.createOMElement("address", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                addressElem.addAttribute(
                        fac.createOMAttribute("uri", nullNS, staticSubscription.getEndpointUrl()));
                endpointElem.addChild(addressElem);
                staticSubElem.addChild(endpointElem);
                if (staticSubscription.getExpires() != null) {
                    OMElement expiresElem =
                            fac.createOMElement("expires", XMLConfigConstants.SYNAPSE_OMNAMESPACE);
                    fac.createOMText(expiresElem,
                            ConverterUtil.convertToString(staticSubscription.getExpires()));
                    staticSubElem.addChild(expiresElem);
                }
                evenSourceElem.addChild(staticSubElem);
            }
View Full Code Here


    public SynapseSubscription() {
        this.setId(UIDGenerator.generateURNString());
        this.setDeliveryMode(EventingConstants.WSE_DEFAULT_DELIVERY_MODE);
        SubscriptionData subscriptionData = new SubscriptionData();
        subscriptionData.setProperty(SynapseEventingConstants.STATIC_ENTRY, "false");
        this.setSubscriptionData(subscriptionData);
    }
View Full Code Here

                    .getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "class"));
            if (clazz != null) {
                String className = clazz.getAttributeValue();
                try {
                    Class subscriptionManagerClass = Class.forName(className);
                    SubscriptionManager manager =
                            (SubscriptionManager) subscriptionManagerClass.newInstance();
                    Iterator itr = subscriptionManagerElem.getChildrenWithName(PROPERTIES_QNAME);
                    while (itr.hasNext()) {
                        OMElement propElem = (OMElement) itr.next();
                        String propName =
                                propElem.getAttribute(new QName("name")).getAttributeValue();
                        String propValue =
                                propElem.getAttribute(new QName("value")).getAttributeValue();
                        if (propName != null && !"".equals(propName.trim()) &&
                                propValue != null && !"".equals(propValue.trim())) {

                            propName = propName.trim();
                            propValue = propValue.trim();

                            PasswordManager passwordManager =
                                    PasswordManager.getInstance();
                            String key = eventSource.getName() + "." + propName;

                            if (passwordManager.isInitialized()
                                    && passwordManager.isTokenProtected(key)) {
                                eventSource.putConfigurationProperty(propName, propValue);
                                propValue = passwordManager.resolve(propValue);
                            }

                            manager.addProperty(propName, propValue);
                        }
                    }
                    eventSource.setSubscriptionManager(manager);
                    eventSource.getSubscriptionManager()
                            .init(); // Initialise before doing further processing, required for static subscriptions
View Full Code Here

TOP

Related Classes of org.wso2.carbon.rulecep.commons.descriptions.QNameFactory

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.