1 package org.jacorb.ir; 2 3 22 23 import java.lang.reflect.*; 24 import java.util.*; 25 26 import org.omg.CORBA.INTF_REPOS ; 27 import org.omg.PortableServer.POA ; 28 29 import org.apache.avalon.framework.logger.Logger; 30 31 34 35 public class ExceptionDef 36 extends Contained 37 implements org.omg.CORBA.ExceptionDefOperations 38 { 39 private org.omg.CORBA.TypeCode type; 40 private Class myClass; 41 private Class helperClass; 42 private org.omg.CORBA.StructMember [] members; 43 private Hashtable contained = new Hashtable(); 44 private Logger logger; 45 private ClassLoader loader; 46 private POA poa; 47 48 public ExceptionDef(Class c, 49 org.omg.CORBA.Container _defined_in, 50 org.omg.CORBA.Repository ir, 51 ClassLoader loader, 52 POA poa, 53 Logger logger) 54 { 55 this.logger = logger; 56 this.loader = loader; 57 this.poa = poa; 58 def_kind = org.omg.CORBA.DefinitionKind.dk_Exception; 59 containing_repository = ir; 60 defined_in = _defined_in; 61 if (defined_in == null) 62 { 63 throw new INTF_REPOS ("defined_in = null"); 64 } 65 if (containing_repository == null) 66 { 67 throw new INTF_REPOS ("containing_repository = null"); 68 } 69 70 try 71 { 72 String classId = c.getName(); 73 myClass = c; 74 version( "1.0" ); 75 if( classId.indexOf('.') > 0 ) 76 { 77 name( classId.substring( classId.lastIndexOf('.')+1)); 78 absolute_name = 79 org.omg.CORBA.ContainedHelper.narrow( defined_in ).absolute_name() + "::" + name; 80 } 81 else 82 { 83 name( classId ); 84 absolute_name = "::" + name; 85 } 86 87 helperClass = this.loader.loadClass(classId + "Helper") ; 88 id( (String )helperClass.getDeclaredMethod("id", (Class []) null).invoke( null, (Object []) null )); 89 type = 90 TypeCodeUtil.getTypeCode(myClass, this.loader, null, classId, this.logger ); 91 try 92 { 93 members = new org.omg.CORBA.StructMember [ type.member_count() ]; 94 for( int i = 0; i < members.length; i++ ) 95 { 96 members[i] = new org.omg.CORBA.StructMember ( type.member_name(i), 97 type.member_type(i), 98 null ); 99 } 100 } 101 catch( Exception e ) 102 { 103 this.logger.error("Caught Exception", e); 104 } 105 106 if (this.logger.isDebugEnabled()) 107 { 108 this.logger.debug("ExceptionDef: " + absolute_name); 109 } 110 } 111 catch ( Exception e ) 112 { 113 this.logger.error("Caught Exception", e); 114 throw new INTF_REPOS ( ErrorMsg.IR_Not_Implemented, 115 org.omg.CORBA.CompletionStatus.COMPLETED_NO); 116 } 117 } 118 119 121 122 void define() 123 { 124 for( int i = 0; i < members.length; i++ ) 125 { 126 members[i].type_def = IDLType.create( members[i].type, 127 containing_repository, 128 this.logger, 129 this.poa); 130 } 131 } 132 133 135 136 public org.omg.CORBA.ExceptionDescription describe_exception() 137 { 138 return new org.omg.CORBA.ExceptionDescription (name(), 139 id(), 140 org.omg.CORBA.ContainedHelper.narrow( defined_in ).id(), 141 version(), 142 type()); 143 } 144 145 public org.omg.CORBA.TypeCode type() 146 { 147 if (type == null) 148 { 149 throw new INTF_REPOS ("Exception TypeCode is null"); 150 } 151 return type; 152 } 153 154 public org.omg.CORBA.Contained lookup(java.lang.String search_name) 155 { 156 return null; 157 } 158 159 160 public org.omg.CORBA.StructMember [] members() 161 { 162 return members; 163 } 164 165 166 168 public void members(org.omg.CORBA.StructMember [] a) 169 { 170 } 171 172 173 public org.omg.CORBA.ModuleDef create_module( String id, String name, String version) 174 { 175 return null; 176 } 177 178 public org.omg.CORBA.ConstantDef create_constant(java.lang.String id, java.lang.String name, java.lang.String version, org.omg.CORBA.IDLType type, org.omg.CORBA.Any value) 179 { 180 return null; 181 } 182 183 public org.omg.CORBA.StructDef create_struct( String id, String name, String version, org.omg.CORBA.StructMember [] members){ 184 return null; 185 } 186 187 public org.omg.CORBA.UnionDef create_union( String id, String name, String version, org.omg.CORBA.IDLType discriminator_type, org.omg.CORBA.UnionMember [] members){ 188 return null; 189 } 190 191 public org.omg.CORBA.EnumDef create_enum( String id, String name, String version, String [] members){ 192 return null; 193 } 194 195 public org.omg.CORBA.AliasDef create_alias( String id, String name, String version, org.omg.CORBA.IDLType original_type){ 196 return null; 197 } 198 199 202 203 public org.omg.CORBA.ExceptionDef create_exception(java.lang.String id, java.lang.String name , java.lang.String version, org.omg.CORBA.StructMember [] member ) 204 { 205 return null; 206 } 207 208 211 212 public org.omg.CORBA.InterfaceDef create_interface( 213 String id, 214 String name, 215 String version, 216 org.omg.CORBA.InterfaceDef [] base_interfaces, 217 boolean is_abstract ) 218 { 219 return null; 220 } 221 222 225 226 public org.omg.CORBA.ValueBoxDef create_value_box(java.lang.String id, 227 java.lang.String name, 228 java.lang.String version, 229 org.omg.CORBA.IDLType type) 230 { 231 return null; 232 } 233 234 235 238 239 public org.omg.CORBA.ValueDef create_value( 240 java.lang.String id, 241 java.lang.String name, 242 java.lang.String version, 243 boolean is_custom, 244 boolean is_abstract, 245 org.omg.CORBA.ValueDef base_value, 246 boolean is_truncatable, 247 org.omg.CORBA.ValueDef [] abstract_base_values, 248 org.omg.CORBA.InterfaceDef [] supported_interfaces, 249 org.omg.CORBA.Initializer [] initializers) 250 { 251 return null; 252 } 253 254 255 258 259 public org.omg.CORBA.NativeDef create_native(java.lang.String id, 260 java.lang.String name, 261 java.lang.String version) 262 { 263 return null; 264 } 265 266 267 268 270 public org.omg.CORBA.DefinitionKind def_kind() 271 { 272 return org.omg.CORBA.DefinitionKind.dk_Exception; 273 } 274 275 public void destroy(){ 276 throw new INTF_REPOS (ErrorMsg.IR_Not_Implemented, 277 org.omg.CORBA.CompletionStatus.COMPLETED_NO); 278 } 279 280 281 public org.omg.CORBA.Contained [] lookup_name( String search_name, int levels_to_search, org.omg.CORBA.DefinitionKind limit_type, boolean exclude_inherited) 282 { 283 return null; 284 } 285 286 public org.omg.CORBA.ContainerPackage.Description[] describe_contents(org.omg.CORBA.DefinitionKind limit_type, boolean exclude_inherited, int max_returned_objs){ 287 return null; 288 } 289 290 291 public org.omg.CORBA.Contained [] contents(org.omg.CORBA.DefinitionKind limit_type, 292 boolean exclude_inherited) 293 { 294 Hashtable limited = new Hashtable(); 295 296 298 for( Enumeration e = contained.elements(); e.hasMoreElements(); ) 299 { 300 Contained c = (Contained)e.nextElement(); 301 if( limit_type.value() == org.omg.CORBA.DefinitionKind._dk_all || 302 limit_type.value() == c.def_kind.value() ) 303 { 304 limited.put( c, "" ); 305 } 306 } 307 308 org.omg.CORBA.Contained [] c = new org.omg.CORBA.Contained [limited.size()]; 309 int i; 310 Enumeration e; 311 for( e = limited.keys(), i=0 ; e.hasMoreElements(); i++ ) 312 c[i] = (org.omg.CORBA.Contained )e.nextElement(); 313 return c; 314 315 } 316 317 318 320 public org.omg.CORBA.ContainedPackage.Description describe() 321 { 322 org.omg.CORBA.Any a = orb.create_any(); 323 org.omg.CORBA.ExceptionDescription ed = describe_exception(); 324 org.omg.CORBA.ExceptionDescriptionHelper.insert( a, ed ); 325 return new org.omg.CORBA.ContainedPackage.Description( org.omg.CORBA.DefinitionKind.dk_Exception, a); 326 } 327 328 } 329 330 331 | Popular Tags |