FileDocCategorySizeDatePackage
TransientObjectManager.javaAPI DocJava SE 5 API5369Fri Aug 26 14:54:28 BST 2005com.sun.corba.se.impl.oa.toa

TransientObjectManager

public final class TransientObjectManager extends Object

Fields Summary
private com.sun.corba.se.spi.orb.ORB
orb
private int
maxSize
private Element[]
elementArray
private Element
freeList
Constructors Summary
public TransientObjectManager(com.sun.corba.se.spi.orb.ORB orb)

	this.orb = orb ;

        elementArray = new Element[maxSize];
        elementArray[maxSize-1] = new Element(maxSize-1,null);
        for ( int i=maxSize-2; i>=0; i-- ) 
            elementArray[i] = new Element(i,elementArray[i+1]);
        freeList = elementArray[0];
    
Methods Summary
public synchronized voiddeleteServant(byte[] transientKey)

        int index = ORBUtility.bytesToInt(transientKey,0);
	if (orb.transientObjectManagerDebugFlag)
	    dprint( "deleting servant at index=" + index ) ;

        elementArray[index].delete(freeList);
        freeList = elementArray[index];
    
private voiddoubleSize()

        // Assume caller is synchronized

        Element old[] = elementArray;
        int oldSize = maxSize;
        maxSize *= 2;
        elementArray = new Element[maxSize];

        for ( int i=0; i<oldSize; i++ )
            elementArray[i] = old[i];    

        elementArray[maxSize-1] = new Element(maxSize-1,null);
        for ( int i=maxSize-2; i>=oldSize; i-- ) 
            elementArray[i] = new Element(i,elementArray[i+1]);
        freeList = elementArray[oldSize];
    
voiddprint(java.lang.String msg)


         
	ORBUtility.dprint( this, msg ) ;
    
public synchronized byte[]getKey(java.lang.Object servant)

        for ( int i=0; i<maxSize; i++ )
            if ( elementArray[i].valid && 
                 elementArray[i].servant == servant )
                return elementArray[i].toBytes();

        // if we come here Object does not exist
	return null;
    
public synchronized java.lang.ObjectlookupServant(byte[] transientKey)

        int index = ORBUtility.bytesToInt(transientKey,0);
        int counter = ORBUtility.bytesToInt(transientKey,4);

	if (orb.transientObjectManagerDebugFlag)
	    dprint( "lookupServant called with index=" + index + ", counter=" + counter ) ;

        if (elementArray[index].counter == counter &&
            elementArray[index].valid ) {
	    if (orb.transientObjectManagerDebugFlag)
	        dprint( "\tcounter is valid" ) ;
            return elementArray[index].servant;
	}

        // servant not found 
	if (orb.transientObjectManagerDebugFlag)
	    dprint( "\tcounter is invalid" ) ;
        return null;
    
public synchronized java.lang.ObjectlookupServantData(byte[] transientKey)

        int index = ORBUtility.bytesToInt(transientKey,0);
        int counter = ORBUtility.bytesToInt(transientKey,4);

	if (orb.transientObjectManagerDebugFlag)
	    dprint( "lookupServantData called with index=" + index + ", counter=" + counter ) ;

        if (elementArray[index].counter == counter &&
            elementArray[index].valid ) {
	    if (orb.transientObjectManagerDebugFlag)
	        dprint( "\tcounter is valid" ) ;
            return elementArray[index].servantData;
	}

        // servant not found 
	if (orb.transientObjectManagerDebugFlag)
	    dprint( "\tcounter is invalid" ) ;
        return null;
    
public synchronized byte[]storeServant(java.lang.Object servant, java.lang.Object servantData)

        if ( freeList == null ) 
            doubleSize();

        Element elem = freeList;
        freeList = (Element)freeList.servant;
        
        byte[] result = elem.getKey(servant, servantData);
	if (orb.transientObjectManagerDebugFlag)
	    dprint( "storeServant returns key for element " + elem ) ;
	return result ;