Skip to content

servlets

James Moger edited this page Nov 20, 2015 · 1 revision

Servlets.java

The conf/Servlets.java class is an implicit ServletsModule within your Fathom application and allows you to programatically specify servlets and filters to build URL mappings.

This class does not support @RequireSetting or mode-specific (@DEV, @TEST, & @PROD) annotations, however the same functionality can be achieved using getSettings().isDev(), etc.

!!! Warning "Not Required" You are not required to have this class on your classpath.

Layout

YourApp
└── src
    └── main
        └── java
            └── conf
                └── Servlets.java

!!! Note This class depends on the value of the application.package setting. If you have specified an application package then your Servlets class must be ${package}/conf/Servlets.java.

Configuration

package conf;

public class Servlets extends ServletsModule {

    @Override
    protected void setup() {

      // serve all requests to the application context with MyServlet
      serve("/*").with(MyServlet.class);

      if (getSettings().isDev()) {
        // add an audit filter for the DEV mode
        filter("/*").through(MyAuditFilter.class);
      }

    }

}
Clone this wiki locally