public class AbstractConnectionHandler extends java.lang.Object implements IAbstractConnectionHandler
| Modifier and Type | Class and Description |
|---|---|
class |
AbstractConnectionHandler.ConnectionPanel |
static class |
AbstractConnectionHandler.SendInfo
Struct class that holds send information.
|
| Modifier and Type | Field and Description |
|---|---|
protected long |
acktimeout
The max delay before an acknowledgement is received.
|
protected long |
alivetime
The latest alive time.
|
protected AbstractConnection |
con
The connection.
|
protected long |
leasetime
The lease time.
|
protected int |
maxresends
The maximum number of resends.
|
protected MessageService |
ms
The message service.
|
protected java.util.Map<java.lang.String,java.lang.Object> |
nonfunc
The non-functional properties.
|
protected java.util.Map<java.lang.Object,AbstractConnectionHandler.SendInfo> |
unacked
The unacknowledged messages.
|
| Constructor and Description |
|---|
AbstractConnectionHandler(MessageService ms,
java.util.Map<java.lang.String,java.lang.Object> nonfunc)
Create a new connection handler.
|
AbstractConnectionHandler(MessageService ms,
java.util.Map<java.lang.String,java.lang.Object> nonfunc,
int maxresends,
long acktimeout,
long leasetime)
Create a new connection handler.
|
| Modifier and Type | Method and Description |
|---|---|
void |
ackReceived(java.lang.Object id,
java.lang.Object content)
Called when an ack was received.
|
void |
close()
Close the connection.
|
protected java.util.TimerTask |
createAckTimer(java.lang.Object id)
Triggers resends of packets if no ack has been received in acktimeout.
|
void |
createGui() |
protected javax.swing.JPanel |
createPanel() |
protected AbstractSendTask |
createTask(java.lang.String type,
byte[] content,
java.lang.Integer seqnumber,
java.util.Map<java.lang.String,java.lang.Object> nonfunc)
Create a new task.
|
protected AbstractSendTask |
createTask(java.lang.String type,
java.lang.Object content,
boolean usecodecs,
java.lang.Integer seqnumber,
java.util.Map<java.lang.String,java.lang.Object> nonfunc)
Create a new task.
|
jadex.commons.future.IFuture<java.lang.Void> |
doClose()
Called from connection.
|
protected byte[] |
getCodecIds()
Get the codec ids.
|
protected jadex.bridge.service.types.message.ICodec[] |
getCodecs()
Get the codecs.
|
protected AbstractConnection |
getConnection()
Get the connection.
|
int |
getConnectionId()
Get the id.
|
protected long |
getLeasetime()
Get the leasetime.
|
protected byte |
getMessageType(java.lang.String type)
Get the message type for a given type, e.g.
|
java.util.Map<java.lang.String,java.lang.Object> |
getNonFunctionalProperties()
Get the non-functional properties.
|
protected ITransport[] |
getTransports()
Get the transports.
|
void |
initReceived()
Received the init message.
|
boolean |
isClosed()
Get the closed.
|
boolean |
isConnectionAlive()
Test if the connection is alive.
|
void |
notifyInited() |
protected <E> jadex.commons.future.IFuture<E> |
scheduleStep(jadex.bridge.IComponentStep<E> step)
Schedule a step on the message service component.
|
protected jadex.commons.future.IFuture<java.lang.Object> |
sendAcknowledgedMessage(AbstractSendTask task,
java.lang.Object id)
Send a message and wait for an ack.
|
jadex.commons.future.IFuture<java.lang.Void> |
sendAlive()
Send alive message.
|
jadex.commons.future.IFuture<java.lang.Void> |
sendInit()
Send init message.
|
protected void |
sendTask(AbstractSendTask task)
Send a task.
|
void |
setAliveTime(long alivetime)
Set the alive time of the other connection side.
|
void |
setConnection(AbstractConnection con)
Set the connection (needed as connection and handler need each other).
|
void |
setNonFunctionalProperties(java.util.Map<java.lang.String,java.lang.Object> nonfunc)
Set the non-functional properties.
|
protected MessageService ms
protected AbstractConnection con
protected long alivetime
protected long leasetime
protected java.util.Map<java.lang.Object,AbstractConnectionHandler.SendInfo> unacked
protected int maxresends
protected long acktimeout
protected java.util.Map<java.lang.String,java.lang.Object> nonfunc
public AbstractConnectionHandler(MessageService ms, java.util.Map<java.lang.String,java.lang.Object> nonfunc)
public AbstractConnectionHandler(MessageService ms, java.util.Map<java.lang.String,java.lang.Object> nonfunc, int maxresends, long acktimeout, long leasetime)
public void setConnection(AbstractConnection con)
setConnection in interface IAbstractConnectionHandlerpublic void initReceived()
public void ackReceived(java.lang.Object id,
java.lang.Object content)
public void close()
public void setAliveTime(long alivetime)
alivetime - The alive time.public boolean isConnectionAlive()
public boolean isClosed()
public int getConnectionId()
public jadex.commons.future.IFuture<java.lang.Void> doClose()
doClose in interface IAbstractConnectionHandlerpublic jadex.commons.future.IFuture<java.lang.Void> sendInit()
sendInit in interface IAbstractConnectionHandlerpublic jadex.commons.future.IFuture<java.lang.Void> sendAlive()
public void notifyInited()
notifyInited in interface IAbstractConnectionHandlerprotected AbstractConnection getConnection()
protected jadex.bridge.service.types.message.ICodec[] getCodecs()
protected byte[] getCodecIds()
protected ITransport[] getTransports()
public java.util.Map<java.lang.String,java.lang.Object> getNonFunctionalProperties()
getNonFunctionalProperties in interface IAbstractConnectionHandlerpublic void setNonFunctionalProperties(java.util.Map<java.lang.String,java.lang.Object> nonfunc)
nonfunc - The non-functional properties.protected byte getMessageType(java.lang.String type)
type - The message type.protected AbstractSendTask createTask(java.lang.String type, byte[] content, java.lang.Integer seqnumber, java.util.Map<java.lang.String,java.lang.Object> nonfunc)
type - The message type.content - The content.seqnumber - The sequence number.protected AbstractSendTask createTask(java.lang.String type, java.lang.Object content, boolean usecodecs, java.lang.Integer seqnumber, java.util.Map<java.lang.String,java.lang.Object> nonfunc)
type - The message type.content - The content.usecodecs - Flag if codecs should be used to encode the content.seqnumber - The sequence number.protected void sendTask(AbstractSendTask task)
task - The task.protected jadex.commons.future.IFuture<java.lang.Object> sendAcknowledgedMessage(AbstractSendTask task, java.lang.Object id)
task - The send task.id - The id of the call (e.g. sequence number).protected long getLeasetime()
protected <E> jadex.commons.future.IFuture<E> scheduleStep(jadex.bridge.IComponentStep<E> step)
protected java.util.TimerTask createAckTimer(java.lang.Object id)
id - The message id.public void createGui()
protected javax.swing.JPanel createPanel()