ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb WLRun.java WLStop.java
Date Sun, 04 Feb 2001 08:34:38 GMT
conor       01/02/04 00:34:38

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/ejb
                        WLRun.java WLStop.java
  Log:
  Changes to wlstop and wlrun to work with weblogic 6.0
  
  Use under 5.1 is unchanged. Under WL6.0, a number of new attributes
  must be provided. An example of use under WL6.0 is
  
    <target name="petstore">
      <wlrun taskname="petstore"
             classpath="${weblogic.classes}"
             name="petstoreServer"
             domain="petstore"
             home="${weblogic.home}"
             password="petstorePassword"
             beahome="${bea.home}"/>
    </target>
  
  Thanks to Andrew Sliwkowski and Peter Cardimino of BEA for clarifying how
  to get this to run under WL6.0
  
  Revision  Changes    Path
  1.9       +187 -11   jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java
  
  Index: WLRun.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- WLRun.java	2001/01/03 14:18:39	1.8
  +++ WLRun.java	2001/02/04 08:34:37	1.9
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2000, 2001 The Apache Software Foundation.  All rights 
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -69,7 +69,9 @@
    * @author <a href="mailto:conor@cortexebusiness.com.au">Conor MacNeill</a>,
Cortex ebusiness Pty Limited
    */
   public class WLRun extends Task {
  -    static private final String defaultPolicyFile = "weblogic.policy";
  +    static protected final String DEFAULT_WL51_POLICY_FILE = "weblogic.policy";
  +    static protected final String DEFAULT_WL60_POLICY_FILE = "lib/weblogic.policy";
  +    static protected final String DEFAULT_PROPERTIES_FILE = "weblogic.properties";
   
       /**
        * The classpath to be used when running the Java VM. It must contain the weblogic
  @@ -83,6 +85,10 @@
       private Path weblogicClasspath;
   
       private String weblogicMainClass = "weblogic.Server";
  +    
  +    /**
  +     * Addional arguments to pass to the JVM used to run weblogic
  +     */
       private String additionalArgs = "";
       
       /**
  @@ -94,6 +100,11 @@
        * The weblogic system home directory
        */
       private File weblogicSystemHome;
  +
  +    /**
  +     * The weblogic domain
  +     */
  +    private String weblogicDomainName;
       
       /**
        * The name of the weblogic server - used to select the server's directory in the 
  @@ -104,14 +115,55 @@
       /**
        * The file containing the weblogic properties for this server.
        */
  -    private String weblogicPropertiesFile = "weblogic.properties";
  +    private String weblogicPropertiesFile = null;
   
       /**
        * additional args to pass to the spawned jvm
        */
       private String additionalJvmArgs = "";
  +
  +    /**
  +     * The location of the BEA Home under which this server is run.
  +     * WL6 only
  +     */
  +    private File beaHome = null;
  +
  +    /**
  +     * The management username
  +     */
  +    private String managementUsername = "system";
       
       /**
  +     * The management password
  +     */
  +    private String managementPassword = null;
  +
  +    /**
  +     * The provate key password - used for SSL
  +     */
  +    private String pkPassword = null;
  +
  +    /**
  +     * Add the classpath for the user classes
  +     */
  +    public Path createClasspath() {
  +        if (classpath == null) {
  +            classpath = new Path(project);
  +        }
  +        return classpath.createPath();
  +    }
  +
  +    /**
  +     * Get the classpath to the weblogic classpaths
  +     */
  +    public Path createWLClasspath() {
  +        if (weblogicClasspath == null) {
  +            weblogicClasspath = new Path(project);
  +        }
  +        return weblogicClasspath.createPath();
  +    }
  +
  +    /**
        * Do the work.
        *
        * The work is actually done by creating a separate JVM to run a helper task. 
  @@ -129,10 +181,84 @@
           if (!weblogicSystemHome.isDirectory()) {
               throw new BuildException("weblogic home directory " + weblogicSystemHome.getPath()
+ 
                                        " is not valid");
  +        }
  +
  +        if (beaHome != null) {
  +            executeWLS6();
  +        }
  +        else {
  +            executeWLS();
  +        }
  +    }
  +    
  +    private void executeWLS6() {
  +        
  +        if (!beaHome.isDirectory()) {
  +            throw new BuildException("BEA home " + beaHome.getPath() + 
  +                                     " is not valid");
  +        }
  +        
  +        File securityPolicyFile = null;
  +        if (securityPolicy == null) {
  +            securityPolicyFile = new File(weblogicSystemHome, DEFAULT_WL60_POLICY_FILE);
  +        }
  +        else {
  +            securityPolicyFile = new File(weblogicSystemHome, securityPolicy);
  +        }
  +
  +        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 = (Java)project.createTask("java");
  +        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);                         
           }
  -                
  -        File propertiesFile = new File(weblogicSystemHome, weblogicPropertiesFile);
  +            
  +        if (weblogicServer.executeJava() != 0) {                         
  +            throw new BuildException("Execution of weblogic server failed");
  +        }
  +     }
  +    
  +    private void executeWLS() {
  +
  +        File propertiesFile = null;
           
  +        if (weblogicPropertiesFile == null) {
  +            propertiesFile = new File(weblogicSystemHome, DEFAULT_PROPERTIES_FILE);
  +        }
  +        else {
  +            propertiesFile = new File(weblogicSystemHome, weblogicPropertiesFile);
  +        }
           if (!propertiesFile.exists()) {
               throw new BuildException("Properties file " + weblogicPropertiesFile +
                                        " not found in weblogic home " + weblogicSystemHome);
  @@ -140,7 +266,7 @@
   
           File securityPolicyFile = null;
           if (securityPolicy == null) {
  -            securityPolicyFile = new File(weblogicSystemHome, defaultPolicyFile);
  +            securityPolicyFile = new File(weblogicSystemHome, DEFAULT_WL51_POLICY_FILE);
           }
           else {
               securityPolicyFile = new File(weblogicSystemHome, securityPolicy);
  @@ -170,7 +296,9 @@
           weblogicServer.createJvmarg().setLine(jvmArgs);
           weblogicServer.createArg().setLine(additionalArgs);
           
  -        weblogicServer.setClasspath(classpath);                         
  +        if (classpath != null) {
  +            weblogicServer.setClasspath(classpath);                         
  +        }
           if (weblogicServer.executeJava() != 0) {                         
               throw new BuildException("Execution of weblogic server failed");
           }
  @@ -178,9 +306,9 @@
   
       
       /**
  -     * Set the classpath to be used for this compilation.
  +     * Set the classpath to be used for this execution.
        *
  -     * @param s the classpath to use when executing the weblogic task.
  +     * @param s the classpath to use when executing the weblogic server.
        */
       public void setClasspath(Path classpath) {
           this.classpath = classpath;
  @@ -211,9 +339,19 @@
        *
        * @param weblogicHome the home directory of weblogic.
        *
  +     */
  +    public void setHome(File weblogicHome) {
  +        weblogicSystemHome = weblogicHome;
  +    }
  +
  +    /**
  +     * The location of the BEA Home.
  +     *
  +     * @param beaHome the BEA Home directory.
  +     *
        */
  -    public void setHome(String weblogicHome) {
  -        weblogicSystemHome = new File(weblogicHome);
  +    public void setBEAHome(File beaHome) {
  +        this.beaHome = beaHome;
       }
       
       /**
  @@ -226,6 +364,15 @@
       }
       
       /**
  +     * Set the Domain to run in
  +     *
  +     * @param domain the domain
  +     */
  +    public void setDomain(String domain) {
  +        this.weblogicDomainName = domain;
  +    }
  +    
  +    /**
        * Set the properties file to use.
        *
        * The location of the properties file is relative to the weblogi system home
  @@ -244,9 +391,38 @@
           this.additionalJvmArgs = args;
       }
       
  +    /**
  +     * Set the management username to run the server
  +     *
  +     * @param username the management username of the server.
  +     */
  +    public void setUsername(String username) {
  +        this.managementUsername = username;
  +    }
  +    
  +
  +    /**
  +     * Set the management password of the server
  +     *
  +     * @param password the management pasword of the server.
  +     */
  +    public void setPassword(String password) {
  +        this.managementPassword = password;
  +    }
  +    
  +    /**
  +     * Set the private key password so the server can decrypt the SSL private key file.
  +     *
  +     * @param pkpassword the private key password,
  +     */
  +    public void setPKPassword(String pkpassword) {
  +        this.pkPassword = pkpassword;
  +    }
  +    
       public void setArgs(String args) {
           additionalArgs = args;
       }
  +
       
       public void setWeblogicMainClass(String c) {
           weblogicMainClass = c;
  
  
  
  1.6       +28 -1     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLStop.java
  
  Index: WLStop.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLStop.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WLStop.java	2001/01/03 14:18:39	1.5
  +++ WLStop.java	2001/02/04 08:34:38	1.6
  @@ -95,6 +95,12 @@
       private int delay = 0;
       
       /**
  +     * The location of the BEA Home under which this server is run.
  +     * WL6 only
  +     */
  +    private File beaHome = null;
  +
  +    /**
        * Do the work.
        *
        * The work is actually done by creating a separate JVM to run the weblogic admin task
  @@ -116,7 +122,17 @@
           Java weblogicAdmin = (Java)project.createTask("java");
           weblogicAdmin.setFork(true);
           weblogicAdmin.setClassname("weblogic.Admin");
  -        String args = serverURL + " SHUTDOWN " + username + " " + password + " " + delay;
  +        String args;
  +        
  +        if (beaHome == null) {
  +            args = serverURL + " SHUTDOWN " + username + " " + password + " " + delay;
  +        }
  +        else {
  +            args = " -url " + serverURL + 
  +                   " -username " + username +
  +                   " -password " + password +
  +                   " SHUTDOWN " + " " + delay;
  +        }            
   
           weblogicAdmin.setArgs(args);
           weblogicAdmin.setClasspath(new Path(project, execClassPath));                 
       
  @@ -168,4 +184,15 @@
       public void setDelay(String s) {
           delay = Integer.parseInt(s);
       }
  +
  +    /**
  +     * The location of the BEA Home.
  +     *
  +     * @param beaHome the BEA Home directory.
  +     *
  +     */
  +    public void setBEAHome(File beaHome) {
  +        this.beaHome = beaHome;
  +    }
  +    
   }
  
  
  

Mime
View raw message