FileDocCategorySizeDatePackage
SlotTableStack.javaAPI DocJava SE 5 API5596Fri Aug 26 14:54:22 BST 2005com.sun.corba.se.impl.interceptors

SlotTableStack

public class SlotTableStack extends Object
SlotTableStack is the container of SlotTable instances for each thread

Fields Summary
private List
tableContainer
private int
currentIndex
private SlotTablePool
tablePool
private com.sun.corba.se.spi.orb.ORB
orb
private com.sun.corba.se.impl.logging.InterceptorsSystemException
wrapper
Constructors Summary
SlotTableStack(com.sun.corba.se.spi.orb.ORB orb, SlotTable table)
Constructs the stack and and SlotTablePool

       this.orb = orb;
       wrapper = InterceptorsSystemException.get( orb, CORBALogDomains.RPC_PROTOCOL ) ;

       currentIndex = 0;
       tableContainer = new java.util.ArrayList( );
       tablePool = new SlotTablePool( );
       // SlotTableStack will be created with one SlotTable on the stack.
       // This table is used as the reference to query for number of 
       // allocated slots to create other slottables.
       tableContainer.add( currentIndex, table );
       currentIndex++;
    
Methods Summary
SlotTablepeekSlotTable()
peekSlotTable gets the top SlotTable from the SlotTableStack without popping.

       return (SlotTable) tableContainer.get( currentIndex - 1);
    
voidpopSlotTable()
popSlotTable does the following 1: pops the top SlotTable in the SlotTableStack 2: resets the slots in the SlotTable which resets the slotvalues to null if there are any previous sets. 3: puts the reset SlotTable into the SlotTablePool to reuse

        if( currentIndex <= 1 ) {
            // Do not pop the SlotTable, If there is only one.
            // This should not happen, But an extra check for safety.
	    throw wrapper.cantPopOnlyPicurrent() ;
        }
        currentIndex--;
        SlotTable table = (SlotTable)tableContainer.get( currentIndex );
        tableContainer.set( currentIndex, null ); // Do not leak memory.
        table.resetSlots( );
        tablePool.putSlotTable( table );
    
voidpushSlotTable()
pushSlotTable pushes a fresh Slot Table on to the stack by doing the following, 1: Checks to see if there is any SlotTable in SlotTablePool If present then use that instance to push into the SlotTableStack 2: If there is no SlotTable in the pool, then creates a new one and pushes that into the SlotTableStack

        SlotTable table = tablePool.getSlotTable( );
        if( table == null ) {
            // get an existing PICurrent to get the slotSize
            SlotTable tableTemp = peekSlotTable();
            table = new SlotTable( orb, tableTemp.getSize( ));
        }
        // NOTE: Very important not to always "add" - otherwise a memory leak.
        if (currentIndex == tableContainer.size()) {
            // Add will cause the table to grow.
            tableContainer.add( currentIndex, table );
        } else if (currentIndex > tableContainer.size()) {
	    throw wrapper.slotTableInvariant( new Integer( currentIndex ),
		new Integer( tableContainer.size() ) ) ;
        } else {
            // Set will override unused slots.
            tableContainer.set( currentIndex, table );
        }
        currentIndex++;