jdk/src/java.base/share/classes/java/net/spi/URLStreamHandlerProvider.java
author chegar
Mon, 23 Feb 2015 15:48:20 +0000
changeset 29097 01a70c01f5a1
child 32982 a54c0a721890
permissions -rw-r--r--
8064924: Update java.net.URL to work with modules Reviewed-by: alanb, plevart, psandoz
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
 *
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    33
 *<p> A URL stream handler provider is a concrete subclass of this class that
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
 *
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    44
 * @since 1.9
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    45
 */
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    46
public abstract class URLStreamHandlerProvider
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    47
    implements URLStreamHandlerFactory
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
    private static Void checkPermission() {
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    50
        SecurityManager sm = System.getSecurityManager();
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    51
        if (sm != null)
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    52
            sm.checkPermission(new RuntimePermission("setFactory"));
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    53
        return null;
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    54
    }
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    55
    private URLStreamHandlerProvider(Void ignore) { }
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    56
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
     * Initializes a new URL stream handler provider.
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
     * @throws  SecurityException
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    61
     *          If a security manager has been installed and it denies
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    62
     *          {@link RuntimePermission}{@code ("setFactory")}.
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    63
     */
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    64
    protected URLStreamHandlerProvider() {
01a70c01f5a1 8064924: Update java.net.URL to work with modules
chegar
parents:
diff changeset
    65
        this(checkPermission());
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
}