[jboss-dev-forums] [Design of POJO Server] - Re: VFS Permissions - JBMICROCONT-149
david.lloyd@jboss.com
do-not-reply at jboss.com
Tue Nov 11 15:41:04 EST 2008
Here's my little test:
import java.net.URL;
| import java.net.URLConnection;
| import java.net.URLStreamHandlerFactory;
| import java.net.URLStreamHandler;
| import java.io.IOException;
|
| public final class Main {
|
| public static void main(String[] args) throws IOException {
| final URL urlOne = new URL("http", "www.google.com", "/");
| final URLConnection conn = urlOne.openConnection();
| final Class<? extends URLConnection> origClass = conn.getClass();
| URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
| public URLStreamHandler createURLStreamHandler(final String protocol) {
| if (protocol.equals("http")) {
| return new URLStreamHandler() {
| @Override
| protected URLConnection openConnection(final URL u) throws IOException {
| return new URLConnection(u) {
| @Override
| public void connect() throws IOException {
| }
| };
| }
| };
| } else {
| return null;
| }
| }
| });
| final URL urlTwo = new URL("http", "www.google.com", "/");
| final URLConnection conn2 = urlTwo.openConnection();
| final Class<? extends URLConnection> newClass = conn2.getClass();
| System.out.println("First: " + origClass.getName() + ", second: " + newClass.getName());
| }
| }
The expected result is that the two classes printed are different, which demonstrates that the cache does not survive the setURLStreamHandlerFactory call.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4188601#4188601
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4188601
More information about the jboss-dev-forums
mailing list