Skip to content

BorderTech/java-servlet-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Servlet Tools

Status

Build Status Quality Gate Status Reliability Rating Coverage Codacy Badge javadoc Maven Central

Content

What is Servlet Tools

Servlet Tools provides helper filters and listeners to make it easier to use Servlet annotations.

Why use Servlet Tools

A project may have existing Servlet filters/listeners or 3rd party filters/listeners that are not annotated.

If the project is not using a web.xml and relying on Servlet annotations, the Servlet Tools combo filter/listener makes it easier for projects to combine these filters/listeners into a single class that can be annotated.

Without Servlet Tools the project would need to (1) define each filter/listener in a web.xml or (2) extend the existing filters/listeners and annotate the new classes.

Getting started

Add dependency:

<project>
  ....
  <dependency>
    <groupId>com.github.bordertech.taskmaster</groupId>
    <artifactId>java-servlet-tools</artifactId>
    <version>1.0.0</version>
  </dependency>
  ....
</project>

Combo Filter

How to create a combo filter that combines multiple servlet filters into one annotated class:

  • Create a new class that extends AbstractComboFilter
  • In the constructor, define the filter classes to be combined
  • Annotate the new class with @WebFilter
  @WebFilter
  public class MyFilter extends AbstractComboFilter {

    public MyFilter() {
      super(new ExistingFilter(), new AnotherFilter());
    }

  }

Combo Listener

How to create a combo listener that combines multiple servlet listeners into one annotated class:

  • Create a new class that extends AbstractComboServletListener
  • In the constructor, define the listener classes to be combined
  • Annotate the new class with @WebListener
  @WebListener
  public class MyListener extends AbstractComboServletListener {

    public MyListener() {
      super(new ExistingListener(), new AnotherListener());
    }

  }

Contributing

Refer to these guidelines for Workflow and Releasing.

About

Servlet Tools such as filters and listeners

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages