Milyn-Smooks Version 0.4

org.milyn
Class SmooksServletFilter

java.lang.Object
  extended byorg.milyn.SmooksServletFilter
All Implemented Interfaces:
javax.servlet.Filter

public class SmooksServletFilter
extends java.lang.Object
implements javax.servlet.Filter

Smooks Servlet Filter.

Smooks controller class for the J2EE Servlet environment. This class pipes the Servlet response into a ServletResponseWrapper instance for transformation and serialisation. The default response wrapper is the HtmlServletResponseWrapper which transforms a HTML stream based on the content delivery resource configuration for the requesting device. See PassThruServletResponseWrapper.

Requirements

Deployment

To deploy Smooks:
  1. Download and explode the Smooks distribution.
  2. The distribution "build" folder contains the file "WEB-INF.zip". This is the WEB-INF folder from the CNN.com sample (minus binaries i.e. empty lib folder). This file contains the only Smooks configuration-set that's available at the moment. Unzip this file into the root of your target application. This is a temporary measure - the next release should manage the configurations more cleanly.
  3. Deploy the Smooks binaries into the Servlet container i.e. into /WEB-INF/lib. The binaries are located in the "build" folder in the distribution.
    Note: Don't copy the WEB-INF.zip file to the target container.
  4. Deploy the Smooks dependencies into the Servlet container i.e. into /WEB-INF/lib. The dependencies are located in the "lib" folder in the distribution.
    Note: Don't copy the servlet.jar file to the target container.
    Note: The Smooks distribution contains the Tinak binaries so there's no need to pre-install Tinak.
To enable Smooks Content delivery in your Servlet container, add the following to the application web.xml file.
 <filter>
	<filter-name>SmooksFilter</filter-name>
	<filter-class>org.milyn.SmooksServletFilter</filter-class>
 </filter>
 <filter-mapping>
	<filter-name>SmooksFilter</filter-name>
	<url-pattern>*.jsp</url-pattern>
 </filter-mapping>

Content Delivery Unit Configuration

Read the Content Delivery Units overview before reading this section.

How does Smooks load Content Delivery Units in a Servlet container? This section tries to explain how this works at present.

Webapp WEB-INF Structure

The following illustration shows a sample Smooks Content Delivery Unit/Resource configuration in a Servlet container. Smooks uses the "smooks-cdr.lst" file to load the .cdrl and .cdrar files from the cdr folder. Read the Content Delivery Units overview for more on how Smooks uses the .cdrl and .cdrar files to load the Content Delivery Resources.

Author:
tfennelly

Constructor Summary
SmooksServletFilter()
           
 
Method Summary
 void destroy()
           
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain filterChain)
           
 void init(javax.servlet.FilterConfig config)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmooksServletFilter

public SmooksServletFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig config)
          throws javax.servlet.ServletException
Specified by:
init in interface javax.servlet.Filter
Throws:
javax.servlet.ServletException

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain filterChain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Specified by:
doFilter in interface javax.servlet.Filter
Throws:
java.io.IOException
javax.servlet.ServletException

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Filter

Milyn-Smooks Version 0.4