|
What this is
Other links
The source code
/*
* Copyright 2001-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.tomcat.util.net;
import java.io.IOException;
import java.net.ConnectException;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Vector;
import org.apache.tomcat.util.compat.Jdk11Compat;
/**
*/
public final class StreamHandlerFactory implements URLStreamHandlerFactory {
/** System property for protocol handlers.
*/
public static final String SYS_PROTOCOLS = "java.protocol.handler.pkgs";
private String protocolString = null;
private Vector protocols = null;
private Jdk11Compat jdk11Compat = Jdk11Compat.getJdkCompat();
public StreamHandlerFactory() {
loadProtocols();
}
/** Create a
java.net.URL(String,String,int,String) .
*/
private synchronized void loadProtocols() {
if(protocolString == System.getProperty(SYS_PROTOCOLS))
return;
String protocolS = System.getProperty(SYS_PROTOCOLS);
if(protocolS != null) {
protocols = new Vector();
StringTokenizer tok = new StringTokenizer(protocolS,"|");
while(tok.hasMoreTokens()) {
String protStr = tok.nextToken();
protocols.addElement(protStr);
}
}
protocolString = protocolS;
}
/** A connection-less URLStreamHandler to allow parsing-only URLs.
*/
public class DummyStreamHandler extends URLStreamHandler {
DummyStreamHandler() {
}
protected URLConnection openConnection(java.net.URL xx) throws IOException{
throw new ConnectException("Connections are not supported.");
}
}
}
|
... this post is sponsored by my books ... | |
![]() #1 New Release! |
![]() FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.