use of org.apache.synapse.commons.executors.PriorityExecutor in project wso2-synapse by wso2.
the class PriorityExecutorDeployer method deploySynapseArtifact.
@Override
public String deploySynapseArtifact(OMElement artifactConfig, String fileName, Properties properties) {
if (log.isDebugEnabled()) {
log.debug("PriorityExecutor Deployment from file : " + fileName + " : Started");
}
try {
PriorityExecutor e = PriorityExecutorFactory.createExecutor(SynapseConstants.SYNAPSE_NAMESPACE, artifactConfig, true, properties);
if (e != null) {
e.setFileName((new File(fileName)).getName());
if (log.isDebugEnabled()) {
log.debug("PriorityExecutor with name '" + e.getName() + "' has been built from the file " + fileName);
}
getSynapseConfiguration().addPriorityExecutor(e.getName(), e);
e.init();
if (log.isDebugEnabled()) {
log.debug("PriorityExecutor Deployment from file : " + fileName + " : Completed");
}
log.info("PriorityExecutor named '" + e.getName() + "' has been deployed from file : " + fileName);
return e.getName();
} else {
handleSynapseArtifactDeploymentError("PriorityExecutor Deployment Failed. " + "The artifact described in the file " + fileName + " is not a PriorityExecutor");
}
} catch (Exception e) {
handleSynapseArtifactDeploymentError("PriorityExecutor Deployment from the file : " + fileName + " : Failed.", e);
}
return null;
}
use of org.apache.synapse.commons.executors.PriorityExecutor in project wso2-synapse by wso2.
the class PriorityExecutorDeployer method undeploySynapseArtifact.
@Override
public void undeploySynapseArtifact(String artifactName) {
if (log.isDebugEnabled()) {
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("PriorityExecutor Undeployement of entry named : " + artifactName + " : Failed", e);
}
}
use of org.apache.synapse.commons.executors.PriorityExecutor in project wso2-synapse by wso2.
the class SynapseConfiguration method init.
/**
* This method will be called in the startup of Synapse or in an initiation
* and will initialize all the managed parts of the Synapse Configuration
*
* @param se SynapseEnvironment specifying the env to be initialized
*/
public synchronized void init(SynapseEnvironment se) {
SynapseConfiguration previouseConfiguration = null;
if (log.isDebugEnabled()) {
log.debug("Initializing the Synapse Configuration using the SynapseEnvironment");
}
// initialize registry
if (registry != null && registry instanceof ManagedLifecycle) {
((ManagedLifecycle) registry).init(se);
}
// we initialize xpath extensions here since synapse environment is available
initXpathExtensions(se);
initCarbonTenantConfigurator(se);
// initialize endpoints
for (Endpoint endpoint : getDefinedEndpoints().values()) {
try {
endpoint.init(se);
} catch (Exception e) {
log.error(" Error in initializing endpoint [" + endpoint.getName() + "] " + e.getMessage());
}
}
// initialize sequence templates
for (TemplateMediator seqTemplate : getSequenceTemplates().values()) {
try {
seqTemplate.init(se);
} catch (Exception e) {
log.error(" Error in initializing Sequence Template [" + seqTemplate.getName() + "] " + e.getMessage());
}
}
String tenantDomain = getTenantDomain(se);
if (tenantDomain != null) {
previouseConfiguration = SynapseConfigUtils.getSynapseConfiguration(tenantDomain);
SynapseConfigUtils.addSynapseConfiguration(tenantDomain, this);
}
if (previouseConfiguration != null) {
destroyExistingInbounds(previouseConfiguration);
}
for (InboundEndpoint endpoint : getInboundEndpoints()) {
try {
endpoint.init(se);
} catch (Exception e) {
inboundEndpointMap.remove(endpoint.getName());
log.error(" Error in initializing inbound endpoint [" + endpoint.getName() + "] " + e.getMessage());
}
}
// initialize managed mediators
for (ManagedLifecycle seq : getDefinedSequences().values()) {
if (seq != null) {
try {
seq.init(se);
} catch (Exception e) {
log.error(" Error in initializing Sequence " + e.getMessage());
}
}
}
// initialize all the proxy services
for (ProxyService proxy : getProxyServices()) {
try {
if (proxy.getTargetInLineEndpoint() != null) {
proxy.getTargetInLineEndpoint().init(se);
}
if (proxy.getTargetInLineInSequence() != null) {
proxy.getTargetInLineInSequence().init(se);
}
if (proxy.getTargetInLineOutSequence() != null) {
proxy.getTargetInLineOutSequence().init(se);
}
if (proxy.getTargetInLineFaultSequence() != null) {
proxy.getTargetInLineFaultSequence().init(se);
}
} catch (Exception e) {
log.error(" Error in initializing Proxy Service [ " + proxy.getName() + "] " + e.getMessage());
}
}
// initialize the startups
for (ManagedLifecycle stp : getStartups()) {
if (stp != null) {
try {
stp.init(se);
} catch (Exception e) {
log.error(" Error in initializing Stratups " + e.getMessage());
}
}
}
// initialize sequence executors
for (PriorityExecutor executor : getPriorityExecutors().values()) {
try {
executor.init();
} catch (Exception e) {
log.error(" Error in initializing Executor [ " + executor.getName() + "] " + e.getMessage());
}
}
// initialize message stores
for (MessageStore messageStore : messageStores.values()) {
try {
messageStore.init(se);
} catch (Exception e) {
log.error(" Error in initializing Message Store [ " + messageStore.getName() + "] " + e.getMessage());
}
}
// initialize message processors
for (MessageProcessor messageProcessor : messageProcessors.values()) {
try {
messageProcessor.init(se);
} catch (Exception e) {
log.error(" Error in initializing Message Processor [ " + messageProcessor.getName() + "] " + e.getMessage());
}
}
for (API api : apiTable.values()) {
try {
api.init(se);
} catch (Exception e) {
log.error(" Error in initializing API [ " + api.getName() + "] " + e.getMessage());
}
}
initImportedLibraries(se);
}
use of org.apache.synapse.commons.executors.PriorityExecutor 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