title: Spring xml to java config: how to convert nested xml bean definition
body: <pre><code> &lt;bean
      name="ticketValidationFilter"
      class="org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter"
      p:service="https://my.local.service.com/cas-client"&gt;
      &lt;property name="ticketValidator"&gt;
      &lt;bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator"&gt;
      &lt;constructor-arg index="0" value="https://localhost:8443/cas" /&gt;
      &lt;/bean&gt;
      &lt;/property&gt;
    &lt;/bean&gt;
  </code></pre>
  
  <p>Can anyone please help to convert this xml definition to java config? Specifically, I am confused about how to declare <code>ticketValidator</code>.</p>
  
  <pre><code>    @Bean
      FilterRegistrationBean ticketValidationFilter(){
  
          Filter ticketValidationFilter = new
                  org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter();
  
          FilterRegistrationBean frb = new FilterRegistrationBean();
          frb.addUrlPatterns("/*");
          frb.setFilter(ticketValidationFilter);
  
          // ticket Validator somewhere here
  
          Map&lt;String, String&gt; initParamMap = new HashMap&lt;String, String&gt;();
          initParamMap.put("service", "http://localhost:8889/cas-client");
          frb.setInitParameters(initParamMap);
  
          return frb;
      }
  </code></pre>
  
  <p><strong>-----UPDATE FOR FILTERS CONFIG-------</strong></p>
  
  <p>if you use nested beans for filter configuration(Eg. like in my case), whatever properties you set on your filters - they will be null if you use just setters(don't know why, if anyone eager to explain please do).</p>
  
  <p>To solve this issue: create filter(@Component) that extends GenericFilterBean and set your properties there. Then @Autowire it to your config and use setters on filter registration as usual.** </p>
  
  <p>If you have simple configuration property(eg. String) then you can use Map with init params and set it on the FilterRegistration bean.</p>