SchemaFactoryFinder.java revision 286
286N/A * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. 286N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 286N/A * This code is free software; you can redistribute it and/or modify it 286N/A * under the terms of the GNU General Public License version 2 only, as 286N/A * published by the Free Software Foundation. Oracle designates this 286N/A * particular file as subject to the "Classpath" exception as provided 286N/A * by Oracle in the LICENSE file that accompanied this code. 286N/A * This code is distributed in the hope that it will be useful, but WITHOUT 286N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 286N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 286N/A * version 2 for more details (a copy is included in the LICENSE file that 286N/A * accompanied this code). 286N/A * You should have received a copy of the GNU General Public License version 286N/A * 2 along with this work; if not, write to the Free Software Foundation, 286N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 286N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 286N/A * or visit www.oracle.com if you need additional information or have any 286N/A * Implementation of {@link SchemaFactory#newInstance(String)}. 286N/A * @author <a href="Kohsuke.Kawaguchi@Sun.com">Kohsuke Kawaguchi</a> 286N/A * @version $Revision: 1.8 $, $Date: 2010-11-01 04:36:13 $ 286N/A /** debug support code. */ 286N/A *<p> Take care of restrictions imposed by java security model </p> 286N/A * <p>Cache properties for performance.</p> 286N/A * <p>First time requires initialization overhead.</p> 286N/A * <p>Conditional debug printing.</p> 286N/A * <p><code>ClassLoader</code> to use to find <code>SchemaFactory</code>.</p> 286N/A * <p>Constructor that specifies <code>ClassLoader</code> to use 286N/A * to find <code>SchemaFactory</code>.</p> 286N/A * to be used to load resource, {@link SchemaFactory}, and 286N/A * {@link SchemaFactoryLoader} implementations during 286N/A * the resolution process. 286N/A * If this parameter is null, the default system class loader 286N/A ;
// getContextClassLoader() undefined in JDK1.1 286N/A * <p>Creates a new {@link SchemaFactory} object for the specified 286N/A * @param schemaLanguage 286N/A * See {@link SchemaFactory Schema Language} table in <code>SchemaFactory</code> 286N/A * for the list of available schema languages. 286N/A * @return <code>null</code> if the callee fails to create one. 286N/A * @throws NullPointerException 286N/A * If the <code>schemaLanguage</code> parameter is null. 286N/A * <p>Lookup a <code>SchemaFactory</code> for the given <code>schemaLanguage</code>.</p> 286N/A * @param schemaLanguage Schema language to lookup <code>SchemaFactory</code> for. 286N/A * @return <code>SchemaFactory</code> for the given <code>schemaLanguage</code>. 286N/A // system property look up 286N/A String javah = ss.getSystemProperty( "java.home" ); 286N/A String configFile = javah + File.separator + 286N/A File f = new File( configFile ); 286N/A if( ss.doesFileExist(f)) { 286N/A propertyName,f.getAbsolutePath(), new FileInputStream(f)); 286N/A if(sf!=null) return sf; 286N/A debugPrintln("Tried to read "+ f.getAbsolutePath()+", but it doesn't exist."); 286N/A /** <p>Create class using appropriate ClassLoader.</p> 286N/A * @param className Name of class to create. 286N/A * @return Created class or <code>null</code>. 286N/A // use approprite ClassLoader 286N/A * <p>Creates an instance of the specified and returns it.</p> 286N/A * fully qualified class name to be instanciated. 286N/A * if it fails. Error messages will be printed by this method. 286N/A // get Class from className 286N/A // instantiate Class as a SchemaFactory 286N/A * Try to construct using newTransformerFactoryNoServiceLoader 286N/A // Retain maximum compatibility if no security manager. 286N/A "newXMLSchemaFactoryNoServiceLoader" 286N/A /** Iterator that lazily computes one value and returns it. */ 286N/A * Looks up a value in a property file 286N/A * while producing all sorts of debug messages. 286N/A * if there was an error. 286N/A * <p>Look up a value in a property file.</p> 286N/A * <p>Set <code>debug</code> to <code>true</code> to trace property evaluation.</p> 286N/A * @param schemaLanguage Schema Language to support. 286N/A * @param inputName Name of <code>InputStream</code>. 286N/A * @param in <code>InputStream</code> of properties. 286N/A * @return <code>SchemaFactory</code> as determined by <code>keyName</code> value or <code>null</code> if there was an error. 286N/A * @throws IOException If IO error reading from <code>in</code>. 286N/A // read from InputStream until a match is found 286N/A case -
1:
break;
// no comment 286N/A case 0:
line =
"";
break;
// entire line is a comment 286N/A // any content left on line? 286N/A // line content is now the name of the class 286N/A // create an instance of the Class 286N/A // does this Class support desired Schema? 286N/A // return new instance of SchemaFactory or null 286N/A * Returns an {@link Iterator} that enumerates all 286N/A //return (ClassLoader.getSystemResource( SERVICE_ID )); 286N/A //final Enumeration e = classLoader.getResources(SERVICE_ID); 286N/A // wrap it into an Iterator. 286N/A * <p>Search the specified classloader for the given classname.</p> 286N/A * @param classname the fully qualified name of the class to search for 286N/A * @param loader the classloader to search 286N/A * @return the source location of the resource, or null if it wasn't found 286N/A //URL it = loader.getResource(classnameAsResource);