View Javadoc

1   /*
2    * $Id: EnvelopeInterceptor.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.interceptors;
12  
13  import org.mule.umo.Invocation;
14  import org.mule.umo.UMOException;
15  import org.mule.umo.UMOInterceptor;
16  import org.mule.umo.UMOMessage;
17  
18  /**
19   * <code>EnvelopeInterceptor</code> is an intercepter that will fire before and
20   * after an event is received.
21   * 
22   * @author <a href="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
23   * @version $Revision: 7976 $
24   */
25  public abstract class EnvelopeInterceptor implements UMOInterceptor
26  {
27      /**
28       * This method is invoked before the event is processed
29       * 
30       * @param invocation the message invocation being processed
31       */
32      public abstract void before(Invocation invocation) throws UMOException;
33  
34      /**
35       * This method is invoked after the event has been processed
36       * 
37       * @param invocation the message invocation being processed
38       */
39      public abstract void after(Invocation invocation) throws UMOException;
40  
41      public final UMOMessage intercept(Invocation invocation) throws UMOException
42      {
43          before(invocation);
44          UMOMessage message = invocation.execute();
45          invocation.setMessage(message);
46          after(invocation);
47          return message;
48      }
49  }