How to add custom valve to SpaSitePipeline

Hi All,

I am trying to add a custom valve to the SpaSitePipeline. Not able to find correct bean definitions that I can override and add a valve.

There is below documentation exist that only talks about adding custom valve to default HstSitePipeline but in my case I want to add valve to the SpaSitePipeline

Please advice!! Thank you!!

Hello @savan_raiyani ,

the documentation page you have posted is correct.
You only have to do a small change in the provided XML sample.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

  <bean id="yourCustomValve" class="com.example.valve.YourCustomValve">
    <property name="valveName" value="yourCustomValve" />
    <property name="afterValves" value="after-which-valve" />
    <property name="beforeValves" value="before-which-valve" />
  </bean>

  <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">
          <value>PageModelPipeline</value> //Note the difference here
        </property>
      </bean>
    </property>
    <property name="targetMethod" value="addProcessingValve" />
    <property name="arguments">
      <ref bean="yourCustomValve" />
    </property>
  </bean>

</beans>

Kind regards

Did you try targeting SpaSitePipeline? What error do you get?

Hi @Lef_Karamoulas @machak

Thank you for your reply!!

Actually, I don’t know the bean definition for SpaSitePipeline or in other words I don’t have information about valves that already exist for SpaSitePipeline. This is required to configure “afterValves” and “beforeValves” properties in override file.

It’s not called SpaSitePipeline.

If you search the codebase for PageModelPipeline you will find the pipeline definition and the valves involved. The file is called SpringComponentManager-pipelines.xml in hst-core jar

Thank you @Lef_Karamoulas for your reply!!

I don’t see SpringComponentManager-pipelines.xml in my hst-core-14.7.14.jar
located at \target\tomcat9x\webapps\site\WEB-INF\lib. Please see below image for more clarification