Added default id generator to GenericMessage.
This commit is contained in:
@@ -19,6 +19,8 @@ package org.springframework.integration.message;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.springframework.integration.SystemInterruptedException;
|
||||
import org.springframework.integration.util.RandomGuidUidGenerator;
|
||||
import org.springframework.integration.util.UidGenerator;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -34,9 +36,17 @@ public class GenericMessage<T> implements Message<T> {
|
||||
|
||||
private T payload;
|
||||
|
||||
private UidGenerator defaultUidGenerator = new RandomGuidUidGenerator();
|
||||
|
||||
private ReentrantLock lock;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new message with the given id and payload.
|
||||
*
|
||||
* @param id unique identifier for this message
|
||||
* @param payload the message payload
|
||||
*/
|
||||
public GenericMessage(Object id, T payload) {
|
||||
Assert.notNull(id, "id must not be null");
|
||||
Assert.notNull(payload, "payload must not be null");
|
||||
@@ -44,6 +54,19 @@ public class GenericMessage<T> implements Message<T> {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new message with the given payload. The id will be generated by
|
||||
* the default {@link UidGenerator} strategy.
|
||||
*
|
||||
* @param payload the message payload
|
||||
*/
|
||||
public GenericMessage(T payload) {
|
||||
Assert.notNull(payload, "payload must not be null");
|
||||
this.id = this.defaultUidGenerator.generateUid();
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
|
||||
public Object getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user