public SchemaFactory newFactory(String schemaLanguage) { if (schemaLanguage == null) { throw new NullPointerException(); } SchemaFactory f = _newFactory(schemaLanguage); if (f != null) { debugPrintln(() -> "factory '" + f.getClass().getName() + "' was found for " + schemaLanguage); } else { debugPrintln(() -> "unable to find a factory for " + schemaLanguage); } return f; }
SchemaFactory createInstance(String className, boolean useServicesMechanism) { SchemaFactory schemaFactory = null; debugPrintln(() -> "createInstance(" + className + ")"); Class<?> clazz = createClass(className); if (clazz == null) { debugPrintln(() -> "failed to getClass(" + className + ")"); return null; debugPrintln(() -> "loaded " + className + " from " + which(clazz)); schemaFactory = newInstanceNoServiceLoader(clazz); debugPrintln(() -> "could not instantiate " + clazz.getName()); if (debug) { classCastException.printStackTrace(); debugPrintln(() -> "could not instantiate " + clazz.getName()); if (debug) { illegalAccessException.printStackTrace(); debugPrintln(() -> "could not instantiate " + clazz.getName()); if (debug) { instantiationException.printStackTrace();
public static SchemaFactory newInstance(String schemaLanguage, String factoryClassName, ClassLoader classLoader) { ClassLoader cl = classLoader; if (cl == null) { cl = $SchemaFactoryFinder.getContextClassLoader(); } SchemaFactory f = new $SchemaFactoryFinder(cl).createInstance(factoryClassName); if (f == null) { throw new IllegalArgumentException( "Factory " + factoryClassName + " could not be loaded to implement the schema language specified by: " + schemaLanguage); } if (f.isSchemaLanguageSupported(schemaLanguage)) { return f; } else { throw new IllegalArgumentException( "Factory " + f.getClass().getName() + " does not implement the schema language specified by: " + schemaLanguage); } }
debugPrintln(() -> "Looking up system property '" + propertyName + "'"); String r = getSystemProperty(propertyName); if (r != null) { debugPrintln(() -> "The value is '" + r + "'"); sf = createInstance(r, true); if (sf != null) return sf; } else debugPrintln(() -> "The property is undefined."); } catch (Throwable t) { if (debug) { debugPrintln(() -> "failed to look up system property '" + propertyName + "'"); t.printStackTrace(); String javah = getSystemProperty("java.home"); String configFile = javah + File.separator + "conf" + File.separator + "jaxp.properties"; File f = new File(configFile); firstTime = false; if (doesFileExist(f)) { debugPrintln(() -> "Read properties file " + f); cacheProps.load(getFileInputStream(f)); debugPrintln(() -> "found " + factoryClassName + " in $java.home/conf/jaxp.properties"); sf = createInstance(factoryClassName, true); if (sf != null) { return sf;
public static SchemaFactory newDefaultInstance() { return new $SchemaFactoryFinder(null).createInstance(DEFAULT_IMPL, true); }
public static SchemaFactory newInstance(String schemaLanguage) { ClassLoader cl = $SchemaFactoryFinder.getContextClassLoader(); if (cl == null) { cl = SchemaFactory.class.getClassLoader(); } SchemaFactory f = new $SchemaFactoryFinder(cl).newFactory(schemaLanguage); if (f == null) { throw new IllegalArgumentException( "No SchemaFactory" + " that implements the schema language specified by: " + schemaLanguage + " could be loaded"); } return f; }
private static String which(Class<?> clazz) { return getClassSource(clazz); }
SchemaFactory createInstance(String className) { return createInstance(className, false); }
private void debugDisplayClassLoader() { try { if (classLoader == getContextClassLoader()) { debugPrintln(() -> "using thread context class loader (" + classLoader + ") for search"); return; } } catch (Throwable unused) { } if (classLoader == ClassLoader.getSystemClassLoader()) { debugPrintln(() -> "using system class loader (" + classLoader + ") for search"); return; } debugPrintln(() -> "using class loader (" + classLoader + ") for search"); }
public $SchemaFactoryFinder(ClassLoader loader) { this.classLoader = loader; if (debug) { debugDisplayClassLoader(); } }