1 /* _IORInterceptor_3_0Stub.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 org.omg.PortableInterceptor; 40 41 import org.omg.CORBA.MARSHAL; 42 import org.omg.CORBA.portable.ApplicationException; 43 import org.omg.CORBA.portable.Delegate; 44 import org.omg.CORBA.portable.InputStream; 45 import org.omg.CORBA.portable.ObjectImpl; 46 import org.omg.CORBA.portable.OutputStream; 47 import org.omg.CORBA.portable.RemarshalException; 48 49 import java.io.Serializable; 50 51 /** 52 * The IORInterceptor_3_0 stub (proxy), used on the client side. The 53 * {@link IORInterceptor_3_0} methods contain the code for remote invocaton. The 54 * stub is required by {@link IORInterceptor_3_0Helper} .read, .narrow and 55 * .unchecked_narrow methods. 56 * 57 * @specnote Being not specified in 1.5 API, this class is package private. 58 * From that happened to some other stubs, it will likely to appear in the 1.6 59 * or later. Because of this, it is placed here. 60 * 61 * @specnote The stub and the helper support the existence of the interceptor 62 * on the remote side only. To support the corresponding support on the side 63 * where the ORB is registered with this interceptor, you also need 64 * _IORInfoStub, IORInfoHelper and either servants or implementation bases 65 * for both POA and IORInfo. These classes are not defined in the 1.5 API, 66 * hence they are not included. You may need to generate the manually from 67 * the IDL descriptions, available from 68 * http://www.omg.org/docs/formal/04-03-12.pdf. 69 * 70 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) 71 */ 72 class _IORInterceptor_3_0Stub 73 extends ObjectImpl 74 implements IORInterceptor_3_0, Serializable 75 { 76 /** 77 * Use serialVersionUID for interoperability. 78 */ 79 private static final long serialVersionUID = 1; 80 81 /** 82 * Create the IORInterceptor_3_0 stub. To get the stub working, you must later 83 * set the delegate with {@link ObjectImpl#_set_delegate(Delegate)}. 84 */ _IORInterceptor_3_0Stub()85 public _IORInterceptor_3_0Stub() 86 { 87 } 88 89 /** 90 * Create the naming context stub with the given delegate. 91 */ _IORInterceptor_3_0Stub(Delegate delegate)92 public _IORInterceptor_3_0Stub(Delegate delegate) 93 { 94 _set_delegate(delegate); 95 } 96 97 /** 98 * Return the array of repository ids for this object. 99 */ _ids()100 public String[] _ids() 101 { 102 return new String[] { IORInterceptor_3_0Helper.id() }; 103 } 104 105 /** {@inheritDoc} */ adapter_manager_state_changed(int adapterManagerId, short adapterState)106 public void adapter_manager_state_changed(int adapterManagerId, 107 short adapterState) 108 { 109 InputStream input = null; 110 try 111 { 112 OutputStream output = _request("adapter_manager_state_changed", true); 113 output.write_long(adapterManagerId); 114 output.write_short(adapterState); 115 input = _invoke(output); 116 117 } 118 catch (ApplicationException ex) 119 { 120 input = ex.getInputStream(); 121 String id = ex.getId(); 122 throw new MARSHAL(id); 123 } 124 catch (RemarshalException remarsh) 125 { 126 adapter_manager_state_changed(adapterManagerId, adapterState); 127 } 128 finally 129 { 130 _releaseReply(input); 131 } 132 } 133 134 /** {@inheritDoc} */ adapter_state_changed(ObjectReferenceTemplate[] adapters, short adaptersState)135 public void adapter_state_changed(ObjectReferenceTemplate[] adapters, 136 short adaptersState) 137 { 138 InputStream input = null; 139 try 140 { 141 OutputStream output = _request("adapter_state_changed", true); 142 output.write_long(adapters.length); 143 for (int i0 = 0; i0 < adapters.length; i0++) 144 ObjectReferenceTemplateHelper.write(output, adapters[i0]); 145 output.write_short(adaptersState); 146 input = _invoke(output); 147 148 } 149 catch (ApplicationException ex) 150 { 151 input = ex.getInputStream(); 152 String id = ex.getId(); 153 throw new MARSHAL(id); 154 } 155 catch (RemarshalException remarsh) 156 { 157 adapter_state_changed(adapters, adaptersState); 158 } 159 finally 160 { 161 _releaseReply(input); 162 } 163 } 164 165 /** {@inheritDoc} */ components_established(IORInfo info)166 public void components_established(IORInfo info) 167 { 168 InputStream input = null; 169 try 170 { 171 OutputStream output = _request("components_established", true); 172 output.write_Object(info); 173 input = _invoke(output); 174 175 } 176 catch (ApplicationException ex) 177 { 178 input = ex.getInputStream(); 179 String id = ex.getId(); 180 throw new MARSHAL(id); 181 } 182 catch (RemarshalException remarsh) 183 { 184 components_established(info); 185 } 186 finally 187 { 188 _releaseReply(input); 189 } 190 } 191 192 /** {@inheritDoc} */ establish_components(IORInfo info)193 public void establish_components(IORInfo info) 194 { 195 InputStream input = null; 196 try 197 { 198 OutputStream output = _request("establish_components", true); 199 output.write_Object(info); 200 input = _invoke(output); 201 202 } 203 catch (ApplicationException ex) 204 { 205 input = ex.getInputStream(); 206 String id = ex.getId(); 207 throw new MARSHAL(id); 208 } 209 catch (RemarshalException remarsh) 210 { 211 establish_components(info); 212 } 213 finally 214 { 215 _releaseReply(input); 216 } 217 } 218 219 /** {@inheritDoc} */ name()220 public String name() 221 { 222 InputStream input = null; 223 try 224 { 225 OutputStream output = _request("name", true); 226 input = _invoke(output); 227 String returns = input.read_string(); 228 229 return returns; 230 } 231 catch (ApplicationException ex) 232 { 233 input = ex.getInputStream(); 234 String id = ex.getId(); 235 throw new MARSHAL(id); 236 } 237 catch (RemarshalException remarsh) 238 { 239 return name(); 240 } 241 finally 242 { 243 _releaseReply(input); 244 } 245 } 246 247 /** {@inheritDoc} */ destroy()248 public void destroy() 249 { 250 InputStream input = null; 251 try 252 { 253 OutputStream output = _request("destroy", true); 254 input = _invoke(output); 255 256 } 257 catch (ApplicationException ex) 258 { 259 input = ex.getInputStream(); 260 String id = ex.getId(); 261 throw new MARSHAL(id); 262 } 263 catch (RemarshalException remarsh) 264 { 265 destroy(); 266 } 267 finally 268 { 269 _releaseReply(input); 270 } 271 } 272 } 273