in jaxp-api-1.4/src/main/java/javax/xml/xpath/XPathFactoryFinder.java [157:254]
private XPathFactory _newFactory(String uri) {
XPathFactory sf;
String propertyName = SERVICE_CLASS.getName() + ":" + uri;
try {
// If we are deployed into an OSGi environment, leverage it
Class spiClass = org.apache.servicemix.specs.locator.OsgiLocator.locate(SERVICE_CLASS);
if (spiClass != null) {
return (XPathFactory) spiClass.newInstance();
}
} catch (Throwable e) {
}
// system property look up
try {
if (debug) debugPrintln("Looking up system property '"+propertyName+"'" );
String r = SecuritySupport.getSystemProperty(propertyName);
if(r!=null) {
if (debug) debugPrintln("The value is '"+r+"'");
sf = createInstance(r);
if(sf!=null) return sf;
}
else if (debug) {
debugPrintln("The property is undefined.");
}
} catch( Throwable t ) {
if( debug ) {
debugPrintln("failed to look up system property '"+propertyName+"'" );
t.printStackTrace();
}
}
String javah = SecuritySupport.getSystemProperty( "java.home" );
String configFile = javah + File.separator +
"lib" + File.separator + "jaxp.properties";
String factoryClassName = null ;
// try to read from $java.home/lib/jaxp.properties
try {
if(firstTime){
synchronized(cacheProps){
if(firstTime){
File f=new File( configFile );
firstTime = false;
if(SecuritySupport.doesFileExist(f)){
if (debug) debugPrintln("Read properties file " + f);
cacheProps.load(SecuritySupport.getFileInputStream(f));
}
}
}
}
factoryClassName = cacheProps.getProperty(propertyName);
if (debug) debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties");
if (factoryClassName != null) {
sf = createInstance(factoryClassName);
if(sf != null){
return sf;
}
}
} catch (Exception ex) {
if (debug) {
ex.printStackTrace();
}
}
// try META-INF/services files
Iterator sitr = createServiceFileIterator();
while(sitr.hasNext()) {
URL resource = (URL)sitr.next();
if (debug) debugPrintln("looking into " + resource);
try {
sf = loadFromServicesFile(uri, resource.toExternalForm(), SecuritySupport.getURLInputStream(resource));
if(sf!=null) return sf;
} catch(IOException e) {
if( debug ) {
debugPrintln("failed to read "+resource);
e.printStackTrace();
}
}
}
// platform default
if(uri.equals(XPathFactory.DEFAULT_OBJECT_MODEL_URI)) {
if (debug) debugPrintln("attempting to use the platform default W3C DOM XPath lib");
XPathFactory f = createInstance("com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl");
if (f == null) {
//IBM JDK
f = createInstance("org.apache.xpath.jaxp.XPathFactoryImpl");
}
return f;
}
if (debug) debugPrintln("all things were tried, but none was found. bailing out.");
return null;
}