View Javadoc

1   /*
2    * $Id: Invocation.java 7963 2007-08-21 08:53:15Z 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.umo;
12  
13  import org.mule.impl.RequestContext;
14  
15  /**
16   * <code>Invocation</code> represents a link in an interceptor chain. Interceptors
17   * can be configured om Mule Managed components.
18   */
19  // @ThreadSafe
20  public class Invocation
21  {
22      /** The components descriptor */
23      // @GuardedBy(itself)
24      private final UMOImmutableDescriptor descriptor;
25  
26      /** the next invocation in the chain */
27      // @GuardedBy(itself)
28      private final Invocation invocation;
29  
30      /** The current message for the component */
31      // @GuardedBy(this)
32      private UMOMessage message;
33  
34      /**
35       * Constructs an initialised invocation
36       * 
37       * @param descriptor the components descriptor
38       * @param message the current message
39       * @param invocation the next invocation in the chain or null.
40       */
41      public Invocation(UMOImmutableDescriptor descriptor, UMOMessage message, Invocation invocation)
42      {
43          this.descriptor = descriptor;
44          this.message = message;
45          this.invocation = invocation;
46      }
47  
48      /**
49       * Excutes this invocation
50       * 
51       * @return the current message that may have been altered by the invocation
52       * @throws UMOException if something goes wrong
53       */
54      public UMOMessage execute() throws UMOException
55      {
56          return invocation.execute();
57      }
58  
59      /**
60       * Returns the descriptor for the component associated with this invocation
61       * 
62       * @return the descriptor for the component associated with this invocation
63       */
64      public UMOImmutableDescriptor getDescriptor()
65      {
66          return descriptor;
67      }
68  
69      public UMOEvent getEvent()
70      {
71          return RequestContext.getEvent();
72      }
73  
74      /**
75       * Returns the current message
76       * 
77       * @return the current message
78       */
79      public UMOMessage getMessage()
80      {
81          synchronized (this)
82          {
83              return message;
84          }
85      }
86  
87      public void setMessage(UMOMessage message)
88      {
89          synchronized (this)
90          {
91              this.message = message;
92          }
93      }
94  
95  }