FileDocCategorySizeDatePackage
IIOPProfileImpl.javaAPI DocJava SE 5 API8980Fri Aug 26 14:54:24 BST 2005com.sun.corba.se.impl.ior.iiop

IIOPProfileImpl

public class IIOPProfileImpl extends com.sun.corba.se.spi.ior.IdentifiableBase implements com.sun.corba.se.spi.ior.iiop.IIOPProfile
author

Fields Summary
private com.sun.corba.se.spi.orb.ORB
orb
private com.sun.corba.se.impl.logging.IORSystemException
wrapper
private com.sun.corba.se.spi.ior.ObjectId
oid
private com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate
proftemp
private com.sun.corba.se.spi.ior.ObjectKeyTemplate
oktemp
protected String
codebase
protected boolean
cachedCodebase
private boolean
checkedIsLocal
private boolean
cachedIsLocal
private com.sun.corba.se.spi.ior.iiop.GIOPVersion
giopVersion
Constructors Summary
private IIOPProfileImpl(com.sun.corba.se.spi.orb.ORB orb)

	this.orb = orb ;
	wrapper = IORSystemException.get( orb,
	    CORBALogDomains.OA_IOR ) ;
    
public IIOPProfileImpl(com.sun.corba.se.spi.orb.ORB orb, com.sun.corba.se.spi.ior.ObjectKeyTemplate oktemp, com.sun.corba.se.spi.ior.ObjectId oid, com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate proftemp)

	this( orb ) ;
	this.oktemp = oktemp ;
	this.oid = oid ;
	this.proftemp = proftemp ;
    
public IIOPProfileImpl(org.omg.CORBA_2_3.portable.InputStream is)

	this( (ORB)(is.orb()) ) ;
	init( is ) ;
    
public IIOPProfileImpl(com.sun.corba.se.spi.orb.ORB orb, org.omg.IOP.TaggedProfile profile)

	this( orb ) ;

        if (profile == null || profile.tag != TAG_INTERNET_IOP.value ||
	    profile.profile_data == null) {
	    throw wrapper.invalidTaggedProfile() ;
        }

        EncapsInputStream istr = new EncapsInputStream((ORB)orb, profile.profile_data, 
	    profile.profile_data.length);
	istr.consumeEndian();
	init( istr ) ;
    
Methods Summary
public booleanequals(java.lang.Object obj)


         
    
	if (!(obj instanceof IIOPProfileImpl))
	    return false ;

	IIOPProfileImpl other = (IIOPProfileImpl)obj ;

	return oid.equals( other.oid ) && proftemp.equals( other.proftemp ) &&
	    oktemp.equals( other.oktemp ) ;
    
public synchronized java.lang.StringgetCodebase()

	if (!cachedCodebase) {
	    cachedCodebase = true ;
	    codebase = uncachedGetCodeBase() ;
	}

	return codebase ;
    
public synchronized com.sun.corba.se.spi.ior.iiop.GIOPVersiongetGIOPVersion()
Return GIOPVersion for this IOR. Requests created against this IOR will be of the return Version.

	return proftemp.getGIOPVersion() ;
    
public org.omg.IOP.TaggedProfilegetIOPProfile()

	EncapsOutputStream os = new EncapsOutputStream( orb ) ;
	os.write_long( getId() ) ;
	write( os ) ;
	InputStream is = (InputStream)(os.create_input_stream()) ;
	return org.omg.IOP.TaggedProfileHelper.read( is ) ;
    
public intgetId()

	return proftemp.getId() ;
    
public com.sun.corba.se.spi.orb.ORBVersiongetORBVersion()

return
the ORBVersion associated with the object key in the IOR.

        return oktemp.getORBVersion();
    
public com.sun.corba.se.spi.ior.ObjectIdgetObjectId()

	return oid ;
    
public com.sun.corba.se.spi.ior.ObjectKeygetObjectKey()

	ObjectKey result = IORFactories.makeObjectKey( oktemp, oid ) ;
	return result ;
    
public com.sun.corba.se.spi.ior.ObjectKeyTemplategetObjectKeyTemplate()

	return oktemp ;
    
