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