Package org.apache.synapse

Examples of org.apache.synapse.SynapseException


        return configurationProperties.containsKey(name);
    }

    private void handleException(String message, Exception e) {
        log.error(message, e);
        throw new SynapseException(message, e);
    }
View Full Code Here


            if (attName == null || attName.getAttributeValue() == null ||
                attName.getAttributeValue().trim().length() == 0) {
                String msg = "Entry name is a required attribute for a Log property";
                log.error(msg);
                throw new SynapseException(msg);
            } else {
                prop.setName(attName.getAttributeValue());
            }

            // if a value is specified, use it, else look for an expression
            if (attValue != null) {

                if (attValue.getAttributeValue() == null ||
                    attValue.getAttributeValue().trim().length() == 0) {
                   
                    String msg = "Entry attribute value (if specified) " +
                        "is required for a Log property";
                    log.error(msg);
                    throw new SynapseException(msg);

                } else {
                    prop.setValue(attValue.getAttributeValue());
                }

            } else if (attExpr != null) {

                if (attExpr.getAttributeValue() == null ||
                    attExpr.getAttributeValue().trim().length() == 0) {

                    String msg = "Entry attribute expression (if specified) " +
                        "is required for a mediator property";
                    log.error(msg);
                    throw new SynapseException(msg);

                } else {
                    try {
                        prop.setExpression(SynapseXPathFactory.getSynapseXPath(
                            propEle, MediatorProperty.ATT_EXPR_Q));

                    } catch (JaxenException e) {
                        String msg = "Invalid XPapth expression : " + attExpr.getAttributeValue();
                        log.error(msg);
                        throw new SynapseException(msg, e);
                    }
                }

            } else {
                String msg = "Entry attribute value OR expression must " +
                    "be specified for a mediator property";
                log.error(msg);
                throw new SynapseException(msg);
            }

            propertyList.add(prop);
        }
View Full Code Here

            if(childEndpoints == null || childEndpoints.size() == 0){
                String msg = "Invalid Synapse configuration.\n"
                        + "A FailOver must have child elements, but the FailOver "
                        + "'" + failoverEndpoint.getName() + "' does not have any child elements.";
                log.error(msg);
                throw new SynapseException(msg);
            }

            // set endpoints and return
            failoverEndpoint.setChildren(getEndpoints(
                    failoverElement, failoverEndpoint, properties));
View Full Code Here

        SwitchMediator switchMediator = new SwitchMediator();
        OMAttribute source = elem.getAttribute(ATT_SOURCE);
        if (source == null) {
            String msg = "A 'source' XPath attribute is required for a switch mediator";
            log.error(msg);
            throw new SynapseException(msg);
        } else {
            try {

                switchMediator.setSource(SynapseXPathFactory.getSynapseXPath(elem, ATT_SOURCE));

            } catch (JaxenException e) {
                String msg = "Invalid XPath for attribute 'source' : " + source.getAttributeValue();
                log.error(msg);
                throw new SynapseException(msg);
            }
        }
        // after successfully creating the mediator
        // set its common attributes such as tracing etc
        processAuditStatus(switchMediator, elem);
        Iterator iter = elem.getChildrenWithName(CASE_Q);
        while (iter.hasNext()) {
            OMElement caseElem = (OMElement) iter.next();
            SwitchCase aCase = new SwitchCase();
            OMAttribute regex = caseElem.getAttribute(ATT_REGEX);
            if (regex == null) {
                String msg = "The 'regex' attribute is required for a switch case definition";
                log.error(msg);
                throw new SynapseException(msg);
            }
            try {
                aCase.setRegex(Pattern.compile(regex.getAttributeValue()));
            } catch (PatternSyntaxException pse) {
                String msg = "Invalid Regular Expression for attribute 'regex' : "
                        + regex.getAttributeValue();
                log.error(msg);
                throw new SynapseException(msg);
            }
            aCase.setCaseMediator(AnonymousListMediatorFactory.createAnonymousListMediator(
                    caseElem, properties));
            switchMediator.addCase(aCase);
        }
