Package org.apache.synapse.mediators.ext

Examples of org.apache.synapse.mediators.ext.AnnotatedCommandMediator


    private static final QName ANNOTATED_COMMAND_Q =
        new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "annotatedCommand");

    protected Mediator createSpecificMediator(OMElement elem, Properties properties) {

        AnnotatedCommandMediator pojoMediator = new AnnotatedCommandMediator();

        // Class name of the Command object should be present
        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(
                    getClass().getClassLoader().loadClass(name.getAttributeValue()));
        } catch (ClassNotFoundException e) {
            handleException("Unable to load the class specified as the command "
                    + name.getAttributeValue(), e);
        }

        // setting the properties to the command. these properties will be instantiated
        // at the mediation time
        for (Iterator it = elem.getChildElements(); it.hasNext();) {
            OMElement child = (OMElement) it.next();
            if("property".equals(child.getLocalName())) {

                String propName = child.getAttribute(ATT_NAME).getAttributeValue();
                if (propName == null) {
                    handleException(
                        "A POJO command mediator property must specify the name attribute");
                } else {
                    if (child.getAttribute(ATT_EXPRN) != null) {
                        SynapseXPath xpath;
                        try {
                            xpath = SynapseXPathFactory.getSynapseXPath(child, ATT_EXPRN);
                            pojoMediator.addMessageSetterProperty(propName, xpath);
                        } catch (JaxenException e) {
                            handleException("Error instantiating XPath expression : " +
                                child.getAttribute(ATT_EXPRN), e);
                        }
                    } else {
                        if (child.getAttribute(ATT_VALUE) != null) {
                            pojoMediator.addStaticSetterProperty(propName,
                                child.getAttribute(ATT_VALUE).getAttributeValue());
                        } else {
                            handleException("A POJO mediator property must specify either " +
                                "name and expression attributes, or name and value attributes");
                        }
View Full Code Here


    private static final QName ANNOTATED_COMMAND_Q =
        new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "annotatedCommand");

    public Mediator createSpecificMediator(OMElement elem, Properties properties) {

        AnnotatedCommandMediator pojoMediator = new AnnotatedCommandMediator();

        // Class name of the Command object should be present
        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(
                    getClass().getClassLoader().loadClass(name.getAttributeValue()));
        } catch (ClassNotFoundException e) {
            handleException("Unable to load the class specified as the command "
                    + name.getAttributeValue(), e);
        }

        // setting the properties to the command. these properties will be instantiated
        // at the mediation time
        for (Iterator it = elem.getChildElements(); it.hasNext();) {
            OMElement child = (OMElement) it.next();
            if("property".equals(child.getLocalName())) {

                String propName = child.getAttribute(ATT_NAME).getAttributeValue();
                if (propName == null) {
                    handleException(
                        "A POJO command mediator property must specify the name attribute");
                } else {
                    if (child.getAttribute(ATT_EXPRN) != null) {
                        SynapseXPath xpath;
                        try {
                            xpath = SynapseXPathFactory.getSynapseXPath(child, ATT_EXPRN);
                            pojoMediator.addMessageSetterProperty(propName, xpath);
                        } catch (JaxenException e) {
                            handleException("Error instantiating XPath expression : " +
                                child.getAttribute(ATT_EXPRN), e);
                        }
                    } else {
                        if (child.getAttribute(ATT_VALUE) != null) {
                            pojoMediator.addStaticSetterProperty(propName,
                                child.getAttribute(ATT_VALUE).getAttributeValue());
                        } else {
                            handleException("A POJO mediator property must specify either " +
                                "name and expression attributes, or name and value attributes");
                        }
View Full Code Here

    private static final QName ANNOTATED_COMMAND_Q =
        new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "annotatedCommand");

    public Mediator createMediator(OMElement elem) {

        AnnotatedCommandMediator pojoMediator = new AnnotatedCommandMediator();

        // Class name of the Command object should be present
        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(
                    getClass().getClassLoader().loadClass(name.getAttributeValue()));
        } catch (ClassNotFoundException e) {
            handleException("Unable to load the class specified as the command "
                    + name.getAttributeValue(), e);
        }

        // setting the properties to the command. these properties will be instantiated
        // at the mediation time
        for (Iterator it = elem.getChildElements(); it.hasNext();) {
            OMElement child = (OMElement) it.next();
            if("property".equals(child.getLocalName())) {

                String propName = child.getAttribute(ATT_NAME).getAttributeValue();
                if (propName == null) {
                    handleException(
                        "A POJO command mediator property must specify the name attribute");
                } else {
                    if (child.getAttribute(ATT_EXPRN) != null) {
                        AXIOMXPath xpath = null;
                        try {
                            xpath = new AXIOMXPath(
                                child.getAttribute(ATT_EXPRN).getAttributeValue());
                            OMElementUtils.addNameSpaces(xpath, child, log);
                            pojoMediator.addMessageSetterProperty(propName, xpath);
                        } catch (JaxenException e) {
                            handleException("Error instantiating XPath expression : " +
                                child.getAttribute(ATT_EXPRN), e);
                        }
                    } else {
                        if (child.getAttribute(ATT_VALUE) != null) {
                            pojoMediator.addStaticSetterProperty(propName,
                                child.getAttribute(ATT_VALUE).getAttributeValue());
                        } else {
                            handleException("A POJO mediator property must specify either " +
                                "name and expression attributes, or name and value attributes");
                        }
View Full Code Here

    private static final QName ANNOTATED_COMMAND_Q =
        new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "annotatedCommand");

    public Mediator createMediator(OMElement elem) {

        AnnotatedCommandMediator pojoMediator = new AnnotatedCommandMediator();

        // Class name of the Command object should be present
        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(
                    getClass().getClassLoader().loadClass(name.getAttributeValue()));
        } catch (ClassNotFoundException e) {
            handleException("Unable to load the class specified as the command "
                    + name.getAttributeValue(), e);
        }

        // setting the properties to the command. these properties will be instantiated
        // at the mediation time
        for (Iterator it = elem.getChildElements(); it.hasNext();) {
            OMElement child = (OMElement) it.next();
            if("property".equals(child.getLocalName())) {

                String propName = child.getAttribute(ATT_NAME).getAttributeValue();
                if (propName == null) {
                    handleException(
                        "A POJO command mediator property must specify the name attribute");
                } else {
                    if (child.getAttribute(ATT_EXPRN) != null) {
                        SynapseXPath xpath = null;
                        try {
                            xpath = SynapseXPathFactory.getSynapseXPath(child, ATT_EXPRN);
                            pojoMediator.addMessageSetterProperty(propName, xpath);
                        } catch (JaxenException e) {
                            handleException("Error instantiating XPath expression : " +
                                child.getAttribute(ATT_EXPRN), e);
                        }
                    } else {
                        if (child.getAttribute(ATT_VALUE) != null) {
                            pojoMediator.addStaticSetterProperty(propName,
                                child.getAttribute(ATT_VALUE).getAttributeValue());
                        } else {
                            handleException("A POJO mediator property must specify either " +
                                "name and expression attributes, or name and value attributes");
                        }
View Full Code Here

TOP

Related Classes of org.apache.synapse.mediators.ext.AnnotatedCommandMediator

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.