1 7 8 package com.sun.corba.se.impl.interceptors; 9 10 import org.omg.CORBA.CompletionStatus ; 11 import org.omg.CORBA.INTERNAL ; 12 import org.omg.PortableInterceptor.Current ; 13 import org.omg.PortableInterceptor.InvalidSlot ; 14 15 import com.sun.corba.se.impl.corba.AnyImpl; 16 17 import com.sun.corba.se.impl.logging.InterceptorsSystemException; 18 import com.sun.corba.se.spi.logging.CORBALogDomains; 19 20 import com.sun.corba.se.spi.orb.ORB; 21 22 25 public class SlotTableStack 26 { 27 private class SlotTablePool { 29 30 private SlotTable[] pool; 32 33 private final int HIGH_WATER_MARK = 5; 37 38 private int currentIndex; 40 41 SlotTablePool( ) { 42 pool = new SlotTable[HIGH_WATER_MARK]; 43 currentIndex = 0; 44 } 45 46 49 void putSlotTable( SlotTable table ) { 50 if( currentIndex >= HIGH_WATER_MARK ) { 53 return; 55 } 56 pool[currentIndex] = table; 57 currentIndex++; 58 } 59 60 63 SlotTable getSlotTable( ) { 64 if( currentIndex == 0 ) { 66 return null; 67 } 68 currentIndex--; 70 return pool[currentIndex]; 71 } 72 } 73 74 private java.util.List tableContainer; 77 78 private int currentIndex; 80 81 private SlotTablePool tablePool; 84 85 private ORB orb; 87 88 private InterceptorsSystemException wrapper ; 89 90 93 SlotTableStack( ORB orb, SlotTable table ) { 94 this.orb = orb; 95 wrapper = InterceptorsSystemException.get( orb, CORBALogDomains.RPC_PROTOCOL ) ; 96 97 currentIndex = 0; 98 tableContainer = new java.util.ArrayList ( ); 99 tablePool = new SlotTablePool( ); 100 tableContainer.add( currentIndex, table ); 104 currentIndex++; 105 } 106 107 108 117 void pushSlotTable( ) { 118 SlotTable table = tablePool.getSlotTable( ); 119 if( table == null ) { 120 SlotTable tableTemp = peekSlotTable(); 122 table = new SlotTable( orb, tableTemp.getSize( )); 123 } 124 if (currentIndex == tableContainer.size()) { 126 tableContainer.add( currentIndex, table ); 128 } else if (currentIndex > tableContainer.size()) { 129 throw wrapper.slotTableInvariant( new Integer ( currentIndex ), 130 new Integer ( tableContainer.size() ) ) ; 131 } else { 132 tableContainer.set( currentIndex, table ); 134 } 135 currentIndex++; 136 } 137 138 147 void popSlotTable( ) { 148 if( currentIndex <= 1 ) { 149 throw wrapper.cantPopOnlyPicurrent() ; 152 } 153 currentIndex--; 154 SlotTable table = (SlotTable)tableContainer.get( currentIndex ); 155 tableContainer.set( currentIndex, null ); table.resetSlots( ); 157 tablePool.putSlotTable( table ); 158 } 159 160 164 SlotTable peekSlotTable( ) { 165 return (SlotTable) tableContainer.get( currentIndex - 1); 166 } 167 168 } 169 170 | Popular Tags |