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

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


            return;
        }

        int i = 0;
        while (properties.hasNext()) {
            ResourceDescription property = properties.next();
            if (property != null) {
                AXIOMXPath xPath = (AXIOMXPath) property.getExpression();
                String id = baseId + String.valueOf(i);
                if (xPath != null) {
                    registerNameSpaces(xPath, id, owner, httpSession);
                }
                Collection<OMNamespace> namespaces = property.getNameSpaces();
                if (!namespaces.isEmpty()) {
                    NameSpacesInformationRepository repository =
                            getNameSpacesInformationRepository(httpSession);
                    NameSpacesInformation information =
                            getNameSpacesInformation(owner, id, repository);
View Full Code Here


                    String name = request.getParameter(id + "Name" + i);
                    String type = request.getParameter(id + "Type" + i);

                    if (type != null && !"".equals(type)) {

                        ResourceDescription description = new ResourceDescription();
                        if (name != null && !"".equals(name)) {
                            description.setName(name.trim());
                        }
                        description.setType(type.trim());
                        String valueID = id + "Value" + i;
                        String value = request.getParameter(valueID);
                        if (value != null && !"".equals(value.trim())) {
                            value = value.trim();
                            String typeSelector = request.getParameter(id + "TypeSelection" + i);
                            boolean isExpression = typeSelector != null &&
                                    "expression".equals(typeSelector.trim());
                            boolean isKey = typeSelector != null &&
                                    "key".equals(typeSelector.trim());
                            if (isExpression) {
                                description.setExpression(xPathFactory.createSynapseXPath(valueID,
                                        value.trim(), session));
                            } else if (isKey) {
                                description.setKey(value);
                            } else {
                                description.setValue(value);
                            }
                        }
                        if ("fact".equals(id)) {
                            mediatorDescription.addFactDescription(description);
                        } else {
View Full Code Here

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

            "]]></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();
View Full Code Here

     */
    public void buildOutMessage(AxisOperation axisOperation,
                                List<ResourceDescription> results,
                                OutputAdapterFactory factory) {
        try {
            ResourceDescription firstDescription = results.get(0);
            if (!OMElementResourceAdapter.TYPE.equals(firstDescription.getType())) {
                throw new LoggedRuntimeException("Invalid result !! result type is invalid", log);
            }
            String methodName = axisOperation.getName().getLocalPart();
            String partQName = methodName + RESPONSE;
            AxisMessage outMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
            outMessage.setName(partQName);
            XmlSchemaSequence sequence = generateSchema(firstDescription.getChildResources(),
                    partQName, factory.getOutputAdapters(), "item");
             XmlSchemaComplexType methodSchemaType =
                    createSchemaTypeForMethodPart(partQName);
            if(sequence != null){
                methodSchemaType.setParticle(sequence);
            }
            QName elementQName = typeTable.getQNamefortheType(partQName);
            setParentElementQName((List)results.get(0).getChildResources(), elementQName);
            outMessage.setElementQName(elementQName);
            firstDescription.setElementQName(elementQName);
            service.addMessageElementQNameToOperationMapping(methodSchemaType.getQName(),
                    axisOperation);
        } catch (Exception e) {
            throw new LoggedRuntimeException("Error when preparing out-message " +
                    "of operation : " + axisOperation.getName(), e, log);
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.ResourceDescription

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.