Last active
May 29, 2018 14:17
-
-
Save mkarg/a38a68f6025f1ef6ddb4916022bd150d to your computer and use it in GitHub Desktop.
Minimal Example for JAX-RS Bootstrapping on Java SE 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2018 Markus KARG. All rights reserved. | |
* | |
* This program and the accompanying materials are made available under the | |
* terms of the Eclipse Public License v. 2.0, which is available at | |
* http://www.eclipse.org/legal/epl-2.0. | |
* | |
* This Source Code may also be made available under the following Secondary | |
* Licenses when the conditions for such availability set forth in the | |
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | |
* version 2 with the GNU Classpath Exception, which is available at | |
* https://www.gnu.org/software/classpath/license.html. | |
* | |
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | |
*/ | |
package jaxrs.examples.bootstrap; | |
import java.io.IOException; | |
import java.util.concurrent.CompletableFuture; | |
import java.util.concurrent.ExecutionException; | |
import javax.ws.rs.JAXRS; | |
import javax.ws.rs.JAXRS.Instance; | |
/** | |
* Minimum Java SE Bootstrap Example | |
* | |
* @author Markus KARG ([email protected]) | |
*/ | |
public class MinimumSeBootstrapExample { | |
public void main(final String[] args) throws IOException, InterruptedException, ExecutionException { | |
final CompletableFuture<Instance> boot = JAXRS.start(new HelloWorld(), JAXRS.Configuration.builder().build()).toCompletableFuture(); | |
final Instance instance = boot.get(); | |
System.out.println("Press any key to shutdown."); | |
System.in.read(); | |
instance.stop().toCompletableFuture().join(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mkarg Newer versions of example are much nicer. I still find System.in.read() unrealistic; process should stop on a signal.