public class Gateway extends java.lang.Object implements Messenger, java.io.Closeable
Modifier and Type | Field and Description |
---|---|
protected Agent |
agent |
static long |
BLOCKING
Represents a blocking timeout of infinite time.
|
protected Container |
container |
static long |
NON_BLOCKING
Represents a non-blocking timeout of 0 seconds.
|
protected boolean |
shutdownContainer |
Modifier | Constructor and Description |
---|---|
protected |
Gateway() |
|
Gateway(Container container)
Creates a gateway based on an exsiting container.
|
|
Gateway(Platform platform,
java.lang.String hostname,
int port)
Creates a gateway connecting to a specified master container over TCP/IP.
|
|
Gateway(Platform platform,
java.lang.String devname,
int baud,
java.lang.String settings)
Creates a gateway connecting to a specified master container over RS232.
|
|
Gateway(java.lang.String hostname,
int port)
Creates a gateway connecting to a specified master container over TCP/IP.
|
|
Gateway(java.lang.String devname,
int baud,
java.lang.String settings)
Creates a gateway connecting to a specified master container over RS232.
|
Modifier and Type | Method and Description |
---|---|
AgentID |
agent(java.lang.String name)
Returns an object representing a named agent.
|
AgentID |
agentForService(java.lang.Enum<?> service)
Finds an agent that provides a named service.
|
AgentID |
agentForService(java.lang.String service)
Finds an agent that provides a named service.
|
AgentID[] |
agentsForService(java.lang.Enum<?> service)
Finds all agents that provides a named service.
|
AgentID[] |
agentsForService(java.lang.String service)
Finds all agents that provides a named service.
|
boolean |
authenticate(java.lang.String creds)
Authenticate to server.
|
void |
close()
Closes the gateway.
|
void |
finalize() |
void |
flush()
Flushes the incoming message queue.
|
AgentID |
getAgentID()
Gets the agent ID associated with the gateway.
|
Container |
getContainer()
Gets the container for the gateway.
|
Platform |
getPlatform()
Gets the platform for the gateway.
|
protected void |
init() |
Message |
receive()
Returns a message received by the gateway.
|
Message |
receive(java.lang.Class<?> cls)
Returns a message of a given class received by the gateway.
|
Message |
receive(java.lang.Class<?> cls,
long timeout)
Returns a message of a given class received by the gateway.
|
Message |
receive(long timeout)
Returns a message received by the agent.
|
Message |
receive(Message m)
Returns a response message received by the gateway.
|
Message |
receive(MessageFilter filter)
Returns a message received by the gateway and matching the given filter.
|
Message |
receive(MessageFilter filter,
long timeout)
Returns a message received by the gateway and matching the given filter.
|
Message |
receive(Message m,
long timeout)
Returns a response message received by the gateway.
|
Message |
request(Message msg)
Sends a request and waits for a response.
|
Message |
request(Message msg,
long timeout)
Sends a request and waits for a response.
|
boolean |
send(Message m)
Sends a message to the recipient indicated in the message.
|
boolean |
subscribe(AgentID topic)
Subscribes the gateway to receive all messages sent to the given topic.
|
AgentID |
topic(AgentID topic)
Returns an object representing the notification topic for an agent.
|
AgentID |
topic(AgentID aid,
java.lang.Enum<?> topic)
Returns an object representing a named notification topic for an agent.
|
AgentID |
topic(AgentID aid,
java.lang.String topic)
Returns an object representing a named notification topic for an agent.
|
AgentID |
topic(java.lang.Enum<?> topic)
Returns an object representing the named topic.
|
AgentID |
topic(java.lang.String topic)
Returns an object representing the named topic.
|
boolean |
unsubscribe(AgentID topic)
Unsubscribes the gateway from a given topic.
|
public static final long NON_BLOCKING
public static final long BLOCKING
protected Container container
protected Agent agent
protected boolean shutdownContainer
protected Gateway()
public Gateway(Platform platform, java.lang.String hostname, int port) throws java.io.IOException
platform
- platform to usehostname
- hostname to connect to.port
- TCP port to connect to.java.io.IOException
public Gateway(java.lang.String hostname, int port) throws java.io.IOException
hostname
- hostname to connect to.port
- TCP port to connect to.java.io.IOException
public Gateway(Platform platform, java.lang.String devname, int baud, java.lang.String settings) throws java.io.IOException
platform
- platform to usedevname
- device name of the RS232 port.baud
- baud rate for the RS232 port.settings
- RS232 settings (null for defaults, or "N81" for no parity, 8 bits, 1 stop bit).java.io.IOException
public Gateway(java.lang.String devname, int baud, java.lang.String settings) throws java.io.IOException
devname
- device name of the RS232 port.baud
- baud rate for the RS232 port.settings
- RS232 settings (null for defaults, or "N81" for no parity, 8 bits, 1 stop bit).java.io.IOException
public Gateway(Container container)
protected void init()
public Container getContainer()
public Platform getPlatform()
public boolean authenticate(java.lang.String creds)
creds
- credentials to authenticate with.public AgentID getAgentID()
public void flush()
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public boolean send(Message m)
Messenger
public Message receive(MessageFilter filter, long timeout)
Messenger
public Message receive(MessageFilter filter)
Messenger
public Message receive(long timeout)
Messenger
public final Message receive()
Messenger
public Message receive(java.lang.Class<?> cls, long timeout)
Messenger
public Message receive(java.lang.Class<?> cls)
Messenger
public Message receive(Message m, long timeout)
Messenger
public Message receive(Message m)
Messenger
public Message request(Message msg, long timeout)
Messenger
public Message request(Message msg)
Messenger
public AgentID topic(java.lang.String topic)
topic
- name of the topic.public AgentID topic(java.lang.Enum<?> topic)
topic
- name of the topic.public AgentID topic(AgentID topic)
topic
- agent to get notification topic for.public AgentID topic(AgentID aid, java.lang.String topic)
aid
- agent to get notification topic for.topic
- name for the notification topic.public AgentID topic(AgentID aid, java.lang.Enum<?> topic)
aid
- agent to get notification topic for.topic
- name for the notification topic.public AgentID agent(java.lang.String name)
name
- name of the agent.public boolean subscribe(AgentID topic)
topic
- the topic to subscribe to.public boolean unsubscribe(AgentID topic)
topic
- the topic to unsubscribe.public AgentID agentForService(java.lang.String service)
service
- the named service of interest.public AgentID agentForService(java.lang.Enum<?> service)
service
- the named service of interest.public AgentID[] agentsForService(java.lang.String service)
service
- the named service of interest.public AgentID[] agentsForService(java.lang.Enum<?> service)
service
- the named service of interest.public void finalize()
finalize
in class java.lang.Object