/** * This method loads a class using the context class loader if we're * running under Java2 or higher. * * @param className Name of the class to load */ static Class getClassForName(String className) throws ClassNotFoundException { // Hack for backwards compatibility with XalanJ1 stylesheets if(className.equals("org.apache.xalan.xslt.extensions.Redirect")) { className = "org.apache.xalan.lib.Redirect"; } return ObjectFactory.findProviderClass( className, ObjectFactory.findClassLoader(), true); }
/** * Finds the implementation Class object in the specified order. The * specified order is the following: * <ol> * <li>query the system property using <code>System.getProperty</code> * <li>read <code>META-INF/services/<i>factoryId</i></code> file * <li>use fallback classname * </ol> * * @return instance of factory, never null * * @param factoryId Name of the factory to find, same as * a property name * @param fallbackClassName Implementation class name, if nothing else * is found. Use null to mean no fallback. * * @exception ObjectFactory.ConfigurationError */ static Object createObject(String factoryId, String fallbackClassName) throws ConfigurationError { return createObject(factoryId, null, fallbackClassName); } // createObject(String,String):Object
throws ConfigurationError String factoryClassName = lookUpFactoryClassName(factoryId, propertiesFilename, fallbackClassName); ClassLoader cl = findClassLoader(); Class providerClass = findProviderClass(factoryClassName, cl, true); debugPrintln("created new instance of " + providerClass + " using ClassLoader: " + cl); return providerClass;
/** * Create an instance of a class using the specified ClassLoader */ static Object newInstance(String className, ClassLoader cl, boolean doFallback) throws ConfigurationError { // assert(className != null); try{ Class providerClass = findProviderClass(className, cl, doFallback); Object instance = providerClass.newInstance(); debugPrintln("created new instance of " + providerClass + " using ClassLoader: " + cl); return instance; } catch (ClassNotFoundException x) { throw new ConfigurationError( "Provider " + className + " not found", x); } catch (Exception x) { throw new ConfigurationError( "Provider " + className + " could not be instantiated: " + x, x); } }
try manager = ObjectFactory.newInstance( BSF_MANAGER, ObjectFactory.findClassLoader(), true);
ClassLoader cl = findClassLoader(); debugPrintln("found jar resource=" + serviceId + " using ClassLoader: " + cl); debugPrintln("found in resource, value=" + factoryClassName);
throws ConfigurationError Class factoryClass = lookUpFactoryClass(factoryId, propertiesFilename, fallbackClassName); debugPrintln("created new instance of factory " + factoryId); return instance; } catch (Exception x) {
String systemProp = SecuritySupport.getSystemProperty(factoryId); if (systemProp != null) { debugPrintln("found system property, value=" + systemProp); return systemProp; debugPrintln("found in " + propertiesFilename + ", value=" + factoryClassName); return factoryClassName; return findJarServiceProviderName(factoryId);
BSF_MANAGER = ObjectFactory.lookUpFactoryClassName(propName, null, null);
/** * Finds the implementation Class object in the specified order. The * specified order is the following: * <ol> * <li>query the system property using <code>System.getProperty</code> * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file * <li>read <code>META-INF/services/<i>factoryId</i></code> file * <li>use fallback classname * </ol> * * @return Class object of factory, never null * * @param factoryId Name of the factory to find, same as * a property name * @param propertiesFilename The filename in the $java.home/lib directory * of the properties file. If none specified, * ${java.home}/lib/xalan.properties will be used. * @param fallbackClassName Implementation class name, if nothing else * is found. Use null to mean no fallback. * * @exception ObjectFactory.ConfigurationError */ static Class lookUpFactoryClass(String factoryId) throws ConfigurationError { return lookUpFactoryClass(factoryId, null, null); } // lookUpFactoryClass(String):Class
try manager = ObjectFactory.newInstance( BSF_MANAGER, ObjectFactory.findClassLoader(), true);
/** * Create an instance of a class using the specified ClassLoader */ static Object newInstance(String className, ClassLoader cl, boolean doFallback) throws ConfigurationError { // assert(className != null); try{ Class providerClass = findProviderClass(className, cl, doFallback); Object instance = providerClass.newInstance(); debugPrintln("created new instance of " + providerClass + " using ClassLoader: " + cl); return instance; } catch (ClassNotFoundException x) { throw new ConfigurationError( "Provider " + className + " not found", x); } catch (Exception x) { throw new ConfigurationError( "Provider " + className + " could not be instantiated: " + x, x); } }
ClassLoader cl = findClassLoader(); debugPrintln("found jar resource=" + serviceId + " using ClassLoader: " + cl); debugPrintln("found in resource, value=" + factoryClassName);
throws ConfigurationError Class factoryClass = lookUpFactoryClass(factoryId, propertiesFilename, fallbackClassName); debugPrintln("created new instance of factory " + factoryId); return instance; } catch (Exception x) {
String systemProp = ss.getSystemProperty(factoryId); if (systemProp != null) { debugPrintln("found system property, value=" + systemProp); return systemProp; debugPrintln("found in " + propertiesFilename + ", value=" + factoryClassName); return factoryClassName; return findJarServiceProviderName(factoryId);
BSF_MANAGER = ObjectFactory.lookUpFactoryClassName(propName, null, null);
/** * Finds the implementation Class object in the specified order. The * specified order is the following: * <ol> * <li>query the system property using <code>System.getProperty</code> * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file * <li>read <code>META-INF/services/<i>factoryId</i></code> file * <li>use fallback classname * </ol> * * @return Class object of factory, never null * * @param factoryId Name of the factory to find, same as * a property name * @param propertiesFilename The filename in the $java.home/lib directory * of the properties file. If none specified, * ${java.home}/lib/xalan.properties will be used. * @param fallbackClassName Implementation class name, if nothing else * is found. Use null to mean no fallback. * * @exception ObjectFactory.ConfigurationError */ static Class lookUpFactoryClass(String factoryId) throws ConfigurationError { return lookUpFactoryClass(factoryId, null, null); } // lookUpFactoryClass(String):Class
/** * This method loads a class using the context class loader if we're * running under Java2 or higher. * * @param className Name of the class to load */ static Class getClassForName(String className) throws ClassNotFoundException { // Hack for backwards compatibility with XalanJ1 stylesheets if(className.equals("org.apache.xalan.xslt.extensions.Redirect")) { className = "org.apache.xalan.lib.Redirect"; } return ObjectFactory.findProviderClass( className, ObjectFactory.findClassLoader(), true); }
throws ConfigurationError String factoryClassName = lookUpFactoryClassName(factoryId, propertiesFilename, fallbackClassName); ClassLoader cl = findClassLoader(); Class providerClass = findProviderClass(factoryClassName, cl, true); debugPrintln("created new instance of " + providerClass + " using ClassLoader: " + cl); return providerClass;
try manager = ObjectFactory.newInstance( BSF_MANAGER, ObjectFactory.findClassLoader(), true);