SocketFactoryContactInfoListIteratorImpl.java revision 608:7e06bf1dcb09
1213136Spjd/* 2213136Spjd * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. 3213136Spjd * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4213136Spjd * 5213136Spjd * This code is free software; you can redistribute it and/or modify it 6213136Spjd * under the terms of the GNU General Public License version 2 only, as 7213136Spjd * published by the Free Software Foundation. Oracle designates this 8213136Spjd * particular file as subject to the "Classpath" exception as provided 9213136Spjd * by Oracle in the LICENSE file that accompanied this code. 10213136Spjd * 11213136Spjd * This code is distributed in the hope that it will be useful, but WITHOUT 12213136Spjd * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13213136Spjd * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14213136Spjd * version 2 for more details (a copy is included in the LICENSE file that 15213136Spjd * accompanied this code). 16213136Spjd * 17213136Spjd * You should have received a copy of the GNU General Public License version 18213136Spjd * 2 along with this work; if not, write to the Free Software Foundation, 19213136Spjd * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20213136Spjd * 21213136Spjd * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22213136Spjd * or visit www.oracle.com if you need additional information or have any 23213136Spjd * questions. 24213136Spjd */ 25213136Spjd 26213136Spjdpackage com.sun.corba.se.impl.legacy.connection; 27213136Spjd 28213136Spjdimport org.omg.CORBA.CompletionStatus; 29213136Spjdimport org.omg.CORBA.SystemException; 30213136Spjd 31213136Spjdimport com.sun.corba.se.pept.transport.ContactInfo; 32213136Spjd 33213136Spjdimport com.sun.corba.se.spi.legacy.connection.GetEndPointInfoAgainException; 34213136Spjdimport com.sun.corba.se.spi.orb.ORB; 35213136Spjdimport com.sun.corba.se.spi.transport.CorbaContactInfo; 36213136Spjdimport com.sun.corba.se.spi.transport.CorbaContactInfoList; 37213136Spjdimport com.sun.corba.se.spi.transport.SocketInfo; 38219702Sae 39213136Spjdimport com.sun.corba.se.impl.transport.CorbaContactInfoListIteratorImpl; 40213136Spjdimport com.sun.corba.se.impl.transport.SharedCDRContactInfoImpl; 41213136Spjd 42213136Spjdpublic class SocketFactoryContactInfoListIteratorImpl 43213136Spjd extends CorbaContactInfoListIteratorImpl 44213136Spjd{ 45213136Spjd private SocketInfo socketInfoCookie; 46213136Spjd 47213136Spjd public SocketFactoryContactInfoListIteratorImpl( 48213136Spjd ORB orb, 49213136Spjd CorbaContactInfoList corbaContactInfoList) 50213136Spjd { 51213136Spjd super(orb, corbaContactInfoList, null, null); 52213136Spjd } 53213136Spjd 54213136Spjd //////////////////////////////////////////////////// 55213136Spjd // 56213136Spjd // java.util.Iterator 57213136Spjd // 58213136Spjd 59213136Spjd public boolean hasNext() 60213136Spjd { 61213136Spjd return true; 62213136Spjd } 63213136Spjd 64213136Spjd public Object next() 65213136Spjd { 66213136Spjd if (contactInfoList.getEffectiveTargetIOR().getProfile().isLocal()){ 67213136Spjd return new SharedCDRContactInfoImpl( 68213136Spjd orb, contactInfoList, 69213136Spjd contactInfoList.getEffectiveTargetIOR(), 70213136Spjd orb.getORBData().getGIOPAddressDisposition()); 71213136Spjd } else { 72213136Spjd // REVISIT: 73213136Spjd // on comm_failure maybe need to give IOR instead of located. 74213136Spjd return new SocketFactoryContactInfoImpl( 75213136Spjd orb, contactInfoList, 76213136Spjd contactInfoList.getEffectiveTargetIOR(), 77213136Spjd orb.getORBData().getGIOPAddressDisposition(), 78213136Spjd socketInfoCookie); 79213136Spjd } 80213136Spjd } 81213136Spjd 82213136Spjd //////////////////////////////////////////////////// 83213136Spjd // 84213136Spjd // pept.ContactInfoListIterator 85213136Spjd // 86213136Spjd 87213136Spjd public boolean reportException(ContactInfo contactInfo, 88213136Spjd RuntimeException ex) 89213136Spjd { 90213136Spjd this.failureContactInfo = (CorbaContactInfo)contactInfo; 91213136Spjd this.failureException = ex; 92213136Spjd if (ex instanceof org.omg.CORBA.COMM_FAILURE) { 93213136Spjd 94213136Spjd if (ex.getCause() instanceof GetEndPointInfoAgainException) { 95213136Spjd socketInfoCookie = 96213136Spjd ((GetEndPointInfoAgainException) ex.getCause()) 97213136Spjd .getEndPointInfo(); 98213136Spjd return true; 99213136Spjd } 100213136Spjd 101213136Spjd SystemException se = (SystemException) ex; 102213136Spjd if (se.completed == CompletionStatus.COMPLETED_NO) { 103213136Spjd if (contactInfoList.getEffectiveTargetIOR() != 104213136Spjd contactInfoList.getTargetIOR()) 105213136Spjd { 106213136Spjd // retry from root ior 107213136Spjd contactInfoList.setEffectiveTargetIOR( 108213136Spjd contactInfoList.getTargetIOR()); 109213136Spjd return true; 110213136Spjd } 111213136Spjd } 112213136Spjd } 113213136Spjd return false; 114213136Spjd } 115213136Spjd} 116213136Spjd 117213136Spjd// End of file. 118213136Spjd