Package org.apache.synapse.mediators.base

Examples of org.apache.synapse.mediators.base.SequenceMediator


     * <drop/>
     *
     * @param config the configuration to be updated
     */
    public static void setDefaultFaultSequence(SynapseConfiguration config) {
        SequenceMediator fault = new SequenceMediator();
        fault.setName(org.apache.synapse.SynapseConstants.FAULT_SEQUENCE_KEY);
        LogMediator log = new LogMediator();
        log.setLogLevel(LogMediator.FULL);

        MediatorProperty mp = new MediatorProperty();
        mp.setName("MESSAGE");
        mp.setValue("Executing default \"fault\" sequence");
        log.addProperty(mp);

        mp = new MediatorProperty();
        mp.setName("ERROR_CODE");
        try {
            mp.setExpression(new SynapseXPath("get-property('ERROR_CODE')"));
        } catch (JaxenException ignore) {}
        log.addProperty(mp);

        mp = new MediatorProperty();
        mp.setName("ERROR_MESSAGE");
        try {
            mp.setExpression(new SynapseXPath("get-property('ERROR_MESSAGE')"));
        } catch (JaxenException ignore) {}
        log.addProperty(mp);

        fault.addChild(log);
        fault.addChild(new DropMediator());

        // set aspect configuration
        AspectConfiguration configuration = new AspectConfiguration(fault.getName());
        fault.configure(configuration);

        config.addSequence(org.apache.synapse.SynapseConstants.FAULT_SEQUENCE_KEY, fault);
    }
View Full Code Here


     * @return the default configuration to be used
     */
    public static SynapseConfiguration getDefaultConfiguration() {
        // programatically create an empty configuration which just log and drop the messages
        SynapseConfiguration config = SynapseConfigUtils.newConfiguration();
        SequenceMediator mainMediator = new SequenceMediator();
        mainMediator.addChild(new LogMediator());
        mainMediator.addChild(new DropMediator());
        mainMediator.setName(SynapseConstants.MAIN_SEQUENCE_KEY);
        config.addSequence(SynapseConstants.MAIN_SEQUENCE_KEY, mainMediator);
        SequenceMediator faultMediator = new SequenceMediator();
        LogMediator fault = new LogMediator();
        fault.setLogLevel(LogMediator.FULL);
        faultMediator.addChild(fault);
        faultMediator.setName(SynapseConstants.FAULT_SEQUENCE_KEY);
        config.addSequence(SynapseConstants.FAULT_SEQUENCE_KEY, faultMediator);
        config.setDescription("The default configuration of the ESB, that is created " +
                "programatically at the startup");
        return config;
    }
