1 /*
2  * Copyright (c) 2002, 2003, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 
27 package com.sun.corba.se.impl.protocol;
28 
29 import org.omg.CORBA.portable.ServantObject ;
30 
31 import com.sun.corba.se.spi.protocol.LocalClientRequestDispatcherFactory ;
32 import com.sun.corba.se.spi.protocol.LocalClientRequestDispatcher ;
33 
34 import com.sun.corba.se.spi.orb.ORB ;
35 
36 import com.sun.corba.se.spi.oa.OAInvocationInfo ;
37 import com.sun.corba.se.spi.oa.OADestroyed ;
38 
39 import com.sun.corba.se.spi.ior.IOR;
40 
41 import com.sun.corba.se.spi.logging.CORBALogDomains;
42 
43 import com.sun.corba.se.impl.logging.POASystemException ;
44 
45 public class FullServantCacheLocalCRDImpl extends ServantCacheLocalCRDBase
46 {
FullServantCacheLocalCRDImpl( ORB orb, int scid, IOR ior )47     public FullServantCacheLocalCRDImpl( ORB orb, int scid, IOR ior )
48     {
49         super( (com.sun.corba.se.spi.orb.ORB)orb, scid, ior ) ;
50     }
51 
servant_preinvoke( org.omg.CORBA.Object self, String operation, Class expectedType )52     public ServantObject servant_preinvoke( org.omg.CORBA.Object self,
53         String operation, Class expectedType )
54     {
55         OAInvocationInfo cachedInfo = getCachedInfo() ;
56         if (!checkForCompatibleServant( cachedInfo, expectedType ))
57             return null ;
58 
59         // Note that info is shared across multiple threads
60         // using the same subcontract, each of which may
61         // have its own operation.  Therefore we need to clone it.
62         OAInvocationInfo info = new OAInvocationInfo( cachedInfo, operation ) ;
63         orb.pushInvocationInfo( info ) ;
64 
65         try {
66             info.oa().enter() ;
67         } catch (OADestroyed pdes) {
68             throw wrapper.preinvokePoaDestroyed( pdes ) ;
69         }
70 
71         return info ;
72     }
73 
servant_postinvoke(org.omg.CORBA.Object self, ServantObject servantobj)74     public void servant_postinvoke(org.omg.CORBA.Object self,
75                                    ServantObject servantobj)
76     {
77         OAInvocationInfo cachedInfo = getCachedInfo() ;
78         cachedInfo.oa().exit() ;
79         orb.popInvocationInfo() ;
80     }
81 }
82