amyroh      2002/08/13 01:08:17

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardServer.java
               catalina/src/share/org/apache/catalina/users
                        MemoryUserDatabase.java
  Log:
  Improve internationalization - store file with utf-8 encoding and add
  encoding='utf-8' at xml header.
  
  Patch submitted by Takashi Okamoto [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.31      +23 -20    
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java
  
  Index: StandardServer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardServer.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- StandardServer.java       10 Jul 2002 09:49:01 -0000      1.30
  +++ StandardServer.java       13 Aug 2002 08:08:17 -0000      1.31
  @@ -71,6 +71,8 @@
   import java.beans.PropertyDescriptor;
   import java.io.File;
   import java.io.FileWriter;
  +import java.io.FileOutputStream;
  +import java.io.OutputStreamWriter;
   import java.io.InputStream;
   import java.io.IOException;
   import java.io.PrintWriter;
  @@ -203,7 +205,7 @@
       /**
        * ServerLifecycleListener classname.
        */
  -    private static String SERVER_LISTENER_CLASS_NAME = 
  +    private static String SERVER_LISTENER_CLASS_NAME =
           "org.apache.catalina.mbeans.ServerLifecycleListener";
   
   
  @@ -382,7 +384,7 @@
   
       /**
        * Set the global naming resources.
  -     * 
  +     *
        * @param namingResources The new global naming resources
        */
       public void setGlobalNamingResources
  @@ -742,7 +744,7 @@
           // Open an output writer for the new configuration file
           PrintWriter writer = null;
           try {
  -            writer = new PrintWriter(new FileWriter(configNew));
  +            writer = new PrintWriter(new OutputStreamWriter(new 
FileOutputStream(configNew), "UTF8"));
           } catch (IOException e) {
               if (writer != null) {
                   try {
  @@ -828,7 +830,7 @@
               }
           }
               return(filtered.toString());
  -    } 
  +    }
   
   
       /**
  @@ -1156,7 +1158,7 @@
                   storeRealm(writer, indent + 2, realm);
               }
           }
  -        
  +
           // Store nested <Resources> element
           DirContext resources = context.getResources();
           if (resources != null) {
  @@ -1304,7 +1306,7 @@
               }
           }
           */
  -        
  +
           // Store nested <Resources> element
           DirContext resources = dcontext.getResources();
           if (resources != null) {
  @@ -1474,7 +1476,7 @@
   
       }
   
  -    
  +
       /**
        * Store the specified Host properties.
        *
  @@ -1718,7 +1720,7 @@
       private void storeNamingResources(PrintWriter writer, int indent,
                                         NamingResources resources)
           throws Exception {
  -       
  +
           // Store nested <Ejb> elements
           ContextEjb[] ejbs = resources.findEjbs();
           if (ejbs.length > 0) {
  @@ -1731,7 +1733,7 @@
                   writer.println("/>");
               }
           }
  -                
  +
           // Store nested <Environment> elements
           ContextEnvironment[] envs = resources.findEnvironments();
           if (envs.length > 0) {
  @@ -1744,7 +1746,7 @@
                   writer.println("/>");
               }
           }
  -                
  +
           // Store nested <LocalEjb> elements
           ContextLocalEjb[] lejbs = resources.findLocalEjbs();
           if (lejbs.length > 0) {
  @@ -1757,7 +1759,7 @@
                   writer.println("/>");
               }
           }
  -                
  +
           // Store nested <Resource> elements
           ContextResource[] dresources = resources.findResources();
           for (int i = 0; i < dresources.length; i++) {
  @@ -1844,11 +1846,11 @@
               writer.print("<ResourceLink");
               storeAttributes(writer, false, resourceLinks[i]);
               writer.println("/>");
  -        }       
  +        }
   
       }
  -    
  -    
  +
  +
       /**
        * Store the specified Realm properties.
        *
  @@ -1916,6 +1918,7 @@
                                Server server) throws Exception {
   
           // Store the beginning of this element
  +        writer.println("<?xml version='1.0' encoding='utf-8'?>");
           for (int i = 0; i < indent; i++) {
               writer.print(' ');
           }
  @@ -1946,7 +1949,7 @@
               }
               writer.println("</GlobalNamingResources>");
           }
  -        
  +
           // Store nested <Service> elements
           Service services[] = server.findServices();
           for (int i = 0; i < services.length; i++) {
  @@ -2137,7 +2140,7 @@
   
   
       /**
  -     * Get the lifecycle listeners associated with this lifecycle. If this 
  +     * Get the lifecycle listeners associated with this lifecycle. If this
        * Lifecycle has no listeners registered, a zero-length array is returned.
        */
       public LifecycleListener[] findLifecycleListeners() {
  
  
  
  1.7       +6 -6      
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryUserDatabase.java
  
  Index: MemoryUserDatabase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/users/MemoryUserDatabase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MemoryUserDatabase.java   10 Feb 2002 03:20:17 -0000      1.6
  +++ MemoryUserDatabase.java   13 Aug 2002 08:08:17 -0000      1.7
  @@ -506,11 +506,11 @@
   
               // Configure our PrintWriter
               FileOutputStream fos = new FileOutputStream(fileNew);
  -            OutputStreamWriter osw = new OutputStreamWriter(fos);
  +            OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF8");
               writer = new PrintWriter(osw);
   
               // Print the file prolog
  -            writer.println("<?xml version='1.0'?>");
  +            writer.println("<?xml version='1.0' encoding='utf-8'?>");
               writer.println("<tomcat-users>");
   
               // Print entries for each defined role, group, and user
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to