KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > spi > protocol > ForwardException


1 /*
2  * @(#)ForwardException.java 1.27 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.corba.se.spi.protocol;
9
10 import org.omg.CORBA.BAD_PARAM JavaDoc ;
11
12 import com.sun.corba.se.impl.orbutil.ORBUtility ;
13
14 import com.sun.corba.se.spi.ior.IOR ;
15
16 import com.sun.corba.se.spi.orb.ORB ;
17
18 /**
19  * Thrown to signal an OBJECT_FORWARD or LOCATION_FORWARD
20  */

21 public class ForwardException extends RuntimeException JavaDoc {
22     private ORB orb ;
23     private org.omg.CORBA.Object JavaDoc obj;
24     private IOR ior ;
25
26     public ForwardException( ORB orb, IOR ior ) {
27         super();
28
29     this.orb = orb ;
30     this.obj = null ;
31     this.ior = ior ;
32     }
33
34     public ForwardException( ORB orb, org.omg.CORBA.Object JavaDoc obj) {
35         super();
36
37     // This check is done early so that no attempt
38
// may be made to do a location forward to a local
39
// object. Doing this lazily would allow
40
// forwarding to locals in some restricted cases.
41
if (obj instanceof org.omg.CORBA.LocalObject JavaDoc)
42         throw new BAD_PARAM JavaDoc() ;
43
44     this.orb = orb ;
45     this.obj = obj ;
46     this.ior = null ;
47     }
48
49     public synchronized org.omg.CORBA.Object JavaDoc getObject()
50     {
51     if (obj == null) {
52         obj = ORBUtility.makeObjectReference( ior ) ;
53     }
54
55     return obj ;
56     }
57
58     public synchronized IOR getIOR()
59     {
60     if (ior == null) {
61         ior = ORBUtility.getIOR( obj ) ;
62     }
63
64     return ior ;
65     }
66 }
67
Popular Tags