1 19 24 25 package org.netbeans.modules.j2ee.dd.impl.webservices; 26 27 31 import org.netbeans.modules.j2ee.dd.api.webservices.Webservices; 32 33 public class WebServicesProxy implements Webservices { 34 private Webservices webSvc; 35 private String version; 36 private java.util.List listeners; 37 public boolean writing = false; 38 private org.xml.sax.SAXParseException error; 39 private int ddStatus; 40 41 42 public WebServicesProxy(Webservices webService, String version) { 43 this.webSvc = webService; 44 this.version = version; 45 listeners = new java.util.ArrayList (); 46 } 47 48 public void setOriginal(Webservices webSvc) { 49 if (this.webSvc != webSvc) { 50 for (int i=0;i<listeners.size();i++) { 51 java.beans.PropertyChangeListener pcl = 52 (java.beans.PropertyChangeListener )listeners.get(i); 53 if (this.webSvc != null) this.webSvc.removePropertyChangeListener(pcl); 54 if (webSvc != null) webSvc.addPropertyChangeListener(pcl); 55 56 } 57 this.webSvc = webSvc; 58 if (webSvc != null) setProxyVersion(webSvc.getVersion().toString()); 59 } 60 } 61 62 public Webservices getOriginal() { 63 return webSvc; 64 } 65 66 public void setProxyVersion(java.lang.String value) { 67 if ((version == null && value != null) || !version.equals(value)) { 68 java.beans.PropertyChangeEvent evt = 69 new java.beans.PropertyChangeEvent (this, PROPERTY_VERSION, version, value); 70 version = value; 71 for (int i=0;i<listeners.size();i++) { 72 ((java.beans.PropertyChangeListener )listeners.get(i)).propertyChange(evt); 73 } 74 } 75 } 76 77 public org.xml.sax.SAXParseException getError() { 78 return error; 79 } 80 81 public void setError(org.xml.sax.SAXParseException error) { 82 this.error = error; 83 } 84 85 public int getStatus() { 86 return ddStatus; 87 } 88 89 public void setStatus(int value) { 90 if (ddStatus != value) { 91 java.beans.PropertyChangeEvent evt = 92 new java.beans.PropertyChangeEvent (this, PROPERTY_STATUS, new Integer (ddStatus), new Integer (value)); 93 ddStatus = value; 94 for (int i=0;i<listeners.size();i++) { 95 ((java.beans.PropertyChangeListener )listeners.get(i)).propertyChange(evt); 96 } 97 } 98 } 99 100 public java.math.BigDecimal getVersion() { 101 return new java.math.BigDecimal (version); 102 } 103 104 public int addWebserviceDescription(org.netbeans.modules.j2ee.dd.api.webservices.WebserviceDescription value) { 105 if(webSvc == null) 106 return -1; 107 else 108 return webSvc.addWebserviceDescription(value); 109 } 110 111 112 public org.netbeans.modules.j2ee.dd.api.webservices.WebserviceDescription[] getWebserviceDescription() { 113 if(webSvc == null) 114 return new org.netbeans.modules.j2ee.dd.api.webservices.WebserviceDescription[0]; 115 else 116 return webSvc.getWebserviceDescription(); 117 } 118 119 public org.netbeans.modules.j2ee.dd.api.webservices.WebserviceDescription getWebserviceDescription(int index) { 120 if(webSvc == null) 121 return null; 122 else 123 return webSvc.getWebserviceDescription(index); 124 } 125 126 public org.netbeans.modules.j2ee.dd.api.webservices.WebserviceDescription newWebserviceDescription() { 127 if(webSvc == null) 128 return null; 129 else 130 return webSvc.newWebserviceDescription(); 131 } 132 133 public int removeWebserviceDescription(org.netbeans.modules.j2ee.dd.api.webservices.WebserviceDescription value) { 134 if(webSvc == null) 135 return -1; 136 else 137 return webSvc.removeWebserviceDescription(value); 138 } 139 140 public void setWebserviceDescription(org.netbeans.modules.j2ee.dd.api.webservices.WebserviceDescription[] value) { 141 if(webSvc != null){ 142 webSvc.setWebserviceDescription(value); 143 } 144 } 145 146 public void setWebserviceDescription(int index, org.netbeans.modules.j2ee.dd.api.webservices.WebserviceDescription value) { 147 if(webSvc != null){ 148 webSvc.setWebserviceDescription(index, value); 149 } 150 } 151 152 public int sizeWebserviceDescription() { 153 if(webSvc == null) 154 return 0; 155 else 156 return webSvc.sizeWebserviceDescription(); 157 } 158 159 160 public Object getValue(String name) { 161 if(webSvc == null) 162 return null; 163 else 164 return webSvc.getValue(name); 165 } 166 167 public java.lang.String getId() { 168 if(webSvc == null) 169 return null; 170 else 171 return webSvc.getId(); 172 } 173 174 public void setId(java.lang.String value) { 175 if(webSvc != null) { 176 webSvc.setId(value); 177 } 178 } 179 180 public java.util.Map getAllDescriptions() { 181 return webSvc==null?new java.util.HashMap ():webSvc.getAllDescriptions(); 182 } 183 184 public String getDescription(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 185 return webSvc==null?null:webSvc.getDescription(locale); 186 } 187 188 public String getDefaultDescription() { 189 return webSvc==null?null:webSvc.getDefaultDescription(); 190 } 191 192 public java.util.Map getAllDisplayNames() { 193 return webSvc==null?new java.util.HashMap ():webSvc.getAllDisplayNames(); 194 } 195 196 public String getDefaultDisplayName() { 197 return webSvc==null?null:webSvc.getDefaultDisplayName(); 198 } 199 200 public String getDisplayName(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 201 return webSvc==null?null:webSvc.getDisplayName(locale); 202 } 203 204 public org.netbeans.modules.j2ee.dd.api.common.Icon getDefaultIcon() { 205 return webSvc==null?null:webSvc.getDefaultIcon(); 206 } 207 208 public java.util.Map getAllIcons() { 209 return webSvc==null?new java.util.HashMap ():webSvc.getAllIcons(); 210 } 211 212 public String getLargeIcon() { 213 return webSvc==null?null:webSvc.getLargeIcon(); 214 } 215 216 public String getLargeIcon(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 217 return webSvc==null?null:webSvc.getLargeIcon(locale); 218 } 219 220 public String getSmallIcon() { 221 return webSvc==null?null:webSvc.getSmallIcon(); 222 } 223 224 public String getSmallIcon(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 225 return webSvc==null?null:webSvc.getSmallIcon(locale); 226 } 227 228 public void removeAllDescriptions() { 229 if (webSvc!=null) webSvc.removeAllDescriptions(); 230 } 231 232 public void removeDescription() { 233 if (webSvc!=null) webSvc.removeDescription(); 234 } 235 236 public void removeDescriptionForLocale(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 237 if (webSvc!=null) webSvc.removeDescriptionForLocale(locale); 238 } 239 240 public void removeAllDisplayNames() { 241 if (webSvc!=null) webSvc.removeAllDisplayNames(); 242 } 243 244 public void removeDisplayName() { 245 if (webSvc!=null) webSvc.removeDisplayName(); 246 } 247 248 public void removeDisplayNameForLocale(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 249 if (webSvc!=null) webSvc.removeDisplayNameForLocale(locale); 250 } 251 252 public void removeAllIcons() { 253 if (webSvc!=null) webSvc.removeAllIcons(); 254 } 255 256 public void removeIcon() { 257 if (webSvc!=null) webSvc.removeIcon(); 258 } 259 260 public void removeIcon(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 261 if (webSvc!=null) webSvc.removeIcon(locale); 262 } 263 264 public void removeLargeIcon() { 265 if (webSvc!=null) webSvc.removeLargeIcon(); 266 } 267 268 public void removeLargeIcon(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 269 if (webSvc!=null) webSvc.removeLargeIcon(locale); 270 } 271 272 public void removeSmallIcon() { 273 if (webSvc!=null) webSvc.removeSmallIcon(); 274 } 275 276 public void removeSmallIcon(String locale) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 277 if (webSvc!=null) webSvc.removeSmallIcon(locale); 278 } 279 280 public void setAllDescriptions(java.util.Map descriptions) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 281 if (webSvc!=null) webSvc.setAllDescriptions(descriptions); 282 } 283 284 public void setDescription(String description) { 285 if (webSvc!=null) webSvc.setDescription(description); 286 } 287 288 public void setDescription(String locale, String description) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 289 if (webSvc!=null) webSvc.setDescription(locale, description); 290 } 291 292 public void setAllDisplayNames(java.util.Map displayNames) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 293 if (webSvc!=null) webSvc.setAllDisplayNames(displayNames); 294 } 295 296 public void setDisplayName(String displayName) { 297 if (webSvc!=null) webSvc.setDisplayName(displayName); 298 } 299 300 public void setDisplayName(String locale, String displayName) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 301 if (webSvc!=null) webSvc.setDisplayName(locale, displayName); 302 } 303 304 public void setAllIcons(String [] locales, String [] smallIcons, String [] largeIcons) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 305 if (webSvc!=null) webSvc.setAllIcons(locales, smallIcons, largeIcons); 306 } 307 308 public void setLargeIcon(String icon) { 309 if (webSvc!=null) webSvc.setLargeIcon(icon); 310 } 311 312 public void setLargeIcon(String locale, String icon) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 313 if (webSvc!=null) webSvc.setLargeIcon(locale, icon); 314 } 315 316 public void setSmallIcon(String icon) { 317 if (webSvc!=null) webSvc.setSmallIcon(icon); 318 } 319 320 public void setSmallIcon(String locale, String icon) throws org.netbeans.modules.j2ee.dd.api.common.VersionNotSupportedException { 321 if (webSvc!=null) webSvc.setSmallIcon(locale, icon); 322 } 323 324 public void setIcon(org.netbeans.modules.j2ee.dd.api.common.Icon icon) { 325 if (webSvc!=null) webSvc.setIcon(icon); 326 } 327 328 public org.netbeans.modules.j2ee.dd.api.common.CommonDDBean addBean(String beanName, String [] propertyNames, Object [] propertyValues, String keyProperty) throws ClassNotFoundException , org.netbeans.modules.j2ee.dd.api.common.NameAlreadyUsedException { 329 return webSvc==null?null:webSvc.addBean(beanName, propertyNames, propertyValues, keyProperty); 330 } 331 332 public org.netbeans.modules.j2ee.dd.api.common.CommonDDBean addBean(String beanName) throws ClassNotFoundException { 333 return webSvc==null?null:webSvc.addBean(beanName); 334 } 335 336 public org.netbeans.modules.j2ee.dd.api.common.CommonDDBean createBean(String beanName) throws ClassNotFoundException { 337 return webSvc==null?null:webSvc.createBean(beanName); 338 } 339 340 public org.netbeans.modules.j2ee.dd.api.common.CommonDDBean findBeanByName(String beanName, String propertyName, String value) { 341 return webSvc==null?null:webSvc.findBeanByName(beanName, propertyName, value); 342 } 343 344 public void addPropertyChangeListener(java.beans.PropertyChangeListener pcl) { 345 if (webSvc != null) { 346 webSvc.addPropertyChangeListener(pcl); 347 } 348 listeners.add(pcl); 349 } 350 351 public void removePropertyChangeListener(java.beans.PropertyChangeListener pcl) { 352 if (webSvc != null) { 353 webSvc.removePropertyChangeListener(pcl); 354 } 355 listeners.remove(pcl); 356 } 357 358 public void merge(org.netbeans.modules.j2ee.dd.api.common.RootInterface bean, int mode) { 359 if (webSvc != null) { 360 if (bean instanceof WebServicesProxy) 361 webSvc.merge(((WebServicesProxy)bean).getOriginal(), mode); 362 else webSvc.merge(bean, mode); 363 } 364 } 365 366 public void write(java.io.OutputStream os) throws java.io.IOException { 367 if (webSvc != null) { 368 writing = true; 369 if (webSvc instanceof org.netbeans.modules.j2ee.dd.impl.webservices.model_1_1.Webservices) { 370 org.netbeans.modules.j2ee.dd.impl.webservices.model_1_1.Webservices webSvcImpl = 371 (org.netbeans.modules.j2ee.dd.impl.webservices.model_1_1.Webservices)webSvc; 372 if (webSvcImpl._getSchemaLocation()==null) { 373 webSvcImpl._setSchemaLocation("http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd"); } 375 } else if (webSvc instanceof org.netbeans.modules.j2ee.dd.impl.webservices.model_1_2.Webservices) { 376 org.netbeans.modules.j2ee.dd.impl.webservices.model_1_2.Webservices webSvcImpl = 377 (org.netbeans.modules.j2ee.dd.impl.webservices.model_1_2.Webservices)webSvc; 378 if (webSvcImpl._getSchemaLocation()==null) { 379 webSvcImpl._setSchemaLocation("http://java.sun.com/xml/ns/javaee http://www.ibm.com/webservices/xsd/javaee_web_services_1_2.xsd"); } 381 } 382 webSvc.write(os); 383 } 384 } 385 386 public void write(org.openide.filesystems.FileObject fo) throws java.io.IOException { 387 if (webSvc != null) { 388 try { 389 org.openide.filesystems.FileLock lock = fo.lock(); 390 try { 391 java.io.OutputStream os = fo.getOutputStream(lock); 392 try { 393 writing = true; 394 write(os); 395 } finally { 396 os.close(); 397 } 398 } 399 finally { 400 lock.releaseLock(); 401 } 402 } catch (org.openide.filesystems.FileAlreadyLockedException ex) { 403 org.openide.loaders.DataObject dobj = org.openide.loaders.DataObject.find(fo); 405 if (dobj != null && dobj instanceof WebServicesProxy.OutputProvider) 406 ((WebServicesProxy.OutputProvider)dobj).write(this); 407 else 408 throw ex; 409 } 410 } 411 } 412 413 public Object clone() { 414 WebServicesProxy proxy = null; 415 if (webSvc == null) 416 proxy = new WebServicesProxy(null, version); 417 else { 418 Webservices clonedWebSvc = (Webservices)webSvc.clone(); 419 proxy = new WebServicesProxy(clonedWebSvc, version); 420 if (Webservices.VERSION_1_1.equals(version)) { 421 ((org.netbeans.modules.j2ee.dd.impl.webservices.model_1_1.Webservices)clonedWebSvc)._setSchemaLocation 422 ("http://java.sun.com/xml/ns/j2ee http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd"); } else if (Webservices.VERSION_1_2.equals(version)) { 424 ((org.netbeans.modules.j2ee.dd.impl.webservices.model_1_2.Webservices)clonedWebSvc)._setSchemaLocation 425 ("http://java.sun.com/xml/ns/javaee http://www.ibm.com/webservices/xsd/javaee_web_services_1_2.xsd"); } 427 } 428 proxy.setError(error); 429 proxy.setStatus(ddStatus); 430 return proxy; 431 } 432 433 436 public static interface OutputProvider { 437 public void write(Webservices webSvc) throws java.io.IOException ; 438 public org.openide.filesystems.FileObject getTarget(); 439 } 440 } 441 | Popular Tags |