1 7 8 package com.sun.corba.se.impl.ior.iiop; 9 10 import java.util.Iterator ; 11 12 import org.omg.IOP.TAG_INTERNET_IOP ; 13 14 import org.omg.CORBA_2_3.portable.InputStream ; 15 import org.omg.CORBA_2_3.portable.OutputStream ; 16 17 import com.sun.corba.se.spi.ior.TaggedComponent ; 18 import com.sun.corba.se.spi.ior.TaggedProfile ; 19 import com.sun.corba.se.spi.ior.TaggedProfileTemplate ; 20 import com.sun.corba.se.spi.ior.TaggedProfileTemplateBase ; 21 import com.sun.corba.se.spi.ior.ObjectKeyTemplate ; 22 import com.sun.corba.se.spi.ior.ObjectId ; 23 import com.sun.corba.se.spi.ior.IdentifiableContainerBase ; 24 import com.sun.corba.se.spi.ior.IdentifiableBase ; 25 26 import com.sun.corba.se.impl.ior.EncapsulationUtility ; 27 28 import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate ; 29 import com.sun.corba.se.spi.ior.iiop.IIOPAddress ; 30 import com.sun.corba.se.spi.ior.iiop.IIOPFactories ; 31 32 import com.sun.corba.se.impl.encoding.EncapsOutputStream ; 33 34 import com.sun.corba.se.impl.encoding.CDROutputStream ; 35 36 import com.sun.corba.se.spi.ior.iiop.GIOPVersion ; 37 import com.sun.corba.se.spi.orb.ORB ; 38 39 43 public class IIOPProfileTemplateImpl extends TaggedProfileTemplateBase 44 implements IIOPProfileTemplate 45 { 46 private ORB orb ; 47 private GIOPVersion giopVersion ; 48 private IIOPAddress primary ; 49 50 public boolean equals( Object obj ) 51 { 52 if (!(obj instanceof IIOPProfileTemplateImpl)) 53 return false ; 54 55 IIOPProfileTemplateImpl other = (IIOPProfileTemplateImpl)obj ; 56 57 return super.equals( obj ) && giopVersion.equals( other.giopVersion ) && 58 primary.equals( other.primary ) ; 59 } 60 61 public int hashCode() 62 { 63 return super.hashCode() ^ giopVersion.hashCode() ^ primary.hashCode() ; 64 } 65 66 public TaggedProfile create( ObjectKeyTemplate oktemp, ObjectId id ) 67 { 68 return IIOPFactories.makeIIOPProfile( orb, oktemp, id, this ) ; 69 } 70 71 public GIOPVersion getGIOPVersion() 72 { 73 return giopVersion ; 74 } 75 76 public IIOPAddress getPrimaryAddress() 77 { 78 return primary ; 79 } 80 81 public IIOPProfileTemplateImpl( ORB orb, GIOPVersion version, IIOPAddress primary ) 82 { 83 this.orb = orb ; 84 this.giopVersion = version ; 85 this.primary = primary ; 86 if (giopVersion.getMinor() == 0) 87 makeImmutable() ; 90 } 91 92 public IIOPProfileTemplateImpl( InputStream istr ) 93 { 94 byte major = istr.read_octet() ; 95 byte minor = istr.read_octet() ; 96 giopVersion = GIOPVersion.getInstance( major, minor ) ; 97 primary = new IIOPAddressImpl( istr ) ; 98 orb = (ORB)(istr.orb()) ; 99 if (minor > 0) 101 EncapsulationUtility.readIdentifiableSequence( 102 this, orb.getTaggedComponentFactoryFinder(), istr ) ; 103 104 makeImmutable() ; 105 } 106 107 public void write( ObjectKeyTemplate okeyTemplate, ObjectId id, OutputStream os) 108 { 109 giopVersion.write( os ) ; 110 primary.write( os ) ; 111 112 116 OutputStream encapsulatedOS = new EncapsOutputStream( (ORB)os.orb(), 118 ((CDROutputStream)os).isLittleEndian() ) ; 119 120 okeyTemplate.write( id, encapsulatedOS ) ; 121 EncapsulationUtility.writeOutputStream( encapsulatedOS, os ) ; 122 123 if (giopVersion.getMinor() > 0) 124 EncapsulationUtility.writeIdentifiableSequence( this, os ) ; 125 } 126 127 129 public void writeContents( OutputStream os) 130 { 131 giopVersion.write( os ) ; 132 primary.write( os ) ; 133 134 if (giopVersion.getMinor() > 0) 135 EncapsulationUtility.writeIdentifiableSequence( this, os ) ; 136 } 137 138 public int getId() 139 { 140 return TAG_INTERNET_IOP.value ; 141 } 142 143 public boolean isEquivalent( TaggedProfileTemplate temp ) 144 { 145 if (!(temp instanceof IIOPProfileTemplateImpl)) 146 return false ; 147 148 IIOPProfileTemplateImpl tempimp = (IIOPProfileTemplateImpl)temp ; 149 150 return primary.equals( tempimp.primary ) ; 151 } 152 153 } 154 | Popular Tags |