KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > remoting > callback > Callback


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.callback;
8
9 import java.util.Map JavaDoc;
10 import org.jboss.remoting.InvocationRequest;
11 import org.jboss.remoting.InvokerLocator;
12
13
14 /**
15  * This is the class to use for sending callback payloads from the
16  * server handler to the callback listener.
17  *
18  * @author <a HREF="mailto:tom.elrod@jboss.com">Tom Elrod</a>
19  */

20 public class Callback extends InvocationRequest
21 {
22    static final long serialVersionUID = -4778964132014467531L;
23
24    public final static String JavaDoc CALLBACK_HANDLE_OBJECT_KEY = "callback_handle_object";
25    public final static String JavaDoc SERVER_LOCATOR_KEY = "server_locator";
26
27    /**
28     * Constructs the callback object with any object payload.
29     *
30     * @param callbackPayload
31     */

32    public Callback(Object JavaDoc callbackPayload)
33    {
34       super(callbackPayload);
35    }
36
37    /**
38     * Returns the handle object originally specified when initially registering
39     * the callback listener. This can be used to provide context upon callbacks.
40     *
41     * @return
42     */

43    public Object JavaDoc getCallbackHandleObject()
44    {
45       Object JavaDoc handleObject = null;
46       Map JavaDoc returnPayload = getReturnPayload();
47       if(returnPayload != null)
48       {
49          handleObject = returnPayload.get(CALLBACK_HANDLE_OBJECT_KEY);
50       }
51       return handleObject;
52    }
53
54    /**
55     * Gets the callback payload sent from the server handler.
56     *
57     * @return
58     */

59    public Object JavaDoc getCallbackObject()
60    {
61       return getParameter();
62    }
63
64    /**
65     * Gets the locator for the target server where the callback was generated (this will be for
66     * the same server that the callback client was registered).
67     *
68     * @return
69     */

70    public InvokerLocator getServerLocator()
71    {
72       InvokerLocator locator = null;
73       Map JavaDoc returnPayload = getReturnPayload();
74       if(returnPayload != null)
75       {
76          locator = (InvokerLocator) returnPayload.get(SERVER_LOCATOR_KEY);
77       }
78       return locator;
79    }
80 }
Popular Tags