1 18 package org.apache.tools.ant.taskdefs.optional.ejb; 19 20 21 import java.io.File ; 22 import org.apache.tools.ant.BuildException; 23 import org.apache.tools.ant.Task; 24 import org.apache.tools.ant.taskdefs.Java; 25 import org.apache.tools.ant.types.Path; 26 27 33 public class WLStop extends Task { 34 37 private Path classpath; 38 39 42 private String username; 43 44 47 private String password; 48 49 52 private String serverURL; 53 54 57 private int delay = 0; 58 59 63 private File beaHome = null; 64 65 73 public void execute() throws BuildException { 74 if (username == null || password == null) { 75 throw new BuildException("weblogic username and password must both be set"); 76 } 77 78 if (serverURL == null) { 79 throw new BuildException("The url of the weblogic server must be provided."); 80 } 81 82 Java weblogicAdmin = new Java(this); 83 weblogicAdmin.setFork(true); 84 weblogicAdmin.setClassname("weblogic.Admin"); 85 String args; 86 87 if (beaHome == null) { 88 args = serverURL + " SHUTDOWN " + username + " " + password + " " + delay; 89 } else { 90 args = " -url " + serverURL 91 + " -username " + username 92 + " -password " + password 93 + " SHUTDOWN " + " " + delay; 94 } 95 96 weblogicAdmin.createArg().setLine(args); 97 weblogicAdmin.setClasspath(classpath); 98 weblogicAdmin.execute(); 99 } 100 101 107 public void setClasspath(Path path) { 108 this.classpath = path; 109 } 110 111 116 public Path createClasspath() { 117 if (classpath == null) { 118 classpath = new Path(getProject()); 119 } 120 return classpath.createPath(); 121 } 122 123 129 public void setUser(String s) { 130 this.username = s; 131 } 132 133 139 public void setPassword(String s) { 140 this.password = s; 141 } 142 143 149 public void setUrl(String s) { 150 this.serverURL = s; 151 } 152 153 154 160 public void setDelay(String s) { 161 delay = Integer.parseInt(s); 162 } 163 164 171 public void setBEAHome(File beaHome) { 172 this.beaHome = beaHome; 173 } 174 175 } 176 | Popular Tags |