Package org.apache.synapse.message.processors

Examples of org.apache.synapse.message.processors.MessageProcessor


        return messageStore;
    }

    public static MessageProcessor defineMessageProcessor(SynapseConfiguration config,
                                                          OMElement elem, Properties properties) {
        MessageProcessor processor  = MessageProcessorFactory.createMessageProcessor(elem);
        config.addMessageProcessor(processor.getName() , processor);
        return processor;
    }
View Full Code Here


            Iterator messageProcessors = FileUtils.iterateFiles(messageProcessorDir, extensions, false);
            while (messageProcessors.hasNext()) {
                File file = (File) messageProcessors.next();
                OMElement document = getOMElement(file);
                MessageProcessor messageProcessor = SynapseXMLConfigurationFactory.defineMessageProcessor(
                        synapseConfig, document, properties);
                if (messageProcessor != null) {
                    messageProcessor.setFileName(file.getName());
                    synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(),
                            messageProcessor.getName());
                }
            }
        }
    }
View Full Code Here

     * Creates a Message processor instance from given xml configuration element
     * @param elem OMElement of that contain the Message processor configuration
     * @return  created message processor instance
     */
    public static MessageProcessor createMessageProcessor(OMElement elem) {
        MessageProcessor processor = null;
        OMAttribute clssAtt = elem.getAttribute(CLASS_Q);

        if(clssAtt != null) {
            try {
                Class cls = Class.forName(clssAtt.getAttributeValue());
                processor = (MessageProcessor) cls.newInstance();
            } catch (Exception e) {
                handleException("Error while creating Message processor " + e.getMessage());
            }
        } else {
            /**We throw Exception since there is not default processor*/
            handleException("Can't create Message processor without a provider class");
        }

        OMAttribute nameAtt = elem.getAttribute(NAME_Q);
        if (nameAtt != null) {
            assert processor != null;
            processor.setName(nameAtt.getAttributeValue());
        } else {
            handleException("Can't create Message processor without a name ");
        }

        OMAttribute storeAtt = elem.getAttribute(MESSAGE_STORE_Q);

        if(storeAtt != null) {
            assert processor != null;
            processor.setMessageStoreName(storeAtt.getAttributeValue());
        } else {
            handleException("Can't create message processor with out a message processor");
        }

        OMElement descriptionElem = elem.getFirstChildWithName(DESCRIPTION_Q);
        if (descriptionElem != null) {
            assert processor != null;
            processor.setDescription(descriptionElem.getText());
        }

        assert processor != null;
        processor.setParameters(getParameters(elem));

        return processor;
    }
