当前位置: 首页>>代码示例>>Java>>正文


Java URLStreamHandlerFactory.createURLStreamHandler方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:26,代码来源:DirContextURLStreamHandlerFactory.java

示例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);
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:32,代码来源:URLFactory.java

示例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);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:28,代码来源:StandardClassLoader.java

示例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;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:URLClassPath.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:URLClassPath.java

示例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;
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:26,代码来源:DirContextURLStreamHandlerFactory.java

示例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;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:24,代码来源:JRResourcesUtil.java

示例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;
}
 
开发者ID:vilie,项目名称:javify,代码行数:17,代码来源:URLStreamHandlerCache.java

示例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;
    }
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:24,代码来源:DirContextURLStreamHandlerFactory.java

示例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;
}
 
开发者ID:igor-suhorukov,项目名称:mvn-classloader,代码行数:16,代码来源:ChainURLStreamHandlerFactory.java

示例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;
}
 
开发者ID:igor-suhorukov,项目名称:mvn-classloader,代码行数:13,代码来源:LoadableURLStreamHandlerFactory.java

示例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;
}
 
开发者ID:lobobrowser,项目名称:LoboBrowser,代码行数:13,代码来源:PlatformStreamHandlerFactory.java

示例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;
}
 
开发者ID:oswetto,项目名称:LoboEvolution,代码行数:14,代码来源:PlatformStreamHandlerFactory.java

示例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");
    }
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:20,代码来源:URLClassPath.java

示例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;
}
 
开发者ID:B4dT0bi,项目名称:silvertunnel-ng,代码行数:23,代码来源:URLUtil.java


注:本文中的java.net.URLStreamHandlerFactory.createURLStreamHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。