FileDocCategorySizeDatePackage
CorbaContactInfoListIteratorImpl.javaAPI DocJava SE 5 API7013Fri Aug 26 14:54:32 BST 2005com.sun.corba.se.impl.transport

CorbaContactInfoListIteratorImpl

public class CorbaContactInfoListIteratorImpl extends Object implements CorbaContactInfoListIterator

Fields Summary
protected ORB
orb
protected CorbaContactInfoList
contactInfoList
protected CorbaContactInfo
successContactInfo
protected CorbaContactInfo
failureContactInfo
protected RuntimeException
failureException
protected Iterator
effectiveTargetIORIterator
protected CorbaContactInfo
previousContactInfo
protected boolean
isAddrDispositionRetry
protected IIOPPrimaryToContactInfo
primaryToContactInfo
protected ContactInfo
primaryContactInfo
protected List
listOfContactInfos
Constructors Summary
public CorbaContactInfoListIteratorImpl(ORB orb, CorbaContactInfoList corbaContactInfoList, ContactInfo primaryContactInfo, List listOfContactInfos)

	this.orb = orb;
	this.contactInfoList = corbaContactInfoList;
	this.primaryContactInfo = primaryContactInfo;
	if (listOfContactInfos != null) {
	    // listOfContactInfos is null when used by the legacy
	    // socket factory.  In that case this iterator is NOT used.
	    this.effectiveTargetIORIterator = listOfContactInfos.iterator();
	}
	// List is immutable so no need to synchronize access.
	this.listOfContactInfos = listOfContactInfos;

	this.previousContactInfo = null;
	this.isAddrDispositionRetry = false;

	this.successContactInfo = null;
	this.failureContactInfo = null;
	this.failureException = null;

	primaryToContactInfo = orb.getORBData().getIIOPPrimaryToContactInfo();
    
Methods Summary
public com.sun.corba.se.pept.transport.ContactInfoListgetContactInfoList()

	return contactInfoList;
    
public java.lang.RuntimeExceptiongetFailureException()

	if (failureException == null) {
	    return
		ORBUtilSystemException.get( orb,
					    CORBALogDomains.RPC_TRANSPORT )
		    .invalidContactInfoListIteratorFailureException();
	} else {
	    return failureException;
	}
    
public booleanhasNext()

	// REVISIT: Implement as internal closure iterator which would
	// wraps sticky or default.  Then hasNext and next just call
	// the closure.

	if (isAddrDispositionRetry) {
	    return true;
	}

	boolean result;

	if (primaryToContactInfo != null) {
	    result = primaryToContactInfo.hasNext(primaryContactInfo,
						  previousContactInfo,
						  listOfContactInfos);
	} else {
	    result = effectiveTargetIORIterator.hasNext();
	}

	return result;
    
public java.lang.Objectnext()

	if (isAddrDispositionRetry) {
	    isAddrDispositionRetry = false;
	    return previousContactInfo;
	}

	// We hold onto the last in case we get an addressing
	// disposition retry.  Then we use it again.

	// We also hold onto it for the sticky manager.

	if (primaryToContactInfo != null) {
	    previousContactInfo = (CorbaContactInfo)
		primaryToContactInfo.next(primaryContactInfo,
					  previousContactInfo,
					  listOfContactInfos);
	} else {
	    previousContactInfo = (CorbaContactInfo)
		effectiveTargetIORIterator.next();
	}

	return previousContactInfo;
    
public voidremove()

	throw new UnsupportedOperationException();
    
public voidreportAddrDispositionRetry(com.sun.corba.se.spi.transport.CorbaContactInfo contactInfo, short disposition)

	previousContactInfo.setAddressingDisposition(disposition);
	isAddrDispositionRetry = true;
    
public booleanreportException(com.sun.corba.se.pept.transport.ContactInfo contactInfo, java.lang.RuntimeException ex)

	this.failureContactInfo = (CorbaContactInfo)contactInfo;
	this.failureException = ex;
	if (ex instanceof COMM_FAILURE) {
	    SystemException se = (SystemException) ex;
	    if (se.completed == CompletionStatus.COMPLETED_NO) {
		if (hasNext()) {
		    return true;
		}
		if (contactInfoList.getEffectiveTargetIOR() !=
		    contactInfoList.getTargetIOR()) 
                {
		    // retry from root ior
		    updateEffectiveTargetIOR(contactInfoList.getTargetIOR());
		    return true;
		}
	    }
	}
	return false;
    
public voidreportRedirect(com.sun.corba.se.spi.transport.CorbaContactInfo contactInfo, com.sun.corba.se.spi.ior.IOR forwardedIOR)

	updateEffectiveTargetIOR(forwardedIOR);
    
public voidreportSuccess(com.sun.corba.se.pept.transport.ContactInfo contactInfo)

	this.successContactInfo = (CorbaContactInfo)contactInfo;
    
public voidupdateEffectiveTargetIOR(com.sun.corba.se.spi.ior.IOR newIOR)

	contactInfoList.setEffectiveTargetIOR(newIOR);
	// If we report the exception in _request (i.e., beginRequest
	// we cannot throw RemarshalException to the stub because _request
	// does not declare that exception.
	// To keep the two-level dispatching (first level chooses ContactInfo,
	// second level is specific to that ContactInfo/EPT) we need to
	// ensure that the request dispatchers get their iterator from the 
	// InvocationStack (i.e., ThreadLocal). That way if the list iterator
	// needs a complete update it happens right here.
	((CorbaInvocationInfo)orb.getInvocationInfo())
	    .setContactInfoListIterator(contactInfoList.iterator());