|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.kuka.comm.net.NetConnectionHandler<S,C,T>
C - the type of connection this handler createsS - the type of server this handler is forT - a type to identify the incoming connection request (e.g. Socket for TCP or DatagramPacket
for UDP)public abstract class NetConnectionHandler<S extends Server,C extends NetConnection,T>
Base class for handling incoming connection requests at a server. Instances of this class decide whether an incoming connection is accepted, which connection type is created and how the connection is configured.
Subclasses must specify the connection type to be created on an incoming request by implementing
createConnection(Server, Object). By overriding acceptConnection(Server, Object) subclasses can
decide whether an incoming request is accepted. The default implementation accepts all requests.
| Constructor Summary | |
|---|---|
protected |
NetConnectionHandler(NetConnectionConfigurator<C> configurator)
Creates a new connection handler that uses the given configurator to configure the connection and accepts an unlimited number of connections. |
protected |
NetConnectionHandler(NetConnectionConfigurator<C> configurator,
int maxConnections)
Creates a new connection handler that uses the given configurator to configure incoming connections and limits the maximum number of active connections to maxConnections. |
| Method Summary | |
|---|---|
protected boolean |
acceptConnection(S server,
T identifier)
Checks whether an incoming connection request is accepted. |
protected abstract C |
createConnection(S server,
T identifier)
Creates a new connection for an incoming connection request. |
NetConnectionConfigurator<C> |
getConfigurator()
|
int |
getMaxConnections()
|
C |
handleConnection(S server,
T identifier)
Creates a new connection for an incoming connection request. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected NetConnectionHandler(NetConnectionConfigurator<C> configurator)
configurator - the configurator used to configure incoming connections, must not be null
protected NetConnectionHandler(NetConnectionConfigurator<C> configurator,
int maxConnections)
maxConnections.
maxConnections - the maximum number of simultaneous connections, must be greater than 0configurator - the configurator used to configure incoming connections, must not be null| Method Detail |
|---|
public final C handleConnection(S server,
T identifier)
If the number of currently active connection exceeds the maximum allowed number, or the incoming request is
refused (i.e. acceptConnection(Server, Object) returns false) this method returns
null.
server - the server receiving the incoming connection requestidentifier - object that can be used to identify the incoming connection request
null if the connection is refusedpublic final int getMaxConnections()
public final NetConnectionConfigurator<C> getConfigurator()
protected boolean acceptConnection(S server,
T identifier)
server - the server receiving the incoming connection requestidentifier - object that can be used to identify the incoming connection request
true if the incoming connection request was accepted, false otherwise.
protected abstract C createConnection(S server,
T identifier)
server - the server receiving the incoming connection requestidentifier - object that can be used to identify the incoming connection request
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||