當前位置: 首頁>>代碼示例>>Java>>正文


Java PathHandler類代碼示例

本文整理匯總了Java中io.undertow.server.handlers.PathHandler的典型用法代碼示例。如果您正苦於以下問題:Java PathHandler類的具體用法?Java PathHandler怎麽用?Java PathHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PathHandler類屬於io.undertow.server.handlers包,在下文中一共展示了PathHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import io.undertow.server.handlers.PathHandler; //導入依賴的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

示例2: startHttpServer

import io.undertow.server.handlers.PathHandler; //導入依賴的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

示例3: startImpl

import io.undertow.server.handlers.PathHandler; //導入依賴的package包/類
protected void startImpl() {
    try {
        fathomDeploymentManager = createFathomDeploymentManager();
        HttpHandler fathomHandler = fathomDeploymentManager.start();

        String contextPath = settings.getContextPath();

        // create a handler than redirects non-context requests to the context
        PathHandler contextHandler = Handlers.path(Handlers.redirect(contextPath));

        // add the handler with the context prefix
        contextHandler.addPrefixPath(contextPath, fathomHandler);

        GracefulShutdownHandler rootHandler = new GracefulShutdownHandler(contextHandler);
        server = createServer(rootHandler);

        String version = server.getClass().getPackage().getImplementationVersion();
        log.info("Starting Undertow {}", version);

        server.start();
    } catch (Exception e) {
        throw new FathomException(e);
    }
}
 
開發者ID:gitblit,項目名稱:fathom,代碼行數:25,代碼來源:Server.java

示例4: init

import io.undertow.server.handlers.PathHandler; //導入依賴的package包/類
private void init(PathHandler pathHandler) throws ServletException {
  // Deployment info
  ServletContainer servletContainer = Servlets.defaultContainer();
  DeploymentInfo deploymentInfo = VasHelper.deploymentInfo();

  // Boot context & post processors
  context = new BootContextImpl(properties, pathHandler, deploymentInfo, services);
  VasHelper.lookupHandlerPostProcessors(context);

  // Deployment
  DeploymentManager deploymentManager = servletContainer.addDeployment(deploymentInfo);
  deploymentManager.deploy();

  pathHandler.addPrefixPath(Const.CONTEXT_NAME, deploymentManager.start());
  boot();
}
 
開發者ID:vvergnolle,項目名稱:vas,代碼行數:17,代碼來源:VasImpl.java

示例5: publish

import io.undertow.server.handlers.PathHandler; //導入依賴的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

示例6: publishCanonicalNamespace

import io.undertow.server.handlers.PathHandler; //導入依賴的package包/類
private static void publishCanonicalNamespace(final Catalog catalog, final String basePath, final PathHandler pathHandler, final SerializationManager manager, final DocumentationDeploymentFactory factory) {
	final ContentNegotiationHandler contentNegotiation = contentNegotiation().
		negotiate(
			negotiableModuleContent(),
			new ModuleRepresentionGenerator(manager));
	if(factory!=null) {
		contentNegotiation.
			negotiate(
				NegotiableContent.newInstance().support(HTML),
				new ModuleDocumentationRedirector(factory));
	}
	pathHandler.
		addPrefixPath(
			basePath,
			moduleReverseProxy(
				catalog,
				methodController(
					contentNegotiation).
					allow(Methods.GET)
			)
		);
}
 
開發者ID:SmartDeveloperHub,項目名稱:sdh-vocabulary,代碼行數:23,代碼來源:VocabularyPublisher.java

示例7: setUpClass

import io.undertow.server.handlers.PathHandler; //導入依賴的package包/類
/**
 * Sets up the test environment, generates data to upload, starts an
 * Undertow instance which will receive the client requests.
 * @throws Exception If an error occurred with the servlets
 */
@BeforeClass
public static void setUpClass() throws Exception {
    DeploymentInfo servletBuilder = Servlets.deployment()
            .setClassLoader(UndertowIntegrationTest.class.getClassLoader())
            .setContextPath("/")
            .setDeploymentName("ROOT.war")
            .addServlets(
                    Servlets.servlet("AsyncUploadServlet", AsyncUploadServlet.class)
                            .addMapping("/async")
                            .setAsyncSupported(true),
                    Servlets.servlet("BlockingUploadServlet", BlockingUploadServlet.class)
                            .addMapping("/blocking")
                            .setAsyncSupported(false)
            );

    DeploymentManager manager = Servlets.defaultContainer().addDeployment(servletBuilder);
    manager.deploy();
    PathHandler path = Handlers.path(Handlers.redirect("/")).addPrefixPath("/", manager.start());

    server = Undertow.builder()
            .addHttpListener(8080, "localhost")
            .setHandler(path)
            .build();
    server.start();
}
 
