in jaxws-api-2.2/src/main/java/javax/xml/ws/spi/FactoryFinder.java [167:246]
static Object find(String factoryId, String fallbackClassName)
throws ConfigurationError {
final String iFactoryId = factoryId;
final String iFallbackClassName = fallbackClassName;
Object obj =
doPrivileged( new PrivilegedAction<Object>() {
public Object run() {
debugPrintln("debug is on");
// Section 6.2.1 of the jaxws spec gives lookup order as
// 1. META-INF/services definition
// 2. ${java.home}/lib/jaxws.properties file
// 3. System property
// 4. The default implementation class
ClassLoader classLoader = findClassLoader();
try {
// If we are deployed into an OSGi environment, leverage it
Class factoryClass = null;
if (FactoryFinder.class.getClassLoader() != null) {
factoryClass = FactoryFinder.class.getClassLoader().loadClass(iFactoryId);
} else {
factoryClass = Class.forName(iFactoryId);
}
Class spiClass = org.apache.servicemix.specs.locator.OsgiLocator.locate(factoryClass, iFactoryId);
if (spiClass != null) {
debugPrintln("Found spiClass: " + spiClass);
return spiClass.newInstance();
} else {
debugPrintln("No spiClass found in OSGi");
}
} catch (Throwable e) {
if (debug) e.printStackTrace();
}
try {
// check the META-INF/services definitions, and return it if
// we find something.
Object service = ProviderLocator.getService(iFactoryId, FactoryFinder.class, classLoader);
if (service != null) {
return service;
}
} catch (Exception ex) {
if (debug) ex.printStackTrace();
}
try {
String factoryClassName = ProviderLocator.lookupByJREPropertyFile("lib" + File.separator + "jaxrpc.properties", iFactoryId);
if (factoryClassName != null) {
debugPrintln("found java.home property " + factoryClassName);
return newInstance(factoryClassName, classLoader);
}
} catch (Exception ex) {
if (debug) ex.printStackTrace();
}
// Use the system property first
try {
String systemProp =
System.getProperty(iFactoryId);
if (systemProp != null) {
debugPrintln("found system property " + systemProp);
return newInstance(systemProp, classLoader);
}
} catch (SecurityException se) {
}
if (iFallbackClassName == null) {
throw new ConfigurationError(
"Provider for " + iFactoryId + " cannot be found", null);
}
debugPrintln("loaded from fallback value: " + iFallbackClassName);
return newInstance(iFallbackClassName, classLoader);
}
});
return obj;
}