|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.miv.mbox.net.SenderPool
public class SenderPool
Create and cache senders automatically.
A sender pool allows to avoid creating a Sender for
each remote object we want to send message to, since one can use the same
sender for the same host. The sender pool remembers hosts and ports and their
associated sender. It can also create senders automatically for a given
MBoxLocator.
Sender,
Receiver| Field Summary | |
|---|---|
protected boolean |
debug
|
protected HashMap<String,Sender> |
senders
Map of senders. |
| Constructor Summary | |
|---|---|
SenderPool()
Empty sender pool. |
|
SenderPool(boolean debug)
Empty sender pool. |
|
| Method Summary | |
|---|---|
Sender |
connect(MBoxLocator locator)
Create a new sender for the host part of the given locator and cache it. |
Sender |
connect(String hostname,
int port)
Create a new sender to "//hostname:port" and cache it. |
Sender |
getSender(MBoxLocator locator)
Get the sender for the host given by the given locator. |
Sender |
getSender(String hostname,
int port)
Get the sender for the host given by the given hostname and port. |
boolean |
hasSender(MBoxLocator locator)
Is there a cached connection to the hostname and port of the given locator. |
void |
send(MBoxLocator to,
Packet packet)
Send a prepacked message to a distant message box, first creating a sender if not already cached. |
void |
send(String from,
MBoxLocator to,
Object... messages)
Send a message to a distant message box, first creating a sender if not already cached. |
void |
send(String from,
String hostname,
int port,
String to,
Object... messages)
Send a message to a distant message box, first creating a sender if not already cached. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected HashMap<String,Sender> senders
MBoxLocator.getHostId())
as a string and the value is the Sender instance.
protected boolean debug
| Constructor Detail |
|---|
public SenderPool()
public SenderPool(boolean debug)
debug - Activate debugging in all senders created.| Method Detail |
|---|
public boolean hasSender(MBoxLocator locator)
locator - The locator to check.
public Sender getSender(MBoxLocator locator)
locator - The locator of the host to search.
public Sender getSender(String hostname,
int port)
hostname - The hostname of the host to connect to.port - The port to connect to.
public Sender connect(String hostname,
int port)
throws IOException,
UnknownHostException
hostname - The hostname of the host to connect to.port - The port to connect to.
IOException
UnknownHostException
public Sender connect(MBoxLocator locator)
throws IOException,
UnknownHostException
locator - The locator used to create the connection.
IOException
UnknownHostException
public void send(String from,
String hostname,
int port,
String to,
Object... messages)
throws IOException,
UnknownHostException
from - The sender object name.hostname - The host name where the receiver box resides.port - The port of the host where the receiver box resides.to - The receiver box name.messages - The message data.
IOException
UnknownHostException
public void send(String from,
MBoxLocator to,
Object... messages)
throws IOException,
UnknownHostException
from - The sender object name.to - The location and name of the receiver box.messages - The message data.
IOException
UnknownHostException
public void send(MBoxLocator to,
Packet packet)
throws IOException,
UnknownHostException
to - The location and name of the receiver box.packet - The prepacket message.
IOException
UnknownHostException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||