View Javadoc

1   /*
2    * $Id: AbstractSplitter.java 22272 2011-06-27 16:17:16Z mike.schilling $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.routing;
12  
13  import org.mule.api.MuleEvent;
14  import org.mule.api.MuleException;
15  import org.mule.api.MuleMessage;
16  import org.mule.routing.outbound.AbstractMessageSequenceSplitter;
17  import org.mule.routing.outbound.CollectionMessageSequence;
18  
19  import java.util.List;
20  
21  /**
22   * Splits a message invoking the next message processor one for each split part.
23   * Implementations must implement {@link #splitMessage(MuleEvent)} and determine how
24   * the message is split.
25   * <p>
26   * <b>EIP Reference:</b> <a
27   * href="http://www.eaipatterns.com/Sequencer.html">http://www
28   * .eaipatterns.com/Sequencer.html</a>
29   */
30  
31  public abstract class AbstractSplitter extends AbstractMessageSequenceSplitter
32  {
33      @Override
34      @SuppressWarnings("unchecked")
35      protected MessageSequence<?> splitMessageIntoSequence(MuleEvent event) throws MuleException
36      {
37          return new CollectionMessageSequence(splitMessage(event));
38      }
39  
40      protected abstract List<MuleMessage> splitMessage(MuleEvent event) throws MuleException;
41  
42  }