~ubuntu-branches/ubuntu/raring/libjboss-remoting-java/raring

« back to all changes in this revision

Viewing changes to src/org/jboss/remoting/callback/Callback.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: package-import@ubuntu.com-20110909140103-o8ucrolqt5g25k57
Tags: upstream-2.5.3.SP1
ImportĀ upstreamĀ versionĀ 2.5.3.SP1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
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.
6
 
*
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.
11
 
*
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.
16
 
*
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.
21
 
*/
22
 
package org.jboss.remoting.callback;
23
 
 
24
 
import org.jboss.remoting.InvocationRequest;
25
 
import org.jboss.remoting.InvokerLocator;
26
 
import org.jboss.remoting.Version;
27
 
 
28
 
import java.util.HashMap;
29
 
import java.util.Map;
30
 
 
31
 
 
32
 
/**
33
 
 * This is the class to use for sending callback payloads from the
34
 
 * server handler to the callback listener.
35
 
 *
36
 
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
37
 
 */
38
 
public class Callback extends InvocationRequest
39
 
{
40
 
   static final long serialVersionUID;
41
 
 
42
 
   public final static String CALLBACK_HANDLE_OBJECT_KEY = "callback_handle_object";
43
 
   public final static String SERVER_LOCATOR_KEY = "server_locator";
44
 
 
45
 
   static
46
 
   {
47
 
      if(Version.getDefaultVersion() == Version.VERSION_1)
48
 
      {
49
 
         serialVersionUID = -4778964132014467531L;
50
 
      }
51
 
      else
52
 
      {
53
 
         serialVersionUID = -9196653590434634454L;
54
 
      }
55
 
   }
56
 
 
57
 
   /**
58
 
    * Constructs the callback object with any object payload.
59
 
    *
60
 
    * @param callbackPayload
61
 
    */
62
 
   public Callback(Object callbackPayload)
63
 
   {
64
 
      super(callbackPayload);
65
 
   }
66
 
 
67
 
   /**
68
 
    * Returns the handle object originally specified when initially registering
69
 
    * the callback listener.  This can be used to provide context upon callbacks.
70
 
    *
71
 
    * @return
72
 
    */
73
 
   public Object getCallbackHandleObject()
74
 
   {
75
 
      Object handleObject = null;
76
 
      Map returnPayload = getReturnPayload();
77
 
      if(returnPayload != null)
78
 
      {
79
 
         handleObject = returnPayload.get(CALLBACK_HANDLE_OBJECT_KEY);
80
 
      }
81
 
      return handleObject;
82
 
   }
83
 
 
84
 
   protected void setCallbackHandleObject(Object handleObject)
85
 
   {
86
 
      Map returnPayload = getReturnPayload();
87
 
      if(returnPayload == null)
88
 
      {
89
 
         returnPayload = new HashMap();
90
 
         setReturnPayload(returnPayload);
91
 
      }
92
 
 
93
 
      returnPayload.put(CALLBACK_HANDLE_OBJECT_KEY, handleObject);
94
 
   }
95
 
 
96
 
 
97
 
   /**
98
 
    * Gets the callback payload sent from the server handler.
99
 
    *
100
 
    * @return
101
 
    */
102
 
   public Object getCallbackObject()
103
 
   {
104
 
      return getParameter();
105
 
   }
106
 
 
107
 
   /**
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).
110
 
    *
111
 
    * @return
112
 
    */
113
 
   public InvokerLocator getServerLocator()
114
 
   {
115
 
      InvokerLocator locator = null;
116
 
      Map returnPayload = getReturnPayload();
117
 
      if(returnPayload != null)
118
 
      {
119
 
         locator = (InvokerLocator) returnPayload.get(SERVER_LOCATOR_KEY);
120
 
      }
121
 
      return locator;
122
 
   }
123
 
}
 
 
b'\\ No newline at end of file'