001/* _IDLTypeStub.java -- 002 Copyright (C) 2005, 2006 Free Software Foundation, Inc. 003 004This file is part of GNU Classpath. 005 006GNU Classpath is free software; you can redistribute it and/or modify 007it under the terms of the GNU General Public License as published by 008the Free Software Foundation; either version 2, or (at your option) 009any later version. 010 011GNU Classpath is distributed in the hope that it will be useful, but 012WITHOUT ANY WARRANTY; without even the implied warranty of 013MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014General Public License for more details. 015 016You should have received a copy of the GNU General Public License 017along with GNU Classpath; see the file COPYING. If not, write to the 018Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 01902110-1301 USA. 020 021Linking this library statically or dynamically with other modules is 022making a combined work based on this library. Thus, the terms and 023conditions of the GNU General Public License cover the whole 024combination. 025 026As a special exception, the copyright holders of this library give you 027permission to link this library with independent modules to produce an 028executable, regardless of the license terms of these independent 029modules, and to copy and distribute the resulting executable under 030terms of your choice, provided that you also meet, for each linked 031independent module, the terms and conditions of the license of that 032module. An independent module is a module which is not derived from 033or based on this library. If you modify this library, you may extend 034this exception to your version of the library, but you are not 035obligated to do so. If you do not wish to do so, delete this 036exception statement from your version. */ 037 038 039package org.omg.CORBA; 040 041import gnu.CORBA.Minor; 042import gnu.CORBA.TypeCodeHelper; 043 044import org.omg.CORBA.portable.ApplicationException; 045import org.omg.CORBA.portable.Delegate; 046import org.omg.CORBA.portable.InputStream; 047import org.omg.CORBA.portable.ObjectImpl; 048import org.omg.CORBA.portable.OutputStream; 049import org.omg.CORBA.portable.RemarshalException; 050 051import java.io.Serializable; 052 053/** 054 * The stub for the IDL type. This stub can be used to access the 055 * remote IDL type object, if its IOR is known. To create the 056 * working instance with the known IOR, pass {@link gnu.CORBA.IorDelegate} 057 * to the constructor. 058 * 059 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) 060 */ 061public class _IDLTypeStub 062 extends ObjectImpl 063 implements IDLType, Serializable 064{ 065 /** 066 * Use serialVersionUID (v1.4) for interoperability. 067 */ 068 private static final long serialVersionUID = 9150293942452453626L; 069 070 /** 071 * Create the instance of the IDL type stub without 072 * the set delegate. The delegate must be set anyway before calling 073 * any remote method. 074 */ 075 public _IDLTypeStub() 076 { 077 } 078 079 /** 080 * Create an instance with the given delegate. 081 * 082 * @see gnu.CORBA.IorDelegate 083 */ 084 public _IDLTypeStub(Delegate delegate) 085 { 086 _set_delegate(delegate); 087 } 088 089 /** 090 * Get the typecode of the remote IDL type object. The method is 091 * written following OMG specification, treating the typecode 092 * as a read only attribute rather than a method. This means, 093 * the operation name is "_get_type". 094 * 095 * @return a typecode, returned by the remote IDL type object. 096 */ 097 public TypeCode type() 098 { 099 InputStream in = null; 100 try 101 { 102 OutputStream out = _request("_get_type", true); 103 in = _invoke(out); 104 return TypeCodeHelper.read(in); 105 } 106 catch (ApplicationException ex) 107 { 108 in = ex.getInputStream(); 109 throw new org.omg.CORBA.MARSHAL(ex.getId()); 110 } 111 catch (RemarshalException rex) 112 { 113 return type(); 114 } 115 catch (UserException ex) 116 { 117 MARSHAL m = new MARSHAL(); 118 m.minor = Minor.UserException; 119 m.initCause(ex); 120 throw m; 121 } 122 finally 123 { 124 _releaseReply(in); 125 } 126 } 127 128 /** 129 * Get the definition kind of the remote IDL type object. The method is 130 * written following OMG specification, treating the typecode 131 * as a read only attribute rather than a method. This means, 132 * the operation name is "_get_def_kind". 133 * 134 * @return a definition kind, returned by remote IDL type object. 135 */ 136 public DefinitionKind def_kind() 137 { 138 InputStream in = null; 139 try 140 { 141 OutputStream out = _request("_get_def_kind", true); 142 in = _invoke(out); 143 return DefinitionKindHelper.read(in); 144 } 145 catch (ApplicationException ex) 146 { 147 in = ex.getInputStream(); 148 throw new org.omg.CORBA.MARSHAL(ex.getId()); 149 } 150 catch (RemarshalException rex) 151 { 152 return def_kind(); 153 } 154 finally 155 { 156 _releaseReply(in); 157 } 158 } 159 160 /** 161 * Destroy the remote IDL type object. 162 */ 163 public void destroy() 164 { 165 InputStream in = null; 166 try 167 { 168 OutputStream out = _request("destroy", true); 169 in = _invoke(out); 170 } 171 catch (ApplicationException ex) 172 { 173 in = ex.getInputStream(); 174 throw new org.omg.CORBA.MARSHAL(ex.getId()); 175 } 176 catch (RemarshalException rex) 177 { 178 destroy(); 179 } 180 finally 181 { 182 _releaseReply(in); 183 } 184 } 185 186 /** 187 * Return the array of repository ids of the IDL type. 188 * 189 * @return "IDL:omg.org/CORBA/IDLType:1.0" and 190 * "IDL:omg.org/CORBA/IRObject:1.0", always. 191 */ 192 public String[] _ids() 193 { 194 return new String[] 195 { 196 "IDL:omg.org/CORBA/IDLType:1.0", "IDL:omg.org/CORBA/IRObject:1.0" 197 }; 198 } 199}