1 19 20 25 package org.netbeans.modules.j2ee.sun.ws7.serverresources.dd; 26 27 import java.util.Arrays ; 28 import java.util.HashMap ; 29 import java.util.HashSet ; 30 import java.util.Iterator ; 31 import java.util.List ; 32 import java.util.Map ; 33 import java.util.Set ; 34 import java.util.Vector ; 35 import org.netbeans.modules.schema2beans.BaseBean; 36 import org.netbeans.modules.schema2beans.BeanProp; 37 import org.netbeans.modules.schema2beans.Common; 38 import org.netbeans.modules.schema2beans.Version; 39 40 import org.netbeans.modules.j2ee.sun.dd.api.CommonDDBean; 41 import org.netbeans.modules.j2ee.sun.dd.api.DDException; 42 43 public abstract class SunBaseBean extends BaseBean implements CommonDDBean { 44 45 47 public SunBaseBean(Vector comps, Version version) { 48 super(comps, version); 49 } 50 51 53 public void dump(StringBuffer str, String indent){ 54 } 55 56 public CommonDDBean getPropertyParent(String name){ 57 if(this.graphManager() != null) 58 return (CommonDDBean) this.graphManager().getPropertyParent(name); 59 else 60 return null; 61 } 62 63 public void write(java.io.Writer w) throws java.io.IOException , org.netbeans.modules.j2ee.sun.dd.api.DDException { 64 try { 65 super.write(w); 66 } catch(org.netbeans.modules.schema2beans.Schema2BeansException ex) { 67 DDException ddEx = new DDException(ex.getMessage()); 71 ddEx.setStackTrace(ex.getStackTrace()); 72 throw ddEx; 73 } 74 } 75 76 public void merge(CommonDDBean root, int mode) { 77 ((BaseBean) this).merge((BaseBean) root, mode); 79 } 80 81 84 public CommonDDBean cloneVersion(String version) { 85 97 SunBaseBean bean = null; 98 99 try { 100 Class newBeanClass = getNewBeanClass(version); 102 103 if(this.getClass() == newBeanClass) { 105 return (SunBaseBean) this.clone(); 106 } 107 108 bean = (SunBaseBean) newBeanClass.newInstance(); 109 } catch(Exception e) { 110 throw new IllegalArgumentException (e.getMessage(), e); 112 } 113 114 if (this.graphManager != null && this.graphManager.getBeanRoot() == this) { 116 throw new IllegalArgumentException ("Use setVersion() to change version of root bean " + this.getClass().getName()); 117 } 118 119 String [] attrs = this.getAttributeNames(); 122 if (attrs != null) { 123 for(int j=0; j<attrs.length; j++) { 124 String a = attrs[j]; 125 if (!this.beanProp().getAttrProp(a).isFixed()) { 126 String v = this.getAttributeValue(a); 127 if (bean.getAttributeValue(a) != v) { 128 bean.setAttributeValue(a, v); 129 } 130 } 131 } 132 } 133 134 138 Iterator it = beanPropsIterator(); 139 140 while (it.hasNext()) { 142 BeanProp prop = (BeanProp)it.next(); 143 144 if (prop == null) { 145 continue; 146 } 147 148 String name = prop.getBeanName(); 149 150 if (Common.isArray(prop.type)) { 151 int size = prop.size(); 152 if (Common.isBean(prop.type)) { 153 for(int i=0; i<size; i++) { 154 BaseBean b = (BaseBean)prop.getValue(i); 155 if (b != null) { 156 b = (SunBaseBean) ((SunBaseBean)b).cloneVersion(version); 157 } 158 try { 159 bean.addValue(name, b); 160 } catch(IllegalArgumentException ex) { 161 System.out.println(ex.getMessage()); 163 if(ex.getCause() != null) { 164 System.out.println(ex.getCause().getMessage()); 165 } 166 } 167 } 168 } else { 169 for(int i=0; i<size; i++) { 170 try { 171 bean.addValue(name, prop.getValue(i)); 172 } catch(IllegalArgumentException ex) { 173 System.out.println(ex.getMessage()); 175 if(ex.getCause() != null) { 176 System.out.println(ex.getCause().getMessage()); 177 } 178 } 179 } 180 181 attrs = prop.getAttributeNames(); 183 for(int j=0; j<attrs.length; j++) { 184 String a = attrs[j]; 185 if (!prop.getAttrProp(a).isFixed()) { 186 for(int i=0; i<size; i++) { 187 String v = prop.getAttributeValue(i, a); 188 if (bean.getAttributeValue(name, i, a) != v) { 189 bean.setAttributeValue(name, i, a, v); 190 } 191 } 192 } 193 } 194 } 195 } else { 196 if (Common.isBean(prop.type)) { 197 BaseBean b = (BaseBean)prop.getValue(0); 198 if (b != null) { 199 b = (SunBaseBean) ((SunBaseBean)b).cloneVersion(version); 200 } 201 try { 202 bean.setValue(name, b); 203 } catch(IllegalArgumentException ex) { 204 System.out.println(ex.getMessage()); 206 if(ex.getCause() != null) { 207 System.out.println(ex.getCause().getMessage()); 208 } 209 } 210 } else { 211 try { 212 bean.setValue(name, prop.getValue(0)); 213 } catch(IllegalArgumentException ex) { 214 System.out.println(ex.getMessage()); 216 if(ex.getCause() != null) { 217 System.out.println(ex.getCause().getMessage()); 218 } 219 } 220 221 attrs = prop.getAttributeNames(); 223 for(int j=0; j<attrs.length; j++) { 224 String a = attrs[j]; 225 if (!prop.getAttrProp(a).isFixed()) { 226 String v = prop.getAttributeValue(0, a); 227 if (bean.getAttributeValue(name, 0, a) != v) { 228 bean.setAttributeValue(name, a, v); 229 } 230 } 231 } 232 } 233 } 234 } 235 236 return bean; 237 } 238 239 private Class getNewBeanClass(String version) throws ClassNotFoundException { 240 String oldName = this.getClass().getName(); 241 String className = oldName.substring(oldName.lastIndexOf('.')+1); 242 String key = version + className; 243 String modelPostfix = (String ) commonBeanModelMap.get(key); 244 245 StringBuffer buf = new StringBuffer (128); 246 if(modelPostfix != null) { 247 buf.append("org.netbeans.modules.j2ee.sun.dd.impl.common.model_"); 249 buf.append(modelPostfix); 250 } else { 251 int modelIndex = oldName.indexOf("model_"); 253 buf.append(oldName.substring(0, modelIndex+6)); 254 buf.append(version.charAt(0)); 255 buf.append('_'); 256 buf.append(version.charAt(2)); 257 buf.append('_'); 258 buf.append(version.charAt(3)); 259 } 260 261 buf.append('.'); 262 buf.append(className); 263 String newClass = buf.toString(); 264 return Class.forName(newClass); 265 } 266 267 272 private static Map commonBeanModelMap = new HashMap (471); 273 274 static { 275 commonBeanModelMap.put("1.30EjbRef", "2_1_0"); 277 commonBeanModelMap.put("1.30ResourceRef", "2_1_0"); 278 commonBeanModelMap.put("1.30ResourceEnvRef", "2_1_0"); 279 280 commonBeanModelMap.put("1.40EjbRef", "2_1_0"); 282 commonBeanModelMap.put("1.40ResourceRef", "2_1_0"); 283 commonBeanModelMap.put("1.40ResourceEnvRef", "2_1_0"); 284 commonBeanModelMap.put("1.40ServiceRef", "2_1_1"); 285 commonBeanModelMap.put("1.40LoginConfig", "2_1_1"); 286 commonBeanModelMap.put("1.40MessageDestination", "2_1_1"); 287 288 commonBeanModelMap.put("1.40PortInfo", "2_1_1"); 289 commonBeanModelMap.put("1.40CallProperty", "2_1_1"); 290 commonBeanModelMap.put("1.40StubProperty", "2_1_1"); 291 commonBeanModelMap.put("1.40ServiceQname", "2_1_1"); 292 commonBeanModelMap.put("1.40WsdlPort", "2_1_1"); 293 commonBeanModelMap.put("1.40MessageSecurity", "2_1_1"); 294 commonBeanModelMap.put("1.40MessageSecurityBinding", "2_1_1"); 295 296 commonBeanModelMap.put("1.41EjbRef", "2_1_0"); 298 commonBeanModelMap.put("1.41ResourceRef", "2_1_0"); 299 commonBeanModelMap.put("1.41ResourceEnvRef", "2_1_0"); 300 commonBeanModelMap.put("1.41ServiceRef", "2_1_1"); 301 commonBeanModelMap.put("1.41LoginConfig", "2_1_1"); 302 commonBeanModelMap.put("1.41MessageDestination", "2_1_1"); 303 304 commonBeanModelMap.put("1.41PortInfo", "2_1_1"); 305 commonBeanModelMap.put("1.41CallProperty", "2_1_1"); 306 commonBeanModelMap.put("1.41StubProperty", "2_1_1"); 307 commonBeanModelMap.put("1.41ServiceQname", "2_1_1"); 308 commonBeanModelMap.put("1.41WsdlPort", "2_1_1"); 309 commonBeanModelMap.put("1.41MessageSecurity", "2_1_1"); 310 commonBeanModelMap.put("1.41MessageSecurityBinding", "2_1_1"); 311 312 commonBeanModelMap.put("5.00EjbRef", "2_1_0"); 314 commonBeanModelMap.put("5.00ResourceRef", "2_1_0"); 315 commonBeanModelMap.put("5.00ResourceEnvRef", "2_1_0"); 316 commonBeanModelMap.put("5.00ServiceRef", "2_1_1"); 317 commonBeanModelMap.put("5.00LoginConfig", "2_1_1"); 318 commonBeanModelMap.put("5.00MessageDestination", "2_1_1"); 319 commonBeanModelMap.put("5.00MessageDestinationRef", "3_0_0"); 320 321 commonBeanModelMap.put("5.00PortInfo", "2_1_1"); 322 commonBeanModelMap.put("5.00CallProperty", "2_1_1"); 323 commonBeanModelMap.put("5.00StubProperty", "2_1_1"); 324 commonBeanModelMap.put("5.00ServiceQname", "2_1_1"); 325 commonBeanModelMap.put("5.00WsdlPort", "2_1_1"); 326 commonBeanModelMap.put("5.00MessageSecurity", "2_1_1"); 327 commonBeanModelMap.put("5.00MessageSecurityBinding", "2_1_1"); 328 329 commonBeanModelMap.put("1.30SecurityRoleMapping", "2_1_0"); 331 332 commonBeanModelMap.put("1.40SecurityRoleMapping", "2_1_0"); 334 335 commonBeanModelMap.put("5.00SecurityRoleMapping", "3_0_0"); 337 338 commonBeanModelMap.put("2.00SecurityRoleMapping", "2_1_0"); 340 commonBeanModelMap.put("2.00WebserviceDescription", "2_1_1"); 341 commonBeanModelMap.put("2.00MessageDestination", "2_1_1"); 342 commonBeanModelMap.put("2.00ResourceRef", "2_1_0"); 343 commonBeanModelMap.put("2.00EjbRef", "2_1_0"); 344 commonBeanModelMap.put("2.00ResourceEnvRef", "2_1_0"); 345 commonBeanModelMap.put("2.00ServiceRef", "2_1_1"); 346 commonBeanModelMap.put("2.00LoginConfig", "2_1_1"); 347 commonBeanModelMap.put("2.00WebserviceEndpoint", "2_1_1"); 348 commonBeanModelMap.put("2.00DefaultResourcePrincipal", "2_1_0"); 349 350 commonBeanModelMap.put("3.00PortInfo", "2_1_1"); 351 commonBeanModelMap.put("3.00CallProperty", "2_1_1"); 352 commonBeanModelMap.put("3.00StubProperty", "2_1_1"); 353 commonBeanModelMap.put("3.00ServiceQname", "2_1_1"); 354 commonBeanModelMap.put("3.00WsdlPort", "2_1_1"); 355 commonBeanModelMap.put("3.00MessageSecurity", "2_1_1"); 356 commonBeanModelMap.put("3.00MessageSecurityBinding", "2_1_1"); 357 358 commonBeanModelMap.put("2.10SecurityRoleMapping", "2_1_0"); 360 commonBeanModelMap.put("2.10WebserviceDescription", "2_1_1"); 361 commonBeanModelMap.put("2.10MessageDestination", "2_1_1"); 362 commonBeanModelMap.put("2.10ResourceRef", "2_1_0"); 363 commonBeanModelMap.put("2.10EjbRef", "2_1_0"); 364 commonBeanModelMap.put("2.10ResourceEnvRef", "2_1_0"); 365 commonBeanModelMap.put("2.10ServiceRef", "2_1_1"); 366 commonBeanModelMap.put("2.10LoginConfig", "2_1_1"); 367 commonBeanModelMap.put("2.10WebserviceEndpoint", "2_1_1"); 368 commonBeanModelMap.put("2.10DefaultResourcePrincipal", "2_1_0"); 369 370 commonBeanModelMap.put("2.10PortInfo", "2_1_1"); 371 commonBeanModelMap.put("2.10CallProperty", "2_1_1"); 372 commonBeanModelMap.put("2.10StubProperty", "2_1_1"); 373 commonBeanModelMap.put("2.10ServiceQname", "2_1_1"); 374 commonBeanModelMap.put("2.10WsdlPort", "2_1_1"); 375 commonBeanModelMap.put("2.10MessageSecurity", "2_1_1"); 376 commonBeanModelMap.put("2.10MessageSecurityBinding", "2_1_1"); 377 378 commonBeanModelMap.put("2.11SecurityRoleMapping", "2_1_0"); 380 commonBeanModelMap.put("2.11WebserviceDescription", "2_1_1"); 381 commonBeanModelMap.put("2.11MessageDestination", "2_1_1"); 382 commonBeanModelMap.put("2.11ResourceRef", "2_1_0"); 383 commonBeanModelMap.put("2.11EjbRef", "2_1_0"); 384 commonBeanModelMap.put("2.11ResourceEnvRef", "2_1_0"); 385 commonBeanModelMap.put("2.11ServiceRef", "2_1_1"); 386 commonBeanModelMap.put("2.11LoginConfig", "2_1_1"); 387 commonBeanModelMap.put("2.11WebserviceEndpoint", "2_1_1"); 388 commonBeanModelMap.put("2.11DefaultResourcePrincipal", "2_1_0"); 389 commonBeanModelMap.put("2.11MethodParams", "2_1_1"); 390 391 commonBeanModelMap.put("2.11PortInfo", "2_1_1"); 392 commonBeanModelMap.put("2.11CallProperty", "2_1_1"); 393 commonBeanModelMap.put("2.11StubProperty", "2_1_1"); 394 commonBeanModelMap.put("2.11ServiceQname", "2_1_1"); 395 commonBeanModelMap.put("2.11WsdlPort", "2_1_1"); 396 commonBeanModelMap.put("2.11MessageSecurity", "2_1_1"); 397 commonBeanModelMap.put("2.11MessageSecurityBinding", "2_1_1"); 398 399 commonBeanModelMap.put("3.00SecurityRoleMapping", "3_0_0"); 401 commonBeanModelMap.put("3.00WebserviceDescription", "2_1_1"); 402 commonBeanModelMap.put("3.00MessageDestination", "2_1_1"); 403 commonBeanModelMap.put("3.00ResourceRef", "2_1_0"); 404 commonBeanModelMap.put("3.00EjbRef", "2_1_0"); 405 commonBeanModelMap.put("3.00ResourceEnvRef", "2_1_0"); 406 commonBeanModelMap.put("3.00ServiceRef", "2_1_1"); 407 commonBeanModelMap.put("3.00LoginConfig", "3_0_0"); 408 commonBeanModelMap.put("3.00MessageDestinationRef", "3_0_0"); 409 commonBeanModelMap.put("3.00WebserviceEndpoint", "3_0_0"); 410 commonBeanModelMap.put("3.00DefaultResourcePrincipal", "2_1_0"); 411 commonBeanModelMap.put("3.00MethodParams", "2_1_1"); 412 413 commonBeanModelMap.put("3.00PortInfo", "2_1_1"); 414 commonBeanModelMap.put("3.00CallProperty", "2_1_1"); 415 commonBeanModelMap.put("3.00StubProperty", "2_1_1"); 416 commonBeanModelMap.put("3.00ServiceQname", "2_1_1"); 417 commonBeanModelMap.put("3.00WsdlPort", "2_1_1"); 418 commonBeanModelMap.put("3.00MessageSecurity", "2_1_1"); 419 commonBeanModelMap.put("3.00MessageSecurityBinding", "2_1_1"); 420 421 commonBeanModelMap.put("2.30SecurityRoleMapping", "2_1_0"); 423 commonBeanModelMap.put("2.30ResourceEnvRef", "2_1_0"); 424 commonBeanModelMap.put("2.30ResourceRef", "2_1_0"); 425 commonBeanModelMap.put("2.30EjbRef", "2_1_0"); 426 commonBeanModelMap.put("2.30ServiceRef", "2_1_1"); 427 commonBeanModelMap.put("2.30LoginConfig", "2_1_1"); 428 commonBeanModelMap.put("2.30MessageDestination", "2_1_1"); 429 commonBeanModelMap.put("2.30WebserviceDescription", "2_1_1"); 430 commonBeanModelMap.put("2.30WebserviceEndpoint", "2_1_1"); 431 432 commonBeanModelMap.put("2.30PortInfo", "2_1_1"); 433 commonBeanModelMap.put("2.30CallProperty", "2_1_1"); 434 commonBeanModelMap.put("2.30StubProperty", "2_1_1"); 435 commonBeanModelMap.put("2.30ServiceQname", "2_1_1"); 436 commonBeanModelMap.put("2.30WsdlPort", "2_1_1"); 437 commonBeanModelMap.put("2.30MessageSecurity", "2_1_1"); 438 commonBeanModelMap.put("2.30MessageSecurityBinding", "2_1_1"); 439 440 commonBeanModelMap.put("2.40SecurityRoleMapping", "2_1_0"); 442 commonBeanModelMap.put("2.40EjbRef", "2_1_0"); 443 commonBeanModelMap.put("2.40ResourceRef", "2_1_0"); 444 commonBeanModelMap.put("2.40ResourceEnvRef", "2_1_0"); 445 commonBeanModelMap.put("2.40ServiceRef", "2_1_1"); 446 commonBeanModelMap.put("2.40LoginConfig", "2_1_1"); 447 commonBeanModelMap.put("2.40MessageDestination", "2_1_1"); 448 commonBeanModelMap.put("2.40WebserviceDescription", "2_1_1"); 449 commonBeanModelMap.put("2.40WebserviceEndpoint", "2_1_1"); 450 451 commonBeanModelMap.put("2.40PortInfo", "2_1_1"); 452 commonBeanModelMap.put("2.40CallProperty", "2_1_1"); 453 commonBeanModelMap.put("2.40StubProperty", "2_1_1"); 454 commonBeanModelMap.put("2.40ServiceQname", "2_1_1"); 455 commonBeanModelMap.put("2.40WsdlPort", "2_1_1"); 456 commonBeanModelMap.put("2.40MessageSecurity", "2_1_1"); 457 commonBeanModelMap.put("2.40MessageSecurityBinding", "2_1_1"); 458 459 commonBeanModelMap.put("2.41SecurityRoleMapping", "2_1_0"); 461 commonBeanModelMap.put("2.41EjbRef", "2_1_0"); 462 commonBeanModelMap.put("2.41ResourceRef", "2_1_0"); 463 commonBeanModelMap.put("2.41ResourceEnvRef", "2_1_0"); 464 commonBeanModelMap.put("2.41ServiceRef", "2_1_1"); 465 commonBeanModelMap.put("2.41LoginConfig", "2_1_1"); 466 commonBeanModelMap.put("2.41MessageDestination", "2_1_1"); 467 commonBeanModelMap.put("2.41WebserviceDescription", "2_1_1"); 468 commonBeanModelMap.put("2.41WebserviceEndpoint", "2_1_1"); 469 470 commonBeanModelMap.put("2.41PortInfo", "2_1_1"); 471 commonBeanModelMap.put("2.41CallProperty", "2_1_1"); 472 commonBeanModelMap.put("2.41StubProperty", "2_1_1"); 473 commonBeanModelMap.put("2.41ServiceQname", "2_1_1"); 474 commonBeanModelMap.put("2.41WsdlPort", "2_1_1"); 475 commonBeanModelMap.put("2.41MessageSecurity", "2_1_1"); 476 commonBeanModelMap.put("2.41MessageSecurityBinding", "2_1_1"); 477 478 commonBeanModelMap.put("2.50SecurityRoleMapping", "3_0_0"); 480 commonBeanModelMap.put("2.50EjbRef", "2_1_0"); 481 commonBeanModelMap.put("2.50ResourceRef", "2_1_0"); 482 commonBeanModelMap.put("2.50ResourceEnvRef", "2_1_0"); 483 commonBeanModelMap.put("2.50ServiceRef", "2_1_1"); 484 commonBeanModelMap.put("2.50LoginConfig", "2_1_1"); 485 commonBeanModelMap.put("2.50MessageDestination", "2_1_1"); 486 commonBeanModelMap.put("2.50MessageDestinationRef", "3_0_0"); 487 commonBeanModelMap.put("2.50WebserviceDescription", "2_1_1"); 488 489 commonBeanModelMap.put("2.50PortInfo", "2_1_1"); 490 commonBeanModelMap.put("2.50CallProperty", "2_1_1"); 491 commonBeanModelMap.put("2.50StubProperty", "2_1_1"); 492 commonBeanModelMap.put("2.50ServiceQname", "2_1_1"); 493 commonBeanModelMap.put("2.50WsdlPort", "2_1_1"); 494 commonBeanModelMap.put("2.50MessageSecurity", "2_1_1"); 495 commonBeanModelMap.put("2.50MessageSecurityBinding", "2_1_1"); 496 } 497 } 498 | Popular Tags |