Class Configuration

java.lang.Object
org.javalite.activeweb.Configuration

public class Configuration extends Object
Author:
Igor Polevoy
  • Constructor Details

    • Configuration

      public Configuration()
  • Method Details

    • setUseDefaultLayoutForErrors

      public static void setUseDefaultLayoutForErrors(boolean useDefaultLayoutForErrors)
      Set to true if you want ActiveWeb to wrap the errors, such as 404, and 500 in a default layout. False will ensure that these pages will render without default layout.

      System errors

      The following system errors are affected by this setting:
      • CompilationException - when there are compilation errors in controller
      • ClassLoadException - failure to load a controller class for any reason
      • ActionNotFoundException - action method is not found in controller class
      • ViewMissingException - corresponding view is missing
      • ViewException - FreeMarker barfed on the view
      If you need custom dynamic layout for error.ftl and 404.ftl, use "@wrap" tag and conditions inside the error templates.

      Application level

      This method does not affect application errors (exceptions thrown by your code). However, it is typical for an ActiveWeb project to define a top controller filter called CatchAllFilter and process application level exceptions in that filter:
                  package app.controllers;
                  import org.javalite.activeweb.controller_filters.HttpSupportFilter;
                  import static org.javalite.common.Collections.map;
                  public class CatchAllFilter extends HttpSupportFilter {
                      public void onException(Exception e) {
                          render("/system/error", map("message", e.getMessage())).layout("error_layout");
                      }
                  }
       
      This way you have a complete control over how your error messages are displayed.
      Parameters:
      useDefaultLayoutForErrors - true to use default layout, false no not to use it.
    • useDefaultLayoutForErrors

      protected static boolean useDefaultLayoutForErrors()
      True to use default layout for error pages, false not to.
      Returns:
      true to use default layout for error pages, false not to.
    • logRequestParams

      public static boolean logRequestParams()
    • isTesting

      public static boolean isTesting()
      This method is used internally by ActiveWeb tests. Do not use in your projects. If you need this feature, use: AppConfig#isInTestMode
      Returns:
      true if running in tests.
    • setTesting

      protected static void setTesting(boolean testing)
    • getFreeMarkerConfig

      public static AbstractFreeMarkerConfig getFreeMarkerConfig()
    • getTemplateManager

      public static TemplateManager getTemplateManager()
    • get

      public static String get(String name)
    • getDefaultLayout

      public static String getDefaultLayout()
    • getBootstrapClassName

      public static String getBootstrapClassName()
    • getControllerConfigClassName

      public static String getControllerConfigClassName()
    • getDbConfigClassName

      public static String getDbConfigClassName()
    • getRouteConfigClassName

      public static String getRouteConfigClassName()
    • getTargetDir

      public static String getTargetDir()
    • getRootPackage

      public static String getRootPackage()
    • rollback

      public static boolean rollback()
    • activeReload

      public static boolean activeReload()
    • getMaxUploadSize

      public static int getMaxUploadSize()
    • getTmpDir

      public static File getTmpDir()
    • setFilters

      protected static void setFilters(List<HttpSupportFilter> allFilters)
    • getFilters

      protected static List<HttpSupportFilter> getFilters()
    • injectFilters

      protected static void injectFilters()
    • logHeaders

      public static void logHeaders(String... headerNames)
      Provide names of headers to log to the log system with each request. This configuration is dynamic and can be changed during runtime.
      Parameters:
      headerNames - list of headers to log. If the first argument is '*', all headers will be logged.
    • getLogHeaders

      protected static List<String> getLogHeaders()
    • getControllerClassInfos

      public static CloseableList<io.github.classgraph.ClassInfo> getControllerClassInfos(ClassLoader classLoader)
      Returns a list of controllers that are reachable and not abstract.
      Parameters:
      classLoader - - a classloader to use when looking for controllers.
      Returns:
      list of ControllerInfo.
    • addEndpointMapping

      public static void addEndpointMapping(AbstractWebSocketConfig.EndpointMapping mapping)
    • getAppEndpointClass

      public static Class<? extends AppEndpoint> getAppEndpointClass(String path)