View Full Code Here

        return null;
    }

    private static void handleException(String msg, Exception e) {
        log.error(msg, e);
        throw new SynapseException(msg, e);
    }
View Full Code Here

                            SynapseConstants.SYNAPSE_SERVER_CTX_INFO);
            if (serverCtxParam == null ||
                    !(serverCtxParam.getValue() instanceof ServerContextInformation)) {
                String msg = "ServerContextInformation not found";
                log.error(msg);
                throw new SynapseException(msg);
            }

            ServerContextInformation contextInformation =
                    (ServerContextInformation) serverCtxParam.getValue();
View Full Code Here

        OMAttribute name = elem.getAttribute(ATT_NAME);
        if (name == null) {
            String msg = "The name of the actual mediator class is a required attribute";
            log.error(msg);
            throw new SynapseException(msg);
        }
        Class clazz = null;
        Mediator m = null;
        try {
            clazz = getClass().getClassLoader().loadClass(
                    name.getAttributeValue());
            m = (Mediator) clazz.newInstance();
        } catch (Exception e) {
            String msg = "Error : " + name.getAttributeValue();
            log.error(msg, e);
            throw new SynapseException(msg, e);
        }

        for (Iterator it = elem.getChildrenWithName(PROP_Q); it.hasNext();) {
            OMElement child = (OMElement) it.next();
View Full Code Here

                        getChildrenWithName((MEMBER)).hasNext()){
                    String msg =
                            "Invalid Synapse configuration. " +
                            "child elements";
                    log.error(msg);
                    throw new SynapseException(msg);
                }
                List<Endpoint> endpoints
                        = getEndpoints(loadbalanceElement, loadbalanceEndpoint, properties);
                loadbalanceEndpoint.setChildren(endpoints);
                algorithm =
                        LoadbalanceAlgorithmFactory.
                                createLoadbalanceAlgorithm(loadbalanceElement, endpoints);
                algorithm.setLoadBalanceEndpoint(loadbalanceEndpoint);
            } else if (loadbalanceElement.getFirstChildWithName(MEMBER) != null) {
                if(loadbalanceElement.
                        getChildrenWithName((XMLConfigConstants.ENDPOINT_ELT)).hasNext()){
                    String msg =
                            "Invalid Synapse configuration. " +
                            "loadbalanceEndpoint element cannot have both member & endpoint " +
                            "child elements";
                    log.error(msg);
                    throw new SynapseException(msg);
                }

                List<Member> members = getMembers(loadbalanceElement);
                loadbalanceEndpoint.setMembers(members);
                algorithm =
                        LoadbalanceAlgorithmFactory.
                                createLoadbalanceAlgorithm2(loadbalanceElement, members);
                loadbalanceEndpoint.startApplicationMembershipTimer();
            }

            if (loadbalanceEndpoint.getChildren() == null &&
                    loadbalanceEndpoint.getMembers() == null) {
                String msg = "Invalid Synapse configuration.\n"
                    + "A LoadbalanceEndpoint must have child elements, but the LoadbalanceEndpoint "
                    + "'" + loadbalanceEndpoint.getName() + "' does not have any child elements.";
                log.error(msg);
                throw new SynapseException(msg);
            }
           
            // set load balance algorithm
            loadbalanceEndpoint.setAlgorithm(algorithm);
View Full Code Here

        OMAttribute name = elem.getAttribute(ATT_NAME);
        if (name == null) {
            String msg = "The name of the actual POJO command implementation class" +
                    " is a required attribute";
            log.error(msg);
            throw new SynapseException(msg);
        }

        // load the class for the command object
        try {
            pojoMediator.setCommand(
View Full Code Here

        return properties.get(name);
    }

    private void handleException(String message) {
        log.error(message);
        throw new SynapseException(message);
    }
View Full Code Here

TOP

Related Classes of org.apache.synapse.SynapseException

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.