View Javadoc

1   //  Copyright 2005 The Apache Software Foundation
2   //
3   // Licensed under the Apache License, Version 2.0 (the "License");
4   // you may not use this file except in compliance with the License.
5   // You may obtain a copy of the License at
6   //
7   //     http://www.apache.org/licenses/LICENSE-2.0
8   //
9   // Unless required by applicable law or agreed to in writing, software
10  // distributed under the License is distributed on an "AS IS" BASIS,
11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  // See the License for the specific language governing permissions and
13  // limitations under the License.
14  package org.jph.channels.process;
15  
16  import org.jph.channels.OutputChannel;
17  
18  /***
19   * The ProcessingOutputChannel is an OutputChannel that processes a message and posts the
20   * resulting message on an OutputChannel.
21   * <p/>
22   * The message is processed with by the Processor. If the Processor returns
23   * null, nothing is done (so no message is send to the OutputChannel). If the
24   * Processor sends back a message, that message is posted on the following channel.
25   * There is no guarantee that the returning msg will be processed. If the following channel
26   * doesn`t accept the offer (the put will succeed) the message is dropped. Maybe add a
27   * OfferRejectedHandler to give control to deal with this problem?
28   * <p/>
29   * If an error is encountered while processing the message, the ProcessExceptionHandler is
30   * called to deal with the error. (todo:not at the moment)
31   * <p/>
32   * The Message is processed on the Thread that called the put/offer. With the offer
33   * this gives problems because the maximum time between the offer being called on
34   * this ProcessingOutputChannel and moment the message succesfully was offered on the
35   * target is timeout + processingtime. This is something that has to be thought about
36   * (a good solution has to be found).
37   *
38   * @author Peter Veentjer.
39   */
40  public interface ProcessingOutputChannel<Min,Mout> extends OutputChannel<Min> {
41  
42  	/***
43  	 * Returns the Processor this ProcessingOutputChannel uses to process
44  	 * the messages.
45  	 */
46  	Processor<Min, Mout> getMsgProcessor();
47  
48  	/***
49  	 * Returns the OutputChannel the resulting message (if it isn`t null) is send to.
50  	 */
51  	OutputChannel<Mout> getTarget();
52  
53  
54  	/***
55  	 * Return the ProcessExceptionHandler this ProcessingOutputChannel uses to deal
56  	 * with errors that occured while processing the message.
57  	 */
58  	ProcessExceptionHandler<Min> getExceptionHandler();
59  }