本文整理匯總了Java中io.undertow.Undertow類的典型用法代碼示例。如果您正苦於以下問題:Java Undertow類的具體用法?Java Undertow怎麽用?Java Undertow使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Undertow類屬於io.undertow包,在下文中一共展示了Undertow類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import io.undertow.Undertow; //導入依賴的package包/類
public static void main(String[] args) throws ParseException {
Options options = new Options();
options.addOption("p", "port", true, "port number");
options.addOption("n", "hostname", true, "hostname, e.g. localhost");
CommandLine cmd = new DefaultParser().parse(options, args);
int port = Integer.parseInt(cmd.getOptionValue("p", "8080"));
String hostname = cmd.getOptionValue("n", "localhost");
UndertowJaxrsServer ut = new UndertowJaxrsServer();
ut.deploy(new Application() {
@Override
public Set<Class<?>> getClasses() {
Reflections reflections = new Reflections("org.neo4j.extension.firehose");
return reflections.getTypesAnnotatedWith(Path.class);
}
});
ut.start(Undertow.builder().addHttpListener(port, hostname));
System.out.println(String.format("Started server at http://%s:%d/ Hit ^C to stop", hostname, port));
}
示例2: testCustomizeServletContainer
import io.undertow.Undertow; //導入依賴的package包/類
@Test
public void testCustomizeServletContainer() {
env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory();
webConfigurer.customize(container);
assertThat(container.getMimeMappings().get("abs")).isEqualTo("audio/x-mpeg");
assertThat(container.getMimeMappings().get("html")).isEqualTo("text/html;charset=utf-8");
assertThat(container.getMimeMappings().get("json")).isEqualTo("text/html;charset=utf-8");
if (container.getDocumentRoot() != null) {
assertThat(container.getDocumentRoot().getPath()).isEqualTo(FilenameUtils.separatorsToSystem("target/www"));
}
Builder builder = Undertow.builder();
container.getBuilderCustomizers().forEach(c -> c.customize(builder));
OptionMap.Builder serverOptions = (OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions");
assertThat(serverOptions.getMap().get(UndertowOptions.ENABLE_HTTP2)).isNull();
}
示例3: testCustomizeServletContainer
import io.undertow.Undertow; //導入依賴的package包/類
@Test
public void testCustomizeServletContainer() {
env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory();
webConfigurer.customize(container);
assertThat(container.getMimeMappings().get("abs")).isEqualTo("audio/x-mpeg");
assertThat(container.getMimeMappings().get("html")).isEqualTo("text/html;charset=utf-8");
assertThat(container.getMimeMappings().get("json")).isEqualTo("text/html;charset=utf-8");
if (container.getDocumentRoot() != null) {
assertThat(container.getDocumentRoot().getPath()).isEqualTo(FilenameUtils.separatorsToSystem("build/www"));
}
Builder builder = Undertow.builder();
container.getBuilderCustomizers().forEach(c -> c.customize(builder));
OptionMap.Builder serverOptions = (OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions");
assertThat(serverOptions.getMap().get(UndertowOptions.ENABLE_HTTP2)).isNull();
}
示例4: testCustomizeServletContainer
import io.undertow.Undertow; //導入依賴的package包/類
@Test
public void testCustomizeServletContainer() {
env.setActiveProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
UndertowEmbeddedServletContainerFactory container = new UndertowEmbeddedServletContainerFactory();
webConfigurer.customize(container);
assertThat(container.getMimeMappings().get("abs")).isEqualTo("audio/x-mpeg");
assertThat(container.getMimeMappings().get("html")).isEqualTo("text/html;charset=utf-8");
assertThat(container.getMimeMappings().get("json")).isEqualTo("text/html;charset=utf-8");
if (container.getDocumentRoot() != null) {
assertThat(container.getDocumentRoot().getPath()).isEqualTo("target/www");
}
Builder builder = Undertow.builder();
container.getBuilderCustomizers().forEach(c -> c.customize(builder));
OptionMap.Builder serverOptions = (OptionMap.Builder) ReflectionTestUtils.getField(builder, "serverOptions");
assertThat(serverOptions.getMap().get(UndertowOptions.ENABLE_HTTP2)).isNull();
}
示例5: setUp
import io.undertow.Undertow; //導入依賴的package包/類
@Before
public void setUp() {
if(server == null) {
logger.info("starting server");
HttpHandler handler = getPetStoreHandler();
ValidatorHandler validatorHandler = new ValidatorHandler();
validatorHandler.setNext(handler);
handler = validatorHandler;
BodyHandler bodyHandler = new BodyHandler();
bodyHandler.setNext(handler);
handler = bodyHandler;
SwaggerHandler swaggerHandler = new SwaggerHandler();
swaggerHandler.setNext(handler);
handler = swaggerHandler;
server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(handler)
.build();
server.start();
}
}
示例6: setUp
import io.undertow.Undertow; //導入依賴的package包/類
@BeforeClass
public static void setUp() {
if(server == null) {
logger.info("starting server");
HttpHandler handler = getTestHandler();
JwtVerifyHandler jwtVerifyHandler = new JwtVerifyHandler();
jwtVerifyHandler.setNext(handler);
OpenApiHandler openApiHandler = new OpenApiHandler();
openApiHandler.setNext(jwtVerifyHandler);
server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(openApiHandler)
.build();
server.start();
}
}
示例7: setUp
import io.undertow.Undertow; //導入依賴的package包/類
@BeforeClass
public static void setUp() {
if(server == null) {
logger.info("starting server");
HttpHandler handler = getTestHandler();
JwtVerifyHandler jwtVerifyHandler = new JwtVerifyHandler();
jwtVerifyHandler.setNext(handler);
SwaggerHandler swaggerHandler = new SwaggerHandler();
swaggerHandler.setNext(jwtVerifyHandler);
server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(swaggerHandler)
.build();
server.start();
}
}
示例8: setUp
import io.undertow.Undertow; //導入依賴的package包/類
@Before
public void setUp() {
if(server == null) {
logger.info("starting server");
HttpHandler handler = getPetStoreHandler();
ValidatorHandler validatorHandler = new ValidatorHandler();
validatorHandler.setNext(handler);
handler = validatorHandler;
BodyHandler bodyHandler = new BodyHandler();
bodyHandler.setNext(handler);
handler = bodyHandler;
OpenApiHandler openApiHandler = new OpenApiHandler();
openApiHandler.setNext(handler);
handler = openApiHandler;
server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(handler)
.build();
server.start();
}
}
示例9: main
import io.undertow.Undertow; //導入依賴的package包/類
public static void main(String[] args) {
int port = 8080;
/*
* "localhost" will ONLY listen on local host.
* If you want the server reachable from the outside you need to set "0.0.0.0"
*/
String host = "localhost";
/*
* This web server has a single handler with no routing.
* ALL urls are handled by the helloWorldHandler.
*/
Undertow server = Undertow.builder()
// Add the helloWorldHandler as a method reference.
.addHttpListener(port, host, HelloWorldServer::helloWorldHandler)
.build();
logger.debug("starting on http://" + host + ":" + port);
server.start();
}
示例10: main
import io.undertow.Undertow; //導入依賴的package包/類
public static void main(String[] args) {
Base64.Decoder b64decoder = Base64.getUrlDecoder();
final Undertow server = Undertow.builder()
.addHttpListener(8083, "localhost")
.setHandler(exchange -> {
exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
String credential = exchange.getRequestHeaders().getFirst("X-Bouncr-Credential");
String[] tokens = credential.split("\\.", 3);
String json = new String(b64decoder.decode(tokens[1]));
exchange.getResponseSender().send("Server1\n"
+ "profile=" + json + "\n"
);
})
.build();
Runtime.getRuntime().addShutdownHook(new Thread(server::stop));
server.start();
}
示例11: setUp
import io.undertow.Undertow; //導入依賴的package包/類
@BeforeClass
public static void setUp() throws Exception {
// inject in memory constructed info.json to homeDir as classpath
Config.getInstance().clear();
Map<String, Object> map = new HashMap<>();
map.put("enableServerInfo", false);
Config.getInstance().getYaml().dump(map, new PrintWriter(new File(homeDir + "/info.yml")));
// Add home directory to the classpath of the system class loader.
addURL(new File(homeDir).toURI().toURL());
if(server == null) {
logger.info("starting server");
HttpHandler handler = getTestHandler();
server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(handler)
.build();
server.start();
}
}
示例12: setUp
import io.undertow.Undertow; //導入依賴的package包/類
@BeforeClass
public static void setUp() {
if(server == null) {
logger.info("starting server");
HttpHandler handler = getTestHandler();
LimitHandler limitHandler = new LimitHandler();
limitHandler.setNext(handler);
handler = limitHandler;
server = Undertow.builder()
.setServerOption(UndertowOptions.ENABLE_HTTP2, true)
.addHttpListener(8080, "localhost")
.setHandler(handler)
.build();
server.start();
}
}
示例13: setUp
import io.undertow.Undertow; //導入依賴的package包/類
@BeforeClass
public static void setUp() {
if(server == null) {
logger.info("starting server");
HttpHandler handler = getTestHandler();
MetricsHandler metricsHandler = new MetricsHandler();
metricsHandler.setNext(handler);
handler = metricsHandler;
server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(handler)
.build();
server.start();
}
}
示例14: setUp
import io.undertow.Undertow; //導入依賴的package包/類
@BeforeClass
public static void setUp() {
if(server == null) {
logger.info("starting server");
HttpHandler handler = getTestHandler();
AuditHandler auditHandler = new AuditHandler();
auditHandler.setNext(handler);
handler = auditHandler;
CorrelationHandler correlationHandler = new CorrelationHandler();
correlationHandler.setNext(handler);
handler = correlationHandler;
server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(handler)
.build();
server.start();
}
}
示例15: setUp
import io.undertow.Undertow; //導入依賴的package包/類
@BeforeClass
public static void setUp() {
if(server == null) {
logger.info("starting server");
HttpHandler handler = getTestHandler();
SanitizerHandler sanitizerHandler = new SanitizerHandler();
sanitizerHandler.setNext(handler);
handler = sanitizerHandler;
BodyHandler bodyHandler = new BodyHandler();
bodyHandler.setNext(handler);
handler = bodyHandler;
server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(handler)
.build();
server.start();
}
}