Package org.apache.synapse.mediators

Examples of org.apache.synapse.mediators.MediatorProperty


     * @param key property key / feature name
     * @return property string value (usually true|false)
     */
    public Object getFeature(String key) {
        for (Iterator iter = explicityFeatures.iterator(); iter.hasNext();) {
            MediatorProperty prop = (MediatorProperty) iter.next();
            if (key.equals(prop.getName())) {
                return prop.getValue();
            }
        }
        return null;
    }
View Full Code Here


     * @param isFeatureEnable should this feature enable?(true|false)
     * @see #getFeature(String)
     * @throws SAXException on an unknown feature
     */
   public void addFeature(String featureName, boolean isFeatureEnable) throws SAXException {
        MediatorProperty mp = new MediatorProperty();
        mp.setName(featureName);
        if (isFeatureEnable) {
            mp.setValue("true");
        } else {
            mp.setValue("false");
        }
        explicityFeatures.add(mp);
        factory.setFeature(featureName, isFeatureEnable);
    }
View Full Code Here

        }
        serializeProperties(xslt, mediator.getProperties());
        List features = mediator.getFeatures();
        if (!features.isEmpty()) {
            for (Iterator iter = features.iterator(); iter.hasNext();) {
                MediatorProperty mp = (MediatorProperty) iter.next();
                OMElement prop = fac.createOMElement("feature", synNS, xslt);
                if (mp.getName() != null) {
                    prop.addAttribute(fac.createOMAttribute("name", nullNS, mp.getName()));
                } else {
                    handleException("The Feature name is missing");
                }
                if (mp.getValue() != null) {
                    prop.addAttribute(fac.createOMAttribute("value", nullNS, mp.getValue()));
                else {
                    handleException("The Feature value is missing");
                }
            }
        }
View Full Code Here

                    if (dataSourceProperties != null && !dataSourceProperties.isEmpty()) {
                        if (traceOrDebugOn) {
                            traceOrDebug(traceOn, "Setting up properties to the XQDataSource");
                        }
                        for (int i = 0; i < dataSourceProperties.size(); i++) {
                            MediatorProperty prop = (MediatorProperty) dataSourceProperties.get(i);
                            if (prop != null) {
                                cachedXQDataSource.setProperty(prop.getName(), prop.getValue());
                            }
                        }
                    }
                }
View Full Code Here

            // perform transformation
            Transformer transformer = cachedTemplates.newTransformer();
            if (!properties.isEmpty()) {
                // set the parameters which will pass to the Transformation
                for (int i = 0; i < properties.size(); i++) {
                    MediatorProperty prop = (MediatorProperty) properties.get(i);
                    if (prop != null) {
                        if (prop.getValue() != null) {
                            transformer.setParameter(prop.getName(), prop.getValue());
                        } else {
                            transformer.setParameter(prop.getName(),
                                Axis2MessageContext.getStringValue(prop.getExpression(), synCtx));
                        }
                    }
                }
            }
