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


Java PathHandler.addPrefixPath方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: start

import io.undertow.server.handlers.PathHandler; //導入方法依賴的package包/類
public void start() {
    final 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();
    if (builder.storage != null) {
        builder.storage.listen(this);
    } else if (builder.storageFactory != null) {
        builder.storageFactory.listen(this);
    }
}
 
開發者ID:datathings,項目名稱:greycat,代碼行數:14,代碼來源:WSServer.java

示例9: createRootHandler

import io.undertow.server.handlers.PathHandler; //導入方法依賴的package包/類
public HttpHandler createRootHandler(Configuration configuration , ScannerResult scannerResult) {
  PathHandler pathHandler = Handlers.path();

  String appContext = "/" + configuration.getAppContext();
  pathHandler.addPrefixPath( appContext , createAppHandlers(scannerResult));
  if(!scannerResult.getServerEndpoints().isEmpty()){
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(this.getClass().getClassLoader()).setContextPath("/");
    WebSocketDeploymentInfo wsDeployInfo = new WebSocketDeploymentInfo();
    wsDeployInfo.setBuffers(new ByteBufferSlicePool(100, 1000));
    for(Class<?> serverEndpoint : scannerResult.getServerEndpoints() ){
      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();
    try {
      OvertownSessionManager sessionManager = OvertownSessionManager.getInstance();
      String wsContextPath = "ws";
      if( !appContext.endsWith("/") ){
        wsContextPath += appContext + "/" + wsContextPath;
      }
      pathHandler.addPrefixPath( wsContextPath ,
              new SessionAttachmentHandler(  manager.start() , sessionManager.getSessionManager(),
                sessionManager.getSessionConfig()) );
    } catch (ServletException e) {
      e.printStackTrace();
    }
  }
  String staticContextPath = configuration.getStaticRootPath();
  if( !appContext.endsWith("/") ){
    staticContextPath = appContext + "/" + staticContextPath;
  }
  pathHandler.addPrefixPath( staticContextPath , new ResourceHandlerMounter().mount());
  return pathHandler;
}
 
開發者ID:EsmerilProgramming,項目名稱:overtown,代碼行數:39,代碼來源:StartupHandlerImpl.java

示例10: addDmrRedinessHandler

import io.undertow.server.handlers.PathHandler; //導入方法依賴的package包/類
private static HttpHandler addDmrRedinessHandler(PathHandler pathHandler, HttpHandler domainApiHandler, Function<HttpServerExchange, Boolean> readinessFunction) {
    HttpHandler readinessHandler = wrapXFrameOptions(new DmrFailureReadinessHandler(readinessFunction, domainApiHandler, ErrorContextHandler.ERROR_CONTEXT));
    pathHandler.addPrefixPath(DomainApiCheckHandler.PATH, readinessHandler);
    pathHandler.addExactPath(DomainApiCheckHandler.GENERIC_CONTENT_REQUEST, readinessHandler);

    return readinessHandler;
}
 
開發者ID:wildfly,項目名稱:wildfly-core,代碼行數:8,代碼來源:ManagementHttpServer.java

示例11: addTo

import io.undertow.server.handlers.PathHandler; //導入方法依賴的package包/類
public void addTo(PathHandler ph, OptionMap config) {
	ResourceHandler rh = new ResourceHandler(newResourceManager(config));
	rh.setMimeMappings(config.get(Config.MIME_MAPPINGS));
	if (this.cacheTime != null) {
		rh.setCacheTime(this.cacheTime);
	}
	rh.setDirectoryListingEnabled(this.directoryListing);
	rh.setCanonicalizePaths(this.canonicalizePaths);
	if (this.welcomeFiles != null) {
		rh.setWelcomeFiles(this.welcomeFiles);
	}

	ph.addPrefixPath(this.path, rh);
}
 
開發者ID:taichi,項目名稱:siden,代碼行數:15,代碼來源:AssetDef.java

示例12: createContextHandler

import io.undertow.server.handlers.PathHandler; //導入方法依賴的package包/類
protected HttpHandler createContextHandler(HttpHandler pippoHandler) throws ServletException {
    String contextPath = getSettings().getContextPath();

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

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

    return contextHandler;
}
 
開發者ID:decebals,項目名稱:pippo,代碼行數:12,代碼來源:UndertowServer.java

示例13: main

import io.undertow.server.handlers.PathHandler; //導入方法依賴的package包/類
public static void main(final String[] args) {

        final Config config = new DemoConfigFactory().build();

        PathHandler path = new PathHandler();

        path.addExactPath("/", SecurityHandler.build(DemoHandlers.indexHandler(), config, "AnonymousClient"));
        path.addExactPath("/index.html", SecurityHandler.build(DemoHandlers.indexHandler(), config, "AnonymousClient"));

        path.addExactPath("/facebook/notprotected.html", DemoHandlers.protectedIndex);
        path.addExactPath("/facebook/index.html", SecurityHandler.build(DemoHandlers.protectedIndex, config, "FacebookClient"));
        path.addExactPath("/facebook/notprotected.html", SecurityHandler.build(DemoHandlers.notProtectedIndex, config, "AnonymousClient"));
        path.addExactPath("/facebookadmin/index.html", SecurityHandler.build(DemoHandlers.protectedIndex, config, "FacebookClient", "admin"));
        path.addExactPath("/facebookcustom/index.html", SecurityHandler.build(DemoHandlers.protectedIndex, config, "FacebookClient", "custom"));
        path.addExactPath("/twitter/index.html", SecurityHandler.build(DemoHandlers.protectedIndex, config, "TwitterClient,FacebookClient"));
        path.addExactPath("/form/index.html", SecurityHandler.build(DemoHandlers.protectedIndex, config, "FormClient"));
        path.addExactPath("/form/index.html.json", SecurityHandler.build(DemoHandlers.authenticatedJsonHandler, config, "FormClient"));
        path.addExactPath("/basicauth/index.html", SecurityHandler.build(DemoHandlers.protectedIndex, config, "IndirectBasicAuthClient"));
        path.addExactPath("/cas/index.html", SecurityHandler.build(DemoHandlers.protectedIndex, config, "CasClient"));
        path.addExactPath("/saml2/index.html", SecurityHandler.build(DemoHandlers.protectedIndex, config, "SAML2Client"));
        path.addExactPath("/oidc/index.html", SecurityHandler.build(DemoHandlers.protectedIndex, config, "OidcClient"));
        path.addExactPath("/protected/index.html", SecurityHandler.build(DemoHandlers.protectedIndex, config));

        path.addExactPath("/dba/index.html", SecurityHandler.build(DemoHandlers.protectedIndex, config, "DirectBasicAuthClient,ParameterClient"));
        path.addExactPath("/rest-jwt/index.html", SecurityHandler.build(DemoHandlers.protectedIndex, config, "ParameterClient"));

        path.addExactPath("/callback", CallbackHandler.build(config, null, true));
        path.addExactPath("/logout", new ApplicationLogoutHandler(config, "/?defaulturlafterlogout"));

        path.addPrefixPath("/assets/js", Handlers.resource(new ClassPathResourceManager(DemoServer.class.getClassLoader())));

        path.addExactPath("/loginForm.html", DemoHandlers.loginFormHandler(config));
        path.addExactPath("/jwt.html", SecurityHandler.build(DemoHandlers.jwtHandler(), config, "AnonymousClient"));
        path.addExactPath("/forceLogin", DemoHandlers.forceLoginHandler(config));

        Undertow server = Undertow.builder().addHttpListener(8080, "localhost")
                .setHandler(new SessionAttachmentHandler(new ErrorHandler(path), new InMemorySessionManager("SessionManager"), new SessionCookieConfig())).build();
        server.start();
    }
 
開發者ID:pac4j,項目名稱:undertow-pac4j-demo,代碼行數:40,代碼來源:DemoServer.java

示例14: start

import io.undertow.server.handlers.PathHandler; //導入方法依賴的package包/類
@Override
public void start(FolderContext music, FolderContext mount, int port, String user, String password) throws Exception {
	final ResourceHandler musicResourceHandler = new ResourceHandler();
	musicResourceHandler.setResourceManager(new FileResourceManager(music.getFolder(), 0));
	MimeMappings.Builder musicMimeMappingsBuilder = MimeMappings.builder(true);
	musicMimeMappingsBuilder.addMapping("mp3", "audio/mpeg");
	musicMimeMappingsBuilder.addMapping("m4a", "audio/mp4");
	musicResourceHandler.setMimeMappings(musicMimeMappingsBuilder.build());
	
	final ResourceHandler mountResourceHandler = new ResourceHandler();
	mountResourceHandler.setResourceManager(new FileResourceManager(mount.getFolder(), 0));
	mountResourceHandler.addWelcomeFiles("index.json");
	MimeMappings.Builder mountMimeMappingsBuilder = MimeMappings.builder(false);
	mountMimeMappingsBuilder.addMapping("json", "text/json");
	mountResourceHandler.setMimeMappings(mountMimeMappingsBuilder.build());

	final PathHandler pathHandler = new PathHandler(mountResourceHandler);
	pathHandler.addPrefixPath(music.getPath(), musicResourceHandler);
	pathHandler.addPrefixPath(mount.getPath(), mountResourceHandler);
	
	HttpHandler handler = new HttpHandler() {
		@Override
		public void handleRequest(HttpServerExchange exchange) throws Exception {
			System.out.println(exchange.getRequestPath());
			pathHandler.handleRequest(exchange);
		}
	};
	
	undertow = Undertow.builder().addHttpListener(port, null).setHandler(handler).build();
	undertow.start();
}
 
開發者ID:beckchr,項目名稱:musicmount,代碼行數:32,代碼來源:MusicMountServerUndertow.java

示例15: startServer

import io.undertow.server.handlers.PathHandler; //導入方法依賴的package包/類
/**
 * Start server on the given port.
 *
 * @param port
 */
public static void startServer(int port) {

    LOGGER.info(String.format("Starting server on port %d", port));

    PathHandler path = Handlers.path();

    server = Undertow.builder()
            .addHttpListener(port, "localhost")
            .setHandler(path)
            .build();

    server.start();

    LOGGER.info(String.format("Server started on port %d", port));

    DeploymentInfo servletBuilder = Servlets.deployment()
            .setClassLoader(Application.class.getClassLoader())
            .setContextPath("/")
            .addListeners(listener(Listener.class))
            .setResourceManager(new ClassPathResourceManager(Application.class.getClassLoader()))
            .addServlets(
                    Servlets.servlet("jerseyServlet", ServletContainer.class)
                            .setLoadOnStartup(1)
                            .addInitParam("javax.ws.rs.Application", JerseyConfig.class.getName())
                            .addMapping("/api/*"))
            .setDeploymentName("application.war");

    LOGGER.info("Starting application deployment");

    deploymentManager = Servlets.defaultContainer().addDeployment(servletBuilder);
    deploymentManager.deploy();

    try {
        path.addPrefixPath("/", deploymentManager.start());
    } catch (ServletException e) {
        throw new RuntimeException(e);
    }

    LOGGER.info("Application deployed");
}
 
開發者ID:cassiomolin,項目名稱:jersey-jwt,代碼行數:46,代碼來源:Application.java


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