KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > test > integration > service > TestComponent


1 /*
2  * $Id: TestComponent.java 3798 2006-11-04 04:07:14Z 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.test.integration.service;
12
13 import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
14
15 import javax.jms.TextMessage JavaDoc;
16
17 import org.apache.commons.logging.Log;
18 import org.apache.commons.logging.LogFactory;
19
20 public class TestComponent implements ITestComponent
21 {
22     public static final String JavaDoc EXCEPTION_MESSAGE = "Test Component fired an Exception";
23
24     private static final Log logger = LogFactory.getLog(TestComponent.class);
25
26     private AtomicInteger count = new AtomicInteger(0);
27
28     public String JavaDoc receive(String JavaDoc message) throws Exception JavaDoc
29     {
30         logger.info("Received: " + message + " number: " + inc() + " in thread: "
31                     + Thread.currentThread().getName());
32         return "Received: " + message;
33     }
34
35     public String JavaDoc throwsException(String JavaDoc message) throws Exception JavaDoc
36     {
37         throw new TestComponentException(EXCEPTION_MESSAGE);
38     }
39
40     public String JavaDoc receiveJms(TextMessage JavaDoc message) throws Exception JavaDoc
41     {
42         logger.info("Received: " + message.getText() + " Number: " + inc() + " in thread: "
43                     + Thread.currentThread().getName());
44         return "Received: " + message.getText();
45     }
46
47     protected int inc()
48     {
49         return count.incrementAndGet();
50     }
51
52 }
53
Popular Tags