spark.staticfiles.StaticFilesConfiguration Java Examples

The following examples show how to use spark.staticfiles.StaticFilesConfiguration. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestApplication.java    From gocd with Apache License 2.0 6 votes vote down vote up
@Override
public void destroy() {
    //hacky way to reset the state of the routes between tests
    //see Service.stop(), (not invoked directly because it spawns a thread)
    try {
        Method getInstance = Spark.class.getDeclaredMethod("getInstance");
        getInstance.setAccessible(true);
        Service service = (Service) getInstance.invoke(null);
        //Dependent on current version of Spark
        //This is likely to fail in case of upgrades
        clear(service, "routes", Routes.class);
        clear(service, "exceptionMapper", ExceptionMapper.class);
        clear(service, "staticFilesConfiguration", StaticFilesConfiguration.class);
        ReflectionTestUtils.setField(service, "initialized", false);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #2
Source File: JettyFactory.java    From freeacs with MIT License 5 votes vote down vote up
@Override
public EmbeddedServer create(
    Routes routeMatcher,
    StaticFilesConfiguration staticFilesConfiguration,
    ExceptionMapper exceptionMapper,
    boolean hasMultipleHandler) {
  MatcherFilter matcherFilter =
      new MatcherFilter(
          routeMatcher, staticFilesConfiguration, exceptionMapper, false, hasMultipleHandler);
  matcherFilter.init(null);
  JettyHandler handler = new JettyHandler(matcherFilter);
  handler.addEventListener(httpSessionEventListener);
  handler.getSessionCookieConfig().setHttpOnly(httpOnly);
  return new EmbeddedJettyServer(new JettyServer(maxHttpPostSize, maxFormKeys), handler);
}
 
Example #3
Source File: LambdaEmbeddedServerFactory.java    From aws-serverless-java-container with Apache License 2.0 5 votes vote down vote up
@Override
public EmbeddedServer create(Routes routes, StaticFilesConfiguration staticFilesConfiguration, ExceptionMapper exceptionMapper, boolean multipleHandlers) {
    Timer.start("SPARK_SERVER_FACTORY_CREATE");
    if (embeddedServer == null) {
        LambdaEmbeddedServerFactory.embeddedServer = new LambdaEmbeddedServer(routes, staticFilesConfiguration, exceptionMapper, multipleHandlers);
    }
    Timer.stop("SPARK_SERVER_FACTORY_CREATE");
    return embeddedServer;
}
 
Example #4
Source File: LambdaEmbeddedServer.java    From aws-serverless-java-container with Apache License 2.0 5 votes vote down vote up
LambdaEmbeddedServer(Routes routes, StaticFilesConfiguration filesConfig, ExceptionMapper exceptionMapper, boolean multipleHandlers) {
    Timer.start("SPARK_EMBEDDED_SERVER_CONSTRUCTOR");
    applicationRoutes = routes;
    staticFilesConfiguration = filesConfig;
    hasMultipleHandler = multipleHandlers;
    this.exceptionMapper = exceptionMapper;

    // try to initialize the filter here.
    sparkFilter = new MatcherFilter(applicationRoutes, staticFilesConfiguration, exceptionMapper, true, hasMultipleHandler);
    Timer.stop("SPARK_EMBEDDED_SERVER_CONSTRUCTOR");
}
 
Example #5
Source File: StaticFileHandlerFilter.java    From ache with Apache License 2.0 5 votes vote down vote up
public StaticFileHandlerFilter(List<String> indexHtmlPaths, String basePath) {
    this.staticFilesHandler = new StaticFilesConfiguration();
    this.staticFilesHandler.configure("/public");
    this.patterns = WildcardMatcher.fromWhitelist(indexHtmlPaths);
    this.basePath = normalizeBasePath(basePath);
    this.indexHtml = readIndexHtmlFile();
}