Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CounterCallback |
|
| 1.0;1 |
1 | /* | |
2 | * $Id: CounterCallback.java 20321 2010-11-24 15:21:24Z dfeist $ | |
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 | package org.mule.tck.functional; | |
11 | ||
12 | import org.mule.api.MuleEventContext; | |
13 | ||
14 | import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger; | |
15 | ||
16 | /** | |
17 | * A test callback that counts the number of messages received. | |
18 | */ | |
19 | public class CounterCallback implements EventCallback | |
20 | { | |
21 | private AtomicInteger callbackCount; | |
22 | ||
23 | public CounterCallback() | |
24 | 0 | { |
25 | 0 | callbackCount = new AtomicInteger(0); |
26 | 0 | } |
27 | ||
28 | public CounterCallback(AtomicInteger callbackCount) | |
29 | 0 | { |
30 | 0 | this.callbackCount = callbackCount; |
31 | 0 | } |
32 | ||
33 | public void eventReceived(MuleEventContext context, Object Component) throws Exception | |
34 | { | |
35 | 0 | incCallbackCount(); |
36 | 0 | } |
37 | ||
38 | /** | |
39 | * Increment callback count. | |
40 | * @return current count after increment | |
41 | */ | |
42 | protected int incCallbackCount() | |
43 | { | |
44 | 0 | return callbackCount.incrementAndGet(); |
45 | } | |
46 | ||
47 | public int getCallbackCount() | |
48 | { | |
49 | 0 | return callbackCount.intValue(); |
50 | } | |
51 | } |