/** * 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;
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);
private void createXalanTransformerFactory() { final String xalanMessage = "org.apache.xalan.xsltc.trax.SmartTransformerFactoryImpl "+ "could not create an "+ "org.apache.xalan.processor.TransformerFactoryImpl."; // try to create instance of Xalan factory... try { Class xalanFactClass = ObjectFactory.findProviderClass( "org.apache.xalan.processor.TransformerFactoryImpl", ObjectFactory.findClassLoader(), true); _xalanFactory = (SAXTransformerFactory) xalanFactClass.newInstance(); } catch (ClassNotFoundException e) { System.err.println(xalanMessage); } catch (InstantiationException e) { System.err.println(xalanMessage); } catch (IllegalAccessException e) { System.err.println(xalanMessage); } _currFactory = _xalanFactory; }
/** * 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); } }
throws ConfigurationError Class factoryClass = lookUpFactoryClass(factoryId, propertiesFilename, fallbackClassName); debugPrintln("created new instance of factory " + factoryId); return instance; } catch (Exception x) {
ClassLoader cl = findClassLoader(); debugPrintln("found jar resource=" + serviceId + " using ClassLoader: " + cl); debugPrintln("found in resource, value=" + factoryClassName);
public Object run() { return new TransletClassLoader(ObjectFactory.findClassLoader()); } });
/** * 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
final Class clazz = ObjectFactory.findProviderClass( transletName, ObjectFactory.findClassLoader(), true); resetTransientAttributes();
/** * 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); } }
throws ConfigurationError Class factoryClass = lookUpFactoryClass(factoryId, propertiesFilename, fallbackClassName); debugPrintln("created new instance of factory " + factoryId); return instance; } catch (Exception x) {
ClassLoader cl = findClassLoader(); debugPrintln("found jar resource=" + serviceId + " using ClassLoader: " + cl); debugPrintln("found in resource, value=" + factoryClassName);
public Object run() { return new TransletClassLoader(ObjectFactory.findClassLoader()); } });
/** * 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
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;
private void createXalanTransformerFactory() { final String xalanMessage = "org.apache.xalan.xsltc.trax.SmartTransformerFactoryImpl "+ "could not create an "+ "org.apache.xalan.processor.TransformerFactoryImpl."; // try to create instance of Xalan factory... try { Class xalanFactClass = ObjectFactory.findProviderClass( "org.apache.xalan.processor.TransformerFactoryImpl", ObjectFactory.findClassLoader(), true); _xalanFactory = (SAXTransformerFactory) xalanFactClass.newInstance(); } catch (ClassNotFoundException e) { System.err.println(xalanMessage); } catch (InstantiationException e) { System.err.println(xalanMessage); } catch (IllegalAccessException e) { System.err.println(xalanMessage); } _currFactory = _xalanFactory; }
/** * 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); } }
throws ConfigurationError Class factoryClass = lookUpFactoryClass(factoryId, propertiesFilename, fallbackClassName); debugPrintln("created new instance of factory " + factoryId); return instance; } catch (Exception x) {
ClassLoader cl = findClassLoader(); debugPrintln("found jar resource=" + serviceId + " using ClassLoader: " + cl); debugPrintln("found in resource, value=" + factoryClassName);