search close

Installing the Java Module with Dropwizard

access_time Updated Sep 21, 2021

The Signal Sciences Java module can easily be deployed through Dropwizard.

Installation

Download

  1. Download the Java module at https://dl.signalsciences.net/sigsci-module-java/sigsci-module-java_latest.tar.gz

  2. Copy jar file to the application classpath. For example in Tomcat this would be %CATALINA_HOME%\webbapps\<APP_FOLDER>\WEB-INF\lib.

  3. Extract sigsci-module-java_latest.tar.gz. There are two options for deploying the jars:

    • Copy sigsci-module-java-{version}-shaded.jar (an uber jar with all the dependencies bundled) to your application’s classpath (e.g., %CATALINA_HOME%\webbapps\<APP_FOLDER>\WEB-INF\lib).

    • Copy sigsci-module-java-{version}.jar and its dependencies in the lib folder to your application’s classpath (e.g., %CATALINA_HOME%\webbapps\<APP_FOLDER>\WEB-INF\lib). If you already have any of the dependency jar files in your application classpath folder (i.e. for Tomcat in the WEB-INF\lib) then it is not necessary to copy them, even if the version numbers are different. The logging jars are optional based on how slf4j is configured.

For Java projects using Maven for build or deployment, the Signal Sciences Java modules can be installed by adding the following to the project pom.xml:

<repositories>
    <repository>
        <id>sigsci-stable</id>
        <url>https://packages.signalsciences.net/release/maven2</url>
    </repository>
</repositories>

<dependency>
  <groupId>com.signalsciences</groupId>
  <artifactId>sigsci-module-java</artifactId>
  <version>1.1.3</version>
</dependency>

Install and configure

Dropwizard supports standard Java servlet filters, but you will need to register the filter class.

Additional information about Dropwizard servet filter support can be found here.

The Dropwizard framework internally uses the Jetty servlet engine. The Signal Sciences Java module provides servlet filters.

Example run method inside class extending Dropwizard “Application” class

import com.signalsciences.servlet.filter.SigSciFilter;
@Override
public void run(final DwizExampleConfiguration configuration, final Environment environment) {
    environment.servlets().addFilter("SigSciFilter", new SigSciFilter()).addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");
    final HelloWorldResource resource = new HelloWorldResource(
        "%s",
        "Demo value"
    );
    environment.jersey().register(resource);
}