View Full Code Here

        // resource into the appropriate object - e.g. sequence or endpoint
        if (entry.getMapper() != null) {
            entry.setValue(entry.getMapper().getObjectFromOMNode(omNode, properties));

            if (entry.getValue() instanceof SequenceMediator) {
                SequenceMediator seq = (SequenceMediator) entry.getValue();
                seq.setDynamic(true);
                seq.setRegistryKey(entry.getKey());
            } else if (entry.getValue() instanceof Endpoint) {
                Endpoint ep = (Endpoint) entry.getValue();
            }

        } else {
View Full Code Here

                    }
                }
            }
        }

        SequenceMediator sequence = synCtx.isResponse() ? outSequence : inSequence;
        if (sequence != null) {
            registerFaultHandler(synCtx);
            sequence.mediate(synCtx);
            return;
        }

        String sequenceKey = synCtx.isResponse() ? outSequenceKey : inSequenceKey;
        if (sequenceKey != null) {
View Full Code Here

        Map<String, SequenceMediator> definedSequences = new HashMap<String, SequenceMediator>();

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

        if (o != null && o instanceof Mediator) {
            return (Mediator) o;
        } else {
            Mediator m = getConfiguration().getSequence(key);
            if (m instanceof SequenceMediator) {
                SequenceMediator seqMediator = (SequenceMediator) m;
                synchronized (m) {
                    if (!seqMediator.isInitialized()) {
                        seqMediator.init(synEnv);
                    }
                }
            }
            localEntries.put(key, m);
            return m;
View Full Code Here

        try {   
            Mediator m = MediatorFactoryFinder.getInstance().getMediator(
                    artifactConfig, properties);
            if (m instanceof SequenceMediator) {
                SequenceMediator seq = (SequenceMediator) m;
                seq.setFileName((new File(fileName)).getName());
                if (log.isDebugEnabled()) {
                    log.debug("Sequence named '" + seq.getName()
                            + "' has been built from the file " + fileName);
                }
                seq.init(getSynapseEnvironment());
                if (log.isDebugEnabled()) {
                    log.debug("Initialized the sequence : " + seq.getName());
                }
                getSynapseConfiguration().addSequence(seq.getName(), seq);
                if (log.isDebugEnabled()) {
                    log.debug("Sequence Deployment from file : " + fileName + " : Completed");
                }
                log.info("Sequence named '" + seq.getName()
                        + "' has been deployed from file : " + fileName);
                return seq.getName();
            } else {
                handleSynapseArtifactDeploymentError("Sequence Deployment Failed. " +
                        "The artifact described in the file " + fileName + " is not a Sequence");
            }
        } catch (Exception e) {
View Full Code Here

                handleSynapseArtifactDeploymentError("Sequence update failed. The artifact " +
                        "defined in the file: " + fileName + " is not a valid sequence.");
                return null;
            }

            SequenceMediator seq = (SequenceMediator) m;
            seq.setFileName(new File(fileName).getName());

            if ((SynapseConstants.MAIN_SEQUENCE_KEY.equals(existingArtifactName) ||
                    SynapseConstants.FAULT_SEQUENCE_KEY.equals(existingArtifactName)) &&
                    !existingArtifactName.equals(seq.getName())) {
                handleSynapseArtifactDeploymentError(existingArtifactName + " sequence cannot be renamed");
            }

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

            seq.init(getSynapseEnvironment());
            SequenceMediator existingSeq = getSynapseConfiguration().getDefinedSequences().
                    get(existingArtifactName);
            if (existingArtifactName.equals(seq.getName())) {
                getSynapseConfiguration().updateSequence(existingArtifactName, seq);
            } else {
                getSynapseConfiguration().addSequence(seq.getName(), seq);
                getSynapseConfiguration().removeSequence(existingArtifactName);
                log.info("Sequence: " + existingArtifactName + " has been undeployed");
            }

            log.info("Sequence: " + seq.getName() + " has been updated from the file: " + fileName);

            waitForCompletion(); // Give some time for worker threads to release the old sequence
            existingSeq.destroy();
            return seq.getName();

        } catch (DeploymentException e) {
            handleSynapseArtifactDeploymentError("Error while updating the sequence from the " +
                    "file: " + fileName);
View Full Code Here

            log.debug("Sequence Undeployment of the sequence named : "
                    + artifactName + " : Started");
        }
       
        try {
            SequenceMediator seq
                    = getSynapseConfiguration().getDefinedSequences().get(artifactName);
            if (seq != null) {
                if (SynapseConstants.MAIN_SEQUENCE_KEY.equals(seq.getName())
                        || SynapseConstants.FAULT_SEQUENCE_KEY.equals(seq.getName())) {
                    handleSynapseArtifactDeploymentError(
                            "Cannot Undeploy the " + seq.getName() + " sequence");
                }
                getSynapseConfiguration().removeSequence(artifactName);
                if (log.isDebugEnabled()) {
                    log.debug("Destroying the sequence named : " + artifactName);
                }
                seq.destroy();
                if (log.isDebugEnabled()) {
                    log.debug("Sequence Undeployment of the sequence named : "
                            + artifactName + " : Completed");
                }
                log.info("Sequence named '" + seq.getName() + "' has been undeployed");
            } else if (log.isDebugEnabled()) {
                log.debug("Sequence " + artifactName + " has already been undeployed");
            }
        } catch (Exception e) {
            handleSynapseArtifactDeploymentError(
View Full Code Here

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

        try {
            SequenceMediator seq
                    = getSynapseConfiguration().getDefinedSequences().get(artifactName);
            OMElement seqElem = MediatorSerializerFinder.getInstance().getSerializer(seq).
                    serializeMediator(null, seq);
            if (seq.getFileName() != null) {
                String fileName = getServerConfigurationInformation().getSynapseXMLLocation()
                        + File.separator + MultiXMLConfigurationBuilder.SEQUENCES_DIR
                        + File.separator + seq.getFileName();
                writeToFile(seqElem, fileName);
                if (log.isDebugEnabled()) {
                    log.debug("Restoring the Sequence with name : " + artifactName + " : Completed");
                }
                log.info("Sequence named '" + artifactName + "' has been restored");
View Full Code Here

TOP

Related Classes of org.apache.synapse.mediators.base.SequenceMediator

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.