|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object janus.net.ServerBase
public class ServerBase
Diese Klasse bildet die Basis fü Janus/TCP-basierte Server Den einzelnenden TCP/IP-Nachrichten werden Methoden zugeordnet, die die abgeleiteten Klassen implementieren können. Die Basisklasse implementiert einen Echo-Server
ServerLoop
Field Summary | |
---|---|
protected ServerConnection |
conn
Connection |
protected boolean |
debug
Debugging aktiv? |
protected PrintWriter |
debugStream
PrintWriter für Debugging |
protected ExceptionListener |
exceptionListener
Der Exception Listener |
protected String |
name
Name dieses Servers |
protected boolean |
replyPending
Wurde eine Antwort gesendet? |
protected Set |
serverSet
Map mit allen gleichartigen Threads |
protected int |
success_hi
Oberer Grenzwert für erfolgreiche Transaktion |
protected int |
success_lo
Unterer Grenzwert für erfolgreiche Transaktion |
protected Thread |
thread
Server-Thread |
protected int |
transaction_type
Transaktionstyp |
protected String |
ums_alias
Ziel-Alias für UMS-Nachricht |
protected byte[] |
ums_buffer
Datenpuffer fuer UMS-Nachrichten |
protected int |
ums_length
Länge der UMS-Nachricht bzw. der Antwort |
static int |
UMS_MAXLENGTH
Maximallänge einer UMS-Nachricht |
protected int |
ums_reply_len
Maximallänge der UMS-Antwort |
protected String |
ums_terminal
Ziel-Terminal für UMS-Nachricht |
protected Connection |
umsConn
UMS-Connection |
protected Thread |
umsThread
UMS-Server-Thread |
protected Object |
userObject
Beliebiges User-Objekt. |
Constructor Summary | |
---|---|
ServerBase()
Konstruktor ohne Argumente (für ServerLoop ) |
Method Summary | |
---|---|
protected void |
beginTransaction()
Starte eine Transaktion. |
protected void |
endTransaction()
Beende eine Transaktion (Commit). |
ServerConnection |
getConnection()
Rückgabe der Verbindung |
PrintWriter |
getDebugStream()
Rückgabe des DebugStream |
String |
getName()
Rückgabe des Namens |
protected void |
getNextUms()
Lese die nächste UMS-Nachricht aus externer Quelle. |
Connection |
getUmsConnection()
Rückgabe der UMS-Verbindung |
Object |
getUserObject()
Rückgabe des User-Objects |
protected void |
handleAccept()
Baue eine UMS-Verbindung zum Client auf. |
protected void |
handleAwaitIo()
Verarbeite eine eingehende AWAITIO-Nachricht. |
protected void |
handleCancel()
breche einen ausstehenden I/O ab Die Methode sollte überschrieben werden. |
protected void |
handleData()
Verarbeite eine eingehende Daten-Nachricht. |
protected void |
handleExit()
Behandle das Ende des Servers. |
protected void |
handleInit()
Initialisierung. |
protected void |
handleMessage(int message_tag)
Verarbeite eine eingehende Message. |
protected void |
handleTransaction()
Transaktions-Behandlung. |
protected void |
handleUms()
Behandle eine Antwort vom UMS-Client. |
protected void |
handleUmsException(Throwable t)
Behandle eine Exception beim Senden der UMS-Nachricht. |
boolean |
isDebug()
Rückgabe des Debug-Status |
protected void |
logException(Throwable t)
Logging von Exceptions |
protected void |
rollbackTransaction()
Breche eine Transaktion ab (Rollback). |
void |
run()
Thread-Code |
protected void |
sendAck()
Sende positive Quittung |
protected void |
sendAck(String text)
Sende positive Quittung |
protected void |
sendError(int error_code,
int subsystem,
int subsystem_error,
int extended_error,
int error_class,
String text)
Fehlerantwort |
protected void |
sendError(int error_code,
String text)
Fehlerantwort |
void |
sendError(String text)
Fehlerantwort |
void |
sendReply(byte[] buffer,
int offset,
int len)
Antwort an Client. |
void |
sendReply(MessageElement reply)
Antwort an Client. |
void |
sendReply(MessageElement reply,
int len)
Antwort an Client. |
void |
setConnection(ServerConnection conn)
Setzen der Verbindung |
boolean |
setDebug(boolean debug)
Setzen des Debug-Status |
void |
setDebugStream(PrintWriter stream)
Setzen des debugStream und debugStatus |
void |
setDebugStream(String file)
Setzen des debugStream und debugStatus |
void |
setExceptionListener(ExceptionListener exceptionListener)
Setze den ExceptionListener für das Loggig |
void |
setName(String name)
Setzen des Namens |
void |
setUserObject(Object userObject)
Setzen des User-Objects |
void |
stop()
Halte die Server- und UMS-Threads an. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ServerConnection conn
protected boolean debug
protected PrintWriter debugStream
protected ExceptionListener exceptionListener
protected String name
protected boolean replyPending
protected Set serverSet
ServerLoop
protected int success_hi
protected int success_lo
protected Thread thread
protected int transaction_type
protected String ums_alias
protected byte[] ums_buffer
protected int ums_length
public static final int UMS_MAXLENGTH
protected int ums_reply_len
protected String ums_terminal
protected Connection umsConn
protected Thread umsThread
protected Object userObject
ServerLoop.setUserObject(java.lang.Object)
Constructor Detail |
---|
public ServerBase()
ServerLoop
)
Method Detail |
---|
protected void beginTransaction() throws Exception
Exception
protected void endTransaction() throws Exception
Exception
public ServerConnection getConnection()
public PrintWriter getDebugStream()
public String getName()
protected void getNextUms()
public Connection getUmsConnection()
public Object getUserObject()
protected void handleAccept() throws Exception
getNextUms()
handleUms()
und handleUmsException(java.lang.Throwable)
implementieren
Exception
Connection.acceptNew()
protected void handleAwaitIo() throws Exception
Exception
ServerConnection
protected void handleCancel() throws Exception
Exception
ServerConnection
protected void handleData() throws Exception
Exception
ServerConnection
protected void handleExit()
protected void handleInit() throws Exception
Exception
protected void handleMessage(int message_tag) throws Exception
message_tag
- Nachrichtentyp aus Connection
Exception
- Beliebige Ausnahme der Handlerprotected void handleTransaction() throws Exception
beginTransaction()
, endTransaction()
und rollbackTransaction()
ab, die überschrieben
werden können.
Exception
protected void handleUms()
protected void handleUmsException(Throwable t) throws Throwable
Throwable
public boolean isDebug()
protected void logException(Throwable t)
t
- Die Exceptionprotected void rollbackTransaction() throws Exception
Exception
public void run()
run
in interface Runnable
protected void sendAck() throws CommException
CommException
protected void sendAck(String text) throws CommException
text
- Antworttext
CommException
- Allgemeiner Kommunikationsfehlerprotected void sendError(int error_code, int subsystem, int subsystem_error, int extended_error, int error_class, String text) throws CommException
error_code
- Fehlercodesubsystem
- Subsystemsubsystem_error
- Subsystem-Fehlercodeextended_error
- erweiterter Fehlercode
qparam error_class Fehlerklassetext
- Fehlermeldung
CommException
- Allgemeiner KommunikationsfehlerTandemException
protected void sendError(int error_code, String text) throws CommException
error_code
- Fehlercodetext
- Fehlermeldung
CommException
- Allgemeiner Kommunikationsfehlerpublic void sendError(String text) throws CommException
text
- Fehlermeldung
CommException
- Allgemeiner Kommunikationsfehlerpublic void sendReply(byte[] buffer, int offset, int len) throws Exception, CommException
buffer
- Antwort-Pufferoffset
- Offset innerhalb des Pufferslen
- Länge der Antwort
CommException
- Allgemeiner Kommunikationsfehler
Exception
- Fehler in endTransaction()
public void sendReply(MessageElement reply) throws CommException, Exception
reply
- Antwort
CommException
- Allgemeiner Kommunikationsfehler
Exception
- Fehler in endTransaction()
public void sendReply(MessageElement reply, int len) throws CommException, Exception
reply
- Antwortlen
- Länge der Antwort
CommException
- Allgemeiner Kommunikationsfehler
Exception
- Fehler in endTransaction()
public void setConnection(ServerConnection conn)
conn
- Verbindungpublic boolean setDebug(boolean debug)
debug
- Debug-Status
public void setDebugStream(PrintWriter stream)
stream
- Ausgabe-Stream für Debugausgabenpublic void setDebugStream(String file)
file
- Dateiname für Debugausgabenpublic void setExceptionListener(ExceptionListener exceptionListener)
exceptionListener
- Der Listenerpublic void setName(String name)
name
- Der Name des Serverspublic void setUserObject(Object userObject)
userObject
- Beliebiges ObjektServerLoop.setUserObject(java.lang.Object)
public void stop()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |