当前位置: 首页>>代码示例>>Java>>正文


Java Undertow.start方法代码示例

本文整理汇总了Java中io.undertow.Undertow.start方法的典型用法代码示例。如果您正苦于以下问题:Java Undertow.start方法的具体用法?Java Undertow.start怎么用?Java Undertow.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.undertow.Undertow的用法示例。


在下文中一共展示了Undertow.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
}
 
开发者ID:StubbornJava,项目名称:StubbornJava,代码行数:20,代码来源:HelloWorldServer.java

示例2: 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();
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:20,代码来源:ForTestBackendApp.java

示例3: startHttpServer

import io.undertow.Undertow; //导入方法依赖的package包/类
private void startHttpServer ()
{
    Undertow server = Undertow.builder ().addHttpListener ( port, "0.0.0.0" ).setHandler ( new HttpHandler () {
        @Override
        public void handleRequest ( final HttpServerExchange exchange ) throws Exception
        {
            exchange.getResponseHeaders ().put ( Headers.CONTENT_TYPE, "text/plain" );
            String result = createStatusMap ( exchange.getRelativePath () );
            if ( result == null )
            {
                exchange.setStatusCode ( 404 );
            }
            else
            {
                if ( result.startsWith ( "CRIT" ) )
                {
                    exchange.setStatusCode ( 500 );
                }
                exchange.getResponseSender ().send ( result, UTF8 );
            }
        }
    } ).build ();
    logger.info ( "starting server ..." );
    server.start ();
}
 
开发者ID:ibh-systems,项目名称:neoscada-misc,代码行数:26,代码来源:StatusEndpoint.java

示例4: start

import io.undertow.Undertow; //导入方法依赖的package包/类
public static void start(String[] args) throws ServletException {
    Map<String, String> commands = Arrays.stream(args)
            .map(cmd -> cmd.split(REGEX_EQ))
            .collect(toMap(cmdArray -> cmdArray[IDX_ZERO], cmdArray -> cmdArray[IDX_ONE]));
    Config undertowConf = Configs.DEFAULT.undertow();
    Config httpConf = undertowConf.getConfig(KEY_HTTP);
    Logger logger = LoggerFactory.getLogger(Server.class);
    logger.debug("Commands to AdeptJ Runtime: {}", commands);
    int httpPort = handlePortAvailability(httpConf, logger);
    logger.info("Starting AdeptJ Runtime @port: [{}]", httpPort);
    printBanner(logger);
    DeploymentManager manager = Servlets.defaultContainer().addDeployment(deploymentInfo(undertowConf));
    manager.deploy();
    Builder builder = Undertow.builder();
    optimizeWorkerOptions(builder, undertowConf, logger);
    ServerOptions.build(builder, undertowConf);
    builder.addHttpListener(httpPort, httpConf.getString(KEY_HOST));
    enableHttp2(undertowConf, builder, logger);
    enableAJP(undertowConf, builder, logger);
    GracefulShutdownHandler rootHandler = rootHandler(headersHandler(manager.start(), undertowConf), undertowConf);
    Undertow server = builder.setHandler(rootHandler).build();
    server.start();
    Runtime.getRuntime().addShutdownHook(new ShutdownHook(server, manager, rootHandler));
    launchBrowser(commands, httpPort, logger);
    if (!Environment.isServerConfFileExists()) {
        createServerConfFile(logger);
    }
}
 
开发者ID:AdeptJ,项目名称:adeptj-runtime,代码行数:29,代码来源:Server.java

示例5: initServlet

import io.undertow.Undertow; //导入方法依赖的package包/类
private static void initServlet() throws ServletException, NoSuchMethodException {
    ClassLoader classLoader = ClassLoader.getSystemClassLoader();
    DeploymentInfo deploymentInfo = new DeploymentInfo()
            .addListener(Servlets.listener(WeldInitialListener.class))
            .addListener(Servlets.listener(WeldTerminalListener.class))
            .setContextPath("/")
            .setDeploymentName("standalone-javax-mvc-app")
            .addServlet(
                    createServletInfo("/resources/*", "JAX-RS Resources", org.glassfish.jersey.servlet.ServletContainer.class)
            )
            .setResourceManager(new ClassPathResourceManager(classLoader, "META-INF/webapp"))
            .setClassIntrospecter(CdiClassIntrospecter.INSTANCE)
            .setAllowNonStandardWrappers(true)
            .setClassLoader(classLoader);

    ServletContainer servletContainer = Servlets.defaultContainer();
    DeploymentManager deploymentManager = servletContainer.addDeployment(deploymentInfo);
    deploymentManager.deploy();

    Undertow server = Undertow.builder()
            .addHttpListener(8080, "0.0.0.0")
            .setHandler(deploymentManager.start())
            .build();
    server.start();
}
 
