KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > 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.remoting.transport.mock;
8
9 import org.jboss.remoting.HandleCallbackException;
10 import org.jboss.remoting.InvocationRequest;
11 import org.jboss.remoting.InvokerCallbackHandler;
12
13 import java.io.Serializable JavaDoc;
14 import java.util.List JavaDoc;
15
16 /**
17  * @author <a HREF="mailto:telrod@e2technologies.net">Tom Elrod</a>
18  */

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

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

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

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