com.sun.net.httpserver.spi.HttpServerProvider Java Examples

The following examples show how to use com.sun.net.httpserver.spi.HttpServerProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HTTPServer.java    From learnjavabug with MIT License 6 votes vote down vote up
public static void run(String[] args) {
  int port = PORT;
  String context = "/";
  String clazz = "Calc.class";
  if (args != null && args.length > 0) {
    port = Integer.parseInt(args[0]);
    context = args[1];
    clazz = args[2];
  }
  HttpServerProvider provider = HttpServerProvider.provider();
  HttpServer httpserver = null;
  try {
    httpserver = provider.createHttpServer(new InetSocketAddress(port), 100);
  } catch (IOException e) {
    e.printStackTrace();
  }
  //监听端口8080,

  httpserver.createContext(context, new RestGetHandler(clazz));
  httpserver.setExecutor(null);
  httpserver.start();
  System.out.println("server started");
}
 
Example #2
Source File: HttpServer.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}
 
Example #3
Source File: HttpServer.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}
 
Example #4
Source File: HttpServer.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}
 
Example #5
Source File: HttpServer.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}
 
Example #6
Source File: HttpServer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}
 
Example #7
Source File: HttpServer.java    From openjdk-jdk9 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}
 
Example #8
Source File: HttpServer.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}
 
Example #9
Source File: HttpServer.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}
 
Example #10
Source File: HttpServer.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}
 
Example #11
Source File: HttpServer.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}
 
Example #12
Source File: HttpServer.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}
 
Example #13
Source File: HttpServer.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}
 
Example #14
Source File: HttpServer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Create a <code>HttpServer</code> instance which will bind to the
 * specified {@link java.net.InetSocketAddress} (IP address and port number)
 *
 * A maximum backlog can also be specified. This is the maximum number of
 * queued incoming connections to allow on the listening socket.
 * Queued TCP connections exceeding this limit may be rejected by the TCP implementation.
 * The HttpServer is acquired from the currently installed {@link HttpServerProvider}
 *
 * @param addr the address to listen on, if <code>null</code> then bind() must be called
 *  to set the address
 * @param backlog the socket backlog. If this value is less than or equal to zero,
 *          then a system default value is used.
 * @throws BindException if the server cannot bind to the requested address,
 *          or if the server is already bound.
 * @throws IOException
 */

public static HttpServer create (
    InetSocketAddress addr, int backlog
) throws IOException {
    HttpServerProvider provider = HttpServerProvider.provider();
    return provider.createHttpServer (addr, backlog);
}