Search in sources :

Example 6 with Server

use of io.helidon.microprofile.server.Server in project helidon by oracle.

the class Main method main.

/**
 * Run this example.
 *
 * @param args command line arguments (ignored)
 */
public static void main(String[] args) {
    long now = System.nanoTime();
    // everything is configured through application.yaml
    Server server = Server.create();
    now = System.nanoTime() - now;
    System.out.println("Create server: " + TimeUnit.MILLISECONDS.convert(now, TimeUnit.NANOSECONDS));
    now = System.nanoTime();
    server.start();
    port = server.port();
    now = System.nanoTime() - now;
    System.out.println("Start server: " + TimeUnit.MILLISECONDS.convert(now, TimeUnit.NANOSECONDS));
    System.out.println("Endpoint available at http://localhost:" + port + "/helloworld");
}
Also used : Server(io.helidon.microprofile.server.Server)

Example 7 with Server

use of io.helidon.microprofile.server.Server in project helidon by oracle.

the class Main method main.

/**
 * Starts server manually.
 *
 * @param args command line arguments (ignored)
 */
public static void main(String[] args) {
    Server server = Server.builder().host("localhost").port(0).build();
    server.start();
    String endpoint = "http://" + server.host() + ":" + server.port();
    System.out.println("Started application on     " + endpoint + "/helloworld");
    System.out.println("Metrics available on       " + endpoint + "/metrics");
    System.out.println("Heatlh checks available on " + endpoint + "/health");
}
Also used : Server(io.helidon.microprofile.server.Server)

Example 8 with Server

use of io.helidon.microprofile.server.Server in project helidon by oracle.

the class Main method main.

/**
 * Application main entry point.
 * @param args command line arguments
 */
public static void main(final String[] args) {
    LogConfig.configureRuntime();
    Server server = startServer();
    System.out.println("http://localhost:" + server.port() + "/books");
}
Also used : Server(io.helidon.microprofile.server.Server)

Example 9 with Server

use of io.helidon.microprofile.server.Server in project helidon by oracle.

the class Mp1Main method main.

/**
 * Application main entry point.
 * @param args command line arguments.
 */
public static void main(final String[] args) {
    String property = System.getProperty("java.class.path");
    if (null == property || property.trim().isEmpty()) {
        System.out.println("** Running on module path");
    } else {
        System.out.println("** Running on class path");
    }
    // cleanup before tests
    cleanup();
    String jwtToken = generateJwtToken();
    // start CDI
    // Main.main(args);
    Server server = Server.builder().port(7001).applications(new JaxRsApplicationNoCdi()).retainDiscoveredApplications(true).basePath("/cdi").build().start();
    boolean failed = false;
    long now = System.currentTimeMillis();
    try {
        testBean(server.port(), jwtToken);
    } catch (Exception e) {
        e.printStackTrace();
        failed = true;
    }
    long time = System.currentTimeMillis() - now;
    System.out.println("Tests finished in " + time + " millis");
    // Config config = ConfigProvider.getConfig();
    // List<String> names = new ArrayList<>();
    // config.getPropertyNames()
    // .forEach(names::add);
    // names.sort(String::compareTo);
    // System.out.println("All configuration options:");
    // names.forEach(it -> {
    // config.getOptionalValue(it, String.class)
    // .ifPresent(value -> System.out.println(it + "=" + value));
    // });
    server.stop();
    if (failed) {
        System.exit(-1);
    }
}
Also used : Server(io.helidon.microprofile.server.Server) TimeoutException(org.eclipse.microprofile.faulttolerance.exceptions.TimeoutException) IOException(java.io.IOException) ServiceUnavailableException(jakarta.ws.rs.ServiceUnavailableException) ExecutionException(java.util.concurrent.ExecutionException)

Example 10 with Server

use of io.helidon.microprofile.server.Server in project helloworld-web by dbelob.

the class Main method startServer.

/**
 * Start the server.
 *
 * @return the created {@link Server} instance
 * @throws IOException if there are problems reading logging properties
 */
protected static Server startServer() throws IOException {
    // load logging configuration
    LogManager.getLogManager().readConfiguration(Main.class.getResourceAsStream("/logging.properties"));
    // Server will automatically pick up configuration from
    // microprofile-config.properties
    Server server = Server.create();
    server.start();
    return server;
}
Also used : Server(io.helidon.microprofile.server.Server)

Aggregations

Server (io.helidon.microprofile.server.Server)10 Config (io.helidon.config.Config)3 LogConfig (io.helidon.common.LogConfig)1 CrossOriginConfig (io.helidon.webserver.cors.CrossOriginConfig)1 ServiceUnavailableException (jakarta.ws.rs.ServiceUnavailableException)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (org.eclipse.microprofile.faulttolerance.exceptions.TimeoutException)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1