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.IORInterceptorOperations; 46: import org.omg.PortableInterceptor.IORInterceptor_3_0Operations; 47: import org.omg.PortableInterceptor.ObjectReferenceTemplate; 48: 49: /** 50: * A block of the all registered IOR interceptors. 51: * 52: * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) 53: */ 54: public class IORInterceptors implements IORInterceptor_3_0Operations 55: { 56: /** 57: * The array of all registered IOR interceptors. 58: */ 59: private final IORInterceptor[] interceptors; 60: 61: /** 62: * Create the interceptor pack with the registerend interceptor array, 63: * obtained from the registrator. 64: */ 65: public IORInterceptors(Registrator registrator) 66: { 67: interceptors = registrator.getIORInterceptors(); 68: } 69: 70: /** 71: * Call this method for all registered interceptors. 72: */ 73: public void establish_components(IORInfo info) 74: { 75: for (int i = 0; i < interceptors.length; i++) 76: { 77: try 78: { 79: interceptors [ i ].establish_components(info); 80: } 81: catch (Exception exc) 82: { 83: // OMG states we should ignore. 84: } 85: } 86: } 87: 88: /** 89: * Call destroy on all registered interceptors. 90: */ 91: public void destroy() 92: { 93: for (int i = 0; i < interceptors.length; i++) 94: { 95: try 96: { 97: interceptors [ i ].destroy(); 98: } 99: catch (Exception exc) 100: { 101: // OMG states we should ignore. 102: } 103: } 104: } 105: 106: /** 107: * Get the class name. 108: */ 109: public String name() 110: { 111: return getClass().getName(); 112: } 113: 114: /** 115: * Call this method for all registered CORBA 3.0 interceptors. 116: */ 117: public void adapter_manager_state_changed(int adapterManagerId, short adapterState) 118: { 119: for (int i = 0; i < interceptors.length; i++) 120: { 121: try 122: { 123: if (interceptors[i] instanceof IORInterceptor_3_0Operations) 124: { 125: ((IORInterceptor_3_0Operations) interceptors[i]). 126: adapter_manager_state_changed(adapterManagerId, adapterState); 127: } 128: } 129: catch (Exception exc) 130: { 131: OBJ_ADAPTER oa = new OBJ_ADAPTER("components_established failed"); 132: oa.initCause(exc); 133: oa.minor = 6 | OMGVMCID.value; 134: throw oa; 135: } 136: } 137: } 138: 139: /** 140: * Call this method for all registered CORBA 3.0 interceptors. 141: */ 142: public void adapter_state_changed(ObjectReferenceTemplate[] adapters, short adaptersState) 143: { 144: for (int i = 0; i < interceptors.length; i++) 145: { 146: try 147: { 148: if (interceptors[i] instanceof IORInterceptor_3_0Operations) 149: { 150: ((IORInterceptor_3_0Operations) interceptors[i]). 151: adapter_state_changed(adapters, adaptersState); 152: } 153: } 154: catch (Exception exc) 155: { 156: OBJ_ADAPTER oa = new OBJ_ADAPTER("components_established failed"); 157: oa.initCause(exc); 158: oa.minor = 6 | OMGVMCID.value; 159: throw oa; 160: } 161: } 162: } 163: 164: /** 165: * Call this method for all registered CORBA 3.0 interceptors. 166: * 167: * @throws OBJ_ADAPTER minor 6 on any failure (as defined by OMG specs). 168: */ 169: public void components_established(IORInfo info) 170: { 171: for (int i = 0; i < interceptors.length; i++) 172: { 173: try 174: { 175: if (interceptors[i] instanceof IORInterceptor_3_0Operations) 176: { 177: ((IORInterceptor_3_0Operations) interceptors[i]). 178: components_established(info); 179: } 180: } 181: catch (Exception exc) 182: { 183: OBJ_ADAPTER oa = new OBJ_ADAPTER("components_established failed"); 184: oa.initCause(exc); 185: oa.minor = 6 | OMGVMCID.value; 186: throw oa; 187: } 188: } 189: }