src/java.xml/share/classes/javax/xml/xpath/XPathFactoryFinder.java

Print this page




 159         try {
 160             debugPrintln("Looking up system property '"+propertyName+"'" );
 161             String r = ss.getSystemProperty(propertyName);
 162             if(r!=null) {
 163                 debugPrintln("The value is '"+r+"'");
 164                 xpathFactory = createInstance(r, true);
 165                 if (xpathFactory != null) {
 166                     return xpathFactory;
 167                 }
 168             } else
 169                 debugPrintln("The property is undefined.");
 170         } catch( Throwable t ) {
 171             if( debug ) {
 172                 debugPrintln("failed to look up system property '"+propertyName+"'" );
 173                 t.printStackTrace();
 174             }
 175         }
 176 
 177         String javah = ss.getSystemProperty( "java.home" );
 178         String configFile = javah + File.separator +
 179         "conf" + File.separator + "jaxp.properties";
 180 
 181         // try to read from $java.home/conf/jaxp.properties
 182         try {
 183             if(firstTime){
 184                 synchronized(cacheProps){
 185                     if(firstTime){
 186                         File f=new File( configFile );
 187                         firstTime = false;
 188                         if(ss.doesFileExist(f)){
 189                             debugPrintln("Read properties file " + f);
 190                             cacheProps.load(ss.getFileInputStream(f));
 191                         }
 192                     }
 193                 }
 194             }
 195             final String factoryClassName = cacheProps.getProperty(propertyName);
 196             debugPrintln("found " + factoryClassName + " in $java.home/conf/jaxp.properties");
 197 
 198             if (factoryClassName != null) {
 199                 xpathFactory = createInstance(factoryClassName, true);
 200                 if(xpathFactory != null){
 201                     return xpathFactory;
 202                 }
 203             }
 204         } catch (Exception ex) {
 205             if (debug) {
 206                 ex.printStackTrace();
 207             }
 208         }
 209 
 210         // Try with ServiceLoader
 211         assert xpathFactory == null;
 212         xpathFactory = findServiceProvider(uri);
 213 
 214         // The following assertion should always be true.
 215         // Uncomment it, recompile, and run with -ea in case of doubts:
 216         // assert xpathFactory == null || xpathFactory.isObjectModelSupported(uri);




 159         try {
 160             debugPrintln("Looking up system property '"+propertyName+"'" );
 161             String r = ss.getSystemProperty(propertyName);
 162             if(r!=null) {
 163                 debugPrintln("The value is '"+r+"'");
 164                 xpathFactory = createInstance(r, true);
 165                 if (xpathFactory != null) {
 166                     return xpathFactory;
 167                 }
 168             } else
 169                 debugPrintln("The property is undefined.");
 170         } catch( Throwable t ) {
 171             if( debug ) {
 172                 debugPrintln("failed to look up system property '"+propertyName+"'" );
 173                 t.printStackTrace();
 174             }
 175         }
 176 
 177         String javah = ss.getSystemProperty( "java.home" );
 178         String configFile = javah + File.separator +
 179         "lib" + File.separator + "jaxp.properties";
 180 
 181         // try to read from $java.home/lib/jaxp.properties
 182         try {
 183             if(firstTime){
 184                 synchronized(cacheProps){
 185                     if(firstTime){
 186                         File f=new File( configFile );
 187                         firstTime = false;
 188                         if(ss.doesFileExist(f)){
 189                             debugPrintln("Read properties file " + f);
 190                             cacheProps.load(ss.getFileInputStream(f));
 191                         }
 192                     }
 193                 }
 194             }
 195             final String factoryClassName = cacheProps.getProperty(propertyName);
 196             debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties");
 197 
 198             if (factoryClassName != null) {
 199                 xpathFactory = createInstance(factoryClassName, true);
 200                 if(xpathFactory != null){
 201                     return xpathFactory;
 202                 }
 203             }
 204         } catch (Exception ex) {
 205             if (debug) {
 206                 ex.printStackTrace();
 207             }
 208         }
 209 
 210         // Try with ServiceLoader
 211         assert xpathFactory == null;
 212         xpathFactory = findServiceProvider(uri);
 213 
 214         // The following assertion should always be true.
 215         // Uncomment it, recompile, and run with -ea in case of doubts:
 216         // assert xpathFactory == null || xpathFactory.isObjectModelSupported(uri);