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. package com.sun.corba.se.spi.protocol;
  8. import org.omg.CORBA.BAD_PARAM ;
  9. import com.sun.corba.se.impl.orbutil.ORBUtility ;
  10. import com.sun.corba.se.spi.ior.IOR ;
  11. import com.sun.corba.se.spi.orb.ORB ;
  12. /**
  13. * Thrown to signal an OBJECT_FORWARD or LOCATION_FORWARD
  14. */
  15. public class ForwardException extends RuntimeException {
  16. private ORB orb ;
  17. private org.omg.CORBA.Object obj;
  18. private IOR ior ;
  19. public ForwardException( ORB orb, IOR ior ) {
  20. super();
  21. this.orb = orb ;
  22. this.obj = null ;
  23. this.ior = ior ;
  24. }
  25. public ForwardException( ORB orb, org.omg.CORBA.Object obj) {
  26. super();
  27. // This check is done early so that no attempt
  28. // may be made to do a location forward to a local
  29. // object. Doing this lazily would allow
  30. // forwarding to locals in some restricted cases.
  31. if (obj instanceof org.omg.CORBA.LocalObject)
  32. throw new BAD_PARAM() ;
  33. this.orb = orb ;
  34. this.obj = obj ;
  35. this.ior = null ;
  36. }
  37. public synchronized org.omg.CORBA.Object getObject()
  38. {
  39. if (obj == null) {
  40. obj = ORBUtility.makeObjectReference( ior ) ;
  41. }
  42. return obj ;
  43. }
  44. public synchronized IOR getIOR()
  45. {
  46. if (ior == null) {
  47. ior = ORBUtility.getIOR( obj ) ;
  48. }
  49. return ior ;
  50. }
  51. }