Author: hiranya
Date: Mon Feb 7 12:13:20 2011
New Revision: 1067929
URL: http://svn.apache.org/viewvc?rev=1067929&view=rev
Log:
Making the hot update of certain artifacts more transactional
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/AbstractSynapseArtifactDeployer.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/EndpointDeployer.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/LocalEntryDeployer.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/PriorityExecutorDeployer.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/SequenceDeployer.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/TaskDeployer.java
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java?rev=1067929&r1=1067928&r2=1067929&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/SynapseConfiguration.java
Mon Feb 7 12:13:20 2011
@@ -42,6 +42,7 @@ import org.apache.axiom.om.OMNode;
import javax.xml.namespace.QName;
import java.io.IOException;
import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
/**
* The SynapseConfiguration holds the global configuration for a Synapse
@@ -77,19 +78,19 @@ public class SynapseConfiguration implem
/**
* Holds Proxy services defined through Synapse
*/
- private final Map<String, ProxyService> proxyServices = new
HashMap<String, ProxyService>();
+ private final Map<String, ProxyService> proxyServices = new
ConcurrentHashMap<String, ProxyService>();
/**
* This holds a Map of ManagedLifecycle objects
*/
- private final Map<String, Startup> startups = new HashMap<String,
Startup>();
+ private final Map<String, Startup> startups = new
ConcurrentHashMap<String, Startup>();
/**
* The local registry is a simple HashMap and provides the ability to
* override definitions of a remote registry for entries defined locally
* with the same key
*/
- private final Map<String, Object> localRegistry = new HashMap<String,
Object>();
+ private final Map<String, Object> localRegistry = new
ConcurrentHashMap<String, Object>();
/** Holds the synapse properties */
private Properties properties = new Properties();
@@ -112,7 +113,7 @@ public class SynapseConfiguration implem
/**
* Holds Event Sources defined through Synapse
*/
- private Map<String, SynapseEventSource> eventSources = new HashMap<String,
SynapseEventSource>();
+ private Map<String, SynapseEventSource> eventSources = new
ConcurrentHashMap<String, SynapseEventSource>();
/**
* The list of registered configuration observers
@@ -122,12 +123,12 @@ public class SynapseConfiguration implem
/**
* Executors for executing sequences with priorities
*/
- private Map<String, PriorityExecutor> executors = new HashMap<String,
PriorityExecutor>();
+ private Map<String, PriorityExecutor> executors = new
ConcurrentHashMap<String, PriorityExecutor>();
/**
* Messages stores for the synapse configuration.
*/
- private Map<String, MessageStore> messageStores =new HashMap<String,
MessageStore>();
+ private Map<String, MessageStore> messageStores =new
ConcurrentHashMap<String, MessageStore>();
/**
* Description/documentation of the configuration
@@ -157,6 +158,13 @@ public class SynapseConfiguration implem
}
}
+ public synchronized void updateSequence(String key, Mediator mediator) {
+ localRegistry.put(key, mediator);
+ for (SynapseObserver o : observers) {
+ o.sequenceAdded(mediator);
+ }
+ }
+
/**
* Allow a dynamic sequence to be cached and made available through the
* local registry. If a sequence already exists by the specified
@@ -357,6 +365,30 @@ public class SynapseConfiguration implem
}
}
+ public synchronized void updateEntry(String key, Entry entry) {
+ if (entry.getType() == Entry.URL_SRC && entry.getValue() == null) {
+ try {
+ SynapseEnvironment synEnv =
SynapseConfigUtils.getSynapseEnvironment(
+ axisConfiguration);
+
entry.setValue(SynapseConfigUtils.getOMElementFromURL(entry.getSrc()
+ .toString(), synEnv != null ?
synEnv.getServerContextInformation()
+ .getServerConfigurationInformation().getSynapseHome()
: ""));
+ localRegistry.put(key, entry);
+ for (SynapseObserver o : observers) {
+ o.entryAdded(entry);
+ }
+ } catch (IOException e) {
+ handleException("Can not read from source URL : "
+ + entry.getSrc());
+ }
+ } else {
+ localRegistry.put(key, entry);
+ for (SynapseObserver o : observers) {
+ o.entryAdded(entry);
+ }
+ }
+ }
+
/**
* Gives the set of remote entries that are cached in localRegistry as
mapping of entry key
* to the Entry definition
@@ -544,6 +576,13 @@ public class SynapseConfiguration implem
}
}
+ public synchronized void updateEndpoint(String key, Endpoint endpoint) {
+ localRegistry.put(key, endpoint);
+ for (SynapseObserver o : observers) {
+ o.endpointAdded(endpoint);
+ }
+ }
+
/**
* Add a dynamic endpoint definition to the local registry. If an endpoint
already exists by
* the specified name a runtime exception is thrown.
@@ -861,6 +900,13 @@ public class SynapseConfiguration implem
}
}
+ public synchronized void updateStartup(Startup startup) {
+ startups.put(startup.getName(), startup);
+ for (SynapseObserver o : observers) {
+ o.startupAdded(startup);
+ }
+ }
+
/**
* Removes the startup specified by the name. If no startup exists by the
specified name a
* runtime exception is thrown.
@@ -1180,6 +1226,17 @@ public class SynapseConfiguration implem
* @param executor executor
*/
public synchronized void addPriorityExecutor(String name, PriorityExecutor
executor) {
+ if (!executors.containsKey(name)) {
+ executors.put(name, executor);
+ for (SynapseObserver o : observers) {
+ o.priorityExecutorAdded(executor);
+ }
+ } else {
+ handleException("Duplicate priority executor by the name: " +
name);
+ }
+ }
+
+ public synchronized void updatePriorityExecutor(String name,
PriorityExecutor executor) {
executors.put(name, executor);
for (SynapseObserver o : observers) {
o.priorityExecutorAdded(executor);
@@ -1246,6 +1303,7 @@ public class SynapseConfiguration implem
* Removes a Message store from the configuration
*
* @param name name of the message store
+ * @return The message store with the specified name
*/
public MessageStore removeMessageStore(String name) {
return messageStores.remove(name);
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/AbstractSynapseArtifactDeployer.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/AbstractSynapseArtifactDeployer.java?rev=1067929&r1=1067928&r2=1067929&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/AbstractSynapseArtifactDeployer.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/AbstractSynapseArtifactDeployer.java
Mon Feb 7 12:13:20 2011
@@ -369,6 +369,14 @@ public abstract class AbstractSynapseArt
out.close();
}
+ protected void sleep(long millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException ignored) {
+
+ }
+ }
+
protected void handleSynapseArtifactDeploymentError(String msg) {
deployerLog.error(msg);
throw new SynapseArtifactDeploymentException(msg);
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/EndpointDeployer.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/EndpointDeployer.java?rev=1067929&r1=1067928&r2=1067929&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/EndpointDeployer.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/EndpointDeployer.java
Mon Feb 7 12:13:20 2011
@@ -20,6 +20,7 @@
package org.apache.synapse.deployers;
import org.apache.axiom.om.OMElement;
+import org.apache.axis2.deployment.DeploymentException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.config.xml.MultiXMLConfigurationBuilder;
@@ -83,44 +84,43 @@ public class EndpointDeployer extends Ab
String existingArtifactName,
Properties properties) {
if (log.isDebugEnabled()) {
- log.debug("Endpoint Update from file : " + fileName + " :
Started");
+ log.debug("Endpoint update from file : " + fileName + " has
started");
}
try {
Endpoint ep =
EndpointFactory.getEndpointFromElement(artifactConfig, false, properties);
- if (ep != null) {
- ep.setFileName((new File(fileName)).getName());
- if (log.isDebugEnabled()) {
- log.debug("Endpoint named '" + ep.getName()
- + "' has been built from the file " + fileName);
- }
- ep.init(getSynapseEnvironment());
- if (log.isDebugEnabled()) {
- log.debug("Initialized the endpoint : " + ep.getName());
- }
- Endpoint existingEp
- =
getSynapseConfiguration().getDefinedEndpoints().get(existingArtifactName);
- getSynapseConfiguration().removeEndpoint(existingArtifactName);
- if (!existingArtifactName.equals(ep.getName())) {
- log.info("Endpoint named " + existingArtifactName + " has
been Undeployed");
- }
- getSynapseConfiguration().addEndpoint(ep.getName(), ep);
- existingEp.destroy();
- if (log.isDebugEnabled()) {
- log.debug("Endpoint " +
(existingArtifactName.equals(ep.getName()) ?
- "update" : "deployment") + " from file : " +
fileName + " : Completed");
- }
- log.info("Endpoint named '" + ep.getName()
- + "' has been " +
(existingArtifactName.equals(ep.getName()) ?
- "update" : "deployed") + " from file : " +
fileName);
- return ep.getName();
+ if (ep == null) {
+ handleSynapseArtifactDeploymentError("Endpoint update failed.
The artifact " +
+ "defined in the file: " + fileName + " is not a valid
endpoint.");
+ return null;
+ }
+ ep.setFileName(new File(fileName).getName());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Endpoint: " + ep.getName() + " has been built from
the file: " + fileName);
+ }
+
+ ep.init(getSynapseEnvironment());
+ Endpoint existingEp =
getSynapseConfiguration().getDefinedEndpoints().get(existingArtifactName);
+ if (existingArtifactName.equals(ep.getName())) {
+ getSynapseConfiguration().updateEndpoint(existingArtifactName,
ep);
} else {
- handleSynapseArtifactDeploymentError("Endpoint Update Failed.
The artifact " +
- "described in the file " + fileName + " is not an
Endpoint");
+ // The user has changed the name of the endpoint
+ // We should add the updated endpoint as a new endpoint and
remove the old one
+ getSynapseConfiguration().addEndpoint(ep.getName(), ep);
+ getSynapseConfiguration().removeEndpoint(existingArtifactName);
+ log.info("Endpoint: " + existingArtifactName + " has been
undeployed");
}
- } catch (Exception e) {
- handleSynapseArtifactDeploymentError(
- "Endpoint Update from the file : " + fileName + " :
Failed.", e);
+
+ log.info("Endpoint: " + ep.getName() + " has been updated from the
file: " + fileName);
+
+ sleep(2000);
+ existingEp.destroy();
+ return ep.getName();
+
+ } catch (DeploymentException e) {
+ handleSynapseArtifactDeploymentError("Error while updating the
endpoint from the " +
+ "file: " + fileName);
}
return null;
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/LocalEntryDeployer.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/LocalEntryDeployer.java?rev=1067929&r1=1067928&r2=1067929&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/LocalEntryDeployer.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/LocalEntryDeployer.java
Mon Feb 7 12:13:20 2011
@@ -20,6 +20,7 @@
package org.apache.synapse.deployers;
import org.apache.axiom.om.OMElement;
+import org.apache.axis2.deployment.DeploymentException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.config.Entry;
@@ -79,37 +80,38 @@ public class LocalEntryDeployer extends
String existingArtifactName,
Properties properties) {
if (log.isDebugEnabled()) {
- log.debug("LocalEntry Update from file : " + fileName + " :
Started");
+ log.debug("LocalEntry update from file : " + fileName + " has
started");
}
try {
Entry e = EntryFactory.createEntry(artifactConfig, properties);
- if (e != null) {
- e.setFileName((new File(fileName)).getName());
- if (log.isDebugEnabled()) {
- log.debug("LocalEntry with key '" + e.getKey()
- + "' has been built from the file " + fileName);
- }
- getSynapseConfiguration().removeEntry(existingArtifactName);
- if (!existingArtifactName.equals(e.getKey())) {
- log.info("LocalEntry named " + existingArtifactName + "
has been Undeployed");
- }
- getSynapseConfiguration().addEntry(e.getKey(), e);
- if (log.isDebugEnabled()) {
- log.debug("LocalEntry " +
(existingArtifactName.equals(e.getKey()) ?
- "update" : "deployment") + " from file : " +
fileName + " : Completed");
- }
- log.info("LocalEntry named '" + e.getKey()
- + "' has been " +
(existingArtifactName.equals(e.getKey()) ?
- "updated" : "deployed") + " from file : " +
fileName);
- return e.getKey();
+ if (e == null) {
+ handleSynapseArtifactDeploymentError("Local entry update
failed. The artifact " +
+ "defined in the file: " + fileName + " is not a valid
local entry.");
+ return null;
+ }
+ e.setFileName(new File(fileName).getName());
+
+ if (log.isDebugEnabled()) {
+ log.debug("Local entry: " + e.getKey() + " has been built from
the file: " + fileName);
+ }
+
+ if (existingArtifactName.equals(e.getKey())) {
+ getSynapseConfiguration().updateEntry(existingArtifactName, e);
} else {
- handleSynapseArtifactDeploymentError("LocalEntry Update
Failed. The artifact " +
- "described in the file " + fileName + " is not a
LocalEntry");
+ // The user has changed the name of the entry
+ // We should add the updated entry as a new entry and remove
the old one
+ getSynapseConfiguration().addEntry(e.getKey(), e);
+ getSynapseConfiguration().removeEntry(existingArtifactName);
+ log.info("Local entry: " + existingArtifactName + " has been
undeployed");
}
- } catch (Exception e) {
- handleSynapseArtifactDeploymentError(
- "LocalEntry Update from the file : " + fileName + " :
Failed.", e);
+
+ log.info("Endpoint: " + e.getKey() + " has been updated from the
file: " + fileName);
+ return e.getKey();
+
+ } catch (DeploymentException e) {
+ handleSynapseArtifactDeploymentError("Error while updating the
local entry from the " +
+ "file: " + fileName);
}
return null;
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/PriorityExecutorDeployer.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/PriorityExecutorDeployer.java?rev=1067929&r1=1067928&r2=1067929&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/PriorityExecutorDeployer.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/PriorityExecutorDeployer.java
Mon Feb 7 12:13:20 2011
@@ -21,6 +21,8 @@ package org.apache.synapse.deployers;
import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.deployment.DeploymentException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.SynapseConstants;
@@ -78,48 +80,48 @@ public class PriorityExecutorDeployer ex
public String updateSynapseArtifact(OMElement artifactConfig, String
fileName,
String existingArtifactName,
Properties properties) {
if (log.isDebugEnabled()) {
- log.debug("PriorityExecutor Update from file : " + fileName + " :
Started");
+ log.debug("PriorityExecutor update from file : " + fileName + "
has 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 key '" + e.getName()
- + "' has been built from the file " + fileName);
- }
- PriorityExecutor existingExecutor =
-
getSynapseConfiguration().removeExecutor(existingArtifactName);
- if (!existingArtifactName.equals(e.getName())) {
- log.info("PriorityExecutor named " + existingArtifactName +
- " has been Undeployed");
- }
+ 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 (existingExecutor != null) {
- existingExecutor.destroy();
- }
+ 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);
- if (log.isDebugEnabled()) {
- log.debug("PriorityExecutor " +
(existingArtifactName.equals(e.getName()) ?
- "update" : "deployment") + " from file : " +
fileName + " : Completed");
- }
- log.info("PriorityExecutor named '" + e.getName()
- + "' has been " +
(existingArtifactName.equals(e.getName()) ?
- "updated" : "deployed") + " from file : " +
fileName);
+ getSynapseConfiguration().removeExecutor(existingArtifactName);
+ log.info("Executor: " + existingArtifactName + " has been
undeployed");
+ }
- e.init();
+ sleep(2000);
+ existingExecutor.destroy();
- return e.getName();
- } else {
- handleSynapseArtifactDeploymentError("PriorityExecutor Update
Failed. The artifact " +
- "described in the file " + fileName + " is not a
LocalEntry");
- }
- } catch (Exception e) {
- handleSynapseArtifactDeploymentError(
- "PriorityExecutor Update from the file : " + fileName + "
: Failed.", e);
+ log.info("PriorityExecutor: " + e.getName() + " has been updated
from the file: " + fileName);
+ return e.getName();
+
+ } catch (DeploymentException e) {
+ handleSynapseArtifactDeploymentError("Error while updating the
executor from the " +
+ "file: " + fileName);
+ } catch (AxisFault e) {
+ handleSynapseArtifactDeploymentError("Error while creating the
executor from the " +
+ "configuration in file: " + fileName);
}
return null;
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/SequenceDeployer.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/SequenceDeployer.java?rev=1067929&r1=1067928&r2=1067929&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/SequenceDeployer.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/SequenceDeployer.java
Mon Feb 7 12:13:20 2011
@@ -20,6 +20,7 @@
package org.apache.synapse.deployers;
import org.apache.axiom.om.OMElement;
+import org.apache.axis2.deployment.DeploymentException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.Mediator;
@@ -87,52 +88,50 @@ public class SequenceDeployer extends Ab
String existingArtifactName,
Properties properties) {
if (log.isDebugEnabled()) {
- log.debug("Sequence Update from file : " + fileName + " :
Started");
+ log.debug("Sequence update from file : " + fileName + " has
started");
}
try {
- Mediator m = MediatorFactoryFinder.getInstance().getMediator(
- artifactConfig, properties);
- if (m instanceof SequenceMediator) {
- SequenceMediator seq = (SequenceMediator) m;
- if
((SynapseConstants.MAIN_SEQUENCE_KEY.equals(existingArtifactName)
- ||
SynapseConstants.FAULT_SEQUENCE_KEY.equals(existingArtifactName))
- && !existingArtifactName.equals(seq.getName())) {
- handleSynapseArtifactDeploymentError(
- existingArtifactName + " sequence cannot be
renamed");
- }
- 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());
- }
- SequenceMediator existingSeq =
-
getSynapseConfiguration().getDefinedSequences().get(existingArtifactName);
- getSynapseConfiguration().removeSequence(existingArtifactName);
- if (!existingArtifactName.equals(seq.getName())) {
- log.info("Sequence named '" + existingArtifactName + "'
has been Undeployed");
- }
- getSynapseConfiguration().addSequence(seq.getName(), seq);
- existingSeq.destroy();
- if (log.isDebugEnabled()) {
- log.debug("Sequence " +
(existingArtifactName.equals(seq.getName()) ?
- "update" : "deployment") + " from file : " +
fileName + " : Completed");
- }
- log.info("Sequence named '" + seq.getName()
- + "' has been " +
(existingArtifactName.equals(seq.getName()) ?
- "update" : "deployed") + " from file : " +
fileName);
- return seq.getName();
+ Mediator m =
MediatorFactoryFinder.getInstance().getMediator(artifactConfig, properties);
+ if (m == null || !(m instanceof SequenceMediator)) {
+ 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 {
- handleSynapseArtifactDeploymentError("Sequence Update Failed.
" +
- "The artifact described in the file " + fileName + "
is not a Sequence");
+ getSynapseConfiguration().addSequence(seq.getName(), seq);
+ getSynapseConfiguration().removeSequence(existingArtifactName);
+ log.info("Sequence: " + existingArtifactName + " has been
undeployed");
}
- } catch (Exception e) {
- handleSynapseArtifactDeploymentError(
- "Sequence Update from the file : " + fileName + " :
Failed.", e);
+
+ log.info("Sequence: " + seq.getName() + " has been updated from
the file: " + fileName);
+
+ sleep(2000); // 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);
}
return null;
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/TaskDeployer.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/TaskDeployer.java?rev=1067929&r1=1067928&r2=1067929&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/TaskDeployer.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/deployers/TaskDeployer.java
Mon Feb 7 12:13:20 2011
@@ -20,6 +20,7 @@
package org.apache.synapse.deployers;
import org.apache.axiom.om.OMElement;
+import org.apache.axis2.deployment.DeploymentException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.Startup;
@@ -76,39 +77,34 @@ public class TaskDeployer extends Abstra
String existingArtifactName,
Properties properties) {
if (log.isDebugEnabled()) {
- log.debug("StartupTask Update from file : " + fileName + " :
Started");
+ log.debug("StartupTask update from file : " + fileName + " has
started");
}
try {
Startup st =
StartupFinder.getInstance().getStartup(artifactConfig, properties);
- st.setFileName((new File(fileName)).getName());
- if (log.isDebugEnabled()) {
- log.debug("StartupTask named '" + st.getName()
- + "' has been built from the file " + fileName);
- }
- st.init(getSynapseEnvironment());
- if (log.isDebugEnabled()) {
- log.debug("Initialized the StartupTask : " + st.getName());
- }
- Startup existingSt =
-
getSynapseConfiguration().getStartup(existingArtifactName);
- getSynapseConfiguration().removeStartup(existingArtifactName);
- if (!existingArtifactName.equals(st.getName())) {
- log.info("StartupTask named '" + existingArtifactName + "'
has been Undeployed");
- }
+ st.setFileName((new File(fileName)).getName());
+
+ if (log.isDebugEnabled()) {
+ log.debug("StartupTask: " + st.getName() + " has been built
from the file: " + fileName);
+ }
+ st.init(getSynapseEnvironment());
+
+ Startup existingSt =
getSynapseConfiguration().getStartup(existingArtifactName);
+ if (existingArtifactName.equals(st.getName())) {
+ getSynapseConfiguration().updateStartup(st);
+ } else {
getSynapseConfiguration().addStartup(st);
- existingSt.destroy();
- if (log.isDebugEnabled()) {
- log.debug("StartupTask " +
(existingArtifactName.equals(st.getName()) ?
- "update" : "deployment") + " from file : " +
fileName + " : Completed");
- }
- log.info("StartupTask named '" + st.getName()
- + "' has been " +
(existingArtifactName.equals(st.getName()) ?
- "update" : "deployed") + " from file : " +
fileName);
- return st.getName();
- } catch (Exception e) {
- handleSynapseArtifactDeploymentError(
- "StartupTask Update from the file : " + fileName + " :
Failed.", e);
+ getSynapseConfiguration().removeStartup(existingArtifactName);
+ log.info("StartupTask: " + existingArtifactName + " has been
undeployed");
+ }
+
+ existingSt.destroy();
+ log.info("StartupTask: " + st.getName() + " has been updated from
the file: " + fileName);
+ return st.getName();
+
+ } catch (DeploymentException e) {
+ handleSynapseArtifactDeploymentError("Error while updating the
startup task from the " +
+ "file: " + fileName);
}
return null;