开发者ID:shamoh,项目名称:standalone-javax-mvc,代码行数:26,代码来源:Main.java

示例6: main

import io.undertow.Undertow; //导入方法依赖的package包/类
public static void main(String[] args) {
    PathHandler path = new PathHandler()
            .addPrefixPath("/", resource(new ClassPathResourceManager(Dashboard.class.getClassLoader(),
                    Dashboard.class.getPackage())).addWelcomeFiles("chart.html"))
            .addExactPath("/api", new Dashboard());

    Undertow server = Undertow.builder()
            .addHttpListener(6001, "127.0.0.1")
            .setHandler(path)
            .build();
    server.start();

    try {
        Thread.sleep(1000000000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    server.stop();
}
 
开发者ID:tbrooks8,项目名称:Precipice,代码行数:20,代码来源:Entry.java

示例7: startHttpServer

import io.undertow.Undertow; //导入方法依赖的package包/类
public static Undertow startHttpServer() {
    final Undertow httpServer;

    try {
        final PathHandler path = PathHandlerFactory.create();

        httpServer = Undertow.builder()
                .addHttpListener(UaiMockServerContext.getInstance().uaiMockServerConfig.getPort(), UaiMockServerContext.getInstance().uaiMockServerConfig.getHost())
                .setHandler(path)
                .build();

        httpServer.start();
    } catch (final Exception ex) {
        throw new IllegalStateException("Could not start the uaiMockServer.", ex);
    }

    return httpServer;
}
 
开发者ID:uaihebert,项目名称:uaiMockServer,代码行数:19,代码来源:HttpServerUtil.java

示例8: publish

import io.undertow.Undertow; //导入方法依赖的package包/类
private static void publish(final Catalog catalog,final String basePath, final String serializationCachePath, final int port, final String host, final DocumentationStrategy strategy) throws IOException {
	LOGGER.debug("* Publishing vocabularies under {}",basePath);
	final PathHandler pathHandler=path();
	// Module serializations
	final SerializationManager manager=publishSerializations(catalog,pathHandler,serializationCachePath);
	// Catalog documentation
	final DocumentationDeploymentFactory factory = publishDocumentation(catalog,pathHandler,strategy);
	// Canonical namespaces
	publishCanonicalNamespace(catalog, basePath, pathHandler, manager, factory);
	final Undertow server =
		Undertow.
			builder().
				addHttpListener(port,host).
				setHandler(new CanonicalPathHandler(pathHandler)).
				build();
	server.start();
	awaitTerminationRequest();
	server.stop();
}
 
开发者ID:SmartDeveloperHub,项目名称:sdh-vocabulary,代码行数:20,代码来源:VocabularyPublisher.java

示例9: listen

import io.undertow.Undertow; //导入方法依赖的package包/类
/**
 * listening more complex server
 * 
 * @param fn
 */
public Stoppable listen(Function<Undertow.Builder, Undertow.Builder> fn) {
	Undertow.Builder builder = fn.apply(Undertow.builder());
	Undertow server = builder.setHandler(buildHandlers()).build();
	server.start();
	stop.on(stop -> server.stop());
	return new Stoppable() {

		@Override
		public void stop() {
			stop.post(App.this);
		}

		@Override
		public void addShutdownHook() {
			Runtime.getRuntime().addShutdownHook(new Thread(this::stop));
		}
	};
}
 
开发者ID:taichi,项目名称:siden,代码行数:24,代码来源:App.java

示例10: Server

import io.undertow.Undertow; //导入方法依赖的package包/类
public Server() {
    Undertow server = Undertow.builder().addHttpListener(port, "0.0.0.0",
            Handlers.path()
                    .addPrefixPath("rpc", this)
                    .addPrefixPath("/", new ResourceHandler(new ClassPathResourceManager(Server.class.getClassLoader(), "static")).addWelcomeFiles("index.html").setDirectoryListingEnabled(false))
    ).build();
    server.start();
    System.out.println("Server running at : 9077");
}
 
开发者ID:datathings,项目名称:greycat,代码行数:10,代码来源:Server.java

示例11: main

import io.undertow.Undertow; //导入方法依赖的package包/类
public static void main(String[] args) {

        final String urltoConnect = "ws://localhost:5678";
        final String serverUrl = "0.0.0.0";
        final int serverPort = 8080;

        Undertow server = Undertow.builder()
                .addHttpListener(serverPort,serverUrl)
                .setHandler(
                        Handlers.path(
                                Handlers.resource(
                                        new PathResourceManager(Paths.get("plugins/visualizer/src/main/resources").toAbsolutePath(),0)
                                )
                        )
                )
                .build();


        server.start();

        StringBuilder goToBuilder = new StringBuilder();
        goToBuilder.append("http://")
                .append(serverUrl)
                .append(":")
                .append(serverPort)
                .append("?q=")
                .append(urltoConnect);
        System.out.println("Go to: " + goToBuilder);


        System.out.println();

    }
 
开发者ID:datathings,项目名称:greycat,代码行数:34,代码来源:DebugVisualizerServer.java

示例12: main

import io.undertow.Undertow; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    ApplicationContext context = new AnnotationConfigApplicationContext(Application.class);  // (1)
    Undertow server = context.getBean(Undertow.class);
    server.start();
    System.out.println("Press ENTER to exit.");
    System.in.read();
}
 
开发者ID:hantsy,项目名称:spring-reactive-sample,代码行数:8,代码来源:Application.java

示例13: main

import io.undertow.Undertow; //导入方法依赖的package包/类
public static void main(String[]args){
Undertow server = Undertow.builder()
     .addHttpListener(7070, "localhost")
     .setHandler(new HttpHandler() 
{
      public void handleRequest(HttpServerExchange exchange) throws Exception {
   exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");
   exchange.getResponseSender().send("Beos Bank !");
      }
     }).build();
  server.start();
 }
 
开发者ID:PacktPublishing,项目名称:JBoss-Developers-Guide,代码行数:13,代码来源:UndertowHelloWorldServer.java

示例14: main

import io.undertow.Undertow; //导入方法依赖的package包/类
public static void main(String[]args){
Undertow server = Undertow.builder()
     .addHttpListener(7071, "localhost")
     .setHandler(io.undertow.Handlers.resource(
    		 new PathResourceManager(Paths.get("/Users/enonowog/books/jbdevg/code/jbdevg"),10))
                     .setDirectoryListingEnabled(true)
    		 ).build();
  server.start();
 }
 
开发者ID:PacktPublishing,项目名称:JBoss-Developers-Guide,代码行数:10,代码来源:UndertowHelloDirectoryBrowser.java

示例15: main

import io.undertow.Undertow; //导入方法依赖的package包/类
public static void main(String[] args) {

    DeploymentInfo servletBuilder
        = Servlets.deployment()
                  .setClassLoader(MainVaadin.class.getClassLoader())
                  .setContextPath(CONTEXT_PATH)
                  .setDeploymentName("ROOT.war")
                  .setDefaultEncoding("UTF-8")
                  .addServlets(
                      servlet(
                          MainServlet.class.getSimpleName(),
                          MainServlet.class).addMapping("/*")
                  );

    DeploymentManager manager = Servlets
        .defaultContainer()
        .addDeployment(servletBuilder);

    manager.deploy();

    try {
      HttpHandler httpHandler = manager.start();
      PathHandler path = Handlers.path(redirect(CONTEXT_PATH))
                                 .addPrefixPath(CONTEXT_PATH, httpHandler);

      Undertow undertowServer = Undertow.builder()
                                        .addHttpListener(8080, "0.0.0.0")
                                        .setHandler(path)
                                        .build();
      undertowServer.start();

      undertow = Result.success(undertowServer);

      undertowServer.getListenerInfo().forEach(System.out::println);

    } catch (ServletException e) {
      e.printStackTrace();
      undertow = Result.failure(e.getMessage());
    }
  }
 
开发者ID:Java-Publications,项目名称:javamagazin-009-microkernel,代码行数:41,代码来源:MainVaadin.java


注:本文中的io.undertow.Undertow.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。