This article covers a Bloomreach Experience Manager version 13. There's an updated version available that covers our most recent release.

Create a Custom Valve



Develop a custom valve and inject it into the delivery tier's request processing pipeline.


In Bloomreach Experience Manager's delivery framework (HST), requests are processed through a series of valves assembled together as a pipeline. Implementation projects can inject custom valves at any point into the default pipeline.

This page explains how to create a custom valve and inject it into the default request processing pipeline using Spring configuration.

The default pipeline is defined as DefaultSitePipeline in classpath:/org/hippoecm/hst/site/container/SpringComponentManager-pipelines.xml.


A custom valve is implemented as a Java class extending org.hippoecm.hst.container.valves.AbstractOrderableValve. In the Spring bean definition for the custom valve, the properties beforeValves and afterValves can be used to specify where in the existing pipeline the custom valve should be injected. To enable other valves to position themselves relative to the custom valve, the bean definition should also define the property valveName.

Typically, beforeValves and afterValves each specify a single valve but both accept a comma-separated list of valves as well. The valveName, as a best practice, should be equal to the Spring bean id (in case of no id, use a logical name, like the camel case class name).

An example bean definition for a custom valve (full example below):

<bean id="myCustomValve" class="org.example.container.MyCustomValve">
    <property name="valveName" value="myCustomValve" />
    <property name="afterValves" value="securityValve, subjectBasedSessionValve"/>
    <property name="beforeValves" value="pageCachingValve"/>


This example shows a custom valve class MyCustomValve that is injected into the existing HST DefaultSitePipeline after the securityValve and before the pageCachingValve.

Create a Custom Valve Class

In the site/components module of your project, create a Java class MyCustomValve and make it extend AbstractOrderableValve.


package org.example.container;

import org.hippoecm.hst.container.valves.AbstractOrderableValve;
import org.hippoecm.hst.core.container.ContainerException;
import org.hippoecm.hst.core.container.ValveContext;

public class MyCustomValve extends AbstractOrderableValve {
    public void invoke(ValveContext context) throws ContainerException {
        try {
            // perform custom processing here
        } finally {

Configure Spring to Inject the Custom Valve

In the site/components module of your project, create a Spring configuration file src/main/resources/META-INF/hst-assembly/overrides/custom-valves.xml.

Configure a myCustomValve bean for your valve class and specify the valveName, afterValves, and beforeValves properties. Inject your custom bean into the existing HST DefaultSitePipeline.


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

  <bean id="myCustomValve" class="org.example.container.MyCustomValve">
    <property name="valveName" value="myCustomValve" />
    <property name="afterValves" value="securityValve" />
    <property name="beforeValves" value="pageCachingValve" />

  <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
    <property name="targetObject">
      <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetObject" ref="org.hippoecm.hst.core.container.Pipelines" />
        <property name="targetMethod" value="getPipeline" />
        <property name="arguments">
    <property name="targetMethod" value="addProcessingValve" />
    <property name="arguments">
      <ref bean="myCustomValve" />


Rebuild and Restart

Rebuild and restart your project.

Request a page in the site. Your custom valve should be invoked.

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?