開發者ID:Elopteryx,項目名稱:upload-parser,代碼行數:31,代碼來源:UndertowIntegrationTest.java

示例8: createRoutes

import io.undertow.server.handlers.PathHandler; //導入依賴的package包/類
/**
 * Create routes for WebSockets ServerSentEvent and Resource files
 */
private static void createRoutes() {
    if (!error) {
        pathHandler = new PathHandler(getRoutingHandler());
        for (final Route route : Router.getRoutes()) {
            if (RouteType.WEBSOCKET == route.getRouteType()) {
                pathHandler.addExactPath(route.getUrl(),
                        Handlers.websocket(injector.getInstance(WebSocketHandler.class)
                                .withControllerClass(route.getControllerClass())
                                .withAuthentication(route.isAuthenticationRequired())));
            } else if (RouteType.SERVER_SENT_EVENT == route.getRouteType()) {
                pathHandler.addExactPath(route.getUrl(),
                        Handlers.serverSentEvents(injector.getInstance(ServerSentEventHandler.class)
                                .withAuthentication(route.isAuthenticationRequired())));
            } else if (RouteType.RESOURCE_PATH == route.getRouteType()) {
                pathHandler.addPrefixPath(route.getUrl(),
                        new ResourceHandler(new ClassPathResourceManager(Thread.currentThread().getContextClassLoader(), Default.FILES_FOLDER.toString() + route.getUrl())));
            }
        }            
    }
}
 
開發者ID:svenkubiak,項目名稱:mangooio,代碼行數:24,代碼來源:Application.java

示例9: start

import io.undertow.server.handlers.PathHandler; //導入依賴的package包/類
public void start() throws ServletException, IOException {
	DeploymentInfo servletInfo = LuceeServletBuilder.build( libDirs, webroot, webXmlPath, webInfPath );

	deploymentManager = defaultContainer().addDeployment( servletInfo );
	deploymentManager.deploy();

	HttpHandler httpHandler = deploymentManager.start();
	PathHandler pathHandler = Handlers.path( Handlers.redirect( "/" ) ).addPrefixPath( "/", httpHandler );
	Builder     builder     = Undertow.builder();

	builder.addHttpListener( port, host );
	builder.setHandler( pathHandler );

	undertowServer = builder.build();
	undertowServer.start();
}
 
開發者ID:DominicWatson,項目名稱:embedded-lucee-undertow-factory,代碼行數:17,代碼來源:LuceeUndertowServer.java

示例10: mountServerEndpoints

import io.undertow.server.handlers.PathHandler; //導入依賴的package包/類
protected PathHandler mountServerEndpoints(final PathHandler pathHandler , List<Class<?>> serverEndpoints) throws ServletException{
  if(!serverEndpoints.isEmpty()){
    DeploymentInfo builder = new DeploymentInfo()
      .setClassLoader(this.getClass().getClassLoader())
      .setContextPath("/");
    WebSocketDeploymentInfo wsDeployInfo = new WebSocketDeploymentInfo();
    wsDeployInfo.setBuffers(new ByteBufferSlicePool(100, 1000));
    for(Class<?> serverEndpoint : serverEndpoints ){
      wsDeployInfo.addEndpoint( serverEndpoint );
    }
    builder.addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, wsDeployInfo );
    builder.setDeploymentName("websocketDeploy.war");
    
    final ServletContainer container = ServletContainer.Factory.newInstance();
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    pathHandler.addPrefixPath("/", manager.start() );
  }      
  return pathHandler;
}
 
開發者ID:EsmerilProgramming,項目名稱:overtown,代碼行數:21,代碼來源:PathHandlerMounter.java

示例11: mountMethods

