|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.comm.AbstractServer
public abstract class AbstractServer
Abstract base implementation of a Server. This class manages a collection of Connections and a
collection of ServerListener.
| Nested Class Summary | |
|---|---|
protected static interface |
AbstractServer.ConnectionConsumer
Represents an operation on a connection that accepts a single input argument and returns no result. |
| Constructor Summary | |
|---|---|
AbstractServer()
|
|
| Method Summary | |
|---|---|
protected void |
addConnection(Connection connection)
Adds a connection to the internal list of connections. |
void |
addServerListener(ServerListener listener)
Method to add a new listener for this server. |
protected void |
closeAllConnections()
Closes all connections currently in the list of known connections. |
int |
countConnections()
Returns the number of connections handled by this server. |
protected void |
fireAcceptedConnection(Connection connection)
Private method to notify listener about accepted connections. |
protected void |
fireIncomingConnection(Connection connection)
Private method to notify listener about incoming connections. |
protected void |
fireRejectedConnection(Connection connection)
Private method to notify listener about rejected connections. |
protected void |
forEachConnection(AbstractServer.ConnectionConsumer consumer)
Iterates synchronized over all connections contained in this server and applies the given consumer. |
Collection<Connection> |
getConnections()
Returns a snapshot of current connections on this server. |
boolean |
hasConnections()
Returns true if this server has active connections. |
protected void |
removeConnection(Connection connection)
Private method to remove connections from connection list. |
void |
removeServerListener(ServerListener listener)
Method to remove a ServerListener from internal list of listeners. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.kuka.comm.Server |
|---|
isRunning, start, stop |
| Constructor Detail |
|---|
public AbstractServer()
| Method Detail |
|---|
public final Collection<Connection> getConnections()
Server
The returned collection is an unmodifiable copy of the internally held collection of connections. The returned
collection can thus be used to inspect the state of the various connections, but it cannot be used to add or
remove connections from the server. If the collection of connections changes in the server these changes are not
reflected in the returned collection. If you need the number of connections use Server.countConnections().
getConnections in interface ServerServer.countConnections()public final int countConnections()
Server
countConnections in interface Serverpublic final boolean hasConnections()
Server
hasConnections in interface Serverpublic final void addServerListener(ServerListener listener)
ServerServerListener will be notified upon events, which
occur at the server.
addServerListener in interface Serverlistener - The ServerListener to append to list of listeners.public final void removeServerListener(ServerListener listener)
ServerServerListener from internal list of listeners. If the ServerListener isn't in
its list. nothing would happen.
removeServerListener in interface Serverlistener - The ServerListener which should be removed.protected final void forEachConnection(AbstractServer.ConnectionConsumer consumer)
consumer - the consumer to apply to all connectionsprotected final void addConnection(Connection connection)
connection - the connection to addprotected final void removeConnection(Connection connection)
connection - The Connection to remove.protected final void closeAllConnections()
protected final void fireIncomingConnection(Connection connection)
connection - The Connection which has been income by the server.protected final void fireAcceptedConnection(Connection connection)
connection - The Connection which has been accepted by the server.protected final void fireRejectedConnection(Connection connection)
connection - The Connection which has been rejected by the server.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||