public java.lang.ObjectgetServant()
Return the servant for this IOR, if it is local AND if the OA that implements this objref supports direct access to servants outside of an invocation. XXX revisit: do we want this at all? If we do, it might move to the ObjectKeyTemplate instead.

	if (!isLocal())
	    return null ;

	RequestDispatcherRegistry scr = orb.getRequestDispatcherRegistry() ;
	ObjectAdapterFactory oaf = scr.getObjectAdapterFactory( 
	    oktemp.getSubcontractId() ) ;

	ObjectAdapterId oaid = oktemp.getObjectAdapterId() ;
	ObjectAdapter oa = null ;

	try {
	    oa = oaf.find( oaid ) ;
	} catch (SystemException exc) {
	    // Could not find the OA, so just return null.
	    // This usually happens when POAs are being deleted,
	    // and the POA always return null for getLocalServant anyway.
	    wrapper.getLocalServantFailure( exc, oaid.toString() ) ;
	    return null ;
	}

	byte[] boid = oid.getId() ;
	java.lang.Object servant = oa.getLocalServant( boid ) ;
	return servant ;
    
public com.sun.corba.se.spi.ior.TaggedProfileTemplategetTaggedProfileTemplate()

	return proftemp ;
    
public inthashCode()

	return oid.hashCode() ^ proftemp.hashCode() ^ oktemp.hashCode() ;
    
private voidinit(org.omg.CORBA_2_3.portable.InputStream istr)

	// First, read all of the IIOP IOR data
	GIOPVersion version = new GIOPVersion() ;
	version.read( istr ) ;
	IIOPAddress primary = new IIOPAddressImpl( istr ) ;
	byte[] key = EncapsulationUtility.readOctets( istr ) ;

	ObjectKey okey = orb.getObjectKeyFactory().create( key ) ;
	oktemp = okey.getTemplate() ;
	oid = okey.getId() ;

	proftemp = IIOPFactories.makeIIOPProfileTemplate( orb, 
	    version, primary ) ;

	// Handle any tagged components (if applicable)
	if (version.getMinor() > 0) 
	    EncapsulationUtility.readIdentifiableSequence( proftemp,
		orb.getTaggedComponentFactoryFinder(), istr ) ;

	// If there is no codebase in this IOR and there IS a
	// java.rmi.server.codebase property set, we need to
	// update the IOR with the local codebase.  Note that
	// there is only one instance of the local codebase, but it
	// can be safely shared in multiple IORs since it is immutable.
	if (uncachedGetCodeBase() == null) {
	    JavaCodebaseComponent jcc = LocalCodeBaseSingletonHolder.comp ;

	    if (jcc != null) {
		if (version.getMinor() > 0)
		    proftemp.add( jcc ) ;

		codebase = jcc.getURLs() ;
	    }

	    // Whether codebase is null or not, we have it,
	    // and so getCodebase ned never call uncachedGetCodebase.
	    cachedCodebase = true;
	}
    
public booleanisEquivalent(com.sun.corba.se.spi.ior.TaggedProfile prof)

	if (!(prof instanceof IIOPProfile))
	    return false ;

	IIOPProfile other = (IIOPProfile)prof ;

	return oid.equals( other.getObjectId() ) && 
	       proftemp.isEquivalent( other.getTaggedProfileTemplate() ) &&
	       oktemp.equals( other.getObjectKeyTemplate() ) ;
    
public synchronized booleanisLocal()

	if (!checkedIsLocal) {
	    checkedIsLocal = true ;
	    String host = proftemp.getPrimaryAddress().getHost() ;

	    cachedIsLocal = orb.isLocalHost(host) && 
		orb.isLocalServerId(oktemp.getSubcontractId(),
					   oktemp.getServerId()) &&
		orb.getLegacyServerSocketManager()
		    .legacyIsLocalServerPort(
                        proftemp.getPrimaryAddress().getPort());
        }

	return cachedIsLocal ;
    
public voidmakeImmutable()

	proftemp.makeImmutable() ;
    
private java.lang.StringuncachedGetCodeBase()

	Iterator iter = proftemp.iteratorById( TAG_JAVA_CODEBASE.value ) ;

	if (iter.hasNext()) {
	    JavaCodebaseComponent jcbc = (JavaCodebaseComponent)(iter.next()) ;
	    return jcbc.getURLs() ;
	}

	return null ;
    
public voidwriteContents(org.omg.CORBA_2_3.portable.OutputStream os)

	proftemp.write( oktemp, oid, os ) ;