2
* JBoss, Home of Professional Open Source
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
4
* by the @authors tag. See the copyright.txt in the distribution for a
5
* full listing of individual contributors.
7
* This is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
12
* This software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this software; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
22
package org.jboss.remoting.callback;
24
import org.jboss.remoting.InvocationRequest;
25
import org.jboss.remoting.InvokerLocator;
26
import org.jboss.remoting.Version;
28
import java.util.HashMap;
33
* This is the class to use for sending callback payloads from the
34
* server handler to the callback listener.
36
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
38
public class Callback extends InvocationRequest
40
static final long serialVersionUID;
42
public final static String CALLBACK_HANDLE_OBJECT_KEY = "callback_handle_object";
43
public final static String SERVER_LOCATOR_KEY = "server_locator";
47
if(Version.getDefaultVersion() == Version.VERSION_1)
49
serialVersionUID = -4778964132014467531L;
53
serialVersionUID = -9196653590434634454L;
58
* Constructs the callback object with any object payload.
60
* @param callbackPayload
62
public Callback(Object callbackPayload)
64
super(callbackPayload);
68
* Returns the handle object originally specified when initially registering
69
* the callback listener. This can be used to provide context upon callbacks.
73
public Object getCallbackHandleObject()
75
Object handleObject = null;
76
Map returnPayload = getReturnPayload();
77
if(returnPayload != null)
79
handleObject = returnPayload.get(CALLBACK_HANDLE_OBJECT_KEY);
84
protected void setCallbackHandleObject(Object handleObject)
86
Map returnPayload = getReturnPayload();
87
if(returnPayload == null)
89
returnPayload = new HashMap();
90
setReturnPayload(returnPayload);
93
returnPayload.put(CALLBACK_HANDLE_OBJECT_KEY, handleObject);
98
* Gets the callback payload sent from the server handler.
102
public Object getCallbackObject()
104
return getParameter();
108
* Gets the locator for the target server where the callback was generated (this will be for
109
* the same server that the callback client was registered).
113
public InvokerLocator getServerLocator()
115
InvokerLocator locator = null;
116
Map returnPayload = getReturnPayload();
117
if(returnPayload != null)
119
locator = (InvokerLocator) returnPayload.get(SERVER_LOCATOR_KEY);
b'\\ No newline at end of file'