/[classpath]/classpath/gnu/CORBA/IOR_Delegate.java
ViewVC logotype

Diff of /classpath/gnu/CORBA/IOR_Delegate.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by mark, Sat Jul 2 20:32:08 2005 UTC revision 1.5 by audriusa, Fri Jul 22 16:57:47 2005 UTC
# Line 40  package gnu.CORBA; Line 40  package gnu.CORBA;
40    
41  import gnu.CORBA.CDR.cdrBufInput;  import gnu.CORBA.CDR.cdrBufInput;
42  import gnu.CORBA.GIOP.ReplyHeader;  import gnu.CORBA.GIOP.ReplyHeader;
43    import gnu.CORBA.Poa.activeObjectMap;
44    
45    import org.omg.CORBA.CompletionStatus;
46  import org.omg.CORBA.Context;  import org.omg.CORBA.Context;
47  import org.omg.CORBA.ContextList;  import org.omg.CORBA.ContextList;
48  import org.omg.CORBA.ExceptionList;  import org.omg.CORBA.ExceptionList;
# Line 71  public class IOR_Delegate Line 73  public class IOR_Delegate
73    extends Simple_delegate    extends Simple_delegate
74  {  {
75    /**    /**
76       * True if the current IOR does not map into the local servant.
77       * If false, the IOR is either local or should be checked.
78       */
79      boolean remote_ior;
80    
81      /**
82       * If not null, this field contains data about the local servant.
83       */
84      activeObjectMap.Obj local_ior;
85    
86      /**
87     * Contructs an instance of object using the given IOR.     * Contructs an instance of object using the given IOR.
88     */     */
89    public IOR_Delegate(ORB an_orb, IOR an_ior)    public IOR_Delegate(ORB an_orb, IOR an_ior)
# Line 96  public class IOR_Delegate Line 109  public class IOR_Delegate
109                                  NamedValue returns                                  NamedValue returns
110                                 )                                 )
111    {    {
112      gnuRequest request = new gnuRequest();      gnuRequest request = getRequestInstance(target);
113    
114      request.setIor(getIor());      request.setIor(getIor());
115      request.set_target(target);      request.set_target(target);
# Line 127  public class IOR_Delegate Line 140  public class IOR_Delegate
140                                  ContextList ctx_list                                  ContextList ctx_list
141                                 )                                 )
142    {    {
143      gnuRequest request = new gnuRequest();      gnuRequest request = getRequestInstance(target);
144    
145      request.setIor(ior);      request.setIor(ior);
146      request.set_target(target);      request.set_target(target);
# Line 144  public class IOR_Delegate Line 157  public class IOR_Delegate
157    }    }
158    
159    /**    /**
160     * Invoke operation on the given object, writing parameters to the given     * Get the instance of request.
161     * output stream.     */
162      protected gnuRequest getRequestInstance(org.omg.CORBA.Object target)
163      {
164        return new gnuRequest();
165      }
166    
167      /**
168       * Invoke operation on the given object, als handling temproray and permanent
169       * redirections. The ReplyHeader.LOCATION_FORWARD will cause to resend
170       * the request to the new direction. The ReplyHeader.LOCATION_FORWARD_PERM
171       * will cause additionally to remember the new location by this delegate,
172       * so subsequent calls will be immediately delivered to the new target.
173     *     *
174     * @param target the target object.     * @param target the target object.
175     * @param output the output stream, previously returned by     * @param output the output stream, previously returned by
# Line 213  public class IOR_Delegate Line 237  public class IOR_Delegate
237                  }                  }
238                catch (IOException ex)                catch (IOException ex)
239                  {                  {
240                    MARSHAL t = new MARSHAL("Cant read forwarding info");                    MARSHAL t =
241                        new MARSHAL("Cant read forwarding info", 5102,
242                                    CompletionStatus.COMPLETED_NO
243                                   );
244                    t.initCause(ex);                    t.initCause(ex);
245                    throw t;                    throw t;
246                  }                  }
247    
248                request.request.setIor(forwarded);                gnuRequest prev = request.request;
249                  gnuRequest r = getRequestInstance(target);
250    
251                  r.m_args = prev.m_args;
252                  r.m_context = prev.m_context;
253                  r.m_context_list = prev.m_context_list;
254                  r.m_environment = prev.m_environment;
255                  r.m_exceptions = prev.m_exceptions;
256                  r.m_operation = prev.m_operation;
257                  r.m_parameter_buffer = prev.m_parameter_buffer;
258                  r.m_parameter_buffer.request = r;
259                  r.m_result = prev.m_result;
260                  r.m_target = prev.m_target;
261                  r.oneWay = prev.oneWay;
262                  r.setIor(forwarded);
263    
264                  IOR_contructed_object it =
265                    new IOR_contructed_object(orb, forwarded);
266    
267                // If the object has moved permanently, its IOR is replaced.                r.m_target = it;
               if (moved_permanently)  
                 setIor(forwarded);  
268    
269                return invoke(target, request);                request.request = r;
270    
271                  IOR prev_ior = getIor();
272    
273                  setIor(forwarded);
274    
275                  try
276                    {
277                      return invoke(it, request);
278                    }
279                  finally
280                    {
281                      if (!moved_permanently)
282                        setIor(prev_ior);
283                    }
284    
285              default :              default :
286                throw new MARSHAL("Unknow reply status: " + rh.reply_status);                throw new MARSHAL("Unknow reply status: " + rh.reply_status,
287                                    8000 + rh.reply_status,
288                                    CompletionStatus.COMPLETED_NO
289                                   );
290            }            }
291        }        }
292      else      else
# Line 247  public class IOR_Delegate Line 306  public class IOR_Delegate
306     */     */
307    public Request request(org.omg.CORBA.Object target, String operation)    public Request request(org.omg.CORBA.Object target, String operation)
308    {    {
309      gnuRequest request = new gnuRequest();      gnuRequest request = getRequestInstance(target);
310    
311      request.setIor(ior);      request.setIor(ior);
312      request.set_target(target);      request.set_target(target);
# Line 272  public class IOR_Delegate Line 331  public class IOR_Delegate
331                                boolean response_expected                                boolean response_expected
332                               )                               )
333    {    {
334      gnuRequest request = new gnuRequest();      gnuRequest request = getRequestInstance(target);
335    
336      request.setIor(ior);      request.setIor(ior);
337      request.set_target(target);      request.set_target(target);
# Line 308  public class IOR_Delegate Line 367  public class IOR_Delegate
367          // do nothing, then.          // do nothing, then.
368        }        }
369    }    }
370    
371      /**
372       * Reset the remote_ior flag, forcing to check if the object is local
373       * on the next getRequestInstance call.
374       */
375      public void setIor(IOR an_ior)
376      {
377        super.setIor(an_ior);
378        remote_ior = false;
379        local_ior = null;
380      }
381    
382      /**
383       * Checks if the ior is local so far it is easy.
384       */
385      public boolean is_local(org.omg.CORBA.Object self)
386      {
387        if (remote_ior)
388          return false;
389        else if (local_ior != null)
390          return true;
391        else
392          return super.is_local(self);
393      }
394  }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26