1 /*------------------------------------------------------------------------------
2 Name: I_ConnectionStateListener.java
3 Project: xmlBlaster.org
4 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file
5 ------------------------------------------------------------------------------*/
6 package org.xmlBlaster.client;
7
8 import org.xmlBlaster.util.dispatch.ConnectionStateEnum;
9
10 /**
11 * Callback the client from XmlBlasterAccess if the connection to xmlBlaster is lost
12 * or was reestablished (failsafe mode).
13 * <p>
14 * @author xmlBlaster@marcelruff.info
15 */
16 public interface I_ConnectionStateListener
17 {
18 /**
19 * This is the callback method invoked from XmlBlasterAccess
20 * notifying the client that a connection has been established and that its status is now ALIVE.
21 *
22 * <p>
23 * Note that this method is invoked also when the connection has been
24 * established the first time. In this case the connection is fully operational
25 * but your connect() call has not yet returned. You can access the
26 * returned connect QoS in this case with <i>connect.getConnectReturnQos()</i>.
27 * </p>
28 *
29 * <p>
30 * You can erase all entries of the queue manually or add others before you return and in
31 * this way control the behavior.
32 * During you have control in <i>reachedAlive()</i> the client side
33 * queue is blocked and does not accept publish or request messages from other threads.
34 * So you can do peacefully your work (your thread is allowed to modify the queue exclusively).
35 * </p>
36 *
37 * <p>
38 * If you send messages during this method invocation they are queued only and
39 * are sent as soon as this method returns.
40 * </p>
41 *
42 * <p>
43 * This method is invoked by the login polling thread from I_XmlBlasterAccess in which case it is a
44 * physical Alive, and by the connect method on successful login in which case it is a logical Alive.
45 *
46 * </p>
47 * @param oldState The previous state of the connection.
48 * @param connectionHandler An interface which allows you to control the queue and the connection
49 */
50 void reachedAlive(ConnectionStateEnum oldState, I_XmlBlasterAccess connection);
51
52 /**
53 * This is the callback method invoked from XmlBlasterAccess
54 * informing the client that the connection state has changed to POLLING.
55 *
56 * @param oldState The previous state of the connection.
57 * @param connectionHandler An interface which allows you to control the queue and the connection
58 */
59 void reachedPolling(ConnectionStateEnum oldState, I_XmlBlasterAccess connection);
60
61 /**
62 * This is the callback method invoked from XmlBlasterAccess
63 * informing the client that the connection was lost (i.e. when the state of the
64 * connection has gone to DEAD).
65 *
66 * @param oldState The previous state of the connection.
67 * @param connectionHandler An interface which allows you to control the queue and the connection
68 */
69 void reachedDead(ConnectionStateEnum oldState, I_XmlBlasterAccess connection);
70 }
syntax highlighted by Code2HTML, v. 0.9.1