FileDocCategorySizeDatePackage
CorbaContactInfoListImpl.javaAPI DocJava SE 6 API6738Tue Jun 10 00:21:44 BST 2008com.sun.corba.se.impl.transport

CorbaContactInfoListImpl

public class CorbaContactInfoListImpl extends Object implements com.sun.corba.se.spi.transport.CorbaContactInfoList
author
Harold Carr

Fields Summary
protected com.sun.corba.se.spi.orb.ORB
orb
protected com.sun.corba.se.spi.protocol.LocalClientRequestDispatcher
LocalClientRequestDispatcher
protected com.sun.corba.se.spi.ior.IOR
targetIOR
protected com.sun.corba.se.spi.ior.IOR
effectiveTargetIOR
protected List
effectiveTargetIORContactInfoList
protected com.sun.corba.se.pept.transport.ContactInfo
primaryContactInfo
Constructors Summary
public CorbaContactInfoListImpl(com.sun.corba.se.spi.orb.ORB orb)

	this.orb = orb;
    
public CorbaContactInfoListImpl(com.sun.corba.se.spi.orb.ORB orb, com.sun.corba.se.spi.ior.IOR targetIOR)

	this(orb);
	setTargetIOR(targetIOR);
    
Methods Summary
protected voidaddRemoteContactInfos(com.sun.corba.se.spi.ior.IOR effectiveTargetIOR, java.util.List effectiveTargetIORContactInfoList)

	ContactInfo contactInfo;
	List socketInfos = orb.getORBData()
	    .getIORToSocketInfo().getSocketInfo(effectiveTargetIOR);
	Iterator iterator = socketInfos.iterator();
	while (iterator.hasNext()) {
	    SocketInfo socketInfo = (SocketInfo) iterator.next();
	    String type = socketInfo.getType();
	    String host = socketInfo.getHost().toLowerCase();
	    int    port = socketInfo.getPort();
	    contactInfo = createContactInfo(type, host, port);
	    effectiveTargetIORContactInfoList.add(contactInfo);
	}
    
protected com.sun.corba.se.pept.transport.ContactInfocreateContactInfo(java.lang.String type, java.lang.String hostname, int port)

	return new SocketOrChannelContactInfoImpl(
	    orb, this, 
	    // XREVISIT - See Base Line 62
	    effectiveTargetIOR,
	    orb.getORBData().getGIOPAddressDisposition(),
	    type, hostname, port);
    
protected voidcreateContactInfoList()

	if (effectiveTargetIORContactInfoList != null) {
	    return;
	}

	effectiveTargetIORContactInfoList = new ArrayList();

	IIOPProfile iiopProfile = effectiveTargetIOR.getProfile();
	String hostname = 
	    ((IIOPProfileTemplate)iiopProfile.getTaggedProfileTemplate())
	        .getPrimaryAddress().getHost().toLowerCase();
	int    port     = 
	    ((IIOPProfileTemplate)iiopProfile.getTaggedProfileTemplate())
	        .getPrimaryAddress().getPort();
	// For use by "sticky manager" if one is registered.
	primaryContactInfo = 
	    createContactInfo(SocketInfo.IIOP_CLEAR_TEXT, hostname, port);

	if (iiopProfile.isLocal()) {
	    // NOTE: IMPORTANT:
	    // Only do local.  The APP Server interceptors check
	    // effectiveTarget.isLocal - which is determined via
	    // the IOR - so if we added other addresses then
	    // transactions and interceptors would not execute.
	    ContactInfo contactInfo = new SharedCDRContactInfoImpl(
	        orb, this, effectiveTargetIOR, 
		orb.getORBData().getGIOPAddressDisposition());
	    effectiveTargetIORContactInfoList.add(contactInfo);
	} else {
	    addRemoteContactInfos(effectiveTargetIOR,
				  effectiveTargetIORContactInfoList);
	}
    
public synchronized com.sun.corba.se.spi.ior.IORgetEffectiveTargetIOR()

	return effectiveTargetIOR;
    
public synchronized com.sun.corba.se.spi.protocol.LocalClientRequestDispatchergetLocalClientRequestDispatcher()

	return LocalClientRequestDispatcher;
    
public synchronized com.sun.corba.se.spi.ior.IORgetTargetIOR()

	return targetIOR;
    
public synchronized inthashCode()

	return targetIOR.hashCode();
    
public synchronized java.util.Iteratoriterator()

	createContactInfoList();
	return new CorbaContactInfoListIteratorImpl(
            orb, this, primaryContactInfo, 
	    effectiveTargetIORContactInfoList);
    
public synchronized voidsetEffectiveTargetIOR(com.sun.corba.se.spi.ior.IOR effectiveTargetIOR)

	this.effectiveTargetIOR = effectiveTargetIOR;
	effectiveTargetIORContactInfoList = null;
	if (primaryContactInfo != null &&
	    orb.getORBData().getIIOPPrimaryToContactInfo() != null)
	{
	    orb.getORBData().getIIOPPrimaryToContactInfo()
		.reset(primaryContactInfo);
	}
	primaryContactInfo = null;
	setLocalSubcontract();
    
protected voidsetLocalSubcontract()
setLocalSubcontract sets cached information that is set whenever the effectiveTargetIOR changes. Note: this must be maintained accurately whether or not the ORB allows local optimization, because ServantManagers in the POA ALWAYS use local optimization ONLY (they do not have a remote case).

	if (!effectiveTargetIOR.getProfile().isLocal()) {
	    LocalClientRequestDispatcher = new NotLocalLocalCRDImpl();
	    return;
	}

	// XXX Note that this always uses the first IIOP profile to get the
	// scid.  What about multi-profile IORs?  This should perhaps be
	// tied to the current ContactInfo in some way, together with an
	// implementation of ClientDelegate that generally prefers co-located
	// ContactInfo.  This may in fact mean that we should do this at
	// the ContactInfo level, rather than the IOR/profile level.
	int scid = effectiveTargetIOR.getProfile().getObjectKeyTemplate().
	    getSubcontractId() ;
	LocalClientRequestDispatcherFactory lcsf = orb.getRequestDispatcherRegistry().getLocalClientRequestDispatcherFactory( scid ) ;
	LocalClientRequestDispatcher = lcsf.create( scid, effectiveTargetIOR ) ;
    
public synchronized voidsetTargetIOR(com.sun.corba.se.spi.ior.IOR targetIOR)

	this.targetIOR = targetIOR;
	setEffectiveTargetIOR(targetIOR);