src/java.base/share/classes/java/net/spi/URLStreamHandlerProvider.java
author prappo
Tue, 13 Nov 2018 12:24:34 +0000
changeset 52499 768b1c612100
parent 47216 71c04702a3d5
permissions -rw-r--r--
8213490: Networking area typos and inconsistencies cleanup Reviewed-by: alanb, chegar, dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29097
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
     1
/*
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
     4
 *
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    10
 *
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    15
 * accompanied this code).
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    16
 *
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    20
 *
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    23
 * questions.
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    24
 */
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    25
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    26
package java.net.spi;
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    27
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    28
import java.net.URLStreamHandlerFactory;
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    29
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    30
/**
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    31
 * URL stream handler service-provider class.
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    32
 *
52499
768b1c612100 8213490: Networking area typos and inconsistencies cleanup
prappo
parents: 47216
diff changeset
    33
 * <p> A URL stream handler provider is a concrete subclass of this class that
29097
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    34
 * has a zero-argument constructor. URL stream handler providers may be
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    35
 * installed in an instance of the Java platform by adding them to the
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    36
 * application class path.
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    37
 *
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    38
 * <p> A URL stream handler provider identifies itself with a
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    39
 * provider-configuration file named java.net.spi.URLStreamHandlerProvider in
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    40
 * the resource directory META-INF/services. The file should contain a list of
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    41
 * fully-qualified concrete URL stream handler provider class names, one per
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    42
 * line.
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    43
 *
32982
a54c0a721890 8139179: URLStreamHandler* should link to URL ctor that specifies how factories/providers are located
chegar
parents: 29097
diff changeset
    44
 * <p> URL stream handler providers are located at runtime, as specified in the
a54c0a721890 8139179: URLStreamHandler* should link to URL ctor that specifies how factories/providers are located
chegar
parents: 29097
diff changeset
    45
 * {@linkplain java.net.URL#URL(String,String,int,String) URL constructor}.
a54c0a721890 8139179: URLStreamHandler* should link to URL ctor that specifies how factories/providers are located
chegar
parents: 29097
diff changeset
    46
 *
35302
e4d2275861c3 8136494: Update "@since 1.9" to "@since 9" to match java.version.specification
iris
parents: 32982
diff changeset
    47
 * @since 9
29097
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    48
 */
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    49
public abstract class URLStreamHandlerProvider
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    50
    implements URLStreamHandlerFactory
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    51
{
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    52
    private static Void checkPermission() {
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    53
        SecurityManager sm = System.getSecurityManager();
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    54
        if (sm != null)
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    55
            sm.checkPermission(new RuntimePermission("setFactory"));
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    56
        return null;
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    57
    }
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    58
    private URLStreamHandlerProvider(Void ignore) { }
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    59
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    60
    /**
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    61
     * Initializes a new URL stream handler provider.
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    62
     *
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    63
     * @throws  SecurityException
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    64
     *          If a security manager has been installed and it denies
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    65
     *          {@link RuntimePermission}{@code ("setFactory")}.
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    66
     */
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    67
    protected URLStreamHandlerProvider() {
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    68
        this(checkPermission());
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    69
    }
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    70
}