You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-cvs@xml.apache.org by mr...@apache.org on 2008/06/22 03:56:04 UTC

svn commit: r670296 - in /xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers: NewInstance.java ParserFactory.java SecuritySupport.java SecuritySupport12.java XMLReaderFactory.java

Author: mrglavas
Date: Sat Jun 21 18:56:04 2008
New Revision: 670296

URL: http://svn.apache.org/viewvc?rev=670296&view=rev
Log:
Several improvements to the SecuritySupport class:
- Prevent instantiation of the SecuritySupport
- Make all SecuritySupport methods static.
- Deleting the JDK 1.1 version of SecuritySupport which is no longer needed

Removed:
    xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport.java
Modified:
    xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/NewInstance.java
    xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/ParserFactory.java
    xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport12.java
    xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java

Modified: xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/NewInstance.java
URL: http://svn.apache.org/viewvc/xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/NewInstance.java?rev=670296&r1=670295&r2=670296&view=diff
==============================================================================
--- xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/NewInstance.java (original)
+++ xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/NewInstance.java Sat Jun 21 18:56:04 2008
@@ -90,11 +90,9 @@
      */           
     static ClassLoader getClassLoader ()
     {
-        SecuritySupport ss = SecuritySupport.getInstance();
-
         // Figure out which ClassLoader to use for loading the provider
         // class.  If there is a Context ClassLoader then use it.
-        ClassLoader cl = ss.getContextClassLoader();
+        ClassLoader cl = SecuritySupport12.getContextClassLoader();
         if (cl == null) {
             // Assert: we are on JDK 1.1 or we have no Context ClassLoader
             // so use the current ClassLoader

Modified: xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/ParserFactory.java
URL: http://svn.apache.org/viewvc/xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/ParserFactory.java?rev=670296&r1=670295&r2=670296&view=diff
==============================================================================
--- xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/ParserFactory.java (original)
+++ xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/ParserFactory.java Sat Jun 21 18:56:04 2008
@@ -78,8 +78,7 @@
     NullPointerException,
     ClassCastException
     {
-        SecuritySupport ss = SecuritySupport.getInstance();
-        String className = ss.getSystemProperty("org.xml.sax.parser");
+        String className = SecuritySupport12.getSystemProperty("org.xml.sax.parser");
         if (className == null) {
             throw new NullPointerException("No value for sax.parser property");
         } else {

Modified: xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport12.java
URL: http://svn.apache.org/viewvc/xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport12.java?rev=670296&r1=670295&r2=670296&view=diff
==============================================================================
--- xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport12.java (original)
+++ xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/SecuritySupport12.java Sat Jun 21 18:56:04 2008
@@ -33,9 +33,11 @@
  *
  * Security related methods that only work on J2SE 1.2 and newer.
  */
-class SecuritySupport12 extends SecuritySupport {
+final class SecuritySupport12 {
+    
+    private SecuritySupport12() {}
 
-    public ClassLoader getContextClassLoader() {
+    static ClassLoader getContextClassLoader() {
 	return (ClassLoader)
 		AccessController.doPrivileged(new PrivilegedAction() {
 	    public Object run() {
@@ -48,7 +50,7 @@
 	});
     }
 
-    public String getSystemProperty(final String propName) {
+    static String getSystemProperty(final String propName) {
 	return (String)
             AccessController.doPrivileged(new PrivilegedAction() {
                 public Object run() {
@@ -57,7 +59,7 @@
             });
     }
 
-    public FileInputStream getFileInputStream(final File file)
+    static FileInputStream getFileInputStream(final File file)
         throws FileNotFoundException
     {
 	try {
@@ -72,7 +74,7 @@
 	}
     }
 
-    public InputStream getResourceAsStream(final ClassLoader cl,
+    static InputStream getResourceAsStream(final ClassLoader cl,
                                            final String name)
     {
         return (InputStream)

Modified: xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java
URL: http://svn.apache.org/viewvc/xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java?rev=670296&r1=670295&r2=670296&view=diff
==============================================================================
--- xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java (original)
+++ xml/commons/branches/tck-jaxp-1_3_0/java/external/src/org/xml/sax/helpers/XMLReaderFactory.java Sat Jun 21 18:56:04 2008
@@ -111,11 +111,10 @@
     throws SAXException
     {
         String		className = null;
-        SecuritySupport ss = SecuritySupport.getInstance();
         ClassLoader	loader = NewInstance.getClassLoader ();
         
         // 1. try the JVM-instance-wide system property
-        try { className = ss.getSystemProperty (property); }
+        try { className = SecuritySupport12.getSystemProperty (property); }
         catch (Exception e) { /* normally fails for applets */ }
         
         // 2. if that fails, try META-INF/services/
@@ -126,20 +125,20 @@
             className = null;
             
             // First try the Context ClassLoader
-            ClassLoader cl = ss.getContextClassLoader();
+            ClassLoader cl = SecuritySupport12.getContextClassLoader();
             if (cl != null) {
-                is = ss.getResourceAsStream(cl, service);
+                is = SecuritySupport12.getResourceAsStream(cl, service);
                 
                 // If no provider found then try the current ClassLoader
                 if (is == null) {
                     cl = XMLReaderFactory.class.getClassLoader();
-                    is = ss.getResourceAsStream(cl, service);
+                    is = SecuritySupport12.getResourceAsStream(cl, service);
                 }
             } else {
                 // No Context ClassLoader or JDK 1.1 so try the current
                 // ClassLoader
                 cl = XMLReaderFactory.class.getClassLoader();
-                is = ss.getResourceAsStream(cl, service);
+                is = SecuritySupport12.getResourceAsStream(cl, service);
             }
             
             if (is != null) {