From 97a6e80d4f28c61ae3a93f3e2fc4efd1a54f8241 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Mon, 19 Nov 2007 22:00:37 +0000 Subject: [PATCH] Added Message interface, header, and simple document message implementation (EAI-1) --- .../eai/message/DocumentMessage.java | 43 ++++++++ .../springframework/eai/message/Message.java | 28 +++++ .../eai/message/MessageHeader.java | 100 ++++++++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 spring-eai-core/src/main/java/org/springframework/eai/message/DocumentMessage.java create mode 100644 spring-eai-core/src/main/java/org/springframework/eai/message/Message.java create mode 100644 spring-eai-core/src/main/java/org/springframework/eai/message/MessageHeader.java diff --git a/spring-eai-core/src/main/java/org/springframework/eai/message/DocumentMessage.java b/spring-eai-core/src/main/java/org/springframework/eai/message/DocumentMessage.java new file mode 100644 index 0000000000..780947edd7 --- /dev/null +++ b/spring-eai-core/src/main/java/org/springframework/eai/message/DocumentMessage.java @@ -0,0 +1,43 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.eai.message; + +/** + * @author Mark Fisher + */ +public class DocumentMessage implements Message { + + private MessageHeader header; + + private Object payload; + + + public DocumentMessage(Object id, Object payload) { + this.header = new MessageHeader(id); + this.payload = payload; + } + + + public MessageHeader getHeader() { + return this.header; + } + + public Object getPayload() { + return this.payload; + } + +} diff --git a/spring-eai-core/src/main/java/org/springframework/eai/message/Message.java b/spring-eai-core/src/main/java/org/springframework/eai/message/Message.java new file mode 100644 index 0000000000..9d9c91db24 --- /dev/null +++ b/spring-eai-core/src/main/java/org/springframework/eai/message/Message.java @@ -0,0 +1,28 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.eai.message; + +/** + * @author Mark Fisher + */ +public interface Message { + + MessageHeader getHeader(); + + Object getPayload(); + +} diff --git a/spring-eai-core/src/main/java/org/springframework/eai/message/MessageHeader.java b/spring-eai-core/src/main/java/org/springframework/eai/message/MessageHeader.java new file mode 100644 index 0000000000..44b70c2883 --- /dev/null +++ b/spring-eai-core/src/main/java/org/springframework/eai/message/MessageHeader.java @@ -0,0 +1,100 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.eai.message; + +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; + +/** + * @author Mark Fisher + */ +public class MessageHeader { + + private Object id; + + private Object correlationId; + + private String replyChannelName; + + private int sequenceNumber = 1; + + private int sequenceSize = 1; + + private Properties properties = new Properties(); + + private Map attributes = new ConcurrentHashMap(); + + + public MessageHeader(Object id) { + this.id = id; + } + + + public Object getId() { + return this.id; + } + + public Object getCorrelationId() { + return this.correlationId; + } + + public void setCorrelationId(Object correlationId) { + this.correlationId = correlationId; + } + + public String getReplyChannelName() { + return this.replyChannelName; + } + + public void setReplyChannelName(String replyChannelName) { + this.replyChannelName = replyChannelName; + } + + public int getSequenceNumber() { + return this.sequenceNumber; + } + + public void setSequenceNumber(int sequenceNumber) { + this.sequenceNumber = sequenceNumber; + } + + public int getSequenceSize() { + return this.sequenceSize; + } + + public void setSequenceSize(int sequenceSize) { + this.sequenceSize = sequenceSize; + } + + public String getProperty(String key) { + return this.properties.getProperty(key); + } + + public void setProperty(String key, String value) { + this.properties.setProperty(key, value); + } + + public Object getAttribute(String key) { + return this.attributes.get(key); + } + + public void setAttribute(String key, Object value) { + this.attributes.put(key, value); + } + +}