Modified: trunk/core/src/main/java/org/servicemix/jbi/messaging/ExchangePacket.java (657 => 658)
--- trunk/core/src/main/java/org/servicemix/jbi/messaging/ExchangePacket.java 2005-10-25 16:01:03 UTC (rev 657)
+++ trunk/core/src/main/java/org/servicemix/jbi/messaging/ExchangePacket.java 2005-10-25 16:32:21 UTC (rev 658)
@@ -56,8 +56,8 @@
private QName interfaceName;
private QName operationName;
private Exception error;
- private Map properties = new ConcurrentHashMap();
- private Map messages = new ConcurrentHashMap();
+ private Map properties;
+ private Map messages;
private ServiceEndpointImpl endpoint;
private transient Transaction transactionContext;
private transient String endpointName;
@@ -75,15 +75,19 @@
this.exchangeId = null; //???;
this.interfaceName = packet.interfaceName;
CopyTransformer ct = new CopyTransformer();
- for (Iterator it = packet.messages.entrySet().iterator(); it.hasNext();) {
- Map.Entry entry = (Map.Entry) it.next();
- NormalizedMessage copy = new NormalizedMessageImpl();
- ct.transform(null, (NormalizedMessage) entry.getValue(), copy);
- setMessage(copy, (String) entry.getKey());
+ if (packet.messages != null && packet.messages.size() > 0) {
+ for (Iterator it = packet.messages.entrySet().iterator(); it.hasNext();) {
+ Map.Entry entry = (Map.Entry) it.next();
+ NormalizedMessage copy = new NormalizedMessageImpl();
+ ct.transform(null, (NormalizedMessage) entry.getValue(), copy);
+ setMessage(copy, (String) entry.getKey());
+ }
}
this.operationName = packet.operationName;
this.pattern = packet.pattern;
- this.properties.putAll(packet.properties);
+ if (packet.properties != null && packet.properties.size() > 0) {
+ getProperties().putAll(packet.properties);
+ }
this.serviceName = packet.serviceName;
this.sourceId = packet.sourceId;
this.status = packet.status;
@@ -221,6 +225,9 @@
* @return Returns the messages.
*/
public Map getMessages() {
+ if (messages == null) {
+ messages = new ConcurrentHashMap();
+ }
return messages;
}
@@ -231,7 +238,10 @@
* @return a NormalizedMessage
*/
public NormalizedMessage getMessage(String name) {
- return (NormalizedMessage) messages.get(name);
+ if (messages != null) {
+ return (NormalizedMessage) messages.get(name);
+ }
+ return null;
}
/**
@@ -242,13 +252,16 @@
* @throws MessagingException
*/
public void setMessage(NormalizedMessage message, String name) throws MessagingException {
- messages.put(name, message);
+ getMessages().put(name, message);
}
/**
* @return Returns the properties.
*/
public Map getProperties() {
+ if (properties == null) {
+ properties = new ConcurrentHashMap();
+ }
return properties;
}
@@ -257,7 +270,10 @@
* @return the proerty from the exchange
*/
public Object getProperty(String name) {
- return properties.get(name);
+ if (properties != null) {
+ return properties.get(name);
+ }
+ return null;
}
/**
@@ -267,14 +283,23 @@
* @param value
*/
public void setProperty(String name, Object value) {
- properties.put(name, value);
+ if (value == null) {
+ if (properties != null) {
+ properties.remove(name);
+ }
+ } else {
+ getProperties().put(name, value);
+ }
}
/**
* @return property names
*/
public Set getPropertyNames() {
- return Collections.unmodifiableSet(properties.keySet());
+ if (properties != null) {
+ return Collections.unmodifiableSet(properties.keySet());
+ }
+ return Collections.EMPTY_SET;
}
/**
@@ -339,7 +364,6 @@
out.writeObject(sourceId);
out.writeObject(serviceName);
out.writeObject(interfaceName);
- out.writeObject(interfaceName);
out.writeObject(error);
out.writeObject(properties);
out.writeObject(messages);
@@ -362,7 +386,6 @@
sourceId = (ComponentNameSpace) in.readObject();
serviceName = (QName) in.readObject();
interfaceName = (QName) in.readObject();
- interfaceName = (QName) in.readObject();
error = (Exception) in.readObject();
properties = (Map) in.readObject();
messages = (Map) in.readObject();
Modified: trunk/core/src/main/java/org/servicemix/jbi/messaging/NormalizedMessageImpl.java (657 => 658)
--- trunk/core/src/main/java/org/servicemix/jbi/messaging/NormalizedMessageImpl.java 2005-10-25 16:01:03 UTC (rev 657)
+++ trunk/core/src/main/java/org/servicemix/jbi/messaging/NormalizedMessageImpl.java 2005-10-25 16:32:21 UTC (rev 658)
@@ -135,7 +135,13 @@
* @param value
*/
public synchronized void setProperty(String name, Object value) {
- getProperties().put(name, value);
+ if (value == null) {
+ if (properties != null) {
+ properties.remove(name);
+ }
+ } else {
+ getProperties().put(name, value);
+ }
}
/**