本文整理匯總了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);
}
}
示例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();
}
示例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)
)
);
}
示例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())));
}
}
}
}
示例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;
}
示例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();
}
示例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
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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();
}
示例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");
}