|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jabber.jabberbeans.ConnectionBean
ConnectionBean is the main bean for JabberBeans.
A ConnectionBean models the connection to the server, and all other beans rely on the ConnectionBean for server communication.
Internally, a ConnectionBean is just a "standard" interface to the backend (by default, Jabberbeans-SAX) which handles the server communication - you simply create objects and push them through 'send' to get to the server, and subscribe to the right interfaces to 'receive' new objects as they come in.
All the other beans (MessengerBean, IQBean, and RosterBean so far) are considered optional. Internally, they just use the ConnectionBean to send data, and listen to the events being broadcasted by the ConnectionBean to filter their 'received' data (which they then rebroadcast to their respective listeners.)
MessengerBean
,
IQBean
,
RosterBean
,
org.jabber.jabberbeans.sax, Serialized FormInner Class Summary | |
class |
ConnectionBean.InputStreamInterface
|
class |
ConnectionBean.OutputStreamInterface
|
class |
ConnectionBean.XMLStreamMonitor
|
Field Summary | |
private java.util.Vector |
connectionListeners
list of implementing interfaces which are listening for connection change events. |
static int |
DEFAULT_PORT
the default port for jabber servers, 5222 |
private static java.lang.String |
DEFAULT_XMLSTREAM_NS
Default namespace for XMLStream |
private boolean |
DisableAutoHeader
used to disable auto-sending XML stream tag |
private InputStreamHandler |
input
InputStream handling Thread. |
private OutputStreamHandler |
output
OutputStream handling Thread. |
private java.util.Vector |
packetListeners
list of implementing interfaces which are listening for packet broadcast events. |
private java.lang.String |
sessionID
storage for SessionID |
private java.net.Socket |
socket
Socket, if one is used for the connection. |
private ConnectionEvent.EState |
status
holds the current connection status. |
Constructor Summary | |
ConnectionBean()
|
Method Summary | |
void |
addConnectionListener(ConnectionListener l)
addConnectionListener adds a
ConnectionListener to the list of Listeners to be called
when the connection state changes. |
void |
addPacketListener(PacketListener l)
addPacketListener adds a PacketListener to the
list of Listeners to be called when a packet is received or successfully
sent out. |
void |
connect(java.net.InetAddress host)
connect attempts to establish a connection to the
default port on the specified server. |
void |
connect(java.net.InetAddress host,
int port)
connect attempts to establish a server connection to a
specified port. |
void |
connect(java.net.InetAddress host,
java.lang.String name)
connect attempts to establish a server connection to the
default port. |
void |
connect(java.net.InetAddress host,
java.lang.String name,
int port)
connect attempts to establish a server connection to a
specified port. |
void |
connect(java.io.InputStream is,
java.io.OutputStream os)
Begin communication with a Jabber server. |
void |
connect(java.net.Socket s)
Begin communication with a Jabber server. |
void |
delConnectionListener(ConnectionListener l)
delConnectionListener removes a previously added
ConnectionListener from the list of Listeners to be called
when a connection state change event happens. |
void |
delPacketListener(PacketListener l)
delPacketListener removes a
PacketListener to the list of Listeners to be called when
a packet is received or successfully sent out. |
void |
disableStreamHeader()
|
void |
disconnect()
disconnect correctly closes down the connection to the
Jabber server in the backend. |
private void |
disconnected(ConnectionEvent.EReason reason)
|
protected void |
fireReceivedPacket(Packet packet)
Internal method which sends out packet events on received data. |
protected void |
fireSentPacket(Packet packet)
Internal method which sends out packet events on sent data. |
protected void |
fireUnsentPacket(Packet packet)
Internal method which sends out packet events on failed send data. |
ConnectionEvent.EState |
getConnectionState()
returns the current connection state (disconnected, connecting, connected). |
java.lang.String |
getParser()
|
java.lang.String |
getSessionID()
|
void |
onInputDeath(java.lang.Exception e)
handler code for input stream death. |
void |
onOutputDeath(java.lang.Exception e)
handler code for output stream death. |
void |
received(Packet packet)
received is the method used to indicate that a new packet
has arrived. |
void |
send(Packet packet)
send is the method used to send all packets to the server. |
private void |
sendFailed(Packet packet)
sendFailed is the method used to indicate that a packet
failed to send. |
private void |
sent(Packet packet)
sent is the method used to indicate that a new packet
has been sent. |
private void |
setConnecting()
|
protected void |
setConnectionState(ConnectionEvent.EState state,
ConnectionEvent.EReason reason)
internal method which allows you to set the connection state, then broadcast the change to all listening classes. |
void |
setParser(java.lang.String s)
|
private void |
setSocket(java.net.Socket s)
|
Methods inherited from class java.lang.Object |
|
Field Detail |
private ConnectionEvent.EState status
private final java.util.Vector connectionListeners
private final java.util.Vector packetListeners
private java.net.Socket socket
private InputStreamHandler input
private OutputStreamHandler output
public static final int DEFAULT_PORT
private static final java.lang.String DEFAULT_XMLSTREAM_NS
private java.lang.String sessionID
private boolean DisableAutoHeader
Constructor Detail |
public ConnectionBean()
Method Detail |
public void setParser(java.lang.String s)
public java.lang.String getParser()
public void connect(java.net.InetAddress host) throws java.io.IOException
connect
attempts to establish a connection to the
default port on the specified server.host
- InetAddress
of the serverpublic void connect(java.net.InetAddress host, java.lang.String name) throws java.io.IOException
connect
attempts to establish a server connection to the
default port. This version allows you to specify a string, if the
host name the Jabber server expects is different than the one you are
connecting with (e.g. for applets).host
- InetAddress
of the servername
- String
holding the name to send to the Jabber
server on connection.public void connect(java.net.InetAddress host, int port) throws java.io.IOException
connect
attempts to establish a server connection to a
specified port. This implementation takes a hostname and port.host
- InetAddress
of the serverport
- an int
specifying the port numberpublic void connect(java.net.InetAddress host, java.lang.String name, int port) throws java.io.IOException
connect
attempts to establish a server connection to a
specified port. This version allows you to specify a string, if the
host name the Jabber server expects is different than the one you are
connecting with (e.g. for applets).host
- InetAddress
of the servername
- String
holding the name to send to the Jabber
server on connection.port
- an int
specifying the port numberpublic void connect(java.net.Socket s) throws java.io.IOException
s
- Socket
connecting us with the Jabber server.public void connect(java.io.InputStream is, java.io.OutputStream os) throws java.io.IOException
is
- InputStream
for incoming data from the Jabber
serveros
- OutputStream
for sending data out to the
Jabber server.private void setConnecting()
private void setSocket(java.net.Socket s)
public void disconnect()
disconnect
correctly closes down the connection to the
Jabber server in the backend.private void disconnected(ConnectionEvent.EReason reason)
public final void addConnectionListener(ConnectionListener l)
addConnectionListener
adds a
ConnectionListener
to the list of Listeners to be called
when the connection state changes.l
- a ConnectionListener
. Cannot add the same listener
twicepublic final void delConnectionListener(ConnectionListener l)
delConnectionListener
removes a previously added
ConnectionListener
from the list of Listeners to be called
when a connection state change event happens.l
- a ConnectionListener
valuepublic final void addPacketListener(PacketListener l)
addPacketListener
adds a PacketListener
to the
list of Listeners to be called when a packet is received or successfully
sent out.l
- a PacketListener
valuepublic final void delPacketListener(PacketListener l)
delPacketListener
removes a
PacketListener
to the list of Listeners to be called when
a packet is received or successfully sent out.l
- a PacketListener
valuepublic void send(Packet packet)
send
is the method used to send all packets to the server.
A Packet
is a code element that knows how to explain itself
in XML. The Packet
is asynchronously sent to the server,
with registered ConnectionListener
s receiving an event on
successful sending.packet
- a Packet
being sent to the serverpublic void received(Packet packet)
received
is the method used to indicate that a new packet
has arrived. This method is ONLY meant to be used
by the InputStreamHandler thread. Please avoid the urge to use it.
It will probably become non-accessable in the near future, consider
this a warning.packet
- a Packet
arriving from the server.private void sent(Packet packet)
sent
is the method used to indicate that a new packet
has been sent. This method is ONLY meant to be used
by the OutputStreamHandler thread.packet
- a Packet
arriving from the server.private void sendFailed(Packet packet)
sendFailed
is the method used to indicate that a packet
failed to send. This method is ONLY meant to be
used by the OutputStreamHandler thread.packet
- a Packet
arriving from the server.protected final void fireReceivedPacket(Packet packet)
packet
- the packet we are sending out to all subscribed listenersprotected final void fireSentPacket(Packet packet)
packet
- the packet we are sending out to all subscribed listenersprotected final void fireUnsentPacket(Packet packet)
packet
- the packet we are sending out to all subscribed listenerspublic void onOutputDeath(java.lang.Exception e)
public void onInputDeath(java.lang.Exception e)
public final ConnectionEvent.EState getConnectionState()
protected final void setConnectionState(ConnectionEvent.EState state, ConnectionEvent.EReason reason)
state
- new state to enter, based on possibilities from
ConnectionEvent.EState
reason
- the reason we are changing statesConnectionEvent.EState
public java.lang.String getSessionID()
public void disableStreamHeader()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |