Fields Summary |
---|
protected static final String | DEFAULT_WL51_POLICY_FILE |
protected static final String | DEFAULT_WL60_POLICY_FILE |
protected static final String | DEFAULT_PROPERTIES_FILE |
private org.apache.tools.ant.types.Path | classpathThe classpath to be used when running the Java VM. It must contain the
weblogic classes and the implementation classes of the home and
remote interfaces. |
private org.apache.tools.ant.types.Path | weblogicClasspathThe weblogic classpath to the be used when running weblogic. |
private String | weblogicMainClass |
private String | additionalArgsAddional arguments to pass to the JVM used to run weblogic |
private String | securityPolicyThe security policy to use when running the weblogic server |
private File | weblogicSystemHomeThe weblogic system home directory |
private String | weblogicDomainNameThe weblogic domain |
private String | weblogicSystemNameThe name of the weblogic server - used to select the server's directory in the
weblogic home directory. |
private String | weblogicPropertiesFileThe file containing the weblogic properties for this server. |
private String | additionalJvmArgsadditional args to pass to the spawned jvm |
private File | beaHomeThe location of the BEA Home under which this server is run.
WL6 only |
private String | managementUsernameThe management username |
private String | managementPasswordThe management password |
private String | pkPasswordThe provate key password - used for SSL |
Methods Summary |
---|
public org.apache.tools.ant.types.Path | createClasspath()Add the classpath for the user classes
if (classpath == null) {
classpath = new Path(getProject());
}
return classpath.createPath();
|
public org.apache.tools.ant.types.Path | createWLClasspath()Get the classpath to the weblogic classpaths
if (weblogicClasspath == null) {
weblogicClasspath = new Path(getProject());
}
return weblogicClasspath.createPath();
|
public void | execute()Do the work.
The work is actually done by creating a separate JVM to run a helper task.
This approach allows the classpath of the helper task to be set. Since the
weblogic tools require the class files of the project's home and remote
interfaces to be available in the classpath, this also avoids having to
start ant with the class path of the project it is building.
if (weblogicSystemHome == null) {
throw new BuildException("weblogic home must be set");
}
if (!weblogicSystemHome.isDirectory()) {
throw new BuildException("weblogic home directory "
+ weblogicSystemHome.getPath() + " is not valid");
}
if (beaHome != null) {
executeWLS6();
} else {
executeWLS();
}
|
private void | executeWLS()
File securityPolicyFile
= findSecurityPolicyFile(DEFAULT_WL51_POLICY_FILE);
File propertiesFile = null;
if (weblogicPropertiesFile == null) {
weblogicPropertiesFile = DEFAULT_PROPERTIES_FILE;
}
propertiesFile = new File(weblogicSystemHome, weblogicPropertiesFile);
if (!propertiesFile.exists()) {
// OK, properties file may be absolute
propertiesFile = getProject().resolveFile(weblogicPropertiesFile);
if (!propertiesFile.exists()) {
throw new BuildException("Properties file "
+ weblogicPropertiesFile
+ " not found in weblogic home " + weblogicSystemHome
+ " or as absolute file");
}
}
Java weblogicServer = new Java(this);
weblogicServer.setFork(true);
weblogicServer.setClassname(weblogicMainClass);
String jvmArgs = additionalJvmArgs;
if (weblogicClasspath != null) {
jvmArgs += " -Dweblogic.class.path=" + weblogicClasspath;
}
jvmArgs += " -Djava.security.manager -Djava.security.policy==" + securityPolicyFile;
jvmArgs += " -Dweblogic.system.home=" + weblogicSystemHome;
jvmArgs += " -Dweblogic.system.name=" + weblogicSystemName;
jvmArgs += " -Dweblogic.system.propertiesFile=" + weblogicPropertiesFile;
weblogicServer.createJvmarg().setLine(jvmArgs);
weblogicServer.createArg().setLine(additionalArgs);
if (classpath != null) {
weblogicServer.setClasspath(classpath);
}
if (weblogicServer.executeJava() != 0) {
throw new BuildException("Execution of weblogic server failed");
}
|
private void | executeWLS6()
File securityPolicyFile
= findSecurityPolicyFile(DEFAULT_WL60_POLICY_FILE);
if (!beaHome.isDirectory()) {
throw new BuildException("BEA home " + beaHome.getPath()
+ " is not valid");
}
File configFile = new File(weblogicSystemHome, "config/"
+ weblogicDomainName + "/config.xml");
if (!configFile.exists()) {
throw new BuildException("Server config file " + configFile
+ " not found.");
}
if (managementPassword == null) {
throw new BuildException("You must supply a management password "
+ "to start the server");
}
Java weblogicServer = new Java(this);
weblogicServer.setTaskName(getTaskName());
weblogicServer.setFork(true);
weblogicServer.setDir(weblogicSystemHome);
weblogicServer.setClassname(weblogicMainClass);
String jvmArgs = additionalJvmArgs;
jvmArgs += " -Dweblogic.Domain=" + weblogicDomainName;
jvmArgs += " -Dweblogic.Name=" + weblogicSystemName;
jvmArgs += " -Dweblogic.system.home=" + weblogicSystemHome;
jvmArgs += " -Dbea.home=" + beaHome;
jvmArgs += " -Djava.security.policy==" + securityPolicyFile;
jvmArgs += " -Dweblogic.management.username=" + managementUsername;
jvmArgs += " -Dweblogic.management.password=" + managementPassword;
if (pkPassword != null) {
jvmArgs += " -Dweblogic.pkpassword=" + pkPassword;
}
weblogicServer.createJvmarg().setLine(jvmArgs);
weblogicServer.createArg().setLine(additionalArgs);
if (classpath != null) {
weblogicServer.setClasspath(classpath);
}
if (weblogicServer.executeJava() != 0) {
throw new BuildException("Execution of weblogic server failed");
}
|
private java.io.File | findSecurityPolicyFile(java.lang.String defaultSecurityPolicy)
String securityPolicy = this.securityPolicy;
if (securityPolicy == null) {
securityPolicy = defaultSecurityPolicy;
}
File securityPolicyFile = new File(weblogicSystemHome, securityPolicy);
// If an explicit securityPolicy file was specified, it maybe an
// absolute path. Use the project to resolve it.
if (this.securityPolicy != null && !securityPolicyFile.exists()) {
securityPolicyFile = getProject().resolveFile(securityPolicy);
}
// If we still can't find it, complain
if (!securityPolicyFile.exists()) {
throw new BuildException("Security policy " + securityPolicy
+ " was not found.");
}
return securityPolicyFile;
|
public void | setArgs(java.lang.String args)Additional argument string passed to the Weblogic instance;
optional.
additionalArgs = args;
|
public void | setBEAHome(java.io.File beaHome)The location of the BEA Home; implicitly
selects Weblogic 6.0; optional.
this.beaHome = beaHome;
|
public void | setClasspath(org.apache.tools.ant.types.Path classpath)The classpath to be used with the Java Virtual Machine that runs the Weblogic
Server; required. Prior to Weblogic 6.0, this is typically set to the Weblogic
boot classpath. Under Weblogic 6.0 this should include all the
weblogic jars
this.classpath = classpath;
|
public void | setDomain(java.lang.String domain)Set the Domain to run in; required for WL6.0
this.weblogicDomainName = domain;
|
public void | setHome(java.io.File weblogicHome)The location where weblogic lives.
Required. This is the absolute location, not relative to
BEA home.
weblogicSystemHome = weblogicHome;
|
public void | setJvmargs(java.lang.String args)Set the additional arguments to pass to the weblogic JVM
this.additionalJvmArgs = args;
|
public void | setName(java.lang.String serverName)The name of the weblogic server within the weblogic home which is to be run.
Optiona, defaults to "myserver"
this.weblogicSystemName = serverName;
|
public void | setPKPassword(java.lang.String pkpassword)Set the private key password so the server can decrypt the SSL private key file;
optional and only applicable to WL6.0.
this.pkPassword = pkpassword;
|
public void | setPassword(java.lang.String password)Set the management password of the server;
optional and only applicable to WL6.0.
this.managementPassword = password;
|
public void | setPolicy(java.lang.String securityPolicy)The name of the security policy file within the weblogic home directory that
is to be used. If not specified, the default policy file weblogic.policy
is used.
this.securityPolicy = securityPolicy;
|
public void | setProperties(java.lang.String propertiesFilename)The name of the server's properties file within the weblogic home directory
used to control the weblogic instance;
required for WL4.5.1
this.weblogicPropertiesFile = propertiesFilename;
|
public void | setUsername(java.lang.String username)Set the management username to run the server;
optional and only applicable to WL6.0.
this.managementUsername = username;
|
public void | setWeblogicMainClass(java.lang.String c)name of the main class for weblogic; optional.
weblogicMainClass = c;
|
public void | setWlclasspath(org.apache.tools.ant.types.Path weblogicClasspath)Set the weblogic classpath used by the Weblogic Server;
optional, and only applicable to WL4.5.1
The weblogic classpath is used by weblogic to support dynamic class loading.
this.weblogicClasspath = weblogicClasspath;
|