本文整理汇总了Java中java.net.URLStreamHandlerFactory.createURLStreamHandler方法的典型用法代码示例。如果您正苦于以下问题:Java URLStreamHandlerFactory.createURLStreamHandler方法的具体用法?Java URLStreamHandlerFactory.createURLStreamHandler怎么用?Java URLStreamHandlerFactory.createURLStreamHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.net.URLStreamHandlerFactory
的用法示例。
在下文中一共展示了URLStreamHandlerFactory.createURLStreamHandler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createURLStreamHandler
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
/**
* 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;
}
}
示例2: createURL
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
/**
* 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);
}
示例3: convert
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
/**
* Convert an array of String to an array of URL and return it.
*
* @param input The array of String to be converted
* @param factory Handler factory to use to generate the URLs
*/
protected static URL[] convert(String input[],
URLStreamHandlerFactory factory) {
URLStreamHandler streamHandler = null;
URL url[] = new URL[input.length];
for (int i = 0; i < url.length; i++) {
try {
String protocol = parseProtocol(input[i]);
if (factory != null)
streamHandler = factory.createURLStreamHandler(protocol);
else
streamHandler = null;
url[i] = new URL(null, input[i], streamHandler);
} catch (MalformedURLException e) {
url[i] = null;
}
}
return (url);
}
示例4: URLClassPath
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
/**
* 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;
}
示例5: URLClassPath
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
/**
* 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) {
List<URL> path = new ArrayList<>(urls.length);
for (URL url : urls) {
path.add(url);
}
this.path = path;
push(urls);
if (factory != null) {
jarHandler = factory.createURLStreamHandler("jar");
} else {
jarHandler = null;
}
if (DISABLE_ACC_CHECKING)
this.acc = null;
else
this.acc = acc;
}
示例6: createURLStreamHandler
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
/**
* 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;
}
}
示例7: getURLHandler
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
/**
* 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
* @see #getURLHandlerFactory(URLStreamHandlerFactory)
*/
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;
}
示例8: get
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
public synchronized URLStreamHandler get(URLStreamHandlerFactory factory,
String protocol)
{
if (factory == null)
return null;
// Check if there're handler for the same protocol in cache.
HashMap<String, URLStreamHandler> cache = factoryCache.get(factory);
URLStreamHandler handler = cache.get(protocol);
if (handler == null)
{
// Add it to cache.
handler = factory.createURLStreamHandler(protocol);
cache.put(protocol, handler);
}
return handler;
}
示例9: createURLStreamHandler
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
/**
* 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 {
for (URLStreamHandlerFactory factory : userFactories) {
URLStreamHandler handler =
factory.createURLStreamHandler(protocol);
if (handler != null) {
return handler;
}
}
return null;
}
}
示例10: createURLStreamHandler
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
@Override
public URLStreamHandler createURLStreamHandler(String protocol) {
for(URLStreamHandlerFactory urlStreamHandlerFactory: streamHandlerFactories){
URLStreamHandler urlStreamHandler = null;
try {
urlStreamHandler = urlStreamHandlerFactory.createURLStreamHandler(protocol);
} catch (Exception ignore) {
logger.warning(ignore.getMessage());
}
if(urlStreamHandler!=null){
return urlStreamHandler;
}
}
return null;
}
示例11: createURLStreamHandler
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
@Override
public URLStreamHandler createURLStreamHandler(String protocol) {
if(protocol!=null && !SKIP_LIST.contains(protocol.toLowerCase())) {
try {
URLStreamHandlerFactory urlStreamHandlerFactory = urlStreamHandlerFactoryLoadingCache.get(protocol);
return urlStreamHandlerFactory!=null ? urlStreamHandlerFactory.createURLStreamHandler(protocol) : null;
} catch (ExecutionException e) {
logger.severe(e.getMessage());
}
}
return null;
}
示例12: createURLStreamHandler
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
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;
}
示例13: createURLStreamHandler
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
@Override
public URLStreamHandler createURLStreamHandler(String protocol) {
Collection<URLStreamHandlerFactory> factories = this.factories;
synchronized (factories) {
for (URLStreamHandlerFactory f : factories) {
URLStreamHandler handler = f.createURLStreamHandler(protocol);
if (handler != null) {
return handler;
}
}
}
return null;
}
示例14: URLClassPath
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
/**
* 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");
}
}
示例15: openConnection
import java.net.URLStreamHandlerFactory; //导入方法依赖的package包/类
/**
* Returns a {@link java.net.URLConnection URLConnection} instance that
* represents a connection to the remote object referred to by the
* {@code URL}.
*
* @param factory
* @param url
* http or https URL
* @return a {@link java.net.URLConnection URLConnection} linking to the
* URL.
* @exception IOException
* if an I/O exception occurs.
* @see java.net.URL#openConnection()
*/
public static URLConnection openConnection(final URLStreamHandlerFactory factory, final URL url) throws IOException
{
LOG.info("openConnection start with url={}", url);
final URLStreamHandler handler = factory.createURLStreamHandler(url.getProtocol());
final URLConnection result = ((HttpHandler) handler).openConnection(url, null);
LOG.info("openConnection end with result={}", result);
return result;
}