|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectConnProcessor
FlapProcessor
Represents a FLAP connection that manages an outgoing FLAP queue as well
as parsing and processing incoming FLAP packets. A FlapProcessor
can be attached to any pair of input and output streams, allowing one to
read and write FLAP commands to almost any source and destination. For an
easier way to use the most common source and destination, a TCP socket, see
ClientFlapConn
.
FlapProcessor
uses the Java Logging API namespace
"net.kano.joscar.flap"
, logging various events at the levels
Level.CONFIG
, Level.FINE
, and
Level.FINER
, in order to, hopefully, ease the debugging of
FLAP-related applications. For more information on how to log such events,
consult the Java Logging API reference at the J2SE website.
Note that upon receipt of a FLAP packet, an event is passed to each of the
registered vetoable listeners first, halting immediately if a listener
says to halt processing. If a vetoable listener has not halted processing, an
event is next passed to each of the registered non-vetoable (that is,
normal FlapPacketListener
) listeners.
Note that a new instance of FlapProcessor
does not come with any
FLAP command factory installed! You are advised to install
an instance of DefaultFlapCmdFactory
(or your own custom factory).
ClientFlapConn
Constructor Summary | |
FlapProcessor()
Creates a FLAP processor with the default FLAP command factory and not yet attached to an input or output stream. |
|
FlapProcessor(java.net.Socket socket)
Creates a FLAP processor with the default FLAP command factory and attaches it to the given socket. |
Method Summary | |
void |
addExceptionHandler(FlapExceptionHandler handler)
Adds an exception handler for FLAP-related exceptions. |
void |
addPacketListener(FlapPacketListener listener)
Adds a FLAP packet listener to this FLAP processor. |
void |
addVetoablePacketListener(VetoableFlapPacketListener listener)
Adds a "vetoable packet listener." |
void |
handleException(java.lang.Object type,
java.lang.Throwable t)
Processes the given exception with the given error type. |
void |
handleException(java.lang.Object type,
java.lang.Throwable t,
java.lang.Object info)
Processes the given exception with the given error type and error detail info. |
boolean |
readNextFlap()
Reads and processes a single FLAP packet from the attached input stream. |
void |
removeExceptionHandler(FlapExceptionHandler handler)
Removes an exception handler from this FLAP processor. |
void |
removePacketListener(FlapPacketListener listener)
Removes a FLAP packet listener from this FLAP processor. |
void |
removeVetoablePacketListener(VetoableFlapPacketListener listener)
Removes the given vetoable packet listener from this FLAP processor's list of vetoable packet listeners. |
void |
runFlapLoop()
A utility method to read FLAP packets indefinitely (that is, until the end of the stream is reached or an I/O error occurs). |
void |
sendFlap(FlapCommand command)
Sends the given FLAP command on this FLAP processor's attached output stream. |
void |
setFlapCmdFactory(FlapCommandFactory factory)
Sets the FLAP command factory to use for generating FlapCommand s from FLAP packets. |
Methods inherited from class ConnProcessor |
attachToInput, attachToOutput, attachToSocket, detach, getInputStream, getOutputStream, isAttached |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FlapProcessor()
public FlapProcessor(java.net.Socket socket) throws java.io.IOException
readNextFlap()
and runFlapLoop()
.
socket
- the connected socket to which this FLAP processor
should be attached
java.io.IOException
- if an I/O exception occurs while attaching to the
socketConnProcessor.attachToSocket(java.net.Socket)
Method Detail |
public final void addVetoablePacketListener(VetoableFlapPacketListener listener)
listener
- the listener to addpublic final void removeVetoablePacketListener(VetoableFlapPacketListener listener)
listener
- the listener to removepublic final void addPacketListener(FlapPacketListener listener)
listener
- the listener to addpublic final void removePacketListener(FlapPacketListener listener)
listener
- the listener to removepublic final void addExceptionHandler(FlapExceptionHandler handler)
handler
- the handler to addpublic final void removeExceptionHandler(FlapExceptionHandler handler)
handler
- the handler to removepublic final void setFlapCmdFactory(FlapCommandFactory factory)
FlapCommand
s from FLAP packets. This can be
null
, disabling the generation of FlapCommand
s.
factory
- the new factory to use, or null
to disable
the generation of FlapCommand
s on this connectionpublic final void handleException(java.lang.Object type, java.lang.Throwable t)
handleException(type,
t, null)
.
type
- an object representing the type or source of the given
exceptiont
- the exception that was thrownaddExceptionHandler(net.kano.joscar.flap.FlapExceptionHandler)
public final void handleException(java.lang.Object type, java.lang.Throwable t, java.lang.Object info)
type
- an object representing the type or source of the given
exceptiont
- the exception that was throwninfo
- an object containing extra information or details on this
exception and/or what caused itpublic final void sendFlap(FlapCommand command)
command
- the command to sendpublic final void runFlapLoop() throws java.io.IOException
java.io.IOException
- if an I/O error occurspublic final boolean readNextFlap() throws java.io.IOException
false
, it is safe to assume that the
connection died.
true
if a packet was successfully read;
false
otherwise
java.io.IOException
- if an I/O error occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |