Package org.apache.synapse.mediators.template

Examples of org.apache.synapse.mediators.template.TemplateMediator


    public void deleteTemplate(String templateName) throws AxisFault {
        final Lock lock = getLock();
        try {
            lock.lock();
            SynapseConfiguration synCfg = getSynapseConfiguration();
            TemplateMediator sequence = synCfg.getSequenceTemplates().get(templateName);
            if (sequence != null) {
                synCfg.removeSequenceTemplate(templateName);
                MediationPersistenceManager pm = getMediationPersistenceManager();
                pm.deleteItem(templateName, sequence.getFileName(),
                              ServiceBusConstants.ITEM_TYPE_TEMPLATE);
            } else {
                handleException("No defined sequence with name " + templateName
                                + " found to delete in the Synapse configuration");
            }
View Full Code Here


    public OMElement getTemplate(String templateName) throws AxisFault {
        final Lock lock = getLock();
        try {
            lock.lock();
            SynapseConfiguration synapseConfiguration = getSynapseConfiguration();
            TemplateMediator template = synapseConfiguration.getSequenceTemplate(templateName);
            if (template != null) {
                return MediatorSerializerFinder.getInstance().getSerializer(
                        template).serializeMediator(null, template);
            } else {
                handleException("Template with the name "
View Full Code Here

                                                                  getSynapseConfiguration().getProperties());
                    if (log.isDebugEnabled()) {
                        log.debug("Added template : " + templateName + " to the configuration");
                    }

                    TemplateMediator templ = config.getSequenceTemplates().get(templateName);
                    templ.setFileName(ServiceBusUtils.generateFileName(templateName));
                    templ.init(getSynapseEnvironment());

                    //noinspection ConstantConditions
                    persistTemplate(templ);
                }
            } else {
View Full Code Here

            if (templateElement != null && templateElement.getLocalName().equals(
                    XMLConfigConstants.TEMPLATE_ELT.getLocalPart())) {
                String templateName = templateElement.getAttributeValue(new QName("name"));
                SynapseConfiguration config = getSynapseConfiguration();
                log.debug("Saving template : " + templateName);
                TemplateMediator preSeq = config.getSequenceTemplates().get(templateName);
                if (preSeq == null) {
                    handleException("Unable to save template " + templateName + ". Does not exist");
                } else {
                    // we should first try to build the new sequence. if exception we return
                    Mediator mediator = MediatorFactoryFinder.getInstance().getMediator(
                            templateElement, getSynapseConfiguration().getProperties());

                    boolean statisticsEnable = preSeq.isStatisticsEnable();
                    // if everything went successfully we remove the sequence
                    config.removeSequenceTemplate(templateName);
                    if (mediator instanceof TemplateMediator) {
                        if (statisticsEnable) {
                            ((TemplateMediator) mediator).enableStatistics();
                        }
                        ((TemplateMediator) mediator).setFileName(preSeq.getFileName());
                        config.addSequenceTemplate(templateName, (TemplateMediator) mediator);
                    }

                    log.debug("Saved template : " + templateName + " to the configuration");

                    TemplateMediator templ = config.getSequenceTemplates().get(templateName);
                    if (templ != null) {
                        templ.init(getSynapseEnvironment());
                        persistTemplate(templ);
                    }
                }
            } else {
                handleException("Unable to save template. Invalid definition");
View Full Code Here

    public String enableStatistics(String templateName) throws AxisFault {
        final Lock lock = getLock();
        try {
            lock.lock();
            TemplateMediator template;
            template = (TemplateMediator) getSynapseConfiguration().getSequenceTemplate(templateName);
            if (template != null) {
                template.enableStatistics();
                persistTemplate(template);
                return templateName;
            } else {
                handleException("No defined template with name " + templateName
                                + " found to enable statistics in the Synapse configuration");
View Full Code Here

    public String disableStatistics(String templateName) throws AxisFault {
        final Lock lock = getLock();
        try {
            lock.lock();
            TemplateMediator template;
            template = (TemplateMediator) getSynapseConfiguration().getSequenceTemplate(templateName);
            if (template != null) {
                template.disableStatistics();
                persistTemplate(template);
                return templateName;
            } else {
                handleException("No defined template with name " + templateName
                                + " found to disable statistics in the Synapse configuration");
View Full Code Here

    public String enableTracing(String templateName) throws AxisFault {
        final Lock lock = getLock();
        try {
            lock.lock();
            TemplateMediator template;
            template = (TemplateMediator) getSynapseConfiguration().getSequenceTemplate(templateName);
            if (template != null) {
                template.setTraceState(SynapseConstants.TRACING_ON);
                persistTemplate(template);
                return templateName;
            } else {
                handleException("No defined template with name " + templateName
                                + " found to enable tracing in the Synapse configuration");
View Full Code Here

    public String disableTracing(String templateName) throws AxisFault {
        final Lock lock = getLock();
        try {
            lock.lock();
            TemplateMediator template;
            template = (TemplateMediator) getSynapseConfiguration().getSequenceTemplate(templateName);
            if (template != null) {
                template.setTraceState(SynapseConstants.TRACING_OFF);
                persistTemplate(template);
                return templateName;
            } else {
                handleException("No defined template with name " + templateName
                                + " found to disable tracing in the Synapse configuration");
View Full Code Here

TOP

Related Classes of org.apache.synapse.mediators.template.TemplateMediator

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.