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

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

There is a newer version: 1.3.1
Show newest version
/**
 * 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.util.Vector;

/**
 * The interface for a Channel.
 * 
 * @author Knut Eilif Husa, Tellu AS
 * 
 */
public interface Channel extends Processor {

	// Messages
	// Message name for connecting channel
	public static final String CONNECT = "connect";
	
	//routingalgorithm for connecting segment
	public static final String ROUTING_ALGORITHM = "routingAlg";

	// Message name for ack of connecting channel
	public static final String CONNECT_ACK = "connectAck";
	
	// Message name for nack of connecting channel
	public static final String CONNECT_NACK = "connectNack";

	// Message parameters
	// Message paramater in message CONNECT indicating the endpoint uuid
	public static final String CONNECT_UUID = "con_uuid";

	// Message paramater in message CONNECT indicating the endpoint segment
	public static final String CONNECT_SEGMENT = "con_seg";

	// Message paramater in message CONNECT_ACK indicating the allocated
	// endpoint uuid
	public static final String CONNECT_ALLOCATED_UUID = "alloc_uuid";

	// Message paramater in message CONNECT_ACK indicating the router uuid
	public static final String CONNECT_ROUTER_UUID = "router_uuid";

	/**
	 * Returns the inLink of the Channel. The InLink direction is from this
	 * Channel such that messages processed by the channel will be delivered
	 * from the InLink
	 * 
	 * @return the InLink
	 */
	Link getInLink();

	/**
	 * Sets the inLink of the Channel. The InLink direction is from this Channel
	 * such that messages processed by the channel will be delivered from the
	 * InLink
	 * 
	 * @param inLink
	 */
	void setInLink(Link inLink);

	/**
	 * Returns the outLink of the Channel. The OutLink direction is into the
	 * Channel such that messages inserted into the OutLink will be processed by
	 * the Channel
	 * 
	 * @return the Outlink
	 */
	Link getOutLink();

	/**
	 * Sets the outLink of the Channel. The OutLink direction is into the
	 * Channel such that messages inserted into the OutLink will be processed by
	 * the Channel
	 * 
	 * @param outLink
	 */
	void setOutLink(Link outLink);

	/**
	 * Connects the Channel to the LinkManager. Connecting involves the
	 * following actions: Initiate the defined transport mechanism and send the
	 * "connect" message over the transport. Receive the For PluginChannels:
	 * CONNECT_ALLOCATED_UUID (Unique id for the Plugin allocated by the distant
	 * party) Receive the For RouterChannels: CONNECT_UUID (Unique id of the
	 * distant party)
	 * 
	 * @param linkManager
	 *            Manager handling links
	 * @throws ConnectingException
	 *             if connection fails, e.g. due to timeout
	 */
	void connect(Connectable linkManager) throws ConnectingException;

	/**
	 * Disconnects the channel
	 */
	void disconnect();

	/**
	 * Returns the transport mechanism
	 * 
	 * @return the transport mechanism
	 */
	Transport getTransport();

	/**
	 * Sets the Transport mechanism
	 * 
	 * @param transport
	 */
	void setTransport(Transport transport);

	/**
	 * Flag indicating whether this Channel side (Channels always exits in peer
	 * relations) shall initiate connection
	 * 
	 * @return boolean
	 */
	boolean isInit();

	/**
	 * Sets indicating whether this Channel side (Channels always exits in peer
	 * relations) shall initiate connection
	 * 
	 * @param init
	 */
	void setInit(boolean init);

	/**
	 * Sets the LinkManager
	 * 
	 * @param linkmanager
	 */
	void setLinkManager(Connectable linkmanager);

	/**
	 * Returns the LinkManager of this Channel
	 * 
	 * @return the LinkManager
	 */
	Connectable getLinkManager();

	/**
	 * Adds a protocol that this Channel handles. For PluginChannel and
	 * RouterChannel this is defaulted to coos
	 * 
	 * @param protocol
	 */
	void addProtocol(String protocol);

	/**
	 * The protocol that this Channel can handle
	 * 
	 * @return
	 */
	Vector getProtocols();

	/**
	 * Sets the Segment that this channel will connect to on the distant side
	 * 
	 * @param segment
	 */
	void setSegment(String segment);

	/**
	 * Returns the segment of this Channel
	 * 
	 * @return
	 */
	String getSegment();

	/**
	 * Returns a copy of this Channel
	 */
	Processor copy();

	/**
	 * Sets a Vector of protocols that this Channel shall handle
	 * 
	 * @param protocols
	 */
	void setProtocols(Vector protocols);

	public boolean isDefaultGw();

	boolean isConnected();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy