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

Variable Index

 o DISCARD
Well known protocols - The echo protocol identifier.
 o ECHO
Well known protocols - The echo protocol identifier.
 o protocols
The hashtable of accepted protocols.
 o sample
The sigle instance of that class.

Constructor Index

 o SampleMuxHandler()

Method Index

 o acceptSession(MuxStream, int, int)
Are we willing to speak the given protocol on the given session.
 o getStreamHandler()
Get an instance of that sample mux stream handler.
 o log(String)
Log an error.
 o notifySession(MuxSession)
Setup the appropriate protocol handler for that accepted session.
 o registerDefaultHandlers()
Register default protocol handlers for that stream handler.
 o registerHandler(int, MuxProtocolHandler)
Register an instantiated protocol handler for the given protocol id.
 o registerHandler(int, String)
Register a protocol handler for the given protocol identifier.
 o unregisterHandler(int)
Unregister any handler for that protocol.

Variables

 o ECHO
 public static final int ECHO
Well known protocols - The echo protocol identifier.

 o DISCARD
 public static final int DISCARD
Well known protocols - The echo protocol identifier.

 o sample
 protected static SampleMuxHandler sample
The sigle instance of that class.

 o protocols
 protected Hashtable protocols
The hashtable of accepted protocols.

Constructors

 o SampleMuxHandler
 public SampleMuxHandler()

Methods

 o log
 protected void log(String msg)
Log an error.

Parameters:
msg - The message to log.
 o getStreamHandler
 public static synchronized MuxStreamHandler getStreamHandler()
Get an instance of that sample mux stream handler.

Returns:
A MuxStreamHandler conformant instance.
 o 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.
 o notifySession
 public void notifySession(MuxSession session)
Setup the appropriate protocol handler for that accepted session.

Parameters:
session - The newly accepted session.
 o 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
 o 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.
 o unregisterHandler
 public void unregisterHandler(int protid)
Unregister any handler for that protocol.

Parameters:
protid - The identifier of the protocol to unregister.
 o 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