1   package gate.util.protocols.classpath;
2   
3   import java.net.*;
4   import java.io.*;
5   
6   import gate.util.*;
7   import gate.*;
8   
9   /**
10   * The handler for the "classpath://" URLs.
11   * All this class does is to transparently transform a "classpath://" URL into
12   * an URL of the according type and forward all requests through it.
13   */
14  public class Handler extends URLStreamHandler {
15  
16    protected URLConnection openConnection(URL u) throws java.io.IOException {
17      URL actualURL = Gate.getClassLoader().getResource(u.getPath());// Handler.class.getResource(u.getPath());
18      if(actualURL == null) throw new FileNotFoundException(u.toExternalForm());
19      return actualURL.openConnection();
20    }
21  }
22