title: Mule: Setting a property on a spring bean
body: <p>I'm using Mule v3.5.0</p>
  
  <p>At the moment I have a bean called flowContextEnricher, that sets an object to an eventContext session that contains some information about the flow. This information is later used for the audit logging:</p>
  
  <pre><code>@Component
  public abstract class AbstractContextEnricher implements Callable {
  
  public Stream buildStream() {
      final Stream stream = ...
      return stream;
  }
  
  @Override
  public Object onCall(MuleEventContext eventContext) throws Exception {
  
      final Stream stream = buildStream();
  
      eventContext.getSession().setProperty("stream", stream);
  
      return eventContext.getMessage().getPayloadAsString();
  }
  </code></pre>
  
  <p>I want to reuse this ContextEnricher for both online services and mock services, but for the mock services, an additional boolean propery mock has to be set to 'TRUE'.</p>
  
  <p>I can do this, by adding a separate enricher: MockContectEnricher:</p>
  
  <pre><code>@Component
  public class MockContextEnricher implements Callable {
  
      @Override
      public Object onCall(MuleEventContext eventContext) throws Exception {
          eventContext.getSession().setProperty("mock", Boolean.TRUE);
          return eventContext.getMessage().getPayloadAsString();
      }
  }
  </code></pre>
  
  <p>Then I have to call the additional component for all the mock flows. My total flow looks like this:</p>
  
  <pre><code>&lt;flow name="xxxFlowMock" processingStrategy="synchronous"&gt;
      &lt;servlet:inbound-endpoint path="/xxx/mock" responseTimeout="10000" /&gt;
      &lt;component&gt;
          &lt;spring-object bean="mockContextEnricher"/&gt;
      &lt;/component&gt;
      &lt;component&gt;
          &lt;spring-object bean="xxxContextEnricher"/&gt;
      &lt;/component&gt;
      &lt;component&gt;
          &lt;spring-object bean="auditLogger"/&gt;
      &lt;/component&gt;
      ...
  &lt;/flow&gt;
  </code></pre>
  
  <p>This works, but looks a little weird. Isn't it possible to reuse the xxxContextEnricher for both online and mock services and just set a property on the bean?</p>
  
  <pre><code>&lt;property name="mock" value="true"&gt;
  </code></pre>
  
  <p>What's the best way to implement this?</p>