All Packages Class Hierarchy This Package Previous Next Index
Class w3c.www.mux.SampleMuxHandler
java.lang.Object
|
+----w3c.www.mux.SampleMuxHandler
- public class SampleMuxHandler
- extends Object
- implements MuxStreamHandler
-
DISCARD
- Well known protocols - The echo protocol identifier.
-
ECHO
- Well known protocols - The echo protocol identifier.
-
protocols
- The hashtable of accepted protocols.
-
sample
- The sigle instance of that class.
-
SampleMuxHandler()
-
-
acceptSession(MuxStream, int, int)
- Are we willing to speak the given protocol on the given session.
-
getStreamHandler()
- Get an instance of that sample mux stream handler.
-
log(String)
- Log an error.
-
notifySession(MuxSession)
- Setup the appropriate protocol handler for that accepted session.
-
registerDefaultHandlers()
- Register default protocol handlers for that stream handler.
-
registerHandler(int, MuxProtocolHandler)
- Register an instantiated protocol handler for the given protocol id.
-
registerHandler(int, String)
- Register a protocol handler for the given protocol identifier.
-
unregisterHandler(int)
- Unregister any handler for that protocol.
ECHO
public static final int ECHO
- Well known protocols - The echo protocol identifier.
DISCARD
public static final int DISCARD
- Well known protocols - The echo protocol identifier.
sample
protected static SampleMuxHandler sample
- The sigle instance of that class.
protocols
protected Hashtable protocols
- The hashtable of accepted protocols.
SampleMuxHandler
public SampleMuxHandler()
log
protected void log(String msg)
- Log an error.
- Parameters:
- msg - The message to log.
getStreamHandler
public static synchronized MuxStreamHandler getStreamHandler()
- Get an instance of that sample mux stream handler.
- Returns:
- A MuxStreamHandler conformant instance.
acceptSession
public boolean acceptSession(MuxStream stream,
int sessid,
int protid)
- Are we willing to speak the given protocol on the given session.
- Parameters:
- stream - The stream that received the new session.
- sessid - The proposed session identifier.
- protid - The protocol to be spoken on that session.
- Returns:
- A bolean, true if the session is accepted,
false otherwise.
notifySession
public void notifySession(MuxSession session)
- Setup the appropriate protocol handler for that accepted session.
- Parameters:
- session - The newly accepted session.
registerHandler
public void registerHandler(int protid,
String strhandler)
- Register a protocol handler for the given protocol identifier.
This method register a class to handle all new connections for the
given protocol identifier: each new connection will result in a new
instance of the given class being created (the easy, but slow way).
- Parameters:
- protid - The protocol identifier.
- handler - The name of the class to instantiate in order
to get a suitable handler for that protocol.
- See Also:
- MuxProtocolHandler
registerHandler
public void registerHandler(int protid,
MuxProtocolHandler handler)
- Register an instantiated protocol handler for the given protocol id.
This other method of registering protocol handler is faster then
the previous one: it allows you to spare the instantiation of a protocol
handler on each new sessions.
The given handler will be invoked for all new sessions willing to
speak the advertized protocol.
- Parameters:
- protid - The protocol identifier.
- handler - The instantiated protocol handler.
unregisterHandler
public void unregisterHandler(int protid)
- Unregister any handler for that protocol.
- Parameters:
- protid - The identifier of the protocol to unregister.
registerDefaultHandlers
public void registerDefaultHandlers()
- Register default protocol handlers for that stream handler.
This is the right method to override in order to either prevent
well known protocols from being registered, or add new protocol
handlers.
Default protocols registered by this class are:
- echo
- The echo protocol.
- discard
- The discard protocol.
All Packages Class Hierarchy This Package Previous Next Index