/** * 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
/** * 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
/** * 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); } }
checkJAXPVersion(hash); checkProcessorVersion(hash); checkParserVersion(hash); checkAntVersion(hash); checkDOMVersion(hash); checkSAXVersion(hash); checkSystemProperties(hash);
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; } catch (ClassNotFoundException x) { throw new ConfigurationError( "Provider " + factoryClassName + " not found", x); } catch (Exception x) { throw new ConfigurationError( "Provider "+factoryClassName+" could not be instantiated: "+x, x);
throws ConfigurationError SecuritySupport ss = SecuritySupport.getInstance(); ClassLoader context = ss.getContextClassLoader(); ClassLoader system = ss.getSystemClassLoader(); break; chain = ss.getParentClassLoader(chain); chain = ss.getParentClassLoader(chain); };
throws ConfigurationError Class factoryClass = lookUpFactoryClass(factoryId, propertiesFilename, fallbackClassName); throw new ConfigurationError( "Provider for " + factoryId + " cannot be found", null); debugPrintln("created new instance of factory " + factoryId); return instance; } catch (Exception x) { throw new ConfigurationError( "Provider for factory " + factoryId + " could not be instantiated: " + x, x);
Hashtable hash = getEnvironmentHash(); boolean environmentHasErrors = writeEnvironmentReport(hash); logMsg("# WARNING: Potential problems found in your environment!"); logMsg("# Check any 'ERROR' items above against the Xalan FAQs"); logMsg("# to correct potential problems with your classes/jars"); logMsg("# http://xml.apache.org/xalan-j/faq.html"); if (null != outWriter) outWriter.flush(); logMsg("# YAHOO! Your environment seems to be OK."); if (null != outWriter) outWriter.flush();
/** * Report product version information from Ant. * * @param h Hashtable to put information in */ protected void checkAntVersion(Hashtable h) { if (null == h) h = new Hashtable(); try { final String ANT_VERSION_CLASS = "org.apache.tools.ant.Main"; final String ANT_VERSION_METHOD = "getAntVersion"; // noArgs final Class noArgs[] = new Class[0]; Class clazz = ObjectFactory.findProviderClass( ANT_VERSION_CLASS, ObjectFactory.findClassLoader(), true); Method method = clazz.getMethod(ANT_VERSION_METHOD, noArgs); Object returnValue = method.invoke(null, new Object[0]); h.put(VERSION + "ant", (String)returnValue); } catch (Exception e) { h.put(VERSION + "ant", CLASS_NOTPRESENT); } }
ClassLoader context = SecuritySupport.getContextClassLoader(); ClassLoader system = SecuritySupport.getSystemClassLoader(); break; chain = SecuritySupport.getParentClassLoader(chain); chain = SecuritySupport.getParentClassLoader(chain); };
checkJAXPVersion(hash); checkProcessorVersion(hash); checkParserVersion(hash); checkAntVersion(hash); checkDOMVersion(hash); checkSAXVersion(hash); checkSystemProperties(hash);
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; } catch (ClassNotFoundException x) { throw new ConfigurationError( "Provider " + factoryClassName + " not found", x); } catch (Exception x) { throw new ConfigurationError( "Provider "+factoryClassName+" could not be instantiated: "+x, x);
/** * 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); throw new ConfigurationError( "Provider for " + factoryId + " cannot be found", null); debugPrintln("created new instance of factory " + factoryId); return instance; } catch (Exception x) { throw new ConfigurationError( "Provider for factory " + factoryId + " could not be instantiated: " + x, x);
Hashtable hash = getEnvironmentHash(); boolean environmentHasErrors = writeEnvironmentReport(hash); logMsg("# WARNING: Potential problems found in your environment!"); logMsg("# Check any 'ERROR' items above against the Xalan FAQs"); logMsg("# to correct potential problems with your classes/jars"); logMsg("# http://xml.apache.org/xalan-j/faq.html"); if (null != outWriter) outWriter.flush(); logMsg("# YAHOO! Your environment seems to be OK."); if (null != outWriter) outWriter.flush();
/** * Report product version information from Ant. * * @param h Hashtable to put information in */ protected void checkAntVersion(Hashtable h) { if (null == h) h = new Hashtable(); try { final String ANT_VERSION_CLASS = "org.apache.tools.ant.Main"; final String ANT_VERSION_METHOD = "getAntVersion"; // noArgs final Class noArgs[] = new Class[0]; Class clazz = ObjectFactory.findProviderClass( ANT_VERSION_CLASS, ObjectFactory.findClassLoader(), true); Method method = clazz.getMethod(ANT_VERSION_METHOD, noArgs); Object returnValue = method.invoke(null, new Object[0]); h.put(VERSION + "ant", (String)returnValue); } catch (Exception e) { h.put(VERSION + "ant", CLASS_NOTPRESENT); } }
/** * 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
/** * 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 String JAXP11_METHOD = "getDOMImplementation"; clazz = ObjectFactory.findProviderClass( JAXP1_CLASS, ObjectFactory.findClassLoader(), true);
final String JAXP11_METHOD = "getDOMImplementation"; clazz = ObjectFactory.findProviderClass( JAXP1_CLASS, ObjectFactory.findClassLoader(), true);