1 19 20 23 24 package org.netbeans.modules.j2ee.sun.ws7.dm; 25 26 import java.util.List ; 27 import java.util.Map ; 28 import java.io.InputStream ; 29 import java.io.File ; 30 import java.util.Locale ; 31 import java.lang.reflect.Method ; 32 import java.lang.reflect.InvocationTargetException ; 33 34 import javax.enterprise.deploy.model.DeployableObject ; 35 import javax.enterprise.deploy.spi.Target ; 36 import javax.enterprise.deploy.spi.TargetModuleID ; 37 import javax.enterprise.deploy.spi.status.ProgressObject ; 38 import javax.enterprise.deploy.spi.status.ProgressListener ; 39 import javax.enterprise.deploy.spi.status.ProgressEvent ; 40 import javax.enterprise.deploy.spi.status.DeploymentStatus ; 41 import javax.enterprise.deploy.shared.DConfigBeanVersionType ; 42 import javax.enterprise.deploy.spi.exceptions.DConfigBeanVersionUnsupportedException ; 43 import javax.enterprise.deploy.spi.DeploymentManager ; 44 import javax.enterprise.deploy.spi.DeploymentConfiguration ; 45 import javax.enterprise.deploy.shared.ModuleType ; 46 import javax.enterprise.deploy.spi.exceptions.InvalidModuleException ; 47 import javax.enterprise.deploy.spi.exceptions.TargetException ; 48 import javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException ; 49 import javax.enterprise.deploy.spi.factories.DeploymentFactory ; 50 import org.netbeans.modules.j2ee.deployment.plugins.api.InstanceProperties; 51 52 53 import java.io.*; 54 import org.netbeans.modules.j2ee.sun.share.configbean.SunONEDeploymentConfiguration; 55 import org.netbeans.modules.j2ee.sun.dd.api.DDProvider; 56 import org.netbeans.modules.j2ee.sun.dd.api.web.SunWebApp; 57 import org.netbeans.modules.j2ee.sun.ws7.j2ee.ResourceType; 58 import org.netbeans.modules.j2ee.sun.ws7.ui.WS70URIManager; 59 import org.netbeans.modules.j2ee.sun.ws7.ui.WS70ConfigSelectDialog; 60 import org.netbeans.modules.j2ee.sun.ws7.ui.WS70ServerUIWizardIterator; 61 62 import org.openide.DialogDisplayer; 63 import org.openide.NotifyDescriptor; 64 import org.openide.ErrorManager; 65 import org.openide.util.NbBundle; 66 67 71 public class WS70SunDeploymentManager implements DeploymentManager { 72 private DeploymentManager ws70DM; 73 private DeploymentFactory ws70DF; 74 private String uri; 75 private String userName; 76 private String password; 77 private Class dmClass; 78 private String serverLocation; 79 private String host; 80 private int port; 81 private Target defaultTarget; 83 84 private String debugOptions; 86 private boolean isDebugModeEnabled; 87 88 89 90 public WS70SunDeploymentManager(DeploymentFactory df, DeploymentManager dm, String uri, String username, String password) { 91 this.ws70DF = df; 92 this.ws70DM = dm; 93 this.uri = uri; 94 this.userName = username; 95 this.password = password; 96 if(ws70DM!=null){ 99 dmClass = ws70DM.getClass(); 100 serverLocation = WS70URIManager.getLocation(uri); 101 host = WS70URIManager.getHostFromURI(uri); 102 String p = WS70URIManager.getPortFromURI(uri); 103 try{ 104 port = Integer.parseInt(p); 105 }catch(java.lang.NumberFormatException n){ 106 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, n); 107 } 108 } 109 } 110 111 public String getUserName() { 112 return userName; 113 } 114 115 public String getPassword() { 116 return password; 117 } 118 public String getServerLocation(){ 119 return serverLocation; 120 } 121 public String getUri(){ 122 return uri; 123 } 124 public String getHost(){ 125 return host; 126 } 127 public int getPort(){ 128 return port; 129 } 130 131 public void refreshInnerDM(String uname, String pword) { 133 if(uname.equals(userName) && pword.equals(password)){ 134 return; 136 } 137 ClassLoader origClassLoader=Thread.currentThread().getContextClassLoader(); 138 try{ 139 String ws70url = WS70URIManager.getURIWithoutLocation(uri); 140 if(this.isAdminOnSSL()){ 141 ws70url=ws70url+":https"; 142 } 143 ClassLoader loader = WS70SunDeploymentFactory.getLibClassLoader(serverLocation); 144 if(loader!=null){ 145 Thread.currentThread().setContextClassLoader(loader); 146 } 147 ws70DM = ws70DF.getDeploymentManager(ws70url, uname, pword); 148 userName = uname; 149 password = pword; 150 InstanceProperties ip = InstanceProperties.getInstanceProperties(this.getUri()); 151 ip.setProperty(InstanceProperties.USERNAME_ATTR, uname); 152 ip.setProperty(InstanceProperties.PASSWORD_ATTR, pword); 153 }catch(DeploymentManagerCreationException ex){ 154 ErrorManager.getDefault().log(ErrorManager.EXCEPTION, ex.getMessage()); 155 }finally{ 156 Thread.currentThread().setContextClassLoader(origClassLoader); 157 } 158 } 159 public boolean isLocalServer(){ 160 InstanceProperties ip = InstanceProperties.getInstanceProperties(uri); 161 String isLocal = ip.getProperty(WS70ServerUIWizardIterator.PROP_LOCAL_SERVER); 162 return Boolean.parseBoolean(isLocal); 163 } 164 public boolean isAdminOnSSL(){ 165 InstanceProperties ip = InstanceProperties.getInstanceProperties(uri); 166 String isSSL = ip.getProperty(WS70ServerUIWizardIterator.PROP_SSL_PORT); 167 return Boolean.parseBoolean(isSSL); 168 } 169 public Target getDefaultTarget(){ 172 return defaultTarget; 173 } 174 public DeploymentConfiguration createConfiguration(DeployableObject deplObj) 175 throws InvalidModuleException { 176 if (!ModuleType.WAR.equals(deplObj.getType())) { 177 throw new InvalidModuleException ( 178 NbBundle.getMessage(WS70SunDeploymentManager.class, "Invalid_MODULE")); 179 } 180 181 return new SunONEDeploymentConfiguration(deplObj); 182 } 183 184 185 193 public ProgressObject distribute(Target [] targets, InputStream is, InputStream deplPlan) 194 throws IllegalStateException { 195 196 return ws70DM.distribute(targets, is, deplPlan); 197 } 198 199 200 208 public ProgressObject distribute(Target [] targets, File moduleArchive,File deplPlan) 209 throws IllegalStateException { 210 SunWebApp swa = null; 211 try { 212 213 InputStream inputStream = new BufferedInputStream(new FileInputStream(deplPlan), 214 4096); 215 DDProvider provider = DDProvider.getDefault(); 216 swa = provider.getWebDDRoot(inputStream); 217 } catch (Exception e) { 218 e.printStackTrace(); 219 } 221 String ctxRoot = null; 222 if (swa == null) { 223 ErrorManager.getDefault().log( 224 ErrorManager.ERROR, NbBundle.getMessage(WS70SunDeploymentManager.class, "ERR_NULL_SWA")); 225 }else{ 226 ctxRoot = swa.getContextRoot(); 227 ErrorManager.getDefault().log( 228 ErrorManager.USER, NbBundle.getMessage(WS70SunDeploymentManager.class, "MSG_CONTEXTROOT", ctxRoot)); 229 } 230 231 try{ 232 Method distribute = dmClass.getDeclaredMethod("distribute", new Class []{Target [].class, File .class, String .class}); 233 ProgressObject po = (ProgressObject )distribute.invoke(this.ws70DM, new Object []{targets, moduleArchive, ctxRoot}); 234 return po; 235 236 }catch(Exception ex){ 237 ex.printStackTrace(); 238 } 239 return null; 240 } 241 242 public ProgressObject distribute(Target [] target, ModuleType moduleType, InputStream inputStream, InputStream inputStream0) throws IllegalStateException { 243 return distribute(target, inputStream, inputStream0); 244 } 245 246 public Locale getCurrentLocale() { 247 return Locale.getDefault(); 248 } 249 250 public Locale getDefaultLocale() { 251 return Locale.getDefault(); 252 } 253 254 public Locale [] getSupportedLocales() { 255 return Locale.getAvailableLocales(); 256 } 257 258 public boolean isLocaleSupported(Locale locale) { 259 if (locale == null) { 260 return false; 261 } 262 Locale [] supLocales = getSupportedLocales(); 263 for (int i =0; i<supLocales.length; i++) { 264 if (locale.equals (supLocales[i])) { 265 return true; 266 } 267 } 268 return false; 269 } 270 271 public void setLocale(Locale locale) 272 throws UnsupportedOperationException { 273 274 } 275 276 public DConfigBeanVersionType getDConfigBeanVersion() { 277 return DConfigBeanVersionType.V1_4; 278 } 279 280 public boolean isDConfigBeanVersionSupported(DConfigBeanVersionType v) { 281 return DConfigBeanVersionType.V1_4.equals(v); 282 } 283 284 public void setDConfigBeanVersion(DConfigBeanVersionType version) 285 throws DConfigBeanVersionUnsupportedException { 286 if (!DConfigBeanVersionType.V1_4.equals(version)) { 287 throw new DConfigBeanVersionUnsupportedException ( 288 NbBundle.getMessage(WS70SunDeploymentManager.class, "Invalid_CONFIG_VERSION")); 289 } 290 } 291 292 public TargetModuleID [] getAvailableModules(ModuleType moduleType, 293 Target [] targetList) 294 throws IllegalStateException , TargetException { 295 return ws70DM.getAvailableModules(moduleType, targetList); 296 297 } 298 299 300 public TargetModuleID [] getNonRunningModules(ModuleType moduleType, 301 Target [] targetList) 302 throws IllegalStateException , TargetException { 303 return ws70DM.getNonRunningModules(moduleType, targetList); 304 } 305 306 public TargetModuleID [] getRunningModules(ModuleType moduleType, 307 Target [] targetList) 308 throws IllegalStateException , TargetException { 309 return ws70DM.getRunningModules(moduleType, targetList); 310 } 311 312 public Target [] getTargets() throws IllegalStateException { 313 Target [] targets = ws70DM.getTargets(); 314 InstanceProperties ip = InstanceProperties.getInstanceProperties(this.getUri()); 315 String config = ip.getProperty("configName"); if(targets.length==1){ 317 if(config==null){ 318 try{ 319 String cname = this.getConfigNameFromTarget(targets[0]); 320 ip.setProperty("configName", cname); }catch(Exception ex){ 322 ex.printStackTrace(); 323 } 324 } 325 defaultTarget = targets[0]; 326 return targets; 327 } 328 329 String [] configs = new String [targets.length]; 332 for(int i=0;i<targets.length;i++){ 333 try{ 334 configs[i] = this.getConfigNameFromTarget(targets[i]); 335 }catch(Exception ex){ 336 configs[i]=""; 337 ex.printStackTrace(); 338 } 339 } 340 341 342 if(config==null){ 343 WS70ConfigSelectDialog d = new WS70ConfigSelectDialog(configs); 345 if (DialogDisplayer.getDefault().notify(d) ==NotifyDescriptor.OK_OPTION){ 346 config = d.getSelectedConfig(); 347 } 348 if(config==null){ 349 try{ 351 ip.setProperty("configName", this.getConfigNameFromTarget(targets[0])); }catch(Exception ex){ 353 ex.printStackTrace(); 354 } 355 }else{ 356 ip.setProperty("configName", config); } 358 for(int i=0;i<targets.length;i++){ 359 String cname = null; 360 try{ 361 cname = this.getConfigNameFromTarget(targets[i]); 362 }catch(Exception ex){ 363 cname = ""; 364 ex.printStackTrace(); 365 } 366 if(config.equals(cname)){ 367 defaultTarget = targets[i]; 368 return new Target []{targets[i]}; 369 } 370 } 371 }else{ 372 for(int j=0;j<targets.length;j++){ 374 String cname = null; 375 try{ 376 cname = this.getConfigNameFromTarget(targets[j]); 377 }catch(Exception ex){ 378 cname = ""; 379 ex.printStackTrace(); 380 } 381 if(config.equals(cname)){ 382 defaultTarget = targets[j]; 383 return new Target []{targets[j]}; 384 } 385 } 386 } 387 388 ErrorManager.getDefault().log(ErrorManager.WARNING, 389 NbBundle.getMessage(WS70SunDeploymentManager.class, 390 "ERR_GETTARGETS", targets[0].getName())); 391 defaultTarget = targets[0]; 392 return new Target []{targets[0]}; 393 } 394 395 public boolean isRedeploySupported() { 396 return false; 397 } 398 399 public ProgressObject redeploy(TargetModuleID [] targetModuleID, 400 InputStream inputStream, 401 InputStream inputStream2) 402 throws IllegalStateException , UnsupportedOperationException { 403 throw new UnsupportedOperationException (NbBundle.getMessage( 404 WS70SunDeploymentManager.class, "UNSUPPORTED_REDPLOY")); 405 } 406 407 public ProgressObject redeploy(TargetModuleID [] tmID, File file, 408 File file2) 409 throws IllegalStateException , UnsupportedOperationException { 410 throw new UnsupportedOperationException (NbBundle.getMessage( 411 WS70SunDeploymentManager.class, "UNSUPPORTED_REDPLOY")); 412 } 413 414 415 public void release() { 416 } 417 418 419 public ProgressObject start(TargetModuleID [] tmID) 420 throws IllegalStateException { 421 return ws70DM.start(tmID); 422 } 423 424 425 public ProgressObject stop(TargetModuleID [] tmID) 426 throws IllegalStateException { 427 return ws70DM.stop(tmID); 428 429 } 430 431 432 public ProgressObject undeploy(TargetModuleID [] tmID) 433 throws IllegalStateException { 434 return ws70DM.undeploy(tmID); 435 } 436 437 438 public void startServer(String configName) throws Exception { 440 try{ 441 Method startServer = dmClass.getDeclaredMethod("startServer", new Class []{String .class}); Boolean retVal = (Boolean )startServer.invoke(this.ws70DM, new Object []{configName}); 443 }catch(InvocationTargetException ite){ 444 ite.printStackTrace(); 445 throw (Exception )ite.getTargetException(); 446 }catch(Exception ex){ 447 ex.printStackTrace(); 448 throw ex; 449 } 450 } 451 public void stopServer(String configName) throws Exception { 452 try{ 453 Method stopServer = dmClass.getDeclaredMethod("stopServer", new Class []{String .class}); Boolean retVal = (Boolean )stopServer.invoke(this.ws70DM, new Object []{configName}); 455 456 }catch(InvocationTargetException ite){ 457 ite.printStackTrace(); 458 throw (Exception )ite.getTargetException(); 459 }catch(Exception ex){ 460 ex.printStackTrace(); 461 throw ex; 462 } 463 } 464 465 public List getJVMOptions(String configName, Boolean debugOptions, String profilerName){ 466 try{ 467 Method getJVMOptions = dmClass.getDeclaredMethod("getJVMOptions", new Class []{String .class, Boolean .class, String .class}); List options = (List )getJVMOptions.invoke(this.ws70DM, new Object []{configName, debugOptions, profilerName}); 469 return options; 470 471 }catch(Exception ex){ 472 ex.printStackTrace(); 473 } 474 return null; 475 } 476 public Map getJVMProps(String configName) throws IllegalStateException { 477 try{ 478 Method getJvmProps = dmClass.getDeclaredMethod("getJVMProps", new Class []{String .class}); Map options = (Map )getJvmProps.invoke(this.ws70DM, new Object []{configName}); 480 return options; 481 482 }catch(Exception ex){ 483 ex.printStackTrace(); 484 } 485 return null; 486 } 487 public void deployAndReconfig(String configName) throws Exception { 488 try{ 489 Method deployAndReconfig = dmClass.getDeclaredMethod("deployAndReconfig", new Class []{String .class}); 490 deployAndReconfig.invoke(this.ws70DM, new Object []{configName}); 491 }catch(InvocationTargetException ite){ 492 throw (Exception )ite.getTargetException(); 493 }catch(Exception ex){ 494 throw ex; 495 } 496 } 497 public void changeDebugStatus(String configName, 498 boolean enableDisable) throws Exception { 499 try{ 500 Method changeDebugStatus = dmClass.getDeclaredMethod("changeDebugStatus", new Class []{String .class, boolean.class}); changeDebugStatus.invoke(this.ws70DM, new Object []{configName, Boolean.valueOf(enableDisable)}); 502 }catch(InvocationTargetException ite){ 503 ite.printStackTrace(); 504 throw (Exception )ite.getTargetException(); 505 }catch(Exception ex){ 506 ex.printStackTrace(); 507 throw ex; 508 } 509 deployAndReconfig(configName); 510 } 511 public String getDebugOptions(){ 513 return this.debugOptions; 514 } 515 public void setDebugOptions(String debugString){ 517 this.debugOptions = debugString; 518 } 519 public boolean isDebugModeEnabled(){ 520 return this.isDebugModeEnabled; 521 } 522 public void setDebugModeEnabled(boolean debugMode){ 523 isDebugModeEnabled = debugMode; 524 } 525 public String getNodeNameForTarget(Target target){ 526 try{ 527 String configName = this.getConfigNameFromTarget(target); 528 Method getNodeName = dmClass.getDeclaredMethod("getNodeName", new Class []{String .class}); 529 return (String )getNodeName.invoke(this.ws70DM, new Object []{configName}); 530 }catch(Exception ex){ 531 ex.printStackTrace(); 532 } 533 return null; 534 } 535 public boolean changeAppProfilerStatus(String configName, boolean enableDisable){ 536 return true; 537 } 538 public List getResources(ResourceType resType, String configName) throws Exception { 539 String methodName = null; 540 if(resType.eqauls(ResourceType.JDBC)){ 541 methodName = "getJDBCResources"; }else if(resType.eqauls(ResourceType.JNDI)){ 543 methodName = "getJNDIResources"; }else if(resType.eqauls(ResourceType.MAIL)){ 545 methodName = "getMailResources"; }else if(resType.eqauls(ResourceType.CUSTOM)){ 547 methodName = "getCustomResources"; } 549 try{ 550 Method getResources = dmClass.getDeclaredMethod(methodName, new Class []{String .class}); 551 List resources = (List )getResources.invoke(this.ws70DM, new Object []{configName}); 552 return resources; 553 }catch(InvocationTargetException ite){ 554 ite.printStackTrace(); 555 throw (Exception )ite.getTargetException(); 556 }catch(Exception ex){ 557 ex.printStackTrace(); 558 throw ex; 559 } 560 } 561 562 563 public void setResource(ResourceType resType, String configName, 564 String resName, Map resElements, boolean reconfig) throws Exception { 565 try{ 566 String methodName = null; 567 if(resType.eqauls(ResourceType.JDBC)){ 568 methodName = "setJDBCResource"; }else if(resType.eqauls(ResourceType.JNDI)){ 570 methodName = "setJNDIResource"; }else if(resType.eqauls(ResourceType.MAIL)){ 572 methodName = "setMailResource"; }else if(resType.eqauls(ResourceType.CUSTOM)){ 574 methodName = "setCustomResource"; } 576 Method setResource = dmClass.getDeclaredMethod(methodName, new Class []{String .class, String .class, Map .class}); 577 setResource.invoke(this.ws70DM, new Object []{configName, resName, resElements}); 578 if(reconfig){ 579 this.deployAndReconfig(configName); 580 } 581 582 }catch(InvocationTargetException ite){ 583 ite.printStackTrace(); 584 throw (Exception )ite.getTargetException(); 585 }catch(Exception ex){ 586 ex.printStackTrace(); 587 throw ex; 588 } 589 } 590 public void setUserResourceProp(String configName, String resourceType, 591 String jndiName, String propType, List userProps, boolean reconfig) throws Exception { 592 try{ 593 594 Method setUserProps = dmClass.getDeclaredMethod("setUserResourceProp", 595 new Class []{String .class, String .class, String .class, String .class, List .class}); 596 setUserProps.invoke(this.ws70DM, new Object []{configName, resourceType, 597 jndiName, propType, userProps}); 598 if(reconfig){ 599 this.deployAndReconfig(configName); 600 } 601 602 }catch(InvocationTargetException ite){ 603 ite.printStackTrace(); 604 throw (Exception )ite.getTargetException(); 605 }catch(Exception ex){ 606 ex.printStackTrace(); 607 throw ex; 608 } 609 } 610 611 public void deleteResource(ResourceType resType, String configName, String resName)throws Exception { 612 try{ 613 String methodName = null; 614 if(resType.eqauls(ResourceType.JDBC)){ 615 methodName = "delJDBCResource"; }else if(resType.eqauls(ResourceType.JNDI)){ 617 methodName = "delJNDIResource"; }else if(resType.eqauls(ResourceType.MAIL)){ 619 methodName = "delMailResource"; }else if(resType.eqauls(ResourceType.CUSTOM)){ 621 methodName = "delCustomResource"; } 623 Method delResource = dmClass.getDeclaredMethod(methodName, new Class []{String .class, String .class}); 624 delResource.invoke(this.ws70DM, new Object []{configName, resName}); 625 this.deployAndReconfig(configName); 626 627 }catch(InvocationTargetException ite){ 628 ite.printStackTrace(); 629 throw (Exception )ite.getTargetException(); 630 }catch(Exception ex){ 631 ex.printStackTrace(); 632 throw ex; 633 } 634 } 635 public Map getUserResourceProps(String configName, String resourceType, String jndiName, String propType) throws IllegalStateException { 636 try{ 637 Method getUserResourceProps = dmClass.getDeclaredMethod("getUserResourceProps", 638 new Class []{String .class, String .class, String .class, String .class}); 639 Map resources = (Map )getUserResourceProps.invoke(this.ws70DM, new Object []{configName, resourceType, jndiName, propType}); 640 return resources; 641 642 }catch(Exception ex){ 643 ex.printStackTrace(); 644 } 645 return null; 646 } 647 public void addJdbcResource(String configName, String resName, 648 Map resAttrs) throws Exception { 649 try{ 650 Method addJdbcResource = dmClass.getDeclaredMethod("addJDBCResource", 651 new Class []{String .class, String .class, Map .class}); 652 addJdbcResource.invoke(this.ws70DM, new Object []{configName, resName, resAttrs}); 653 }catch(InvocationTargetException ite){ 654 throw (Exception )ite.getTargetException(); 655 }catch(Exception ex){ 656 throw ex; 657 } 658 659 } 660 public void addCustomResource(String configName, String resName, 661 Map resAttrs) throws Exception { 662 try{ 663 Method addCustomResource = dmClass.getDeclaredMethod("addCustomResource", 664 new Class []{String .class, String .class, Map .class}); 665 addCustomResource.invoke(this.ws70DM, new Object []{configName, resName, resAttrs}); 666 }catch(InvocationTargetException ite){ 667 throw (Exception )ite.getTargetException(); 668 }catch(Exception ex){ 669 throw ex; 670 } 671 672 } 673 674 public void addJNDIResource(String configName, String resName, 675 Map resAttrs) throws Exception { 676 try{ 677 Method addJNDIResource = dmClass.getDeclaredMethod("addJNDIResource", 678 new Class []{String .class, String .class, Map .class}); 679 addJNDIResource.invoke(this.ws70DM, new Object []{configName, resName, resAttrs}); 680 }catch(InvocationTargetException ite){ 681 throw (Exception )ite.getTargetException(); 682 }catch(Exception ex){ 683 throw ex; 684 } 685 } 686 public void addMailResource(String configName, String resName, 687 Map resAttrs) throws Exception { 688 try{ 689 Method addMailResource = dmClass.getDeclaredMethod("addMailResource", 690 new Class []{String .class, String .class, Map .class}); 691 addMailResource.invoke(this.ws70DM, new Object []{configName, resName, resAttrs}); 692 }catch(InvocationTargetException ite){ 693 throw (Exception )ite.getTargetException(); 694 }catch(Exception ex){ 695 throw ex; 696 } 697 } 698 public void setJVMOptions(String configName, List jvmOptions, Boolean debugOptions, 699 String profilerName) throws Exception { 700 try{ 701 Method setJVMOptions = dmClass.getDeclaredMethod("setJVMOptions", 702 new Class []{String .class, List .class, Boolean .class, String .class}); 703 setJVMOptions.invoke(this.ws70DM, new Object []{configName, jvmOptions, debugOptions, profilerName}); 704 this.deployAndReconfig(configName); 705 }catch(InvocationTargetException ite){ 706 throw (Exception )ite.getTargetException(); 707 }catch(Exception ex){ 708 throw ex; 709 } 710 } 711 public void setJVMProps(String configName, Map jvmElements) throws Exception { 712 try{ 713 Method setJVMProps = dmClass.getDeclaredMethod("setJVMProps", 714 new Class []{String .class, Map .class}); 715 setJVMProps.invoke(this.ws70DM, new Object []{configName, jvmElements}); 716 this.deployAndReconfig(configName); 717 }catch(InvocationTargetException ite){ 718 throw (Exception )ite.getTargetException(); 719 }catch(Exception ex){ 720 throw ex; 721 } 722 } 723 724 725 public boolean isRunning(){ 726 try { 727 java.net.InetSocketAddress isa = new java.net.InetSocketAddress (java.net.InetAddress.getByName(host), port); 728 java.net.Socket socket = new java.net.Socket (); 729 socket.connect(isa); 730 socket.close(); 731 return true; 732 } catch (IOException e) { 733 return false; 734 } 735 736 } 737 738 public boolean isRunning(String configName){ 739 if(configName==null){ 740 return isRunning(); 741 } 742 try{ 743 Method isRunning = dmClass.getDeclaredMethod("isServerRunning", new Class []{String .class}); 744 Boolean retVal= (Boolean )isRunning.invoke(this.ws70DM, new Object []{configName}); 745 return retVal.booleanValue(); 746 747 }catch(Exception ex){ 748 ex.printStackTrace(); 749 return false; 750 } 751 } 752 private String getConfigNameFromTarget(Target target) throws Exception { 753 try{ 754 Method getConfigName = target.getClass().getDeclaredMethod("getConfigName", new Class []{}); 755 String configName = (String )getConfigName.invoke(target, new Object []{}); 756 return configName; 757 758 }catch(InvocationTargetException ite){ 759 throw (Exception )ite.getTargetException(); 760 }catch(Exception ex){ 761 throw ex; 762 } 763 } 764 } 765 | Popular Tags |