1 /* 2 * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package com.sun.corba.se.impl.legacy.connection; 27 28 import org.omg.CORBA.CompletionStatus; 29 import org.omg.CORBA.SystemException; 30 31 import com.sun.corba.se.pept.transport.ContactInfo; 32 33 import com.sun.corba.se.spi.legacy.connection.GetEndPointInfoAgainException; 34 import com.sun.corba.se.spi.orb.ORB; 35 import com.sun.corba.se.spi.transport.CorbaContactInfo; 36 import com.sun.corba.se.spi.transport.CorbaContactInfoList; 37 import com.sun.corba.se.spi.transport.SocketInfo; 38 39 import com.sun.corba.se.impl.transport.CorbaContactInfoListIteratorImpl; 40 import com.sun.corba.se.impl.transport.SharedCDRContactInfoImpl; 41 42 public class SocketFactoryContactInfoListIteratorImpl 43 extends CorbaContactInfoListIteratorImpl 44 { 45 private SocketInfo socketInfoCookie; 46 47 public SocketFactoryContactInfoListIteratorImpl( 48 ORB orb, 49 CorbaContactInfoList corbaContactInfoList) 50 { 51 super(orb, corbaContactInfoList, null, null); 52 } 53 54 //////////////////////////////////////////////////// 55 // 56 // java.util.Iterator 57 // 58 59 public boolean hasNext() 60 { 61 return true; 62 } 63 64 public Object next() 65 { 66 if (contactInfoList.getEffectiveTargetIOR().getProfile().isLocal()){ 67 return new SharedCDRContactInfoImpl( 68 orb, contactInfoList, 69 contactInfoList.getEffectiveTargetIOR(), 70 orb.getORBData().getGIOPAddressDisposition()); 71 } else { 72 // REVISIT: 73 // on comm_failure maybe need to give IOR instead of located. 74 return new SocketFactoryContactInfoImpl( 75 orb, contactInfoList, 76 contactInfoList.getEffectiveTargetIOR(), 77 orb.getORBData().getGIOPAddressDisposition(), 78 socketInfoCookie); 79 } 80 } 81 82 //////////////////////////////////////////////////// 83 // 84 // pept.ContactInfoListIterator 85 // 86 87 public boolean reportException(ContactInfo contactInfo, 88 RuntimeException ex) 89 { 90 this.failureContactInfo = (CorbaContactInfo)contactInfo; 91 this.failureException = ex; 92 if (ex instanceof org.omg.CORBA.COMM_FAILURE) { 93 94 if (ex.getCause() instanceof GetEndPointInfoAgainException) { 95 socketInfoCookie = 96 ((GetEndPointInfoAgainException) ex.getCause()) 97 .getEndPointInfo(); 98 return true; 99 } 100 101 SystemException se = (SystemException) ex; 102 if (se.completed == CompletionStatus.COMPLETED_NO) { 103 if (contactInfoList.getEffectiveTargetIOR() != 104 contactInfoList.getTargetIOR()) 105 { 106 // retry from root ior 107 contactInfoList.setEffectiveTargetIOR( 108 contactInfoList.getTargetIOR()); 109 return true; 110 } 111 } 112 } 113 return false; 114 } 115 } 116 117 // End of file.