use of org.apache.synapse.message.processor.impl.AbstractMessageProcessor in project wso2-synapse by wso2.
the class MessageProcessorDeployer method updateSynapseArtifact.
@Override
public String updateSynapseArtifact(OMElement artifactConfig, String fileName, String existingArtifactName, Properties properties) {
if (log.isDebugEnabled()) {
log.debug("Message Processor update from file : " + fileName + " has started");
}
try {
MessageProcessor mp = MessageProcessorFactory.createMessageProcessor(artifactConfig);
if (mp == null) {
handleSynapseArtifactDeploymentError("Message Processor update failed. The artifact " + "defined in the file: " + fileName + " is not valid");
return null;
}
mp.setFileName(new File(fileName).getName());
if (log.isDebugEnabled()) {
log.debug("MessageProcessor: " + mp.getName() + " has been built from the file: " + fileName);
}
MessageProcessor existingMp = getSynapseConfiguration().getMessageProcessors().get(existingArtifactName);
if (existingMp instanceof AbstractMessageProcessor) {
((AbstractMessageProcessor) existingMp).destroy(true);
} else {
existingMp.destroy();
}
// We should add the updated MessageProcessor as a new MessageProcessor
// and remove the old one
mp.init(getSynapseEnvironment());
getSynapseConfiguration().removeMessageProcessor(existingArtifactName);
log.info("MessageProcessor: " + existingArtifactName + " has been undeployed");
getSynapseConfiguration().addMessageProcessor(mp.getName(), mp);
log.info("MessageProcessor: " + mp.getName() + " has been updated from the file: " + fileName);
waitForCompletion();
return mp.getName();
} catch (DeploymentException e) {
handleSynapseArtifactDeploymentError("Error while updating the MessageProcessor from the " + "file: " + fileName);
}
return null;
}
use of org.apache.synapse.message.processor.impl.AbstractMessageProcessor in project wso2-synapse by wso2.
the class SynapseConfiguration method destroy.
public synchronized void destroy(boolean preserverState) {
if (log.isDebugEnabled()) {
log.debug("Destroying the Synapse Configuration");
}
// clear the timer tasks of Synapse
synapseTimer.cancel();
synapseTimer = null;
// stop and shutdown all the proxy services
for (ProxyService p : getProxyServices()) {
if (p.getTargetInLineInSequence() != null) {
p.getTargetInLineInSequence().destroy();
}
if (p.getTargetInLineOutSequence() != null) {
p.getTargetInLineOutSequence().destroy();
}
}
// destroy the managed mediators
for (ManagedLifecycle seq : getDefinedSequences().values()) {
seq.destroy();
}
// destroy sequence templates
for (TemplateMediator seqTemplate : getSequenceTemplates().values()) {
seqTemplate.destroy();
}
// destroy inbound endpoint
for (InboundEndpoint endpoint : getInboundEndpoints()) {
// This path trigger from server shutdown hook. So we don't want to remove scheduled inbound tasks
// from registry. Only un-deployment should remove task from registry. Ref product-ei#1206
endpoint.destroy(false);
}
// destroy the managed endpoints
for (Endpoint endpoint : getDefinedEndpoints().values()) {
endpoint.destroy();
}
// destroy the startups
for (ManagedLifecycle stp : startups.values()) {
stp.destroy();
}
// clear session information used for SA load balancing
try {
SALSessions.getInstance().reset();
DataSourceRepositoryHolder.getInstance().getDataSourceRepositoryManager().clear();
} catch (Throwable ignored) {
}
// destroy the priority executors.
for (PriorityExecutor pe : executors.values()) {
pe.destroy();
}
// destroy the Message Stores
for (MessageStore ms : messageStores.values()) {
if (ms instanceof AbstractMessageProcessor) {
((AbstractMessageProcessor) ms).destroy(preserverState);
} else {
ms.destroy();
}
}
// destroy the Message processors
for (MessageProcessor mp : messageProcessors.values()) {
mp.destroy();
}
for (API api : apiTable.values()) {
api.destroy();
}
}
Aggregations