Package org.apache.synapse.commons.executors

Examples of org.apache.synapse.commons.executors.PriorityExecutor


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

        try {
            PriorityExecutor e = PriorityExecutorFactory.createExecutor(
                    SynapseConstants.SYNAPSE_NAMESPACE, artifactConfig, true, properties);
            if (e == null) {
                handleSynapseArtifactDeploymentError("PriorityExecutor update failed. The artifact " +
                        "defined in the file: " + fileName + " is not a valid executor.");
                return null;
            }
            e.setFileName(new File(fileName).getName());

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

            e.init();
            PriorityExecutor existingExecutor = getSynapseConfiguration().getPriorityExecutors().
                    get(existingArtifactName);
            if (existingArtifactName.equals(e.getName())) {
                getSynapseConfiguration().updatePriorityExecutor(existingArtifactName, e);
            } else {
                // The user has changed the name of the executor
                // We should add the updated executor as a new executor and remove the old one
                getSynapseConfiguration().addPriorityExecutor(e.getName(), e);
                getSynapseConfiguration().removeExecutor(existingArtifactName);
                log.info("Executor: " + existingArtifactName + " has been undeployed");
            }

            waitForCompletion();
            existingExecutor.destroy();

            log.info("PriorityExecutor: " + e.getName() + " has been updated from the file: " + fileName);
            return e.getName();

        } catch (DeploymentException e) {
View Full Code Here


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

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

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

        try {
            PriorityExecutor e = getSynapseConfiguration().getPriorityExecutors().get(artifactName);
            OMElement entryElem = PriorityExecutorSerializer.serialize(null, e,
                    SynapseConstants.SYNAPSE_NAMESPACE);
            if (e.getFileName() != null) {
                String fileName = getServerConfigurationInformation().getSynapseXMLLocation()
                        + File.separator + MultiXMLConfigurationBuilder.EXECUTORS_DIR
                        + File.separator + e.getFileName();
                writeToFile(entryElem, fileName);
                if (log.isDebugEnabled()) {
                    log.debug("Restoring the PriorityExecutor with name : "
                            + artifactName + " : Completed");
                }
View Full Code Here

    }

    public static PriorityExecutor defineExecutor(SynapseConfiguration config,
                                                       OMElement elem, Properties properties) {

        PriorityExecutor executor = null;
        try {
            executor = PriorityExecutorFactory.createExecutor(
                    XMLConfigConstants.SYNAPSE_NAMESPACE, elem, true, properties);
            assert executor != null;
            config.addPriorityExecutor(executor.getName(), executor);
        } catch (AxisFault axisFault) {
            String msg = "Executor configuration cannot be built";
            handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_EXECUTORS, msg, axisFault);
        }
        return executor;
View Full Code Here

        synapseConfig.addEventSource(eventSrc.getName(), eventSrc);
        assertItemAdded(eventSrc.getName(), EVENT_SRC);
        synapseConfig.removeEventSource(eventSrc.getName());
        assertItemRemoved(eventSrc.getName(), EVENT_SRC);

        PriorityExecutor exec = new PriorityExecutor();
        exec.setName("exec1");
        synapseConfig.addPriorityExecutor(exec.getName(), exec);
        assertItemAdded(exec.getName(), EXECUTOR);
        synapseConfig.removeExecutor(exec.getName());
        assertItemRemoved(exec.getName(), EXECUTOR);
    }
View Full Code Here

            Iterator executors = FileUtils.iterateFiles(executorsDir, extensions, false);
            while (executors.hasNext()) {
                File file = (File) executors.next();
                OMElement document = getOMElement(file);
                PriorityExecutor executor = SynapseXMLConfigurationFactory.
                        defineExecutor(synapseConfig, document, properties);
                if (executor != null) {
                    executor.setFileName(file.getName());
                    synapseConfig.getArtifactDeploymentStore().addArtifact(
                            file.getAbsolutePath(), executor.getName());
                }
            }
        }
    }
View Full Code Here

        final Lock lock = getLock();

        try {
            lock.lock();
            SynapseConfiguration config = getSynapseConfiguration();
            PriorityExecutor ex = PriorityExecutorFactory.
                    createExecutor(SynapseConstants.SYNAPSE_NAMESPACE, executor,
                            true, new Properties());
            ex.setFileName(ServiceBusUtils.generateFileName(ex.getName()));
            ex.init();
            config.addPriorityExecutor(name, ex);
            MediationPersistenceManager pm = getMediationPersistenceManager();
            pm.saveItem(name, ServiceBusConstants.ITEM_TYPE_EXECUTOR);
            log.info("Adding priority-executor with name: " + name);
        } catch (AxisFault axisFault) {
View Full Code Here

            lock.lock();
            SynapseConfiguration config = getSynapseConfiguration();

            Map<String, PriorityExecutor> exs = config.getPriorityExecutors();
            if (exs != null) {
                PriorityExecutor ex = exs.get(name);
                if (ex != null) {
                    return PriorityExecutorSerializer.serialize(
                            null, ex, SynapseConstants.SYNAPSE_NAMESPACE);
                } else {
                    String msg = "Cannot find an Priority Executor with the name:" + name;
View Full Code Here

        final Lock lock = getLock();
        try {
            lock.lock();
            SynapseConfiguration config = getSynapseConfiguration();

            PriorityExecutor executor = config.removeExecutor(name);

            if (executor != null) {
                executor.destroy();
                log.info("Removed priority executor with name: " + name);
                MediationPersistenceManager pm = getMediationPersistenceManager();
                pm.deleteItem(name, executor.getFileName(),
                        ServiceBusConstants.ITEM_TYPE_EXECUTOR);
            }
        } finally {
            lock.unlock();
        }
View Full Code Here

     *
     * @param name name of the executor
     * @return removed executor
     */
    public synchronized PriorityExecutor removeExecutor(String name) {
        PriorityExecutor executor = executors.remove(name);
        if (executor != null) {
            for (SynapseObserver o : observers) {
                o.priorityExecutorRemoved(executor);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.synapse.commons.executors.PriorityExecutor

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.