View Javadoc

1   /*
2    * $Id: AbstractEnvelopeInterceptor.java 19191 2010-08-25 21:05:23Z tcarlson $
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.interceptor;
12  
13  import org.mule.api.MuleEvent;
14  import org.mule.api.MuleException;
15  import org.mule.api.interceptor.Interceptor;
16  import org.mule.processor.AbstractInterceptingMessageProcessor;
17  
18  /**
19   * <code>EnvelopeInterceptor</code> is an intercepter that will fire before and after
20   * an event is received.
21   */
22  public abstract class AbstractEnvelopeInterceptor extends AbstractInterceptingMessageProcessor implements Interceptor
23  {
24      /**
25       * This method is invoked before the event is processed
26       */
27      public abstract MuleEvent before(MuleEvent event) throws MuleException;
28  
29      /**
30       * This method is invoked after the event has been processed
31       */
32      public abstract MuleEvent after(MuleEvent event) throws MuleException;
33  
34      public MuleEvent process(MuleEvent event) throws MuleException
35      {
36          MuleEvent resultEvent = before(event);
37          resultEvent = processNext(resultEvent);
38          resultEvent = after(resultEvent);
39          return resultEvent;
40      }
41  }