View Full Code Here

     * @param isFeatureEnable should this feature enable?
     */
   
    public void addFeature(String featureName, boolean isFeatureEnable) {
        try {
            MediatorProperty mp = new MediatorProperty();
            mp.setName(featureName);
            if (isFeatureEnable) {
                mp.setValue("true");
            } else {
                mp.setValue("false");
            }
            explicitFeatures.add(mp);
            if (USE_DOM_SOURCE_AND_RESULTS.equals(featureName)) {
                useDOMSourceAndResults = isFeatureEnable;
            } else {
View Full Code Here

        evaluateProperties(synCtx);


        // if the envelope preserving set build the envelope
        MediatorProperty preserveEnv = getProperty(SynapseConstants.PRESERVE_ENVELOPE);
        if (preserveEnv != null && JavaUtils.isTrueExplicitly(preserveEnv.getValue() != null ?
                preserveEnv.getValue() : preserveEnv.getEvaluatedExpression(synCtx))) {
            if (traceOrDebugOn) {
                traceOrDebug(traceOn, "Preserving the envelope by building it before " +
                        "sending, since it is explicitly set");
            }
            synCtx.getEnvelope().build();
View Full Code Here

     * @param name name of the property
     *
     * @return a property with the given name
     */
    public MediatorProperty getProperty(String name) {
        MediatorProperty value = properties.get(name);
        if (value == null) {
            if (getParentEndpoint() instanceof PropertyInclude) {
                value = ((PropertyInclude)getParentEndpoint()).getProperty(name);
            }
        }
View Full Code Here

        SequenceMediator fault = new SequenceMediator();
        fault.setName(org.apache.synapse.SynapseConstants.FAULT_SEQUENCE_KEY);
        LogMediator log = new LogMediator();
        log.setLogLevel(LogMediator.FULL);

        MediatorProperty mp = new MediatorProperty();
        mp.setName("MESSAGE");
        mp.setValue("Executing default \"fault\" sequence");
        log.addProperty(mp);

        mp = new MediatorProperty();
        mp.setName("ERROR_CODE");
        try {
            mp.setExpression(new SynapseXPath("get-property('ERROR_CODE')"));
        } catch (JaxenException ignore) {}
        log.addProperty(mp);

        mp = new MediatorProperty();
        mp.setName("ERROR_MESSAGE");
        try {
            mp.setExpression(new SynapseXPath("get-property('ERROR_MESSAGE')"));
        } catch (JaxenException ignore) {}
        log.addProperty(mp);

        fault.addChild(log);
        fault.addChild(new DropMediator());
View Full Code Here

    private void intialize() {
        // get the global properties
        if (loadBalanceEndpoint != null && loadBalanceEndpoint instanceof PropertyInclude) {
            PropertyInclude include = (PropertyInclude) loadBalanceEndpoint;

            MediatorProperty val = include.getProperty(LB_WEIGHTED_RRLC_ROUNDS_PER_RECAL);
            if (val != null) {
                roundsPerRecalculation = Integer.parseInt(val.getValue());
            }
        }

        // initialize the states list, this runs only once
        list = new WeightedState[endpoints.size()];

        int totalWeight = 0;
        for (Endpoint endpoint : endpoints) {
            if (endpoint instanceof PropertyInclude) {
                PropertyInclude include = (PropertyInclude) endpoint;
                MediatorProperty val = include.getProperty(LB_WEIGHTED_RRLC_WEIGHT);

                if (val == null) {
                    String msg = "Parameter " +
                            "loadbalance.weighted.weight should be specified for every " +
                            "endpoint in the load balance group";
                    log.error(msg);
                    throw new SynapseException(msg);
                }
                totalWeight += Integer.parseInt(val.getValue());
            }
        }

        this.totalWeight = totalWeight;

        for (int i = 0; i < endpoints.size(); i++) {
            Endpoint e = endpoints.get(i);
            if (e instanceof PropertyInclude) {
                PropertyInclude include = (PropertyInclude) e;

                MediatorProperty weight = include.getProperty(
                        LB_WEIGHTED_RRLC_WEIGHT);

                String key;
                URL url;
                if (e instanceof AddressEndpoint) {
                    AddressEndpoint addressEndpoint = (AddressEndpoint) e;
                    try {
                        url = new URL(addressEndpoint.getDefinition().getAddress());
                    } catch (MalformedURLException e1) {
                        String msg = "Mulformed URL in address endpoint";
                        log.error(msg);
                        throw new SynapseException(msg);
                    }
                } else if (e instanceof WSDLEndpoint) {
                    WSDLEndpoint wsdlEndpoint = (WSDLEndpoint) e;
                    try {
                        url = new URL(wsdlEndpoint.getDefinition().getAddress());
                    } catch (MalformedURLException e1) {
                        String msg = "Mulformed URL in address endpoint";
                        log.error(msg);
                        throw new SynapseException(msg);
                    }
                } else {
                    String msg = "Only AddressEndpoint and WSDLEndpoint can be used " +
                                    "with WeightedRRLCAlgorithm";
                    log.error(msg);
                    throw new SynapseException(msg);
                }

                // construct the key
                key = url.getHost() + ":" + url.getPort();

                WeightedState state = new WeightedState(
                        Integer.parseInt(weight.getValue()), i, key);

                MediatorProperty minimumWeight = include.getProperty(
                        LB_WEIGHTED_RRLC_WEIGHT_MIN);
                if (minimumWeight != null) {
                    state.setMinWeight(Integer.parseInt(minimumWeight.getValue()));
                }

                MediatorProperty maxWeight = include.getProperty(
                        LB_WEIGHTED_RRLC_WEIGHT_MAX);
                if (maxWeight != null) {
                    state.setMaxWeight(Integer.parseInt(maxWeight.getValue()));
                }

                list[i] = state;
            }
        }                  
View Full Code Here

TOP

Related Classes of org.apache.synapse.mediators.MediatorProperty

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.