import io.undertow.server.handlers.PathHandler; //導入依賴的package包/類
protected PathHandler mountMethods(PathHandler pathHandler, final Class<?> handlerClass) {
  Controller controllerAnnotation = handlerClass.getAnnotation(Controller.class);

  Method[] methods = handlerClass.getMethods();

  final List<Method> beforeTranslationMethods = identifyBeforeTranslationMethod(methods);
  for (final Method method : methods) {
    Page methodPagePath = method.getAnnotation(Page.class);
    if (methodPagePath != null) {
      HttpHandler h = new HandlerCreator()
          .forPageClass(handlerClass)
          .withPathMethod(method)
          .withExecuteBeforeMethods(beforeTranslationMethods)
          .mount();
      
      String pageRoot = controllerAnnotation.path();
      for (String methodRoot : methodPagePath.value()) {
        pathHandler.addExactPath(pageRoot + "/" + methodRoot, h);
      }
    }
  }

  return pathHandler;
}
 
開發者ID:EsmerilProgramming,項目名稱:overtown,代碼行數:25,代碼來源:PathHandlerMounter.java

示例12: HttpProtocolReceiver

import io.undertow.server.handlers.PathHandler; //導入依賴的package包/類
public HttpProtocolReceiver(final UPID localAddress,
                            final Class<?> messageBaseClass,
                            final ManagedEventBus eventBus)
{
    this.localAddress = localAddress;
    this.messageBaseClass = messageBaseClass;
    this.eventBus = eventBus;

    final PathHandler pathHandler = new PathHandler();
    pathHandler.addPrefixPath(localAddress.getId(), new CanonicalPathHandler(new BlockingHandler(this)));

    this.shutdownHandler = new GracefulShutdownHandler(pathHandler);

    this.httpServer = Undertow.builder()
        .setIoThreads(2)
        .setWorkerThreads(16)
        .addHttpListener(localAddress.getPort(), localAddress.getHost())
        .setHandler(shutdownHandler)
        .build();
}
 
開發者ID:groupon,項目名稱:jesos,代碼行數:21,代碼來源:HttpProtocolReceiver.java

示例13: buildGracefulShutdownHandler

import io.undertow.server.handlers.PathHandler; //導入依賴的package包/類
/**
 * buildGracefulShutdownHandler
 *
 * @param paths
 * @return
 */
private static GracefulShutdownHandler buildGracefulShutdownHandler(PathHandler paths) {
    return new GracefulShutdownHandler(
            new RequestLimitingHandler(new RequestLimit(configuration.getRequestLimit()),
                    new AllowedMethodsHandler(
                            new BlockingHandler(
                                    new GzipEncodingHandler(
                                            new ErrorHandler(
                                                    new HttpContinueAcceptingHandler(paths)
                                            ), configuration.isForceGzipEncoding()
                                    )
                            ), // allowed methods
                            HttpString.tryFromString(RequestContext.METHOD.GET.name()),
                            HttpString.tryFromString(RequestContext.METHOD.POST.name()),
                            HttpString.tryFromString(RequestContext.METHOD.PUT.name()),
                            HttpString.tryFromString(RequestContext.METHOD.DELETE.name()),
                            HttpString.tryFromString(RequestContext.METHOD.PATCH.name()),
                            HttpString.tryFromString(RequestContext.METHOD.OPTIONS.name())
                    )
            )
    );
}
 
開發者ID:SoftInstigate,項目名稱:restheart,代碼行數:28,代碼來源:Bootstrapper.java

示例14: remove

import io.undertow.server.handlers.PathHandler; //導入依賴的package包/類
public synchronized boolean remove(String path, List<String> vhosts) {
    boolean result = false;
    if (vhosts == null) {
        result = null != activeHandlers.remove(path);
        pathHandler.removePrefixPath(path);
    } else {
        for(String host: vhosts) {
            if (null != activeHandlers.remove(host + path)) {
                result = true;
                PathHandler ph = (PathHandler) vhostHandler.getHosts().get(host);
                ph.removePrefixPath(path);
            }
        }
    }
    purge();
    return result;
}
 
開發者ID:projectodd,項目名稱:wunderboss,代碼行數:18,代碼來源:UndertowWeb.java

示例15: start

import io.undertow.server.handlers.PathHandler; //導入依賴的package包/類
public void start() {
    PathHandler pathHandler = Handlers.path();
    for (String name : handlers.keySet()) {
        pathHandler.addPrefixPath(name, handlers.get(name));
    }
    this.server = Undertow.builder().addHttpListener(port, "0.0.0.0", pathHandler).build();
    server.start();
    this.graph.storage().listen(this);//stop
}
 
開發者ID:datathings,項目名稱:greycat,代碼行數:10,代碼來源:WSSharedServer.java


注:本文中的io.undertow.server.handlers.PathHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。