Package org.apache.synapse.endpoints

Examples of org.apache.synapse.endpoints.Template


    public OMElement getTemplate(String templateName) throws AxisFault {
        final Lock lock = getLock();
        try {
            lock.lock();
            SynapseConfiguration synapseConfiguration = getSynapseConfiguration();
            Template template = synapseConfiguration.getEndpointTemplate(templateName);
            if (template != null) {
                OMElement parentElement = null;
//                String dummyParentEl = "<" + "parent xmlns=\"" + SynapseConstants.SYNAPSE_NAMESPACE + "\"" + "/" + ">";
//                parentElement = AXIOMUtil.stringToOM(dummyParentEl);
//                return new TemplateSerializer().serializeEndpointTemplate(template, parentElement).getFirstElement();
View Full Code Here


    public void deleteEndpointTemplate(String templateName) throws AxisFault {
        final Lock lock = getLock();
        try {
            lock.lock();
            SynapseConfiguration synCfg = getSynapseConfiguration();
            Template sequence = synCfg.getEndpointTemplates().get(templateName);
            if (sequence != null) {
                synCfg.removeEndpointTemplate(templateName);
                MediationPersistenceManager pm = getMediationPersistenceManager();
                pm.deleteItem(templateName, sequence.getFileName(),
                              ServiceBusConstants.ITEM_TYPE_TEMPLATE_ENDPOINTS);
            } else {
                handleException("No defined endpoint template with name " + templateName
                                + " found to delete in the Synapse configuration");
            }
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);
                Template preSeq = config.getEndpointTemplates().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
                    Template endpointTemplate = new TemplateFactory().createEndpointTemplate(
                            templateElement, getSynapseConfiguration().getProperties());

                    // if everything went successfully we remove the sequence
                    config.removeEndpointTemplate(templateName);
                    if (endpointTemplate instanceof Template) {
                        ((Template) endpointTemplate).setFileName(preSeq.getFileName());
                        config.addEndpointTemplate(templateName, endpointTemplate);
                    }

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

                    Template templ = config.getEndpointTemplates().get(templateName);
                    if (templ != null) {
//                        templ.init(getSynapseEnvironment());
                        persistTemplate(templ);
                    }
                }
View Full Code Here

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

                    Template templ = config.getEndpointTemplates().get(templateName);
                    templ.setFileName(ServiceBusUtils.generateFileName(templateName));
//                    templ.init(getSynapseEnvironment());

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

        return DYNAMIC_ENDPOITNT_TEMPLATES;
    }

    public static Template getTempalate(String templateName) {
        if (templateName != null) {
            Template test = new Template();
            test.addParameter("ep_param1");
            test.addParameter("ep_param2");
            test.setName(templateName);

            return test;
        }
        return null;
    }
View Full Code Here

                if (seq.getFileName() == null) {
                    MediatorSerializerFinder.getInstance().
                            getSerializer(seq).serializeMediator(definitions, seq);
                }
            } else if (o instanceof Template) {
                Template templEndpoint = (Template) o;
                if (templEndpoint.getFileName() == null) {
                    new TemplateSerializer().serializeEndpointTemplate(templEndpoint, definitions);
                }
            } else if (o instanceof AbstractEndpoint) {
                AbstractEndpoint endpoint = (AbstractEndpoint) o;
                if (endpoint.getFileName() == null) {
View Full Code Here

                    new QName(SynapseConstants.SYNAPSE_NAMESPACE, "endpoint"));
            if (element != null) {
                org.apache.synapse.config.xml.endpoints.TemplateFactory templateFactory =
                        new org.apache.synapse.config.xml.endpoints.TemplateFactory();

                Template tm = templateFactory.createEndpointTemplate(artifactConfig, properties);

                tm.setFileName(new File(fileName).getName());
                if (log.isDebugEnabled()) {
                    log.debug("Endpoint Template named '" + tm.getName()
                            + "' has been built from the file " + fileName);
                }

                getSynapseConfiguration().addEndpointTemplate(tm.getName(), tm);
                if (log.isDebugEnabled()) {
                    log.debug("Template Deployment from file : " + fileName + " : Completed");
                }
                log.info("Endpoint Template named '" + tm.getName()
                        + "' has been deployed from file : " + fileName);

                return tm.getName();
            } else {
                element = artifactConfig.getFirstChildWithName(
                        new QName(SynapseConstants.SYNAPSE_NAMESPACE, "sequence"));
                if (element != null) {
                    Mediator mediator = MediatorFactoryFinder.getInstance().
                            getMediator(artifactConfig, properties);
                    if (mediator instanceof TemplateMediator) {
                        TemplateMediator tm = (TemplateMediator) mediator;

                        tm.setFileName((new File(fileName)).getName());
                        if (log.isDebugEnabled()) {
                            log.debug("Sequence Template named '" + tm.getName()
                                    + "' has been built from the file " + fileName);
                        }

                        tm.init(getSynapseEnvironment());
                        if (log.isDebugEnabled()) {
                            log.debug("Initialized the Template : " + tm.getName());
                        }

                        getSynapseConfiguration().addSequenceTemplate(tm.getName(), tm);
                        if (log.isDebugEnabled()) {
                            log.debug("Template Deployment from file : " + fileName + " : Completed");
                        }
                        log.info("Template named '" + tm.getName()
                                + "' has been deployed from file : " + fileName);

                        return tm.getName();
                    }
                }
            }

        } catch (Exception e) {
View Full Code Here

                    new QName(SynapseConstants.SYNAPSE_NAMESPACE, "endpoint"));
            if (element != null) {
                org.apache.synapse.config.xml.endpoints.TemplateFactory templateFactory =
                        new org.apache.synapse.config.xml.endpoints.TemplateFactory();

                Template tm = templateFactory.createEndpointTemplate(artifactConfig, properties);

                tm.setFileName(new File(fileName).getName());
                if (log.isDebugEnabled()) {
                    log.debug("Endpoint Template named '" + tm.getName()
                            + "' has been built from the file " + fileName);
                }

                Template existingSt = getSynapseConfiguration().
                        getEndpointTemplate(existingArtifactName);

                if (existingArtifactName.equals(tm.getName())) {

                    getSynapseConfiguration().updateEndpointTemplate(tm.getName(), tm);
                } else {
                    getSynapseConfiguration().addEndpointTemplate(tm.getName(), tm);
                    getSynapseConfiguration().removeEndpointTemplate(existingSt.getName());
                    log.info("Template: " + existingArtifactName + " has been undeployed");
                }

                log.info("Template: " + tm.getName() + " has been updated from the file: " + fileName);
                return tm.getName();
            } else {
                element = artifactConfig.getFirstChildWithName(
                        new QName(SynapseConstants.SYNAPSE_NAMESPACE, "sequence"));
                if (element != null) {
                    Mediator mediator = MediatorFactoryFinder.getInstance().
                            getMediator(artifactConfig, properties);
                    if (mediator instanceof TemplateMediator) {
                        TemplateMediator tm = (TemplateMediator) mediator;

                        tm.setFileName((new File(fileName)).getName());
                        if (log.isDebugEnabled()) {
                            log.debug("Sequence Template named '" + tm.getName()
                                    + "' has been built from the file " + fileName);
                        }

                        tm.init(getSynapseEnvironment());
                        if (log.isDebugEnabled()) {
                            log.debug("Initialized the Template : " + tm.getName());
                        }

                        TemplateMediator existingSt = getSynapseConfiguration().
                                getSequenceTemplate(existingArtifactName);

                        if (existingArtifactName.equals(tm.getName())) {
                            getSynapseConfiguration().updateSequenceTemplate(tm.getName(), tm);
                        } else {
                            getSynapseConfiguration().addSequenceTemplate(tm.getName(), tm);
                            getSynapseConfiguration().removeSequenceTemplate(existingSt.getName());
                            log.info("Template: " + existingArtifactName + " has been undeployed");
                        }

                        existingSt.destroy();
                        log.info("Template: " + tm.getName() + " has been updated from the file: " + fileName);
                        return tm.getName();
                    }
                }
            }
View Full Code Here

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

        try {
            Template st = null;
            try {
                st = getSynapseConfiguration().getEndpointTemplate(artifactName);
            } catch (SynapseException e) {
                //could not locate an endpoint template for this particular un-delpoyment. This name refers
                //probably to a sequence tempalte. Thus if  throws a Synapse exception with following message
                //catch n log that and continue this process for undeployment of a sequence template
                if (e.getMessage().indexOf("Cannot locate an either local or remote enrty for key") != -1) {
                    if (log.isDebugEnabled()) {
                        log.debug("Undeploying template is not of endpoint type. Undeployer will now check " +
                                  "for sequence template for the key: " + artifactName);
                    }
                } else {
                    //different error hence stop undeployment/report failure
                    throw e;
                }
            }
            if (st != null) {
                getSynapseConfiguration().removeEndpointTemplate(artifactName);
                if (log.isDebugEnabled()) {
                    log.debug("Destroying the Template named : " + artifactName);
                }
                if (log.isDebugEnabled()) {
                    log.debug("Template Undeployment of the template named : "
                            + artifactName + " : Completed");
                }
                log.info("Template named '" + st.getName() + "' has been undeployed");
            } else {
                TemplateMediator tm = getSynapseConfiguration().getSequenceTemplate(artifactName);
                if (tm != null) {
                    getSynapseConfiguration().removeSequenceTemplate(artifactName);
                    if (log.isDebugEnabled()) {
View Full Code Here

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

        try {
            Template st = getSynapseConfiguration().getEndpointTemplate(artifactName);
            if (st != null) {
                TemplateSerializer ts = new TemplateSerializer();
                OMElement stElem = ts.serializeEndpointTemplate(st, null);
                if (st.getFileName() != null) {
                    String fileName = getServerConfigurationInformation().getSynapseXMLLocation()
                            + File.separator + MultiXMLConfigurationBuilder.TEMPLATES_DIR
                            + File.separator + st.getFileName();
                    writeToFile(stElem, fileName);
                    if (log.isDebugEnabled()) {
                        log.debug("Restoring the Endpoint Template with name : " +
                                artifactName + " : Completed");
                    }
                    log.info("Template named '" + artifactName + "' has been restored");
                }
            } else {
                TemplateMediator mt = getSynapseConfiguration().getSequenceTemplate(artifactName);
                if (mt != null) {
                    TemplateMediatorSerializer ts = new TemplateMediatorSerializer();
                    OMElement stElem = ts.serializeMediator(null, mt);
                    if (mt.getFileName() != null) {
                        String fileName = getServerConfigurationInformation().getSynapseXMLLocation()
                                + File.separator + MultiXMLConfigurationBuilder.TEMPLATES_DIR
                                + File.separator + st.getFileName();
                        writeToFile(stElem, fileName);
                        if (log.isDebugEnabled()) {
                            log.debug("Restoring the Sequence Template with name : " +
                                    artifactName + " : Completed");
                        }
View Full Code Here

TOP

Related Classes of org.apache.synapse.endpoints.Template

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.