Frames | No Frames |
1: /* IORInterceptors.java -- 2: Copyright (C) 2005 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package gnu.CORBA.Interceptor; 40: 41: import org.omg.CORBA.OBJ_ADAPTER; 42: import org.omg.CORBA.OMGVMCID; 43: import org.omg.PortableInterceptor.IORInfo; 44: import org.omg.PortableInterceptor.IORInterceptor; 45: import org.omg.PortableInterceptor.IORInterceptor_3_0Operations; 46: import org.omg.PortableInterceptor.ObjectReferenceTemplate; 47: 48: /** 49: * A block of the all registered IOR interceptors. 50: * 51: * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) 52: */ 53: public class IORInterceptors implements IORInterceptor_3_0Operations 54: { 55: /** 56: * The array of all registered IOR interceptors. 57: */ 58: private final IORInterceptor[] interceptors; 59: 60: /** 61: * Create the interceptor pack with the registerend interceptor array, 62: * obtained from the registrator. 63: */ 64: public IORInterceptors(Registrator registrator) 65: { 66: interceptors = registrator.getIORInterceptors(); 67: } 68: 69: /** 70: * Call this method for all registered interceptors. 71: */ 72: public void establish_components(IORInfo info) 73: { 74: for (int i = 0; i < interceptors.length; i++) 75: { 76: try 77: { 78: interceptors [ i ].establish_components(info); 79: } 80: catch (Exception exc) 81: { 82: // OMG states we should ignore. 83: } 84: } 85: } 86: 87: /** 88: * Call destroy on all registered interceptors. 89: */ 90: public void destroy() 91: { 92: for (int i = 0; i < interceptors.length; i++) 93: { 94: try 95: { 96: interceptors [ i ].destroy(); 97: } 98: catch (Exception exc) 99: { 100: // OMG states we should ignore. 101: } 102: } 103: } 104: 105: /** 106: * Get the class name. 107: */ 108: public String name() 109: { 110: return getClass().getName(); 111: } 112: 113: /** 114: * Call this method for all registered CORBA 3.0 interceptors. 115: */ 116: public void adapter_manager_state_changed(int adapterManagerId, short adapterState) 117: { 118: for (int i = 0; i < interceptors.length; i++) 119: { 120: try 121: { 122: if (interceptors[i] instanceof IORInterceptor_3_0Operations) 123: { 124: ((IORInterceptor_3_0Operations) interceptors[i]). 125: adapter_manager_state_changed(adapterManagerId, adapterState); 126: } 127: } 128: catch (Exception exc) 129: { 130: OBJ_ADAPTER oa = new OBJ_ADAPTER("components_established failed"); 131: oa.initCause(exc); 132: oa.minor = 6 | OMGVMCID.value; 133: throw oa; 134: } 135: } 136: } 137: 138: /** 139: * Call this method for all registered CORBA 3.0 interceptors. 140: */ 141: public void adapter_state_changed(ObjectReferenceTemplate[] adapters, short adaptersState) 142: { 143: for (int i = 0; i < interceptors.length; i++) 144: { 145: try 146: { 147: if (interceptors[i] instanceof IORInterceptor_3_0Operations) 148: { 149: ((IORInterceptor_3_0Operations) interceptors[i]). 150: adapter_state_changed(adapters, adaptersState); 151: } 152: } 153: catch (Exception exc) 154: { 155: OBJ_ADAPTER oa = new OBJ_ADAPTER("components_established failed"); 156: oa.initCause(exc); 157: oa.minor = 6 | OMGVMCID.value; 158: throw oa; 159: } 160: } 161: } 162: 163: /** 164: * Call this method for all registered CORBA 3.0 interceptors. 165: * 166: * @throws OBJ_ADAPTER minor 6 on any failure (as defined by OMG specs). 167: */ 168: public void components_established(IORInfo info) 169: { 170: for (int i = 0; i < interceptors.length; i++) 171: { 172: try 173: { 174: if (interceptors[i] instanceof IORInterceptor_3_0Operations) 175: { 176: ((IORInterceptor_3_0Operations) interceptors[i]). 177: components_established(info); 178: } 179: } 180: catch (Exception exc) 181: { 182: OBJ_ADAPTER oa = new OBJ_ADAPTER("components_established failed"); 183: oa.initCause(exc); 184: oa.minor = 6 | OMGVMCID.value; 185: throw oa; 186: } 187: } 188: } 189: }