Home of: [Atelier "FUJIGURUMA"] >> [PageMixer hosted by SourceForge.net]

SEE "For Readers of English Version",
or Japanese version of this page

Create 'Filter's

This section explains how to customzie Filter creation with PageServlet.


Class diagram

Class diagram in this section is shown below:

Class diagram
Class diagram (click for large figure)

Classes which you must define are colored, and other are already defined.

Class names

In this tutorial, abbreviated class names are used. Complete names are shown below.

Classes of PageMixer framework

NotationFull name
ConsumerContext jp.ne.dti.lares.foozy.pagemixer.mixer.ConsumerContext
Filter jp.ne.dti.lares.foozy.pagemixer.mixer.Filter
FilterFactory jp.ne.dti.lares.foozy.pagemixer.servlet.FilterFactory
FilterPipeline jp.ne.dti.lares.foozy.pagemixer.mixer.FilterPipeline
PageServlet jp.ne.dti.lares.foozy.pagemixer.servlet.PageServlet

Tutorial specific classes

NotationFull name
CommonFilter pagemixer.filter.CommonFilter

Purpose of customization

Separating Filter creation from HTTP response renderring allows you to:

Implement Filter.Factory

PageMixer provides "FilterFactory" for customization of Filter creation.

But in fact, Filter which FilterFactory default implementation create directly is only FilterPipeline. It pushes Filter created by "Filter.Factory"s, which are registered to itself, into FilterPipeline.

Filter.Factory has the method to accept creation request as shown below.

public Filter create(ConsumerContext context)

Method signature of create

You can get runtime information (e.g.: Servlet/web application initialization parameter) via specified ConsumerContext to create Filter.

ATTENTION: For Filter creation cost reduction, PageServlet invokes create method only once per thread.

So, you must not use request or session wide information to create Filter.

Implementation example is shown below.

public Filter create(ConsumerContext context){
    return new CommonFilter();

Implementation of Filter.Factory

It is good idea to define Filter.Factory implementation classes as inner class of each custom Filter classes for maintenance.

Please see API document for detail to implement Filter.Factory and/or override FilterFactory.


Parameters for base class

FilterFactory accepts Servet initialize parameter(s) shown below:

name description
filter.factory.N name of Filter.Factory implement class. "N" is 0 origin number. you can specify multiple Filter.Factorys.

Parameter to use choosen class

To use your custom FilterFactory, you should specify "servlet.filterFactory" Servlet init-param in deployment descriptor as shown below.

    name of your custom FilterFactory

Specify custom FilterFactory

To next section "Deployment"