1 22 package org.jboss.iiop.rmi.ir; 23 24 import org.omg.CORBA.Any ; 25 import org.omg.CORBA.TypeCode ; 26 import org.omg.CORBA.IDLType ; 27 import org.omg.CORBA.IDLTypeHelper ; 28 import org.omg.CORBA.IRObject ; 29 import org.omg.CORBA.DefinitionKind ; 30 import org.omg.CORBA.OperationMode ; 31 import org.omg.CORBA.ParameterDescription ; 32 import org.omg.CORBA.OperationDescription ; 33 import org.omg.CORBA.OperationDescriptionHelper; 34 import org.omg.CORBA.OperationDef ; 35 import org.omg.CORBA.OperationDefOperations ; 36 import org.omg.CORBA.OperationDefPOATie; 37 import org.omg.CORBA.ExceptionDef ; 38 import org.omg.CORBA.ExceptionDescription ; 39 import org.omg.CORBA.ExceptionDescriptionHelper; 40 import org.omg.CORBA.ContainedOperations ; 41 import org.omg.CORBA.ContainedPackage.Description; 42 import org.omg.CORBA.BAD_INV_ORDER ; 43 44 50 class OperationDefImpl 51 extends ContainedImpl 52 implements OperationDefOperations 53 { 54 56 58 60 62 OperationDefImpl(String id, String name, String version, 63 LocalContainer defined_in, 64 TypeCode typeCode, 65 ParameterDescription [] params, 66 ExceptionDef [] exceptions, 67 RepositoryImpl repository) 68 { 69 super(id, name, version, defined_in, 70 DefinitionKind.dk_Operation, repository); 71 72 this.typeCode = typeCode; 73 this.params = params; 74 this.exceptions = exceptions; 75 } 76 77 79 80 82 public IRObject getReference() 83 { 84 if (ref == null) { 85 ref = org.omg.CORBA.OperationDefHelper.narrow( 86 servantToReference(new OperationDefPOATie(this)) ); 87 } 88 return ref; 89 } 90 91 public void allDone() 92 throws IRConstructionException 93 { 94 type_def = IDLTypeImpl.getIDLType(typeCode, repository); 96 97 for (int i = 0; i < params.length; ++i) { 99 LocalIDLType lit = IDLTypeImpl.getIDLType(params[i].type, repository); 100 if (lit==null) 101 throw new RuntimeException ("???????????1?"); 102 params[i].type_def = IDLTypeHelper.narrow(lit.getReference()); 103 if (params[i].type_def==null) 104 throw new RuntimeException ("???????????2?"); 105 } 106 107 getReference(); 108 } 109 110 111 113 public TypeCode result() 114 { 115 return typeCode; 116 } 117 118 public IDLType result_def() 119 { 120 return IDLTypeHelper.narrow(type_def.getReference()); 121 } 122 123 public void result_def(IDLType arg) 124 { 125 throw new BAD_INV_ORDER ("Cannot change RMI/IIOP mapping."); 126 } 127 128 public ParameterDescription [] params() 129 { 130 return params; 131 } 132 133 public void params(ParameterDescription [] arg) 134 { 135 throw new BAD_INV_ORDER ("Cannot change RMI/IIOP mapping."); 136 } 137 138 public OperationMode mode() 139 { 140 return OperationMode.OP_NORMAL; 142 } 143 144 public void mode(OperationMode arg) 145 { 146 throw new BAD_INV_ORDER ("Cannot change RMI/IIOP mapping."); 147 } 148 149 public String [] contexts() 150 { 151 return new String [0]; 153 } 154 155 public void contexts(String [] arg) 156 { 157 throw new BAD_INV_ORDER ("Cannot change RMI/IIOP mapping."); 158 } 159 160 public ExceptionDef [] exceptions() 161 { 162 return exceptions; 163 } 164 165 public void exceptions(ExceptionDef [] arg) 166 { 167 throw new BAD_INV_ORDER ("Cannot change RMI/IIOP mapping."); 168 } 169 170 172 public Description describe() 173 { 174 String defined_in_id = "IR"; 175 176 if (defined_in instanceof ContainedOperations ) 177 defined_in_id = ((ContainedOperations )defined_in).id(); 178 179 ExceptionDescription [] exds; 180 exds = new ExceptionDescription [exceptions.length]; 181 for (int i = 0; i < exceptions.length; ++i) { 182 Description d = exceptions[i].describe(); 183 exds[i] = ExceptionDescriptionHelper.extract(d.value); 184 } 185 186 OperationDescription od; 187 od = new OperationDescription (name, id, defined_in_id, version, typeCode, 188 mode(), contexts(), params(), exds); 189 190 Any any = getORB().create_any(); 191 192 OperationDescriptionHelper.insert(any, od); 193 194 return new Description (DefinitionKind.dk_Operation, any); 195 } 196 197 198 200 202 205 private OperationDef ref = null; 206 207 210 private TypeCode typeCode; 211 212 215 private LocalIDLType type_def; 216 217 220 private ParameterDescription [] params; 221 222 225 private ExceptionDef [] exceptions; 226 227 } 228 229 | Popular Tags |