KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > impl > InterceptorsInvoker


1 /*
2  * $Id: InterceptorsInvoker.java 4259 2006-12-14 03:12:07Z aperepel $
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 MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.impl;
12
13 import org.mule.umo.Invocation;
14 import org.mule.umo.UMOException;
15 import org.mule.umo.UMOImmutableDescriptor;
16 import org.mule.umo.UMOInterceptor;
17 import org.mule.umo.UMOMessage;
18
19 import java.util.List JavaDoc;
20
21 /**
22  * <code>InterceptorsInvoker</code> is used to trigger an interceptor chain.
23  */

24
25 public class InterceptorsInvoker extends Invocation
26 {
27     private final List JavaDoc interceptors;
28     private int cursor = 0;
29
30     public InterceptorsInvoker(List JavaDoc interceptors, MuleDescriptor descriptor, UMOMessage message)
31     {
32         this(interceptors, new ImmutableMuleDescriptor(descriptor), message);
33     }
34
35     public InterceptorsInvoker(List JavaDoc interceptors, UMOImmutableDescriptor descriptor, UMOMessage message)
36     {
37         super(descriptor, message, null);
38         this.interceptors = interceptors;
39     }
40
41     public UMOMessage execute() throws UMOException
42     {
43         if (cursor < interceptors.size())
44         {
45             UMOInterceptor interceptor = (UMOInterceptor)interceptors.get(cursor);
46             incCursor();
47             return interceptor.intercept(this);
48         }
49         return getMessage();
50     }
51
52     private synchronized void incCursor()
53     {
54         cursor++;
55     }
56
57 }
58
Popular Tags