We should probably extract the common code into a new class that specific implementation can reuse. From what I can see 95% of this class is the same for Tomcat 7.x and 8.x.