1 19 25 26 package org.netbeans.modules.j2ee.sun.dd.impl.client; 27 28 import java.beans.PropertyChangeListener ; 29 import java.io.IOException ; 30 import java.io.OutputStream ; 31 import java.io.Writer ; 32 import java.math.BigDecimal ; 33 import org.netbeans.modules.j2ee.sun.dd.api.CommonDDBean; 34 import org.netbeans.modules.j2ee.sun.dd.api.DDException; 35 import org.netbeans.modules.j2ee.sun.dd.api.client.JavaWebStartAccess; 36 import org.netbeans.modules.j2ee.sun.dd.api.client.SunApplicationClient; 37 import org.netbeans.modules.j2ee.sun.dd.api.common.EjbRef; 38 import org.netbeans.modules.j2ee.sun.dd.api.common.MessageDestination; 39 import org.netbeans.modules.j2ee.sun.dd.api.common.MessageDestinationRef; 40 import org.netbeans.modules.j2ee.sun.dd.api.common.ResourceEnvRef; 41 import org.netbeans.modules.j2ee.sun.dd.api.common.ResourceRef; 42 import org.netbeans.modules.j2ee.sun.dd.api.common.ServiceRef; 43 import org.netbeans.modules.j2ee.sun.dd.api.VersionNotSupportedException; 44 45 import org.w3c.dom.Document ; 46 import org.netbeans.modules.j2ee.sun.dd.impl.DTDRegistry; 47 import org.netbeans.modules.j2ee.sun.dd.impl.DDTreeWalker; 48 49 53 public class SunApplicationClientProxy implements SunApplicationClient { 54 55 private SunApplicationClient appClientRoot; 56 private String version; 57 private OutputProvider outputProvider; 58 private int ddStatus; 59 private org.xml.sax.SAXParseException error; 60 private java.util.List listeners; 61 62 63 public SunApplicationClientProxy(SunApplicationClient appClientRoot, String version) { 64 this.appClientRoot = appClientRoot; 65 this.version = version; 66 } 67 68 public void setEjbRef(int index, EjbRef value) { 69 if (appClientRoot != null) appClientRoot.setEjbRef(index, value); 70 } 71 72 public EjbRef getEjbRef(int index) { 73 return appClientRoot == null?null:appClientRoot.getEjbRef(index); 74 } 75 76 public int sizeEjbRef() { 77 return appClientRoot == null?-1:appClientRoot.sizeEjbRef(); 78 } 79 80 public void setEjbRef(EjbRef[] value) { 81 if (appClientRoot != null) appClientRoot.setEjbRef(value); 82 } 83 84 public EjbRef[] getEjbRef() { 85 return appClientRoot == null?null:appClientRoot.getEjbRef(); 86 } 87 88 public int addEjbRef(EjbRef value) { 89 return appClientRoot == null?-1:appClientRoot.addEjbRef(value); 90 } 91 92 public int removeEjbRef(EjbRef value) { 93 return appClientRoot == null?-1:appClientRoot.removeEjbRef(value); 94 } 95 96 public EjbRef newEjbRef() { 97 return appClientRoot == null?null:appClientRoot.newEjbRef(); 98 } 99 100 public void setResourceRef(int index, ResourceRef value) { 101 if (appClientRoot != null) appClientRoot.setResourceRef(index, value); 102 } 103 104 public ResourceRef getResourceRef(int index) { 105 return appClientRoot == null?null:appClientRoot.getResourceRef(index); 106 } 107 108 public int sizeResourceRef() { 109 return appClientRoot == null?-1:appClientRoot.sizeResourceRef(); 110 } 111 112 public void setResourceRef(ResourceRef[] value) { 113 if (appClientRoot != null) appClientRoot.setResourceRef(value); 114 } 115 116 public ResourceRef[] getResourceRef() { 117 return appClientRoot == null?null:appClientRoot.getResourceRef(); 118 } 119 120 public int addResourceRef(ResourceRef value) { 121 return appClientRoot == null?-1:appClientRoot.addResourceRef(value); 122 } 123 124 public int removeResourceRef(ResourceRef value) { 125 return appClientRoot == null?-1:appClientRoot.removeResourceRef(value); 126 } 127 128 public ResourceRef newResourceRef() { 129 return appClientRoot == null?null:appClientRoot.newResourceRef(); 130 } 131 132 public void setResourceEnvRef(int index, ResourceEnvRef value) { 133 if (appClientRoot != null) appClientRoot.setResourceEnvRef(index, value); 134 } 135 136 public ResourceEnvRef getResourceEnvRef(int index) { 137 return appClientRoot == null?null:appClientRoot.getResourceEnvRef(index); 138 } 139 140 public int sizeResourceEnvRef() { 141 return appClientRoot == null?-1:appClientRoot.sizeResourceEnvRef(); 142 } 143 144 public void setResourceEnvRef(ResourceEnvRef[] value) { 145 if (appClientRoot != null) appClientRoot.setResourceEnvRef(value); 146 } 147 148 public ResourceEnvRef[] getResourceEnvRef() { 149 return appClientRoot == null?null:appClientRoot.getResourceEnvRef(); 150 } 151 152 public int addResourceEnvRef(ResourceEnvRef value) { 153 return appClientRoot == null?-1:appClientRoot.addResourceEnvRef(value); 154 } 155 156 public int removeResourceEnvRef(ResourceEnvRef value) { 157 return appClientRoot == null?-1:appClientRoot.removeResourceEnvRef(value); 158 } 159 160 public ResourceEnvRef newResourceEnvRef() { 161 return appClientRoot == null?null:appClientRoot.newResourceEnvRef(); 162 } 163 164 public void setServiceRef(int index, ServiceRef value) { 165 if (appClientRoot != null) appClientRoot.setServiceRef(index, value); 166 } 167 168 public ServiceRef getServiceRef(int index) { 169 return appClientRoot == null?null:appClientRoot.getServiceRef(index); 170 } 171 172 public int sizeServiceRef() { 173 return appClientRoot == null?-1:appClientRoot.sizeServiceRef(); 174 } 175 176 public void setServiceRef(ServiceRef[] value) { 177 if (appClientRoot != null) appClientRoot.setServiceRef(value); 178 } 179 180 public ServiceRef[] getServiceRef() { 181 return appClientRoot == null?null:appClientRoot.getServiceRef(); 182 } 183 184 public int addServiceRef(ServiceRef value) { 185 return appClientRoot == null?-1:appClientRoot.addServiceRef(value); 186 } 187 188 public int removeServiceRef(ServiceRef value) { 189 return appClientRoot == null?-1:appClientRoot.removeServiceRef(value); 190 } 191 192 public ServiceRef newServiceRef() { 193 return appClientRoot == null?null:appClientRoot.newServiceRef(); 194 } 195 196 public void setMessageDestinationRef(int index, MessageDestinationRef value) throws VersionNotSupportedException { 197 if (appClientRoot != null) appClientRoot.setMessageDestinationRef(index, value); 198 } 199 200 public MessageDestinationRef getMessageDestinationRef(int index) throws VersionNotSupportedException { 201 return appClientRoot == null?null:appClientRoot.getMessageDestinationRef(index); 202 } 203 204 public int sizeMessageDestinationRef() throws VersionNotSupportedException { 205 return appClientRoot == null?-1:appClientRoot.sizeMessageDestinationRef(); 206 } 207 208 public void setMessageDestinationRef(MessageDestinationRef[] value) throws VersionNotSupportedException { 209 if (appClientRoot != null) appClientRoot.setMessageDestinationRef(value); 210 } 211 212 public MessageDestinationRef[] getMessageDestinationRef() throws VersionNotSupportedException { 213 return appClientRoot == null?null:appClientRoot.getMessageDestinationRef(); 214 } 215 216 public int addMessageDestinationRef(MessageDestinationRef value) throws VersionNotSupportedException { 217 return appClientRoot == null?-1:appClientRoot.addMessageDestinationRef(value); 218 } 219 220 public int removeMessageDestinationRef(MessageDestinationRef value) throws VersionNotSupportedException { 221 return appClientRoot == null?-1:appClientRoot.removeMessageDestinationRef(value); 222 } 223 224 public MessageDestinationRef newMessageDestinationRef() throws VersionNotSupportedException { 225 return appClientRoot == null?null:appClientRoot.newMessageDestinationRef(); 226 } 227 228 public void setMessageDestination(int index, MessageDestination value) { 229 if (appClientRoot != null) appClientRoot.setMessageDestination(index, value); 230 } 231 232 public MessageDestination getMessageDestination(int index) { 233 return appClientRoot == null?null:appClientRoot.getMessageDestination(index); 234 } 235 236 public int sizeMessageDestination() { 237 return appClientRoot == null?-1:appClientRoot.sizeMessageDestination(); 238 } 239 240 public void setMessageDestination(MessageDestination[] value) { 241 if (appClientRoot != null) appClientRoot.setMessageDestination(value); 242 } 243 244 public MessageDestination[] getMessageDestination() { 245 return appClientRoot == null?null:appClientRoot.getMessageDestination(); 246 } 247 248 public int addMessageDestination(MessageDestination value) { 249 return appClientRoot == null?-1:appClientRoot.addMessageDestination(value); 250 } 251 252 public int removeMessageDestination(MessageDestination value) { 253 return appClientRoot == null?-1:appClientRoot.removeMessageDestination(value); 254 } 255 256 public MessageDestination newMessageDestination() { 257 return appClientRoot == null?null:appClientRoot.newMessageDestination(); 258 } 259 260 public void setJavaWebStartAccess(JavaWebStartAccess value) throws VersionNotSupportedException { 261 if (appClientRoot != null) appClientRoot.setJavaWebStartAccess(value); 262 } 263 264 public JavaWebStartAccess getJavaWebStartAccess() throws VersionNotSupportedException { 265 return appClientRoot == null?null:appClientRoot.getJavaWebStartAccess(); 266 } 267 268 public JavaWebStartAccess newJavaWebStartAccess() throws VersionNotSupportedException { 269 return appClientRoot == null?null:appClientRoot.newJavaWebStartAccess(); 270 } 271 272 public void setVersion(BigDecimal version) { 273 String newVersion = version.toString(); 274 String currentVersion = null; 275 if (this.version.equals(newVersion)) 276 return; 277 if (appClientRoot != null) { 278 Document document = null; 279 if (appClientRoot instanceof org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_3_0.SunApplicationClient) { 280 document = 281 ((org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_3_0.SunApplicationClient)appClientRoot).graphManager().getXmlDocument(); 282 currentVersion = SunApplicationClient.VERSION_1_3_0; 283 }else if (appClientRoot instanceof org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_4_0.SunApplicationClient) { 284 document = 285 ((org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_4_0.SunApplicationClient)appClientRoot).graphManager().getXmlDocument(); 286 currentVersion = SunApplicationClient.VERSION_1_4_0; 287 }else if (appClientRoot instanceof org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_4_1.SunApplicationClient) { 288 document = 289 ((org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_4_1.SunApplicationClient)appClientRoot).graphManager().getXmlDocument(); 290 currentVersion = SunApplicationClient.VERSION_1_4_1; 291 }else if (appClientRoot instanceof org.netbeans.modules.j2ee.sun.dd.impl.client.model_5_0_0.SunApplicationClient) { 292 document = 293 ((org.netbeans.modules.j2ee.sun.dd.impl.client.model_5_0_0.SunApplicationClient)appClientRoot).graphManager().getXmlDocument(); 294 currentVersion = SunApplicationClient.VERSION_5_0_0; 295 } 296 297 document = removeDocType(document); 299 300 if(newVersion.equals(SunApplicationClient.VERSION_5_0_0)){ 301 generate5_00Graph(document); 303 } 304 if(newVersion.equals(SunApplicationClient.VERSION_1_4_1)){ 305 if(currentVersion.equals(SunApplicationClient.VERSION_1_4_0) || currentVersion.equals(SunApplicationClient.VERSION_1_3_0)) 306 generate1_41Graph(document); 307 else 308 downgradeClientJarGraph(document, newVersion, currentVersion); 309 } 310 if(newVersion.equals(SunApplicationClient.VERSION_1_4_0)){ 311 if(currentVersion.equals(SunApplicationClient.VERSION_1_3_0)) 312 generate1_40Graph(document); 313 else 314 downgradeClientJarGraph(document, newVersion, currentVersion); 315 } 316 if(newVersion.equals(SunApplicationClient.VERSION_1_3_0)){ 317 downgradeClientJarGraph(document, newVersion, currentVersion); 319 } 320 } 321 } 322 323 private void downgradeClientJarGraph(Document document, String downgradeVersion, String currentVersion){ 324 DDTreeWalker downgradeScanner = new DDTreeWalker(document, downgradeVersion, currentVersion); 325 downgradeScanner.downgradeSunClientDocument(); 326 if(downgradeVersion.equals(SunApplicationClient.VERSION_1_4_1)){ 327 generate1_41Graph(document); 328 }else if(downgradeVersion.equals(SunApplicationClient.VERSION_1_4_0)){ 329 generate1_40Graph(document); 330 }else if(downgradeVersion.equals(SunApplicationClient.VERSION_1_3_0)){ 331 generate1_30Graph(document); 332 } 333 } 334 335 private void generate5_00Graph(Document document){ 336 org.netbeans.modules.j2ee.sun.dd.impl.client.model_5_0_0.SunApplicationClient appClientGraph = 337 org.netbeans.modules.j2ee.sun.dd.impl.client.model_5_0_0.SunApplicationClient.createGraph(document); 338 appClientGraph.changeDocType(DTDRegistry.SUN_APPCLIENT_50_DTD_PUBLIC_ID, DTDRegistry.SUN_APPCLIENT_50_DTD_SYSTEM_ID); 339 this.appClientRoot = appClientGraph; 340 } 341 342 private void generate1_41Graph(Document document){ 343 org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_4_1.SunApplicationClient appClientGraph = 344 org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_4_1.SunApplicationClient.createGraph(document); 345 appClientGraph.changeDocType(DTDRegistry.SUN_APPCLIENT_141_DTD_PUBLIC_ID, DTDRegistry.SUN_APPCLIENT_141_DTD_SYSTEM_ID); 346 this.appClientRoot = appClientGraph; 347 } 348 349 private void generate1_40Graph(Document document){ 350 org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_4_0.SunApplicationClient appClientGraph = 351 org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_4_0.SunApplicationClient.createGraph(document); 352 appClientGraph.changeDocType(DTDRegistry.SUN_APPCLIENT_140_DTD_PUBLIC_ID, DTDRegistry.SUN_APPCLIENT_140_DTD_SYSTEM_ID); 353 this.appClientRoot = appClientGraph; 354 } 355 356 private void generate1_30Graph(Document document){ 357 org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_3_0.SunApplicationClient appClientGraph = 358 org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_3_0.SunApplicationClient.createGraph(document); 359 appClientGraph.changeDocType(DTDRegistry.SUN_APPCLIENT_130_DTD_PUBLIC_ID, DTDRegistry.SUN_APPCLIENT_130_DTD_SYSTEM_ID); 360 this.appClientRoot = appClientGraph; 361 } 362 363 public BigDecimal getVersion() { 364 return new java.math.BigDecimal (version); 365 } 366 367 private Document getDocument(){ 368 Document document = null; 369 if (appClientRoot instanceof org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_3_0.SunApplicationClient) { 370 document = 371 ((org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_3_0.SunApplicationClient)appClientRoot).graphManager().getXmlDocument(); 372 }else if (appClientRoot instanceof org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_4_0.SunApplicationClient) { 373 document = 374 ((org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_4_0.SunApplicationClient)appClientRoot).graphManager().getXmlDocument(); 375 }else if (appClientRoot instanceof org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_4_1.SunApplicationClient) { 376 document = 377 ((org.netbeans.modules.j2ee.sun.dd.impl.client.model_1_4_1.SunApplicationClient)appClientRoot).graphManager().getXmlDocument(); 378 }else if (appClientRoot instanceof org.netbeans.modules.j2ee.sun.dd.impl.client.model_5_0_0.SunApplicationClient) { 379 document = 380 ((org.netbeans.modules.j2ee.sun.dd.impl.client.model_5_0_0.SunApplicationClient)appClientRoot).graphManager().getXmlDocument(); 381 } 382 return document; 383 } 384 385 private Document removeDocType(Document document){ 386 if (document != null) { 387 org.w3c.dom.Element docElement = document.getDocumentElement(); 388 if (docElement != null) { 389 org.w3c.dom.DocumentType docType = document.getDoctype(); 390 if (docType != null) { 391 document.removeChild(docType); } 393 } 394 } 395 return document; 396 } 397 public void merge(CommonDDBean root, int mode) { 398 if (appClientRoot != null) { 399 if (root instanceof SunApplicationClientProxy) 400 appClientRoot.merge(((SunApplicationClientProxy)root).getOriginal(), mode); 401 else appClientRoot.merge(root, mode); 402 } 403 } 404 405 public CommonDDBean cloneVersion(String version) { 406 return appClientRoot == null ? null : appClientRoot.cloneVersion(version); 407 } 408 409 public SunApplicationClient getOriginal() { 410 return appClientRoot; 411 } 412 413 public void addPropertyChangeListener(PropertyChangeListener pcl) { 414 if (appClientRoot != null) 415 appClientRoot.addPropertyChangeListener(pcl); 416 listeners.add(pcl); 417 } 418 419 public void removePropertyChangeListener(PropertyChangeListener pcl) { 420 if (appClientRoot != null) 421 appClientRoot.removePropertyChangeListener(pcl); 422 listeners.remove(pcl); 423 } 424 425 public Object getValue(String propertyName) { 426 return appClientRoot == null?null:appClientRoot.getValue(propertyName); 427 } 428 429 public Object [] getValues(String name) { 430 return appClientRoot == null?null:appClientRoot.getValues(name); 431 } 432 433 public Object getValue(String name, int index) { 434 return appClientRoot == null?null:appClientRoot.getValue(name, index); 435 } 436 437 public void setValue(String name, Object value) { 438 if (appClientRoot != null) appClientRoot.setValue(name, value); 439 } 440 441 public void setValue(String name, Object [] value) { 442 if (appClientRoot != null) appClientRoot.setValue(name, value); 443 } 444 445 public void setValue(String name, int index, Object value) { 446 if (appClientRoot != null) appClientRoot.setValue(name, index, value); 447 } 448 449 public String getAttributeValue(String name) { 450 return appClientRoot == null?null:appClientRoot.getAttributeValue(name); 451 } 452 453 public String getAttributeValue(String propName, String name) { 454 return appClientRoot == null?null:appClientRoot.getAttributeValue(propName, name); 455 } 456 457 public String getAttributeValue(String propName, int index, String name) { 458 return appClientRoot == null?null:appClientRoot.getAttributeValue(propName, index, name); 459 } 460 461 public void setAttributeValue(String name, String value) { 462 if (appClientRoot != null) appClientRoot.setAttributeValue(name, value); 463 } 464 465 public void setAttributeValue(String propName, int index, String name, String value) { 466 if (appClientRoot != null) appClientRoot.setAttributeValue(propName, index, name, value); 467 } 468 469 public void setAttributeValue(String propName, String name, String value) { 470 if (appClientRoot != null) appClientRoot.setAttributeValue(propName, name, value); 471 } 472 473 public String [] findPropertyValue(String propName, Object value) { 474 return appClientRoot == null?null:appClientRoot.findPropertyValue(propName, value); 475 } 476 477 public int addValue(String name, Object value) { 478 return appClientRoot == null?-1:appClientRoot.addValue(name, value); 479 } 480 481 public int removeValue(String name, Object value) { 482 return appClientRoot == null?-1:appClientRoot.removeValue(name, value); 483 } 484 485 public void removeValue(String name, int index) { 486 if (appClientRoot != null) appClientRoot.removeValue(name, index); 487 } 488 489 public void write(OutputStream os) throws IOException { 490 if (appClientRoot != null) { 491 appClientRoot.write(os); 492 } 493 } 494 495 public void write(Writer w) throws IOException , DDException { 496 if (appClientRoot != null) appClientRoot.write(w); 497 } 498 499 public String dumpBeanNode() { 500 if (appClientRoot != null) 501 return appClientRoot.dumpBeanNode(); 502 else 503 return null; 504 } 505 506 public CommonDDBean getPropertyParent(String name) { 507 return appClientRoot.getPropertyParent(name); 508 } 509 510 public Object clone() { 511 SunApplicationClientProxy proxy = null; 512 if (appClientRoot == null) 513 proxy = new SunApplicationClientProxy(null, version); 514 else { 515 SunApplicationClient clonedSunAppClient=(SunApplicationClient)appClientRoot.clone(); 516 proxy = new SunApplicationClientProxy(clonedSunAppClient, version); 517 } 518 proxy.setError(error); 519 return proxy; 520 } 521 522 public org.xml.sax.SAXParseException getError() { 523 return error; 524 } 525 public void setError(org.xml.sax.SAXParseException error) { 526 this.error=error; 527 } 528 529 public int size(String name) { 530 return appClientRoot == null?-1:appClientRoot.size(name); 531 } 532 535 public static interface OutputProvider { 536 public void write(SunApplicationClient appClientRoot) throws java.io.IOException ; 537 } 538 539 } 540 | Popular Tags |