|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.fhg.igd.semoa.server.CommunicationContextImpl
Supports message passing methods.
The following list of WhatIs
keys are required
by this class:
Nested Class Summary | |
private class |
CommunicationContextImpl.PrivilegedSend
|
Field Summary | |
private AccessControlContext |
acc_
The private AccessControlContext that was
retrieved on creation of this object. |
private AgentCard |
card_
The AgentContext that backs this instance. |
private Spooler |
spooler_
The Spooler that is used to receive
messages. |
Constructor Summary | |
protected |
CommunicationContextImpl(AgentCard card,
Spooler spool)
Creates an instance that poses as the agent with the given card, and uses the given spooler for receiving messages. |
protected |
CommunicationContextImpl(AgentContext context)
Creates an instance that links to the given
AgentContext . |
Method Summary | |
AgentCard |
getCard()
Returns the AgentCard of the agent. |
boolean |
hasNext()
|
Packet |
next()
Returns the next available packet. |
Packet |
next(long millis)
Returns the next available packet. |
void |
send(URL to,
URL from,
byte[] data)
Sends the given message to the specified recipient. |
void |
send(URL to,
URL from,
String text)
|
void |
sendSecure(URL to,
URL from,
byte[] data,
int secflag)
This is a quick & dirty method that offers a posibillity to send a message in secure way (over pods) or in unsecure way (over pod) depending on value of secflag. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private AgentCard card_
AgentContext
that backs this instance.
private Spooler spooler_
Spooler
that is used to receive
messages.
private AccessControlContext acc_
AccessControlContext
that was
retrieved on creation of this object. This context should
be used whenever a privileged action is executed.
Constructor Detail |
protected CommunicationContextImpl(AgentContext context)
AgentContext
.
This constructor retrieves and caches a reference to
the Spooler
of the given context. This
Spooler
is required for receiving messages.
context
- The AgentContext
of the agent
whose communication context this instance is.Spooler
,
SpoolerImpl
protected CommunicationContextImpl(AgentCard card, Spooler spool)
This constructor simplifies creation of daemons that can be reached by means similar to reaching an agent, and can be used e.g., for initializing a kind of AMS.
card
- The AgentCard
with the name
of the agent that is impoersonated by this context.spool
- The Spooler
implementation
that is used for receiving messages.Method Detail |
public AgentCard getCard()
AgentCard
of the agent.
The AgentCard
is the unique representation
of the agent, in particular of the agent's globally
unique name. Agents can be contacted and identified
using their card.
getCard
in interface CommunicationContext
AgentCard
.public void send(URL to, URL from, byte[] data) throws IOException
send
in interface CommunicationContext
to
- The recipient of the message. The recipient
is specified by means of a URL.from
- The sender's URL, or null
if the name and current location of this agent
shall be used.data
- The data that is sent to the receiver.
IOException
- if there is an I/O error during
message sending.
CommunicationException
- if the message cannot
be sent for some reason. Reasons can be: the receiver
is not reachable, the remote host is not reachable,
the receiver is not currently able to receive messages,
et cetera.
SecurityException
- if the name in the given
from
address does not match the implicit
name of the agent to whom this communication context
belongs.public void send(URL to, URL from, String text) throws IOException
send
in interface CommunicationContext
IOException
public void sendSecure(URL to, URL from, byte[] data, int secflag) throws IOException
sendSecure
in interface CommunicationContext
to
- The recipient of the message. The recipient
is specified by means of a URL.from
- The sender's URL, or null
if the name and current location of this agent
shall be used.data
- The data that is sent to the receiversecflag
- = 0 = only unsecure send
= 1 = only secure send
= 2 = if secure not possible
then send unsecure
CommunicationException
- if the message cannot
be sent for some reason. R
SecurityException
- if the name in the given
from
address does not match the implicit
name of the agent to whom this communication context
belongs.
IOException
- if there is an I/O error during
message sending.public boolean hasNext()
hasNext
in interface CommunicationContext
true
if there is a packet available.public Packet next() throws IOException, NoSuchElementException
next
in interface CommunicationContext
Packet
.
NoSuchElementException
- if no more packets are
currently available.
IOException
public Packet next(long millis) throws InterruptedException, IOException
next
in interface CommunicationContext
millis
- The number of milliseconds the spooler waits
for new packets to arrive. A value of 0 blocks forever.
Packet
, or null
if no
packet is available in the given period of milliseconds.
InterruptedException
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |