antelder    2002/06/26 06:07:56

  Modified:    java/src/org/apache/wsif/compiler/schema/tools
                        Schema2Java.java
  Log:
  Change Schema2Java to lazy initialize the workingDirectory and wrap the getProperty 
in a DoPrivileged call
  
  Revision  Changes    Path
  1.4       +25 -3     
xml-axis-wsif/java/src/org/apache/wsif/compiler/schema/tools/Schema2Java.java
  
  Index: Schema2Java.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/compiler/schema/tools/Schema2Java.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Schema2Java.java  24 Jun 2002 13:11:17 -0000      1.3
  +++ Schema2Java.java  26 Jun 2002 13:07:56 -0000      1.4
  @@ -67,6 +67,8 @@
   import java.util.Iterator;
   import java.util.Map;
   import java.util.Vector;
  +import java.security.AccessController;
  +import java.security.PrivilegedAction;
   
   import javax.xml.namespace.QName;
   
  @@ -86,7 +88,7 @@
   public class Schema2Java {
   
       private HashMap registry = new HashMap();
  -    private String workingDirectory = System.getProperty("user.dir");
  +    private String workingDirectory;
       private HashMap namespaceRegistry = new HashMap();
   
       private HashMap undefinedRegistry = new HashMap();
  @@ -632,6 +634,26 @@
           return reg;
   
       }
  +    
  +    /**
  +     * Gets the current working directory for generated Java files.
  +     * @return dir java.lang.String   defaults to the "user.dir" 
  +     *                                 system property
  +     * @see setWorkingDirectory
  +     */
  +    public String getWorkingDirectory() {
  +     if ( workingDirectory == null ) {
  +         workingDirectory = 
  +            (String)AccessController.doPrivileged(
  +                  new PrivilegedAction() {
  +                     public Object run() {
  +                        return System.getProperty("user.dir");
  +                     }
  +                  }
  +               );
  +     }
  +     return workingDirectory;
  +    }
   
       private ClassFile group2Class(SchemaGroup gp) throws SchemaException {
   
  @@ -810,7 +832,7 @@
                   (ClassFile) classFileList.elementAt(classIndex);
               String javaPathName =
                   Conventions.getJavaPathName(
  -                    workingDirectory,
  +                    getWorkingDirectory(),
                       classFile.packageName);
               String javaFileName = classFile.className + ".java";
               OutputStream os =
  @@ -840,7 +862,7 @@
   
           if (javac) {
               for (int i = 0; i < classCount; i++) {
  -                if (Conventions.JDKcompile(fileNames[i], workingDirectory)
  +                if (Conventions.JDKcompile(fileNames[i], getWorkingDirectory() )
                       && verbose) {
                       System.out.println("Compiled file '" + fileNames[i] + "'.");
                   }
  
  
  


Reply via email to