Each type of filter in the filtering system has a filter factory. The role of the factory is to create filters when they are needed by the system and to maintain filter preferences. In order to create a factory a filter must implement the FilterFactory interface. Several methods are defined by this interface, most importantly the createFilter() method which is called by the system to create a new filter to handle an HTTP transaction. setPrefs(), getPrefs(), and viewPrefs() are used to maintain the filter specific preferences. These preferences are passed along to the filter instances using the setPrefs() method in the Filter interface. shutdown() is called by the filtering system to give a factory the chance to save any unsaved data before the filtering system terminates. setManager() provides the factory with an interface to the filter manager which is the part of the filtering system that maintains all the filter factories. Figure 4.11 shows the Java code for the FilterFactory interface.