KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > remoting > transport > mock > MockInvokerCallbackHandler


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.test.remoting.transport.mock;
8
9 import java.io.Serializable JavaDoc;
10 import java.util.List JavaDoc;
11 import org.jboss.remoting.callback.Callback;
12 import org.jboss.remoting.callback.HandleCallbackException;
13 import org.jboss.remoting.callback.InvokerCallbackHandler;
14
15 /**
16  * @author <a HREF="mailto:telrod@e2technologies.net">Tom Elrod</a>
17  */

18 public class MockInvokerCallbackHandler implements InvokerCallbackHandler, Serializable JavaDoc
19 {
20    private String JavaDoc callbackId;
21    private int callbacksRecieved = 0;
22
23    public MockInvokerCallbackHandler(String JavaDoc callbackId)
24    {
25       this.callbackId = callbackId;
26    }
27
28    /**
29     * Will take the callback message and send back to client.
30     * If client locator is null, will store them till client polls to get them.
31     *
32     * @param callback
33     * @throws org.jboss.remoting.callback.HandleCallbackException
34     *
35     */

36    public void handleCallback(Callback callback)
37          throws HandleCallbackException
38    {
39       System.err.println("We got callback on client. " + callback + " for " + this);
40       this.callbacksRecieved++;
41    }
42
43    public int isCallbackReceived()
44    {
45       System.err.println("returning " + callbacksRecieved + " for callback recieved for " + this);
46       return this.callbacksRecieved;
47    }
48
49    //TODO: Important that client caller keeps id unique and maintains id
50
// since used as key when add/remove listener in client subsystem handler -TME
51
public String JavaDoc getId()
52    {
53       return callbackId;
54    }
55
56    /**
57     * Will get current list of callbacks.
58     *
59     * @return
60     */

61    //TODO: This is messed up. Why should client InvokerCallbackHandler have to implement this?
62
// should probably make parent interface that does not have this one -TME
63
public List JavaDoc getCallbacks()
64    {
65       return null;
66    }
67
68    /**
69     * This method is required to be called upon removing a callback listener
70     * so can clean up resources used by the handler. In particular, should
71     * call disconnect on internal Client.
72     */

73    public void destroy()
74    {
75    }
76 }
77
Popular Tags