jdk/src/solaris/classes/sun/net/NetHooks.java
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 6525 56be41b86ef8
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 6525
diff changeset
     2
 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     4
 *
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4166
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4166
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    10
 *
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    15
 * accompanied this code).
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    16
 *
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4166
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4166
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4166
diff changeset
    23
 * questions.
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    24
 */
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    25
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    26
package sun.net;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    27
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    28
import java.net.InetAddress;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    29
import java.io.FileDescriptor;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    30
import java.io.IOException;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    31
import java.security.AccessController;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    32
import java.security.PrivilegedAction;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    33
import sun.security.action.GetPropertyAction;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    34
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    35
/**
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    36
 * Defines static methods to be invoked prior to binding or connecting TCP sockets.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    37
 */
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    38
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    39
public final class NetHooks {
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    40
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    41
    /**
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    42
     * A provider with hooks to allow sockets be converted prior to binding or
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    43
     * connecting a TCP socket.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    44
     *
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    45
     * <p> Concrete implementations of this class should define a zero-argument
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    46
     * constructor and implement the abstract methods specified below.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    47
     */
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    48
    public static abstract class Provider {
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    49
        /**
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    50
         * Initializes a new instance of this class.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    51
         */
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    52
        protected Provider() {}
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    53
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    54
        /**
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    55
         * Invoked prior to binding a TCP socket.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    56
         */
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    57
        public abstract void implBeforeTcpBind(FileDescriptor fdObj,
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    58
                                               InetAddress address,
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    59
                                               int port)
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    60
            throws IOException;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    61
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    62
        /**
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    63
         * Invoked prior to connecting an unbound TCP socket.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    64
         */
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    65
        public abstract void implBeforeTcpConnect(FileDescriptor fdObj,
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    66
                                                 InetAddress address,
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    67
                                                 int port)
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    68
            throws IOException;
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    69
    }
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    70
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    71
    /**
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    72
     * For now, we load the SDP provider on Solaris. In the future this may
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    73
     * be changed to use the ServiceLoader facility to allow the deployment of
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    74
     * other providers.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    75
     */
6525
56be41b86ef8 6965072: Need API to create SDP sockets
alanb
parents: 5506
diff changeset
    76
    private static final Provider provider = new sun.net.sdp.SdpProvider();
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    77
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    78
    /**
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    79
     * Invoke prior to binding a TCP socket.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    80
     */
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    81
    public static void beforeTcpBind(FileDescriptor fdObj,
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    82
                                     InetAddress address,
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    83
                                     int port)
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    84
        throws IOException
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    85
    {
6525
56be41b86ef8 6965072: Need API to create SDP sockets
alanb
parents: 5506
diff changeset
    86
        provider.implBeforeTcpBind(fdObj, address, port);
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    87
    }
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    88
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    89
    /**
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    90
     * Invoke prior to connecting an unbound TCP socket.
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    91
     */
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    92
    public static void beforeTcpConnect(FileDescriptor fdObj,
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    93
                                        InetAddress address,
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    94
                                        int port)
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    95
        throws IOException
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    96
    {
6525
56be41b86ef8 6965072: Need API to create SDP sockets
alanb
parents: 5506
diff changeset
    97
        provider.implBeforeTcpConnect(fdObj, address, port);
2446
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    98
    }
07047237e4d4 4890703: Support SDP (sol)
alanb
parents:
diff changeset
    99
}