You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2007/07/23 04:43:13 UTC

svn commit: r558590 - in /xerces/java/trunk/samples/xni: ObjectFactory.java SecuritySupport.java

Author: mrglavas
Date: Sun Jul 22 19:43:11 2007
New Revision: 558590

URL: http://svn.apache.org/viewvc?view=rev&rev=558590
Log:
Making all methods of SecuritySupport static. There's no longer a need 
for them to be instance methods since we eliminated SecuritySupport12.

Modified:
    xerces/java/trunk/samples/xni/ObjectFactory.java
    xerces/java/trunk/samples/xni/SecuritySupport.java

Modified: xerces/java/trunk/samples/xni/ObjectFactory.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/samples/xni/ObjectFactory.java?view=diff&rev=558590&r1=558589&r2=558590
==============================================================================
--- xerces/java/trunk/samples/xni/ObjectFactory.java (original)
+++ xerces/java/trunk/samples/xni/ObjectFactory.java Sun Jul 22 19:43:11 2007
@@ -130,12 +130,11 @@
     {
         if (DEBUG) debugPrintln("debug is on");
 
-        SecuritySupport ss = SecuritySupport.getInstance();
         ClassLoader cl = findClassLoader();
 
         // Use the system property first
         try {
-            String systemProp = ss.getSystemProperty(factoryId);
+            String systemProp = SecuritySupport.getSystemProperty(factoryId);
             if (systemProp != null) {
                 if (DEBUG) debugPrintln("found system property, value=" + systemProp);
                 return newInstance(systemProp, cl, true);
@@ -151,11 +150,11 @@
             File propertiesFile = null;
             boolean propertiesFileExists = false;
             try {
-                String javah = ss.getSystemProperty("java.home");
+                String javah = SecuritySupport.getSystemProperty("java.home");
                 propertiesFilename = javah + File.separator +
                     "lib" + File.separator + DEFAULT_PROPERTIES_FILENAME;
                 propertiesFile = new File(propertiesFilename);
-                propertiesFileExists = ss.getFileExists(propertiesFile);
+                propertiesFileExists = SecuritySupport.getFileExists(propertiesFile);
             } catch (SecurityException e) {
                 // try again...
                 fLastModified = -1;
@@ -169,7 +168,7 @@
                     // file existed last time
                     if(fLastModified >= 0) {
                         if(propertiesFileExists &&
-                                (fLastModified < (fLastModified = ss.getLastModified(propertiesFile)))) {
+                                (fLastModified < (fLastModified = SecuritySupport.getLastModified(propertiesFile)))) {
                             loadProperties = true;
                         } else {
                             // file has stopped existing...
@@ -182,13 +181,13 @@
                         // file has started to exist:
                         if(propertiesFileExists) {
                             loadProperties = true;
-                            fLastModified = ss.getLastModified(propertiesFile);
+                            fLastModified = SecuritySupport.getLastModified(propertiesFile);
                         } // else, nothing's changed
                     }
                     if(loadProperties) {
                         // must never have attempted to read xerces.properties before (or it's outdeated)
                         fXercesProperties = new Properties();
-                        fis = ss.getFileInputStream(propertiesFile);
+                        fis = SecuritySupport.getFileInputStream(propertiesFile);
                         fXercesProperties.load(fis);
                     }
                 } catch (Exception x) {
@@ -215,7 +214,7 @@
         } else {
             FileInputStream fis = null;
             try {
-                fis = ss.getFileInputStream(new File(propertiesFilename));
+                fis = SecuritySupport.getFileInputStream(new File(propertiesFilename));
                 Properties props = new Properties();
                 props.load(fis);
                 factoryClassName = props.getProperty(factoryId);
@@ -273,12 +272,10 @@
     static ClassLoader findClassLoader()
         throws ConfigurationError
     {
-        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 context = ss.getContextClassLoader();
-        ClassLoader system = ss.getSystemClassLoader();
+        ClassLoader context = SecuritySupport.getContextClassLoader();
+        ClassLoader system = SecuritySupport.getSystemClassLoader();
 
         ClassLoader chain = system;
         while (true) {
@@ -303,7 +300,7 @@
                     if (chain == null) {
                         break;
                     }
-                    chain = ss.getParentClassLoader(chain);
+                    chain = SecuritySupport.getParentClassLoader(chain);
                 }
 
                 // Assert: Current ClassLoader not in chain of
@@ -318,7 +315,7 @@
 
             // Check for any extension ClassLoaders in chain up to
             // boot ClassLoader
-            chain = ss.getParentClassLoader(chain);
+            chain = SecuritySupport.getParentClassLoader(chain);
         };
 
         // Assert: Context ClassLoader not in chain of
@@ -410,21 +407,20 @@
     private static Object findJarServiceProvider(String factoryId)
         throws ConfigurationError
     {
-        SecuritySupport ss = SecuritySupport.getInstance();
         String serviceId = "META-INF/services/" + factoryId;
         InputStream is = null;
 
         // First try the Context ClassLoader
         ClassLoader cl = findClassLoader();
 
-        is = ss.getResourceAsStream(cl, serviceId);
+        is = SecuritySupport.getResourceAsStream(cl, serviceId);
 
         // If no provider found then try the current ClassLoader
         if (is == null) {
             ClassLoader current = ObjectFactory.class.getClassLoader();
             if (cl != current) {
                 cl = current;
-                is = ss.getResourceAsStream(cl, serviceId);
+                is = SecuritySupport.getResourceAsStream(cl, serviceId);
             }
         }
 

Modified: xerces/java/trunk/samples/xni/SecuritySupport.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/samples/xni/SecuritySupport.java?view=diff&rev=558590&r1=558589&r2=558590
==============================================================================
--- xerces/java/trunk/samples/xni/SecuritySupport.java (original)
+++ xerces/java/trunk/samples/xni/SecuritySupport.java Sun Jul 22 19:43:11 2007
@@ -35,16 +35,7 @@
  */
 final class SecuritySupport {
 
-    private static final SecuritySupport securitySupport = new SecuritySupport();
-
-    /**
-     * Return an instance of this class.
-     */
-    static SecuritySupport getInstance() {
-        return securitySupport;
-    }
-
-    ClassLoader getContextClassLoader() {
+    static ClassLoader getContextClassLoader() {
         return (ClassLoader)
         AccessController.doPrivileged(new PrivilegedAction() {
             public Object run() {
@@ -57,7 +48,7 @@
         });
     }
     
-    ClassLoader getSystemClassLoader() {
+    static ClassLoader getSystemClassLoader() {
         return (ClassLoader)
         AccessController.doPrivileged(new PrivilegedAction() {
             public Object run() {
@@ -70,7 +61,7 @@
         });
     }
     
-    ClassLoader getParentClassLoader(final ClassLoader cl) {
+    static ClassLoader getParentClassLoader(final ClassLoader cl) {
         return (ClassLoader)
         AccessController.doPrivileged(new PrivilegedAction() {
             public Object run() {
@@ -86,7 +77,7 @@
         });
     }
     
-    String getSystemProperty(final String propName) {
+    static String getSystemProperty(final String propName) {
         return (String)
         AccessController.doPrivileged(new PrivilegedAction() {
             public Object run() {
@@ -95,7 +86,7 @@
         });
     }
     
-    FileInputStream getFileInputStream(final File file)
+    static FileInputStream getFileInputStream(final File file)
     throws FileNotFoundException
     {
         try {
@@ -110,7 +101,7 @@
         }
     }
     
-    InputStream getResourceAsStream(final ClassLoader cl,
+    static InputStream getResourceAsStream(final ClassLoader cl,
             final String name)
     {
         return (InputStream)
@@ -127,7 +118,7 @@
         });
     }
     
-    boolean getFileExists(final File f) {
+    static boolean getFileExists(final File f) {
         return ((Boolean)
                 AccessController.doPrivileged(new PrivilegedAction() {
                     public Object run() {
@@ -136,7 +127,7 @@
                 })).booleanValue();
     }
     
-    long getLastModified(final File f) {
+    static long getLastModified(final File f) {
         return ((Long)
                 AccessController.doPrivileged(new PrivilegedAction() {
                     public Object run() {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org