1. /*
  2. * @(#)ServantCacheLocalCRDBase.java 1.25 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.impl.protocol;
  8. import org.omg.CORBA.BAD_OPERATION ;
  9. import org.omg.CORBA.INTERNAL ;
  10. import org.omg.CORBA.SystemException ;
  11. import org.omg.CORBA.CompletionStatus ;
  12. import com.sun.corba.se.spi.protocol.LocalClientRequestDispatcher;
  13. import com.sun.corba.se.spi.protocol.ForwardException;
  14. // XXX This should be in the SPI
  15. import com.sun.corba.se.impl.protocol.LocalClientRequestDispatcherBase;
  16. import com.sun.corba.se.spi.oa.OAInvocationInfo;
  17. import com.sun.corba.se.spi.oa.ObjectAdapter;
  18. import com.sun.corba.se.spi.oa.OADestroyed;
  19. import com.sun.corba.se.spi.orb.ORB;
  20. import com.sun.corba.se.spi.ior.IOR ;
  21. import com.sun.corba.se.spi.logging.CORBALogDomains ;
  22. import com.sun.corba.se.impl.logging.POASystemException;
  23. public abstract class ServantCacheLocalCRDBase extends LocalClientRequestDispatcherBase
  24. {
  25. private OAInvocationInfo cachedInfo ;
  26. protected POASystemException wrapper ;
  27. protected ServantCacheLocalCRDBase( ORB orb, int scid, IOR ior )
  28. {
  29. super( orb, scid, ior ) ;
  30. wrapper = POASystemException.get( orb,
  31. CORBALogDomains.RPC_PROTOCOL ) ;
  32. }
  33. protected synchronized OAInvocationInfo getCachedInfo()
  34. {
  35. if (!servantIsLocal)
  36. throw wrapper.servantMustBeLocal() ;
  37. if (cachedInfo == null) {
  38. ObjectAdapter oa = oaf.find( oaid ) ;
  39. cachedInfo = oa.makeInvocationInfo( objectId ) ;
  40. // InvocationInfo must be pushed before calling getInvocationServant
  41. orb.pushInvocationInfo( cachedInfo ) ;
  42. try {
  43. oa.enter( );
  44. oa.getInvocationServant( cachedInfo ) ;
  45. } catch (ForwardException freq) {
  46. throw wrapper.illegalForwardRequest( freq ) ;
  47. } catch( OADestroyed oades ) {
  48. // This is an error since no user of this implementation
  49. // should ever throw this exception
  50. throw wrapper.adapterDestroyed( oades ) ;
  51. } finally {
  52. oa.returnServant( );
  53. oa.exit( );
  54. orb.popInvocationInfo() ;
  55. }
  56. }
  57. return cachedInfo ;
  58. }
  59. }
  60. // End of File