1 12 package org.jacorb.trading.client.proxy; 13 14 import java.io.*; 15 import java.util.*; 16 import org.omg.CORBA.*; 17 import org.omg.CosTrading.*; 18 import org.omg.CosTrading.LookupPackage.*; 19 import org.jacorb.trading.client.util.*; 20 21 public class ProxyLookupImpl extends org.omg.CosTrading.LookupPOA 22 { 23 public ProxyLookupImpl() 24 { 25 } 26 27 28 34 public String _object_name() 35 { 36 return "ProxyDemo"; 37 } 38 39 40 42 public Lookup lookup_if() 43 { 44 throw new org.omg.CORBA.NO_IMPLEMENT (); 45 } 46 47 48 public Register register_if() 49 { 50 throw new org.omg.CORBA.NO_IMPLEMENT (); 51 } 52 53 54 public Link link_if() 55 { 56 throw new org.omg.CORBA.NO_IMPLEMENT (); 57 } 58 59 60 public Proxy proxy_if() 61 { 62 throw new org.omg.CORBA.NO_IMPLEMENT (); 63 } 64 65 66 public Admin admin_if() 67 { 68 throw new org.omg.CORBA.NO_IMPLEMENT (); 69 } 70 71 72 74 public boolean supports_modifiable_properties() 75 { 76 throw new org.omg.CORBA.NO_IMPLEMENT (); 77 } 78 79 80 public boolean supports_dynamic_properties() 81 { 82 throw new org.omg.CORBA.NO_IMPLEMENT (); 83 } 84 85 86 public boolean supports_proxy_offers() 87 { 88 throw new org.omg.CORBA.NO_IMPLEMENT (); 89 } 90 91 92 public org.omg.CORBA.Object type_repos() 93 { 94 throw new org.omg.CORBA.NO_IMPLEMENT (); 95 } 96 97 98 100 101 public int def_search_card() 102 { 103 throw new org.omg.CORBA.NO_IMPLEMENT (); 104 } 105 106 107 public int max_search_card() 108 { 109 throw new org.omg.CORBA.NO_IMPLEMENT (); 110 } 111 112 113 public int def_match_card() 114 { 115 throw new org.omg.CORBA.NO_IMPLEMENT (); 116 } 117 118 119 public int max_match_card() 120 { 121 throw new org.omg.CORBA.NO_IMPLEMENT (); 122 } 123 124 125 public int def_return_card() 126 { 127 throw new org.omg.CORBA.NO_IMPLEMENT (); 128 } 129 130 131 public int max_return_card() 132 { 133 throw new org.omg.CORBA.NO_IMPLEMENT (); 134 } 135 136 137 public int max_list() 138 { 139 throw new org.omg.CORBA.NO_IMPLEMENT (); 140 } 141 142 143 public int def_hop_count() 144 { 145 throw new org.omg.CORBA.NO_IMPLEMENT (); 146 } 147 148 149 public int max_hop_count() 150 { 151 throw new org.omg.CORBA.NO_IMPLEMENT (); 152 } 153 154 155 public FollowOption def_follow_policy() 156 { 157 throw new org.omg.CORBA.NO_IMPLEMENT (); 158 } 159 160 161 public FollowOption max_follow_policy() 162 { 163 throw new org.omg.CORBA.NO_IMPLEMENT (); 164 } 165 166 167 168 170 public void query( 171 String type, 172 String constr, 173 String pref, 174 org.omg.CosTrading.Policy[] policies, 175 SpecifiedProps desired_props, 176 int how_many, 177 OfferSeqHolder offers, 178 OfferIteratorHolder offer_itr, 179 PolicyNameSeqHolder limits_applied) 180 throws IllegalServiceType, 181 UnknownServiceType, 182 IllegalConstraint, 183 IllegalPreference, 184 IllegalPolicyName, 185 PolicyTypeMismatch, 186 InvalidPolicyValue, 187 IllegalPropertyName, 188 DuplicatePropertyName, 189 DuplicatePolicyName 190 { 191 PrintWriter pw = new PrintWriter(System.out); 192 pw.println("Type = " + type); 193 pw.println("Constraint = '" + constr + "'"); 194 pw.println("Preference = '" + pref + "'"); 195 196 for (int i = 0; i < policies.length; i++) 197 { 198 pw.print("Policy[" + i + "] = {" + policies[i].name + ", "); 199 AnyUtil.print(_orb(), pw, policies[i].value); 200 pw.println("}"); 201 } 202 pw.flush(); 203 204 212 213 Offer[] arr = createOffers(); 214 215 int seqCount = Math.min(arr.length, how_many); 217 218 offers.value = new Offer[seqCount]; 219 int count = 0; 220 while (count < seqCount) { 221 offers.value[count] = arr[count]; 222 count++; 223 } 224 225 if (seqCount < arr.length) { 227 int restCount = arr.length - seqCount; 229 Offer[] rest = new Offer[restCount]; 230 231 int pos = 0; 232 while (pos < restCount) { 233 rest[pos] = arr[count]; 234 pos++; 235 count++; 236 } 237 238 OfferIteratorImpl iter = new OfferIteratorImpl(rest, 0); 239 offer_itr.value = iter._this(); 241 } 242 243 limits_applied.value = new String [0]; 244 } 245 246 247 protected Offer[] createOffers() 248 { 249 Offer[] result; 250 251 ORB orb = org.omg.CORBA.ORB.init(); 252 Random rand = new Random(); 253 int numOffers = Math.abs(rand.nextInt()) % 4; 254 result = new Offer[numOffers]; 255 256 for (int i = 0; i < numOffers; i++) { 257 result[i] = new Offer(); 259 result[i].reference = this._this(); result[i].properties = new Property[3]; 261 262 int num = 0; 263 264 result[i].properties[num] = new Property(); 266 result[i].properties[num].name = "name"; 267 result[i].properties[num].value = orb.create_any(); 268 result[i].properties[num].value.insert_string("proxy offer " + i); 269 num++; 270 271 result[i].properties[num] = new Property(); 273 result[i].properties[num].name = "cost"; 274 result[i].properties[num].value = orb.create_any(); 275 result[i].properties[num].value.insert_double( 276 Math.abs(rand.nextDouble())); 277 num++; 278 279 result[i].properties[num] = new Property(); 281 result[i].properties[num].name = "version"; 282 result[i].properties[num].value = orb.create_any(); 283 result[i].properties[num].value.insert_string("1.0" + i); 284 num++; 285 } 286 287 return result; 288 } 289 } 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | Popular Tags |