1 21 package org.jacorb.ir.gui.remoteobject; 22 23 24 25 import org.jacorb.ir.gui.typesystem.*; 26 27 import org.jacorb.ir.gui.typesystem.remote.*; 28 29 import org.omg.CORBA.*; 30 31 38 39 public class RemoteObject 40 41 extends ObjectRepresentant implements AbstractContainer 42 43 { 44 45 46 47 48 49 56 57 protected RemoteObject (org.omg.CORBA.Object counterPart, 58 59 TypeSystemNode type, String name) 60 61 { 62 63 super(counterPart,type,name); 64 65 66 67 } 68 69 76 77 public ModelParticipant[] contents() { 78 79 if (counterPart!=null) { 80 81 IRAttribute[] allFields = (IRAttribute[])((Interface)this.typeSystemNode).getAllFields(); 82 83 ObjectRepresentant[] result = new ObjectRepresentant[allFields.length]; 84 85 for (int i=0; i<allFields.length; i++) { 86 87 Request request = ((org.omg.CORBA.Object )counterPart)._request("_get_"+allFields[i].getName()); 88 89 IRNode associatedNode = (IRNode)allFields[i].getAssociatedTypeSystemNode(); 90 91 request.set_return_type(associatedNode.getTypeCode()); 93 try { 94 95 request.invoke(); 96 97 } 98 99 catch (Exception e) { 100 101 e.printStackTrace(); 102 103 } 104 105 Any any = request.return_value(); 106 107 if (any!=null) { 108 109 result[i] = ObjectRepresentantFactory.create( 110 111 ObjectRepresentantFactory.objectFromAny(any), 112 113 allFields[i].getAssociatedTypeSystemNode(), 114 115 allFields[i]); 116 117 } 118 119 else { 120 121 result[i] = ObjectRepresentantFactory.create(null, allFields[i].getAssociatedTypeSystemNode(),allFields[i]); 122 123 } 124 125 } 126 127 return result; 128 129 } 131 else { 132 133 return new ModelParticipant[0]; 134 135 } 136 137 } 138 139 150 151 public java.lang.Object invokeOperation(IROperation op, String [] params) { 152 153 ModelParticipant[] irParams = op.contents(); 154 155 Request request = ((org.omg.CORBA.Object )counterPart)._request(op.getName()); 156 157 IRNode associatedNode = (IRNode)op.getAssociatedTypeSystemNode(); 158 159 request.set_return_type(associatedNode.getTypeCode()); 161 for (int i=0; i<irParams.length; i++) { 162 163 IRParameter irParam = (IRParameter)irParams[i]; 164 165 switch (irParam.getMode().value()) { 166 167 case ParameterMode._PARAM_IN: 168 169 ObjectRepresentantFactory.insertFromString(request.add_in_arg(),params[i],irParam.getTypeCode().kind()); 170 171 break; 172 173 case ParameterMode._PARAM_OUT: 174 175 ObjectRepresentantFactory.insertFromString(request.add_out_arg(),params[i],irParam.getTypeCode().kind()); 176 177 break; 178 179 case ParameterMode._PARAM_INOUT: 180 181 ObjectRepresentantFactory.insertFromString(request.add_inout_arg(),params[i],irParam.getTypeCode().kind()); 182 183 break; 184 185 } 186 187 } 188 189 request.invoke(); 190 191 Any any = request.return_value(); 192 193 if (any!=null) { 194 195 return ObjectRepresentantFactory.objectFromAny(any); 196 197 } 198 199 return null; 200 201 } 202 203 } 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | Popular Tags |