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     * 
54     * Invoked when the dispatcher goes to synch again after having delivered entries which where
55     * in the queue when the state changed to ALIVE. Note that this could take some time or in
56     * the worst case it could never been invoked if the queue is never completely processed.
57     * 
58     * @param oldState is always ALIVE.
59     * @param connection
60     */
61    void reachedAliveSync(ConnectionStateEnum oldState, I_XmlBlasterAccess connection);
62 
63 
64    /**
65     * This is the callback method invoked from XmlBlasterAccess
66     * informing the client that the connection state has changed to POLLING.
67     *
68     * @param oldState The previous state of the connection.
69     * @param connectionHandler An interface which allows you to control the queue and the connection
70     */
71    void reachedPolling(ConnectionStateEnum oldState, I_XmlBlasterAccess connection);
72 
73    /**
74     * This is the callback method invoked from XmlBlasterAccess
75     * informing the client that the connection was lost (i.e. when the state of the
76     * connection has gone to DEAD).
77     *
78     * @param oldState The previous state of the connection.
79     * @param connectionHandler An interface which allows you to control the queue and the connection
80     */
81    void reachedDead(ConnectionStateEnum oldState, I_XmlBlasterAccess connection);
82 }


syntax highlighted by Code2HTML, v. 0.9.1