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


Java RewriteHandler.setRewriteRequestURI方法代码示例

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


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

示例1: getRewriteHandler

import org.eclipse.jetty.rewrite.handler.RewriteHandler; //导入方法依赖的package包/类
private static Handler getRewriteHandler(Handler wrapped) {
  RewriteHandler rewrites = new RewriteHandler();
  rewrites.setOriginalPathAttribute(ORIGINAL_PATH_ATTRIBUTE_NAME);
  rewrites.setRewriteRequestURI(true);
  rewrites.setRewritePathInfo(true);

  for (Map.Entry<String, String> entry : REGEX_REWRITE_RULES.entrySet()) {
    RewriteRegexRule rule = new RewriteRegexRule();
    rule.setRegex(entry.getKey());
    rule.setReplacement(entry.getValue());
    rewrites.addRule(rule);
  }

  rewrites.setHandler(wrapped);

  return rewrites;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Mesos,代码行数:18,代码来源:JettyServerModule.java

示例2: configureRedirectionRules

import org.eclipse.jetty.rewrite.handler.RewriteHandler; //导入方法依赖的package包/类
private Handler configureRedirectionRules(Handler appHandler) {
  RewriteHandler handler = new RewriteHandler();
  handler.setRewriteRequestURI(false);
  handler.setRewritePathInfo(false);
  handler.setOriginalPathAttribute("requestedPath");

  RewriteRegexRule uiRewriteRule = new RewriteRegexRule();
  uiRewriteRule.setRegex("^/collector/.*");
  uiRewriteRule.setReplacement("/");
  handler.addRule(uiRewriteRule);
  handler.setHandler(appHandler);

  HandlerCollection handlerCollection = new HandlerCollection();
  handlerCollection.setHandlers(new Handler[] {handler, appHandler});
  return handlerCollection;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:17,代码来源:WebServerTask.java

示例3: getRedirectHandler

import org.eclipse.jetty.rewrite.handler.RewriteHandler; //导入方法依赖的package包/类
private Handler getRedirectHandler() {
    RewriteHandler rewrite = new RewriteHandler();
    rewrite.setRewriteRequestURI(true);
    rewrite.setRewritePathInfo(true);

    for (String redirect : getRedirectSet()) {
        RedirectPatternRule rule = new RedirectPatternRule();
        rule.setTerminating(true);
        rule.setPattern(redirect);
        rule.setLocation(CONFIG.getContextPath() + "/manager/home");
        rewrite.addRule(rule);
    }
    return rewrite;
}
 
开发者ID:RWTH-i5-IDSG,项目名称:steve-plugsurfing,代码行数:15,代码来源:SteveAppContext.java

示例4: getRedirectRoot2SandboxHandler

import org.eclipse.jetty.rewrite.handler.RewriteHandler; //导入方法依赖的package包/类
private Handler getRedirectRoot2SandboxHandler() {
    RewriteHandler rewrite = new RewriteHandler();
    rewrite.setRewriteRequestURI(true);
    rewrite.setRewritePathInfo(true);
    
    RedirectRegexRule redirectRoot = new RedirectRegexRule();
    redirectRoot.setRegex("^/$");
    redirectRoot.setReplacement("/sandbox");
    rewrite.addRule(redirectRoot);
    
    return rewrite;
}
 
开发者ID:kaaproject,项目名称:sandbox-frame,代码行数:13,代码来源:KaaSandboxInitializationService.java

示例5: getRewriteHandler

import org.eclipse.jetty.rewrite.handler.RewriteHandler; //导入方法依赖的package包/类
private Optional<Handler> getRewriteHandler(Handler handler) {
    try {
        String rewriteFilePath = configuration.getRewriteFilePath();
        if (rewriteFilePath != null && !(rewriteFilePath = rewriteFilePath.trim()).isEmpty()) {
            RewriteHandler rewriteHandler = new RewriteHandler();
            rewriteHandler.setRewritePathInfo(false);
            rewriteHandler.setRewriteRequestURI(true);
            rewriteHandler.setOriginalPathAttribute("__path");
            rewriteHandler.setHandler(handler);

            JavaType listRuleType = getMapper().getTypeFactory().constructParametricType(List.class, RewriteRule.class);
            List<RewriteRule> rules = getMapper().readValue(new FileInputStream(rewriteFilePath), listRuleType);
            boolean isAnyRuleActive = false;
            for (RewriteRule rule : rules) {
                if (rule.isActive()) {
                    RewriteRegexRule regexRule = new RewriteRegexRule();
                    regexRule.setRegex(rule.getFrom());
                    regexRule.setReplacement(rule.getTo());
                    rewriteHandler.addRule(regexRule);
                    isAnyRuleActive = true;
                }
            }
            return isAnyRuleActive ? Optional.of(rewriteHandler) : Optional.empty();
        }
    } catch (IOException e) {
        STARTUP_LOGGER.error("Unable to read Rewrite Rules", e);
    }
    return Optional.empty();
}
 
开发者ID:flipkart-incubator,项目名称:Poseidon,代码行数:30,代码来源:Poseidon.java

示例6: startWebserver

import org.eclipse.jetty.rewrite.handler.RewriteHandler; //导入方法依赖的package包/类
private void startWebserver() {
  JSONObject config = getConfig();
  webport = Integer.parseInt((String)config.get("port"));

  org.eclipse.jetty.util.log.Log.setLog(new NullLogger());
  
  webserver = new Server(webport);
  webserver.setSessionIdManager(new HashSessionIdManager());
  
  RewriteHandler rewriteHandler = new RewriteHandler();
  rewriteHandler.setRewriteRequestURI(true);
  rewriteHandler.setRewritePathInfo(true);
  rewriteHandler.setOriginalPathAttribute("requestedPath");
  RedirectRegexRule rule = new RedirectRegexRule();
  rule.setRegex("/");
  rule.setReplacement("/index");
  rewriteHandler.addRule(rule);
  
  WebAppContext dynamicHandler = new WebAppContext();
  String webDir = this.getClass().getClassLoader().getResource("web").toExternalForm();
  dynamicHandler.setResourceBase(webDir);
  
  dynamicHandler.addServlet(new ServletHolder(new IndexServlet(this)),"/index");
  dynamicHandler.addServlet(new ServletHolder(new LTIServlet(this)),"/lti");
  dynamicHandler.addServlet(new ServletHolder(new TokenServlet(this)),"/token");
  dynamicHandler.addServlet(new ServletHolder(new AssignmentServlet(this)),"/assignment");
  dynamicHandler.addServlet(new ServletHolder(new ConsumerServlet(this)),"/consumer");
  dynamicHandler.addServlet(new ServletHolder(new LTIConfigServlet()),"/config.xml");
  
  ResourceHandler staticHandler = new ResourceHandler();
  String staticDir = this.getClass().getClassLoader().getResource("static").toExternalForm();
  staticHandler.setResourceBase(staticDir);
  
  HandlerList handlers = new HandlerList();
  handlers.setHandlers(new Handler[] { rewriteHandler, staticHandler, dynamicHandler, new DefaultHandler() });
  webserver.setHandler(handlers);
  try {
    webserver.start();
  } catch (Exception e) {
    getLogger().severe("Failed to start server.");
  }
}
 
开发者ID:instructure,项目名称:MinecraftLTI,代码行数:43,代码来源:MinecraftLTI.java

示例7: start

import org.eclipse.jetty.rewrite.handler.RewriteHandler; //导入方法依赖的package包/类
public void start() throws Exception {
    ((ServerConnector) server.getConnectors()[0]).setReuseAddress(true);

    // Root context
    context.setContextPath("/abnormal");

    // Setup static content
    context.setResourceBase("src/main/webapp/");
    context.addServlet(DefaultServlet.class, "/");

    // Enable Jersey debug output
    context.setInitParameter("com.sun.jersey.config.statistic.Trace", "true");

    // Enable CORS - cross origin resource sharing
    FilterHolder cors = new FilterHolder();
    cors.setInitParameter("allowedOrigins", "https?://localhost:*, https?://*.e-navigation.net:*");
    cors.setInitParameter("allowedHeaders", "*");
    cors.setInitParameter("allowedMethods", "OPTIONS,GET,PUT,POST,DELETE,HEAD");
    cors.setFilter(new CrossOriginFilter());
    context.addFilter(cors, "*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.ASYNC, DispatcherType.INCLUDE));

    // Little hack to satisfy OpenLayers URLs in DMA context
    RewritePatternRule openlayersRewriteRule = new RewritePatternRule();
    openlayersRewriteRule.setPattern("/abnormal/theme/*");
    openlayersRewriteRule.setReplacement("/abnormal/js/theme/");

    RewriteHandler rewrite = new RewriteHandler();
    rewrite.setRewriteRequestURI(true);
    rewrite.setRewritePathInfo(false);
    rewrite.setOriginalPathAttribute("requestedPath");
    rewrite.addRule(openlayersRewriteRule);
    rewrite.setHandler(context);
    server.setHandler(rewrite);

    // Setup Guice-Jersey integration
    context.addEventListener(new GuiceServletContextListener() {
        @Override
        protected Injector getInjector() {
            return Guice.createInjector(new RestModule(
                    repositoryName,
                    pathToEventDatabase,
                    eventRepositoryType,
                    eventDataDbHost,
                    eventDataDbPort,
                    eventDataDbName,
                    eventDataDbUsername,
                    eventDataDbPassword
            ));
        }
    });
    context.addFilter(com.google.inject.servlet.GuiceFilter.class, "/rest/*", EnumSet.allOf(DispatcherType.class));

    // Start the server
    server.start();
}
 
开发者ID:dma-ais,项目名称:AisAbnormal,代码行数:56,代码来源:WebServer.java


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