0N/A/*
617N/A * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
157N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
157N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
157N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
157N/A * or visit www.oracle.com if you need additional information or have any
157N/A * questions.
0N/A */
0N/A
0N/Apackage com.sun.corba.se.impl.ior.iiop;
0N/A
0N/Aimport java.util.Iterator ;
0N/A
0N/Aimport org.omg.IOP.TAG_INTERNET_IOP ;
0N/A
0N/Aimport org.omg.CORBA_2_3.portable.InputStream ;
0N/Aimport org.omg.CORBA_2_3.portable.OutputStream ;
0N/A
0N/Aimport com.sun.corba.se.spi.ior.TaggedComponent ;
0N/Aimport com.sun.corba.se.spi.ior.TaggedProfile ;
0N/Aimport com.sun.corba.se.spi.ior.TaggedProfileTemplate ;
0N/Aimport com.sun.corba.se.spi.ior.TaggedProfileTemplateBase ;
0N/Aimport com.sun.corba.se.spi.ior.ObjectKeyTemplate ;
0N/Aimport com.sun.corba.se.spi.ior.ObjectId ;
0N/Aimport com.sun.corba.se.spi.ior.IdentifiableContainerBase ;
0N/Aimport com.sun.corba.se.spi.ior.IdentifiableBase ;
0N/A
0N/Aimport com.sun.corba.se.impl.ior.EncapsulationUtility ;
0N/A
0N/Aimport com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate ;
0N/Aimport com.sun.corba.se.spi.ior.iiop.IIOPAddress ;
0N/Aimport com.sun.corba.se.spi.ior.iiop.IIOPFactories ;
0N/A
0N/Aimport com.sun.corba.se.impl.encoding.EncapsOutputStream ;
0N/A
0N/Aimport com.sun.corba.se.impl.encoding.CDROutputStream ;
0N/A
0N/Aimport com.sun.corba.se.spi.ior.iiop.GIOPVersion ;
0N/Aimport com.sun.corba.se.spi.orb.ORB ;
0N/A
0N/A/**
0N/A * @author
0N/A * If getMinorVersion==0, this does not contain any tagged components
0N/A */
0N/Apublic class IIOPProfileTemplateImpl extends TaggedProfileTemplateBase
0N/A implements IIOPProfileTemplate
0N/A{
0N/A private ORB orb ;
0N/A private GIOPVersion giopVersion ;
0N/A private IIOPAddress primary ;
0N/A
0N/A public boolean equals( Object obj )
0N/A {
0N/A if (!(obj instanceof IIOPProfileTemplateImpl))
0N/A return false ;
0N/A
0N/A IIOPProfileTemplateImpl other = (IIOPProfileTemplateImpl)obj ;
0N/A
0N/A return super.equals( obj ) && giopVersion.equals( other.giopVersion ) &&
0N/A primary.equals( other.primary ) ;
0N/A }
0N/A
0N/A public int hashCode()
0N/A {
0N/A return super.hashCode() ^ giopVersion.hashCode() ^ primary.hashCode() ;
0N/A }
0N/A
0N/A public TaggedProfile create( ObjectKeyTemplate oktemp, ObjectId id )
0N/A {
0N/A return IIOPFactories.makeIIOPProfile( orb, oktemp, id, this ) ;
0N/A }
0N/A
0N/A public GIOPVersion getGIOPVersion()
0N/A {
0N/A return giopVersion ;
0N/A }
0N/A
0N/A public IIOPAddress getPrimaryAddress()
0N/A {
0N/A return primary ;
0N/A }
0N/A
0N/A public IIOPProfileTemplateImpl( ORB orb, GIOPVersion version, IIOPAddress primary )
0N/A {
0N/A this.orb = orb ;
0N/A this.giopVersion = version ;
0N/A this.primary = primary ;
0N/A if (giopVersion.getMinor() == 0)
0N/A // Adding tagged components is not allowed for IIOP 1.0,
0N/A // so this template is complete and should be made immutable.
0N/A makeImmutable() ;
0N/A }
0N/A
0N/A public IIOPProfileTemplateImpl( InputStream istr )
0N/A {
0N/A byte major = istr.read_octet() ;
0N/A byte minor = istr.read_octet() ;
0N/A giopVersion = GIOPVersion.getInstance( major, minor ) ;
0N/A primary = new IIOPAddressImpl( istr ) ;
0N/A orb = (ORB)(istr.orb()) ;
0N/A // Handle any tagged components (if applicable)
0N/A if (minor > 0)
0N/A EncapsulationUtility.readIdentifiableSequence(
0N/A this, orb.getTaggedComponentFactoryFinder(), istr ) ;
0N/A
0N/A makeImmutable() ;
0N/A }
0N/A
0N/A public void write( ObjectKeyTemplate okeyTemplate, ObjectId id, OutputStream os)
0N/A {
0N/A giopVersion.write( os ) ;
0N/A primary.write( os ) ;
0N/A
0N/A // Note that this is NOT an encapsulation: do not marshal
0N/A // the endianness flag. However, the length is required.
0N/A // Note that this cannot be accomplished with a codec!
0N/A
0N/A // Use the byte order of the given stream
617N/A OutputStream encapsulatedOS =
617N/A sun.corba.OutputStreamFactory.newEncapsOutputStream(
617N/A (ORB)os.orb(), ((CDROutputStream)os).isLittleEndian() ) ;
0N/A
0N/A okeyTemplate.write( id, encapsulatedOS ) ;
0N/A EncapsulationUtility.writeOutputStream( encapsulatedOS, os ) ;
0N/A
0N/A if (giopVersion.getMinor() > 0)
0N/A EncapsulationUtility.writeIdentifiableSequence( this, os ) ;
0N/A }
0N/A
0N/A /** Write out this IIOPProfileTemplateImpl only.
0N/A */
0N/A public void writeContents( OutputStream os)
0N/A {
0N/A giopVersion.write( os ) ;
0N/A primary.write( os ) ;
0N/A
0N/A if (giopVersion.getMinor() > 0)
0N/A EncapsulationUtility.writeIdentifiableSequence( this, os ) ;
0N/A }
0N/A
0N/A public int getId()
0N/A {
0N/A return TAG_INTERNET_IOP.value ;
0N/A }
0N/A
0N/A public boolean isEquivalent( TaggedProfileTemplate temp )
0N/A {
0N/A if (!(temp instanceof IIOPProfileTemplateImpl))
0N/A return false ;
0N/A
0N/A IIOPProfileTemplateImpl tempimp = (IIOPProfileTemplateImpl)temp ;
0N/A
0N/A return primary.equals( tempimp.primary ) ;
0N/A }
0N/A
0N/A}