org.flexiblepower.messaging
@Retention(value=RUNTIME) @Target(value=TYPE) public @interface Port
Modifier and Type | Required Element and Description |
---|---|
java.lang.String |
name
The name of the port.
|
Modifier and Type | Optional Element and Description |
---|---|
java.lang.Class<?>[] |
accepts
Specifies the type of objects that can be received through this port.
|
Cardinality |
cardinality
Specifies the cardinality of this port.
|
java.lang.Class<?>[] |
sends
Specifies the type of objects that can be sent through this port.
|
public abstract java.lang.String name
Endpoint.onConnect(Connection)
method to determine which port
has been connected to. Should be unique for the Endpoint.
This is the only required part of a Port
. If no sends()
or accepts()
is defined, the
port has been defined without any implementation (like an interface). This is useful for specifying on an
interface that should use a specific port.public abstract java.lang.Class<?>[] sends
ConnectionManager
will detect
which ports can be connected to each other, it will check if this set is a subset of the other accepts()
set. The implementation of the Endpoint
should never sent other types of objects through this port,
otherwise the behavior is unspecified (possible throws ClassCastExceptions).public abstract java.lang.Class<?>[] accepts
Connection
, the MessageHandler
should only receive objects of this types.public abstract Cardinality cardinality
Cardinality.SINGLE
, only one Connection
can be created on this port at the same time. If it is set to Cardinality.MULTIPLE
, multiple connections
are possible and should be handled by the Endpoint.onConnect(Connection)
method.