equal
deleted
inserted
replaced
46 * @author <a href="Kohsuke.Kawaguchi@Sun.com">Kohsuke Kawaguchi</a> |
46 * @author <a href="Kohsuke.Kawaguchi@Sun.com">Kohsuke Kawaguchi</a> |
47 * @version $Revision: 1.7 $, $Date: 2010-11-01 04:36:14 $ |
47 * @version $Revision: 1.7 $, $Date: 2010-11-01 04:36:14 $ |
48 * @since 1.5 |
48 * @since 1.5 |
49 */ |
49 */ |
50 class XPathFactoryFinder { |
50 class XPathFactoryFinder { |
|
51 private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xpath.internal"; |
51 |
52 |
52 private static SecuritySupport ss = new SecuritySupport() ; |
53 private static SecuritySupport ss = new SecuritySupport() ; |
53 /** debug support code. */ |
54 /** debug support code. */ |
54 private static boolean debug = false; |
55 private static boolean debug = false; |
55 static { |
56 static { |
244 * @param className Name of class to create. |
245 * @param className Name of class to create. |
245 * @return Created class or <code>null</code>. |
246 * @return Created class or <code>null</code>. |
246 */ |
247 */ |
247 private Class createClass(String className) { |
248 private Class createClass(String className) { |
248 Class clazz; |
249 Class clazz; |
249 |
250 // make sure we have access to restricted packages |
250 // use approprite ClassLoader |
251 boolean internal = false; |
251 try { |
252 if (System.getSecurityManager() != null) { |
252 if (classLoader != null) { |
253 if (className != null && className.startsWith(DEFAULT_PACKAGE)) { |
253 clazz = classLoader.loadClass(className); |
254 internal = true; |
254 } else { |
255 } |
255 clazz = Class.forName(className); |
256 } |
256 } |
257 |
257 } catch (Throwable t) { |
258 // use approprite ClassLoader |
258 if(debug) t.printStackTrace(); |
259 try { |
259 return null; |
260 if (classLoader != null && !internal) { |
260 } |
261 clazz = classLoader.loadClass(className); |
|
262 } else { |
|
263 clazz = Class.forName(className); |
|
264 } |
|
265 } catch (Throwable t) { |
|
266 if(debug) t.printStackTrace(); |
|
267 return null; |
|
268 } |
261 |
269 |
262 return clazz; |
270 return clazz; |
263 } |
271 } |
264 |
272 |
265 /** |
273 /** |