View Full Code Here

            log.debug("MessageProcessor Undeployment of the MessageProcessor named : "
                    + artifactName + " : Started");
        }

        try {
            MessageProcessor mp =
                    getSynapseConfiguration().getMessageProcessors().get(artifactName);
            if (mp != null) {
                getSynapseConfiguration().removeMessageProcessor(artifactName);
                if (log.isDebugEnabled()) {
                    log.debug("Destroying the MessageProcessor named : " + artifactName);
                }
                mp.destroy();
                if (log.isDebugEnabled()) {
                    log.debug("MessageProcessor Undeployment of the endpoint named : "
                            + artifactName + " : Completed");
                }
                log.info("MessageProcessor named '" + mp.getName() + "' has been undeployed");
            } else if (log.isDebugEnabled()) {
                log.debug("MessageProcessor " + artifactName + " has already been undeployed");
            }
        } catch (Exception e) {
            handleSynapseArtifactDeploymentError(
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("Restoring the MessageProcessor with name : " + artifactName + " : Started");
        }

        try {
            MessageProcessor mp
                    = getSynapseConfiguration().getMessageProcessors().get(artifactName);
            OMElement msElem = MessageProcessorSerializer.serializeMessageProcessor(null,mp);
            if (mp.getFileName() != null) {
                String fileName = getServerConfigurationInformation().getSynapseXMLLocation()
                        + File.separator + MultiXMLConfigurationBuilder.MESSAGE_PROCESSOR_DIR
                        + File.separator + mp.getFileName();
                writeToFile(msElem, fileName);
                if (log.isDebugEnabled()) {
                    log.debug("Restoring the MessageProcessor with name : "
                            + artifactName + " : Completed");
                }
View Full Code Here

     * Creates a Message processor instance from given xml configuration element
     * @param elem OMElement of that contain the Message processor configuration
     * @return  created message processor instance
     */
    public static MessageProcessor createMessageProcessor(OMElement elem) {
        MessageProcessor processor = null;
        OMAttribute clssAtt = elem.getAttribute(CLASS_Q);

        if(clssAtt != null) {
            try {
                Class cls = Class.forName(clssAtt.getAttributeValue());
                processor = (MessageProcessor) cls.newInstance();
            } catch (Exception e) {
                handleException("Error while creating Message processor " + e.getMessage());
            }
        } else {
            /**We throw Exception since there is not default processor*/
            handleException("Can't create Message processor without a provider class");
        }

        OMAttribute nameAtt = elem.getAttribute(NAME_Q);
        if (nameAtt != null) {
            assert processor != null;
            processor.setName(nameAtt.getAttributeValue());
        } else {
            handleException("Can't create Message processor without a name ");
        }

        OMAttribute storeAtt = elem.getAttribute(MESSAGE_STORE_Q);

        if(storeAtt != null) {
            assert processor != null;
            processor.setMessageStoreName(storeAtt.getAttributeValue());
        } else {
            handleException("Can't create message processor without a message store");
        }

        OMElement descriptionElem = elem.getFirstChildWithName(DESCRIPTION_Q);
        if (descriptionElem != null) {
            assert processor != null;
            processor.setDescription(descriptionElem.getText());
        }

        assert processor != null;
        processor.setParameters(getParameters(elem));

        return processor;
    }
View Full Code Here

            log.debug("Message Processor Deployment from file : " + fileName + " : Started");
        }

        try{

            MessageProcessor mp = MessageProcessorFactory.createMessageProcessor(artifactConfig);
            if(mp != null) {
                mp.setFileName((new File(fileName)).getName());
                 if (log.isDebugEnabled()) {
                    log.debug("Message Processor named '" + mp.getName()
                            + "' has been built from the file " + fileName);
                }

                if(getSynapseConfiguration().getMessageStore(mp.getMessageStoreName()) != null) {
                    mp.init(getSynapseEnvironment());
                } else {
                    handleSynapseArtifactDeploymentError("Message Processor Deployment from the file :" +
                            fileName + " : Failed. Can not create a Message processor without a Message Store");
                }


                if (log.isDebugEnabled()) {
                    log.debug("Initialized the Message Processor : " + mp.getName());
                }
                getSynapseConfiguration().addMessageProcessor(mp.getName(), mp);
                if (log.isDebugEnabled()) {
                    log.debug("Message Processor Deployment from file : " + fileName +
                            " : Completed");
                }
                log.info("Message Processor named '" + mp.getName()
                        + "' has been deployed from file : " + fileName);
                return mp.getName();
            } else {
                handleSynapseArtifactDeploymentError("Message Processor Deployment from the file : "
                    + fileName + " : Failed. The artifact " +
                        "described in the file  is not a Message Processor");
            }
View Full Code Here

       if (log.isDebugEnabled()) {
            log.debug("Message Processor update from file : " + fileName + " has started");
        }

        try {
            MessageProcessor mp = MessageProcessorFactory.createMessageProcessor(artifactConfig);
            if (mp == null) {
                handleSynapseArtifactDeploymentError("Message Processor update failed. The artifact " +
                        "defined in the file: " + fileName + " is not valid");
                return null;
            }
            mp.setFileName(new File(fileName).getName());

            if (log.isDebugEnabled()) {
                log.debug("MessageProcessor: " + mp.getName() + " has been built from the file: "
                        + fileName);
            }


            MessageProcessor existingMp = getSynapseConfiguration().getMessageProcessors().
                    get(existingArtifactName);
            existingMp.destroy();
            // We should add the updated MessageProcessor as a new MessageProcessor
            // and remove the old one

            mp.init(getSynapseEnvironment());
            getSynapseConfiguration().addMessageProcessor(mp.getName(), mp);
View Full Code Here

        return messageStore;
    }

    public static MessageProcessor defineMessageProcessor(SynapseConfiguration config,
                                                          OMElement elem, Properties properties) {
        MessageProcessor processor  = MessageProcessorFactory.createMessageProcessor(elem);
        config.addMessageProcessor(processor.getName() , processor);
        return processor;
    }
View Full Code Here

            Iterator messageProcessors = FileUtils.iterateFiles(messageProcessorDir, extensions, false);
            while (messageProcessors.hasNext()) {
                File file = (File) messageProcessors.next();
                OMElement document = getOMElement(file);
                MessageProcessor messageProcessor = SynapseXMLConfigurationFactory.defineMessageProcessor(
                        synapseConfig, document, properties);
                if (messageProcessor != null) {
                    messageProcessor.setFileName(file.getName());
                    synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(),
                            messageProcessor.getName());
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.synapse.message.processors.MessageProcessor

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.