All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.coos.messaging.Message Maven / Gradle / Ivy

/**
 * COOS - Connected Objects Operating System (www.connectedobjects.org).
 *
 * Copyright (C) 2009 Telenor ASA and Tellu AS. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see .
 *
 * You may also contact one of the following for additional information:
 * Telenor ASA, Snaroyveien 30, N-1331 Fornebu, Norway (www.telenor.no)
 * Tellu AS, Hagalokkveien 13, N-1383 Asker, Norway (www.tellu.no)
 */
package org.coos.messaging;

import java.io.DataInputStream;
import java.util.Hashtable;

/**
 * @author Knut Eilif Husa, Tellu AS 
 * The message that is transported on the bus
 */
public interface Message {

	// Header fields

	String TRACE_ROUTE = "traceRoute";
	String TRACE = "trace";
	String PRIORITY = "priority";
	String QOS_CLASS = "QoS";
	String MESSAGE_NAME = "name";
	String SECURITYTOKEN = "sectoken";
	String EXCHANGE_PREFIX = "coosx";
	String EXCHANGE_ID = "xId";
	String EXCHANGE_PATTERN = "xpattern";
	String DEFAULT_MESSAGE_NAME = "";
	String TIME_STAMP = "ts";
	String GUARANTEED_DELIVERY = "gd";
	String TRANSACTION_ID = "tId";
	String SENDER_ENDPOINT_NAME = "senderEPName";
	String RECEIVER_ENDPOINT_NAME = "receiverEPName";

	// message type header parameter
	String TYPE = "type";

	// message type values
	String TYPE_MSG = "msg";
	String TYPE_ERROR = "error";
	String TYPE_ANALYZE = "analyze";
	String TYPE_ROUTING_INFO = "routingInfo";
	String TYPE_ALIAS = "alias";

	String ERROR_REASON = "errorReason";
	String ERROR_NO_ROUTE = "noRoute";
	String ERROR_NO_ALIAS = "noAlias";
	String ERROR_TOO_MANY_HOPS = "tooManyHops";
	String ERROR_NO_RECEIVER = "noReciver";

	// message hops field
	String HOPS = "hops";

	// message segment field
	String SEGMENT = "seg";

	// Message content type header parameter
	String CONTENT_TYPE = "contentType";
	// Property content type
	String CONTENT_TYPE_PROPERTY = "property";
	// String content type
	String CONTENT_TYPE_STRING = "string";
	// Byte array content type
	String CONTENT_TYPE_BYTES = "bytes";
	// Object content type
	String CONTENT_TYPE_OBJECT = "object";

	// body serialization method header parameter
	String SERIALIZATION_METHOD = "ser";
	// serialization method ActorFrame, not dependant on java SE but own
	// serialization must be implemented
	String SERIALIZATION_METHOD_AF = "af";
	// serialization method Java, dependant on Java SE
	String SERIALIZATION_METHOD_JAVA = "java";
	// serialization method default
	String SERIALIZATION_METHOD_DEFAULT = "def";

	String getReceiverEndpointUri();

	Message setReceiverEndpointUri(String endpointUri);

	String getSenderEndpointUri();

	Message setSenderEndpointUri(String endpointUri);

	String getHeader(String key);

	public String getType();

	public String getContentType();

	/*
	 * The name of the message.
	 */
	public String getName();

	void setSenderEndpointName(String endpointName);

	String getSenderEndpointName();

	void setReceiverEndpointName(String endpointName);

	String getReceiverEndpointName();

	Message setHeader(String key, String value);

	Hashtable getHeaders();

	/**
	 * Returns the message context of the message.
	 * 
	 * @return
	 */
	MessageContext getMessageContext();

	void setMessageContext(MessageContext ctx);

	Message setBody(byte[] byteBody);

	Message setBody(Hashtable propertyBody);

	Message setBody(String stringBody);

	Message setBody(Object objectBody);

	byte[] getBodyAsBytes();

	Hashtable getBodyAsProperties();

	String getBodyAsString();

	Object getBody();

	byte[] getSerializedBody();

	void deserialize(DataInputStream din) throws Exception;

	byte[] serialize() throws Exception;

	Message copy() throws Exception;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy