KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > protocol > ServantCacheLocalCRDBase


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