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

TOAImpl

public class TOAImpl extends com.sun.corba.se.spi.oa.ObjectAdapterBase implements TOA
The Transient Object Adapter (TOA) represents the OA for purely transient objects. It is used for standard RMI-IIOP as well as backwards compatible server support (i.e. the ORB.connect() method) Its characteristics include:
  • There is only one OA instance of the TOA. Its OAId is { "TOA" }
  • There is not adapter manager. The TOA manager ID is fixed.
  • State is the same as ORB state (TBD)
Other requirements:
  • All object adapters must invoke ORB.adapterCreated when they are created.
  • All adapter managers must invoke ORB.adapterManagerStateChanged when their state changes, mapping the internal state to an ORT state.
  • AdapterStateChanged must be invoked (from somewhere) whenever an adapter state changes that is not due to an adapter manager state change.

Fields Summary
private com.sun.corba.se.impl.oa.toa.TransientObjectManager
servants
Constructors Summary
public TOAImpl(com.sun.corba.se.spi.orb.ORB orb, com.sun.corba.se.impl.oa.toa.TransientObjectManager tom, String codebase)

	super( orb ) ;
	servants = tom ;

	// Make the object key template
	int serverid = ((ORB)getORB()).getTransientServerId();
	int scid = ORBConstants.TOA_SCID ;

	ObjectKeyTemplate oktemp = new JIDLObjectKeyTemplate( orb, scid, serverid ) ;

	// REVISIT - POA specific
	Policies policies = Policies.defaultPolicies;

	// REVISIT - absorb codebase into a policy
	initializeTemplate( oktemp, true,
			    policies, 
			    codebase,
			    null, // manager id
			    oktemp.getObjectAdapterId()
			    ) ;
    
Methods Summary
public voidconnect(org.omg.CORBA.Object objref)

        // Store the objref and get a userkey allocated by the transient
        // object manager.
        byte[] key = servants.storeServant(objref, null);

        // Find out the repository ID for this objref.
	String id = StubAdapter.getTypeIds( objref )[0] ;

	// Create the new objref
	ObjectReferenceFactory orf = getCurrentFactory() ;
	org.omg.CORBA.Object obj = orf.make_object( id, key ) ;

	// Copy the delegate from the new objref to the argument
	// XXX handle the case of an attempt to connect a local object.

	org.omg.CORBA.portable.Delegate delegate = StubAdapter.getDelegate( 
	    obj ) ;
	CorbaContactInfoList ccil = (CorbaContactInfoList)
	    ((ClientDelegate)delegate).getContactInfoList() ;
	LocalClientRequestDispatcher lcs = 
	    ccil.getLocalClientRequestDispatcher() ;

	if (lcs instanceof JIDLLocalCRDImpl) {
	    JIDLLocalCRDImpl jlcs = (JIDLLocalCRDImpl)lcs ;
	    jlcs.setServant( objref ) ;
	} else {	
	    throw new RuntimeException( 
		"TOAImpl.connect can not be called on " + lcs ) ;
	}

	StubAdapter.setDelegate( objref, delegate ) ;
    
public voiddisconnect(org.omg.CORBA.Object objref)

        // Get the delegate, then ior, then transientKey, then delete servant
        org.omg.CORBA.portable.Delegate del = StubAdapter.getDelegate( 
	    objref ) ; 
	CorbaContactInfoList ccil = (CorbaContactInfoList)
	    ((ClientDelegate)del).getContactInfoList() ;
	LocalClientRequestDispatcher lcs = 
	    ccil.getLocalClientRequestDispatcher() ;

	if (lcs instanceof JIDLLocalCRDImpl) {
	    JIDLLocalCRDImpl jlcs = (JIDLLocalCRDImpl)lcs ;
	    byte[] oid = jlcs.getObjectId() ;
	    servants.deleteServant(oid);
	    jlcs.unexport() ;
	} else {	
	    throw new RuntimeException( 
		"TOAImpl.disconnect can not be called on " + lcs ) ;
	}
    
public voidenter()

    
public voidexit()

    
public org.omg.CORBA.PolicygetEffectivePolicy(int type)

	return null ;
    
public java.lang.String[]getInterfaces(java.lang.Object servant, byte[] objectId)
Return the most derived interface for the given servant and objectId.

	return StubAdapter.getTypeIds( servant ) ;
    
public voidgetInvocationServant(com.sun.corba.se.spi.oa.OAInvocationInfo info)
Get the servant for the request given by the parameters. This will update thread Current, so that subsequent calls to returnServant and removeCurrent from the same thread are for the same request.

param
request is the request containing the rest of the request

	java.lang.Object servant = servants.lookupServant( info.id() ) ;
	if (servant == null)
	    // This is expected to result in an RMI-IIOP NoSuchObjectException.
	    // See bug 4973160.
	    servant = new NullServantImpl( lifecycleWrapper().nullServant() ) ;
	info.setServant( servant ) ;
    
public org.omg.CORBA.ObjectgetLocalServant(byte[] objectId)

	return (org.omg.CORBA.Object)(servants.lookupServant( objectId ) ) ;
    
public intgetManagerId()

	return -1 ;
    
public com.sun.corba.se.spi.copyobject.ObjectCopierFactorygetObjectCopierFactory()

	CopierManager cm = getORB().getCopierManager() ;
	return cm.getDefaultObjectCopierFactory() ;
    
public shortgetState()

	return ACTIVE.value ;
    
public voidreturnServant()

	// NO-OP