in saaj-api-1.3/src/main/java/javax/xml/soap/FactoryFinder.java [113:194]
static Object find(String factoryPropertyName,
Class factoryClass,
String defaultFactoryClassName) throws SOAPException {
try {
// If we are deployed into an OSGi environment, leverage it
if (factoryClass == null) {
String factoryClassName = factoryPropertyName;
if (factoryPropertyName.equals("javax.xml.soap.MetaFactory")) {
//this is an exception that the factoryPropertyName isn't
//the actual factory class name, there is no class
//javax.xml.soap.MetaFactory at all
factoryClassName = "javax.xml.soap.SAAJMetaFactory";
}
ClassLoader cl = FactoryFinder.class.getClassLoader();
if (cl == null) {
cl = Thread.currentThread().getContextClassLoader();
}
factoryClass = cl.loadClass(factoryClassName);
}
Class spiClass = org.apache.servicemix.specs.locator.OsgiLocator.locate(factoryClass, factoryPropertyName);
if (spiClass != null) {
return spiClass.newInstance();
}
} catch (Throwable e) {
}
try {
String factoryClassName = System.getProperty(factoryPropertyName);
if (factoryClassName != null) {
return newInstance(factoryClassName);
}
} catch (SecurityException securityexception) {
}
try {
String propertiesFileName = System.getProperty("java.home")
+ File.separator + "lib"
+ File.separator + "jaxm.properties";
File file = new File(propertiesFileName);
if (file.exists()) {
FileInputStream fileInput = new FileInputStream(file);
Properties properties = new Properties();
properties.load(fileInput);
fileInput.close();
String factoryClassName = properties.getProperty(
factoryPropertyName);
return newInstance(factoryClassName);
}
} catch (Exception exception1) {
}
String factoryResource = "META-INF/services/" + factoryPropertyName;
try {
InputStream inputstream = getResource(factoryResource);
if (inputstream != null) {
BufferedReader bufferedreader = new BufferedReader(
new InputStreamReader(inputstream, "UTF-8"));
String factoryClassName = bufferedreader.readLine();
bufferedreader.close();
if ((factoryClassName != null) && !"".equals(factoryClassName)) {
try {
return newInstance(factoryClassName);
} catch (Exception e) {
throw new SOAPException(
"Provider for " + factoryPropertyName + " cannot be found",
null);
}
}
}
} catch (Exception exception2) {
}
if (defaultFactoryClassName == null) {
throw new SOAPException(
"Provider for " + factoryPropertyName + " cannot be found",
null);
} else {
return newInstance(defaultFactoryClassName);
}
}