KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > swing > text > html > parser > ResourceLoader


1 /*
2  * @(#)ResourceLoader.java 1.6 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.swing.text.html.parser;
9
10 import java.io.InputStream JavaDoc;
11
12 /**
13  * Simple class to load resources using the 1.2
14  * security model. Since the html support is loaded
15  * lazily, it's resources are potentially fetched with
16  * applet code in the call stack. By providing this
17  * functionality in a class that is only built on 1.2,
18  * reflection can be used from the code that is also
19  * built on 1.1 to call this functionality (and avoid
20  * the evils of preprocessing). This functionality
21  * is called from ParserDelegator.getResourceAsStream.
22  *
23  * @author Timothy Prinzing
24  * @version 1.6 12/19/03
25  */

26 class ResourceLoader implements java.security.PrivilegedAction JavaDoc {
27
28     ResourceLoader(String JavaDoc name) {
29     this.name = name;
30     }
31
32     public Object JavaDoc run() {
33     Object JavaDoc o = ParserDelegator JavaDoc.class.getResourceAsStream(name);
34     return o;
35     }
36
37     public static InputStream JavaDoc getResourceAsStream(String JavaDoc name) {
38     java.security.PrivilegedAction JavaDoc a = new ResourceLoader JavaDoc(name);
39         return (InputStream JavaDoc) java.security.AccessController.doPrivileged(a);
40     }
41
42     private String JavaDoc name;
43 }
44
Popular Tags