Package org.apache.synapse.endpoints

Examples of org.apache.synapse.endpoints.Template


                                                    OMElement elem, Properties properties) {

        TemplateFactory templateFactory = new TemplateFactory();
        String name = elem.getAttributeValue(new QName(XMLConfigConstants.NULL_NAMESPACE, "name"));
        try {
            Template template = templateFactory.createEndpointTemplate(elem, properties);
            if (template != null) {
                config.addEndpointTemplate(template.getName(), template);
            }
            return template;
        } catch (Exception e) {
            String msg = "Endpoint Template: " + name + "configuration cannot be built";
            handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_TEMPLATES, msg, 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);
                }

                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(), existingSt);
                } 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(), existingSt);
                        } 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

                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

        Map<String, Template> definedTemplates = new HashMap<String, Template>();

        synchronized (this) {
            for (Object o : localRegistry.values()) {
                if (o instanceof Template) {
                    Template template = (Template) o;
                    definedTemplates.put(template.getName(), template);
                }
            }
        }
        return definedTemplates;
    }
View Full Code Here

                o = registry.getResource(entry, getProperties());
                if (o != null && o instanceof Template) {
                    localRegistry.put(key, entry);
                    return (Template) o;
                } else if (o instanceof OMNode) {
                    Template m = new TemplateFactory().createEndpointTemplate(
                            (OMElement) o, properties);
                    if (m != null) {
                        entry.setValue(m);
                        return m;
                    }
View Full Code Here

                } else {
                    element = document.getFirstChildWithName(
                            new QName(SynapseConstants.SYNAPSE_NAMESPACE, "endpoint"));
                    if (element != null) {
                        Template endpointTemplate =
                                SynapseXMLConfigurationFactory.defineEndpointTemplate(
                                        synapseConfig, document, properties);
                        if (endpointTemplate != null) {
                            endpointTemplate.setFileName(file.getName());
                            synapseConfig.getArtifactDeploymentStore().addArtifact(
                                    file.getAbsolutePath(), endpointTemplate.getName());
                        }
                        return;
                    }
                }
            }
View Full Code Here

        Map<String, Template> definedTemplates = new HashMap<String, Template>();

        synchronized (this) {
            for (Object o : localRegistry.values()) {
                if (o instanceof Template) {
                    Template template = (Template) o;
                    definedTemplates.put(template.getName(), template);
                }
            }
        }
        return definedTemplates;
    }
View Full Code Here

TOP

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

Copyright © 2015 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.