Java Code Examples for java.net.URLStreamHandlerFactory#createURLStreamHandler()
The following examples show how to use
java.net.URLStreamHandlerFactory#createURLStreamHandler() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: URLClassPath.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs * @param acc the context to be used when loading classes and resources, may * be null */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory, AccessControlContext acc) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } if (DISABLE_ACC_CHECKING) this.acc = null; else this.acc = acc; }
Example 2
Source File: DirContextURLStreamHandlerFactory.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Creates a new URLStreamHandler instance with the specified protocol. * Will return null if the protocol is not <code>jndi</code>. * * @param protocol the protocol (must be "jndi" here) * @return a URLStreamHandler for the jndi protocol, or null if the * protocol is not JNDI */ @Override public URLStreamHandler createURLStreamHandler(String protocol) { if (protocol.equals("jndi")) { return new DirContextURLStreamHandler(); } else if (protocol.equals("classpath")) { return new ClasspathURLStreamHandler(); } else { for (URLStreamHandlerFactory factory : userFactories) { URLStreamHandler handler = factory.createURLStreamHandler(protocol); if (handler != null) { return handler; } } return null; } }
Example 3
Source File: URLClassPath.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs * @param acc the context to be used when loading classes and resources, may * be null */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory, AccessControlContext acc) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } if (DISABLE_ACC_CHECKING) this.acc = null; else this.acc = acc; }
Example 4
Source File: JRResourcesUtil.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * Returns an URL stream handler for an URL specified as a <code>String</code>. * * @param spec the <code>String</code> to parse as an URL * @param urlHandlerFact an URL stream handler factory * @return an URL stream handler if one was found for the protocol of the URL */ public static URLStreamHandler getURLHandler(String spec, URLStreamHandlerFactory urlHandlerFact) { URLStreamHandlerFactory urlHandlerFactory = urlHandlerFact;//getURLHandlerFactory(urlHandlerFact); URLStreamHandler handler = null; if (urlHandlerFactory != null) { String protocol = getURLProtocol(spec); if (protocol != null) { handler = urlHandlerFactory.createURLStreamHandler(protocol); } } return handler; }
Example 5
Source File: URLClassPath.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs * @param acc the context to be used when loading classes and resources, may * be null */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory, AccessControlContext acc) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } if (DISABLE_ACC_CHECKING) this.acc = null; else this.acc = acc; }
Example 6
Source File: URLClassPath.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs * @param acc the context to be used when loading classes and resources, may * be null */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory, AccessControlContext acc) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } if (DISABLE_ACC_CHECKING) this.acc = null; else this.acc = acc; }
Example 7
Source File: URLClassPath.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs * @param acc the context to be used when loading classes and resources, may * be null */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory, AccessControlContext acc) { ArrayList<URL> path = new ArrayList<>(urls.length); ArrayDeque<URL> unopenedUrls = new ArrayDeque<>(urls.length); for (URL url : urls) { path.add(url); unopenedUrls.add(url); } this.path = path; this.unopenedUrls = unopenedUrls; if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } else { jarHandler = null; } if (DISABLE_ACC_CHECKING) this.acc = null; else this.acc = acc; }
Example 8
Source File: URLClassPath.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs * @param acc the context to be used when loading classes and resources, may * be null */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory, AccessControlContext acc) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } if (DISABLE_ACC_CHECKING) this.acc = null; else this.acc = acc; }
Example 9
Source File: URLFactory.java From particle-android with Apache License 2.0 | 6 votes |
/** * Creates a URL from the specified protocol name, host name, port number, * and file name. * <p/> * No validation of the inputs is performed by this method. * * @param protocol the name of the protocol to use * @param host the name of the host * @param port the port number * @param file the file on the host * @return URL created using specified protocol, host, and file * @throws MalformedURLException if an unknown protocol is specified */ public static URL createURL(String protocol, String host, int port, String file) throws MalformedURLException { URLStreamHandlerFactory factory = _factories.get(protocol); // If there is no URLStreamHandlerFactory registered for the // scheme/protocol, then we just use the regular URL constructor. if (factory == null) { return new URL(protocol, host, port, file); } // If there is a URLStreamHandlerFactory associated for the // scheme/protocol, then we create a URLStreamHandler. And, then use // then use the URLStreamHandler to create a URL. URLStreamHandler handler = factory.createURLStreamHandler(protocol); return new URL(protocol, host, port, file, handler); }
Example 10
Source File: URLClassPath.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs * @param acc the context to be used when loading classes and resources, may * be null */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory, AccessControlContext acc) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } if (DISABLE_ACC_CHECKING) this.acc = null; else this.acc = acc; }
Example 11
Source File: TomcatURLStreamHandlerFactory.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public URLStreamHandler createURLStreamHandler(String protocol) { // Tomcat's handler always takes priority so applications can't override // it. if (WAR_PROTOCOL.equals(protocol)) { return new Handler(); } else if (CLASSPATH_PROTOCOL.equals(protocol)) { return new ClasspathURLStreamHandler(); } // Application handlers for (URLStreamHandlerFactory factory : userFactories) { URLStreamHandler handler = factory.createURLStreamHandler(protocol); if (handler != null) { return handler; } } // Unknown protocol return null; }
Example 12
Source File: StreamHandlerFactory.java From LoboBrowser with MIT License | 5 votes |
public URLStreamHandler createURLStreamHandler(final String protocol) { final Collection<URLStreamHandlerFactory> factories = this.factories; synchronized (factories) { for (final URLStreamHandlerFactory f : factories) { final URLStreamHandler handler = f.createURLStreamHandler(protocol); if (handler != null) { return handler; } } } return null; }
Example 13
Source File: URLClassPath.java From javaide with GNU General Public License v3.0 | 3 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } }
Example 14
Source File: URLClassPath.java From java-n-IDE-for-Android with Apache License 2.0 | 3 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } }
Example 15
Source File: URLClassPath.java From hottub with GNU General Public License v2.0 | 3 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } }
Example 16
Source File: URLClassPath.java From openjdk-8-source with GNU General Public License v2.0 | 3 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } }
Example 17
Source File: URLClassPath.java From jdk8u60 with GNU General Public License v2.0 | 3 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } }
Example 18
Source File: URLClassPath.java From openjdk-8 with GNU General Public License v2.0 | 3 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } }
Example 19
Source File: URLClassPath.java From jdk8u-jdk with GNU General Public License v2.0 | 3 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } }
Example 20
Source File: URLClassPath.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 3 votes |
/** * Creates a new URLClassPath for the given URLs. The URLs will be * searched in the order specified for classes and resources. A URL * ending with a '/' is assumed to refer to a directory. Otherwise, * the URL is assumed to refer to a JAR file. * * @param urls the directory and JAR file URLs to search for classes * and resources * @param factory the URLStreamHandlerFactory to use when creating new URLs */ public URLClassPath(URL[] urls, URLStreamHandlerFactory factory) { for (int i = 0; i < urls.length; i++) { path.add(urls[i]); } push(urls); if (factory != null) { jarHandler = factory.createURLStreamHandler("jar"); } }