1 7 8 package com.sun.corba.se.impl.interceptors; 9 10 import com.sun.corba.se.spi.orb.ORB; 11 import org.omg.PortableInterceptor.Current ; 12 import org.omg.PortableInterceptor.InvalidSlot ; 13 import org.omg.CORBA.Any ; 14 import org.omg.CORBA.BAD_INV_ORDER ; 15 import org.omg.CORBA.CompletionStatus ; 16 17 import com.sun.corba.se.spi.logging.CORBALogDomains ; 18 import com.sun.corba.se.impl.logging.OMGSystemException ; 19 20 27 public class PICurrent extends org.omg.CORBA.LocalObject 28 implements Current 29 { 30 private int slotCounter; 32 33 private ORB myORB; 35 36 private OMGSystemException wrapper ; 37 38 private boolean orbInitializing; 41 42 private ThreadLocal threadLocalSlotTable 45 = new ThreadLocal ( ) { 46 protected Object initialValue( ) { 47 SlotTable table = new SlotTable( myORB, slotCounter ); 48 return new SlotTableStack( myORB, table ); 49 } 50 }; 51 52 56 PICurrent( ORB myORB ) { 57 this.myORB = myORB; 58 wrapper = OMGSystemException.get( myORB, 59 CORBALogDomains.RPC_PROTOCOL ) ; 60 this.orbInitializing = true; 61 slotCounter = 0; 62 } 63 64 65 69 int allocateSlotId( ) { 70 int slotId = slotCounter; 71 slotCounter = slotCounter + 1; 72 return slotId; 73 } 74 75 76 80 SlotTable getSlotTable( ) { 81 SlotTable table = (SlotTable) 82 ((SlotTableStack)threadLocalSlotTable.get()).peekSlotTable(); 83 return table; 84 } 85 86 91 void pushSlotTable( ) { 92 SlotTableStack st = (SlotTableStack)threadLocalSlotTable.get(); 93 st.pushSlotTable( ); 94 } 95 96 97 100 void popSlotTable( ) { 101 SlotTableStack st = (SlotTableStack)threadLocalSlotTable.get(); 102 st.popSlotTable( ); 103 } 104 105 109 public void set_slot( int id, Any data ) throws InvalidSlot 110 { 111 if( orbInitializing ) { 112 throw wrapper.invalidPiCall3() ; 116 } 117 118 getSlotTable().set_slot( id, data ); 119 } 120 121 125 public Any get_slot( int id ) throws InvalidSlot 126 { 127 if( orbInitializing ) { 128 throw wrapper.invalidPiCall4() ; 132 } 133 134 return getSlotTable().get_slot( id ); 135 } 136 137 141 void resetSlotTable( ) { 142 getSlotTable().resetSlots(); 143 } 144 145 149 void setORBInitializing( boolean init ) { 150 this.orbInitializing = init; 151 } 152 } 153 154 155 156 | Popular Tags |