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

Examples of org.wso2.carbon.rulecep.commons.descriptions.rule.mediator.RuleMediatorDescription


            PrivilegedCarbonContext.endTenantFlow();
        }
    }

    private void setTenantCredentialsInCarbonContext() {
        PrivilegedCarbonContext cc = PrivilegedCarbonContext.getThreadLocalCarbonContext();
        cc.setTenantId(ownerTenantId);
        cc.setTenantDomain(ownerTenantDomain);
    }
View Full Code Here


     * @param confElement The OMElement -  The XML representation of rule mediator
     * @return Returns an instance of rule mediator
     */
    public Mediator createSpecificMediator(OMElement confElement , Properties properties) {

        RuleMediatorDescription ruleMediatorDescription =
                RuleMediatorDescriptionFactory.create(confElement, XPATH_FACTORY, CONFIGURATION_EXTENSION_BUILDER);
        RuleMediator ruleMediator = new RuleMediator(ruleMediatorDescription);

        // after successfully creating the mediator
        // set its common attributes such as tracing etc
View Full Code Here

        if (!(m instanceof RuleMediator)) {
            throw new LoggedRuntimeException("Invalid Mediator has passed to serializer", log);
        }
        RuleMediator ruleMediator = (RuleMediator) m;
        RuleMediatorDescription ruleMediatorDescription = ruleMediator.getRuleMediatorDescription();
        OMElement ruleElement =
                RuleMediatorDescriptionSerializer.serialize(ruleMediatorDescription,
                        SYNAPSE_XPATH_SERIALIZER, CONFIGURATION_EXTENSION_SERIALIZER);
        saveTracingState(ruleElement, ruleMediator);
View Full Code Here

    public void testMediator() throws Exception {
        RuleServerManager ruleServerManager = new RuleServerManager();// TODO to get from a OSGI service
        RuleServerConfiguration configuration = new RuleServerConfiguration(
                new DroolsBackendRuntimeFactory());
        ruleServerManager.init(configuration); //TODO
        RuleMediatorDescription ruleMediatorDescription = new RuleMediatorDescription();
        ResourceDescription inputOne = new ResourceDescription();
        inputOne.setName("symbol");
        Symbol ibm = new Symbol("IBM");

        ResourceDescription childOfInputOne = new ResourceDescription();
        childOfInputOne.setName("symbol");
        childOfInputOne.setValue("IBM");
        childOfInputOne.setType(String.class.getName());
        inputOne.addChildResource(childOfInputOne);
        inputOne.setType(ibm.getClass().getName());
        inputOne.setValue(ibm);

        ResourceDescription outputOne = new ResourceDescription();
        outputOne.setName("symbolCustom");
//        outputOne.addChildResource(childOfInputOne);
        outputOne.setType(ibm.getClass().getName());

        ResourceDescription outputsTwo = new ResourceDescription();
        outputsTwo.setName("om");
        outputsTwo.setType(OMElementResourceAdapter.TYPE);
//        outputsTwo.addChildResource(childOfInputOne);

        ResourceDescription outputThree = new ResourceDescription();
        AXIOMXPath target = new AXIOMXPath("//m:request/m:symbol");
        target.addNamespace("m", "http://services.samples/xsd/xsd");
        outputThree.setName("symbol");
        outputThree.setType(String.class.getName());

        AXIOMXPath target2 = new AXIOMXPath("//m:request/m:Symbol");
        target2.addNamespace("m", "http://services.samples/xsd/xsd");

        outputOne.setExpression(target);
        outputsTwo.setExpression(target);
        outputThree.setExpression(target2);

//        PropertyDescription enrtyPoint = new PropertyDescription();
//        enrtyPoint.setName("symbol");
//        enrtyPoint.setValue("Stock Stream");
        SessionDescription sessionDescription = new SessionDescription();
        sessionDescription.setSessionType(SessionDescription.STATEFUL_SESSION);
//        sessionDescription.addSessionPropertyDescription(enrtyPoint);
        ruleMediatorDescription.setSessionDescription(sessionDescription);
        ruleMediatorDescription.addFactDescription(inputOne);
//        configuration.addOutputResourceDescription(outputThree);
//        configuration.addOutputResourceDescription(outputOne);
        ruleMediatorDescription.addResultDescription(outputsTwo);


        RuleSetDescription setDescription = new RuleSetDescription();
        setDescription.setBindURI("RoutingRules");
        setDescription.setRuleSource(createOMElement(drlRule));

        PropertyDescription creationDescription = new PropertyDescription();
        creationDescription.setName(RuleConstants.SOURCE);
        creationDescription.setValue("drl");
        setDescription.addCreationProperty(creationDescription);

        ruleMediatorDescription.setRuleSetDescription(setDescription);
        RuleMediator ruleMediator = new RuleMediator(ruleMediatorDescription);
        ruleMediator.init(null);

        for (int i = 0; i < 3; i++) {
            MessageContext mcTemp = getMessageContext();
View Full Code Here

            "end\n" +
            "]]></x>";

    public void testMediator() throws Exception {

        RuleMediatorDescription ruleMediatorDescription = new RuleMediatorDescription();
        ResourceDescription inputOne = new ResourceDescription();
        inputOne.setName("symbol");
        inputOne.setType(POJOResourceAdapter.TYPE);
        Symbol ibm = new Symbol("IBM");

        ResourceDescription childOfInputOne = new ResourceDescription();
        childOfInputOne.setName("symbol");
        childOfInputOne.setValue("IBM");
        childOfInputOne.setType(String.class.getName());
        ResourceDescription childOfInputTwo = new ResourceDescription();
        childOfInputTwo.setName("price");
        childOfInputTwo.setValue("10000.00");
        childOfInputTwo.setType(Double.class.getName());
        inputOne.addChildResource(childOfInputOne);
        inputOne.addChildResource(childOfInputTwo);
        inputOne.setType(ibm.getClass().getName());
        inputOne.setValue(ibm);

        ResourceDescription outputOne = new ResourceDescription();
        outputOne.setName("symbolCustom");
        outputOne.setType(POJOResourceAdapter.TYPE);
        outputOne.addChildResource(childOfInputOne);
        outputOne.setType(ibm.getClass().getName());

        ResourceDescription outputsTwo = new ResourceDescription();
        outputsTwo.setName("om");
        outputsTwo.setType(OMElementResourceAdapter.TYPE);
//        outputsTwo.addChildResource(childOfInputOne);

        ResourceDescription outputThree = new ResourceDescription();
        AXIOMXPath target = new AXIOMXPath("//m:request/m:symbol");
        target.addNamespace("m", "http://services.samples/xsd/xsd");
        outputThree.setName("symbol");
        outputThree.setType(String.class.getName());

        AXIOMXPath target2 = new AXIOMXPath("//m:request/m:Symbol");
        target2.addNamespace("m", "http://services.samples/xsd/xsd");

        outputOne.setExpression(target);
        outputsTwo.setExpression(target);
        outputThree.setExpression(target2);

//        PropertyDescription enrtyPoint = new PropertyDescription();
//        enrtyPoint.setName("symbol");
//        enrtyPoint.setValue("Stock Stream");
        SessionDescription sessionDescription = new SessionDescription();
        sessionDescription.setSessionType(SessionDescription.STATEFUL_SESSION);
        RuleServerManager ruleServerManager = new RuleServerManager();// TODO to get from a OSGI service
        RuleServerConfiguration configuration = new RuleServerConfiguration(new JSR94BackendRuntimeFactory());
        ruleServerManager.init(configuration); //TODO

//        sessionDescription.addSessionPropertyDescription(enrtyPoint);
        ruleMediatorDescription.setSessionDescription(sessionDescription);
        ruleMediatorDescription.addFactDescription(inputOne);
//        configuration.addOutputResourceDescription(outputThree);
//        configuration.addOutputResourceDescription(outputOne);
        ruleMediatorDescription.addResultDescription(outputsTwo);


        RuleSetDescription setDescription = new RuleSetDescription();
        setDescription.setBindURI("RoutingRules");
        setDescription.setRuleSource(createOMElement(drlRule));

        PropertyDescription creationDescription = new PropertyDescription();
        creationDescription.setName(RuleConstants.SOURCE);
        creationDescription.setValue("drl");
        setDescription.addCreationProperty(creationDescription);

        ruleMediatorDescription.setRuleSetDescription(setDescription);
        RuleMediator ruleMediator = new RuleMediator(ruleMediatorDescription);
        ruleMediator.init(null);

        for (int i = 0; i < 3; i++) {
            MessageContext mcTemp = getMessageContext();
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.rule.mediator.RuleMediatorDescription

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.