View Javadoc

1   /*
2    * Created on 29.04.2005 from Linke
3    *
4    */
5   package test.crispy.example.service;
6   
7   import java.util.List;
8   
9   import org.apache.commons.logging.Log;
10  import org.apache.commons.logging.LogFactory;
11  
12  import test.crispy.JUnitTestException;
13  import test.crispy.JUnitTestException2;
14  import test.crispy.example.model.Kunde;
15  import test.crispy.example.model.Node;
16  import test.crispy.example.model.Primitive;
17  
18  /**
19   * @author Linke
20   *
21   */
22  public class EchoImpl implements Echo {
23  
24  	private static Log log = LogFactory.getLog (Echo.class);
25  	
26  	public static final int WAIT_BY_LONG_EXECUTION = 200;
27  
28  	/**
29  	 * @see test.crispy.example.service.Echo#ping()
30  	 */
31  	public String ping() { return PING_STRING; }
32  	 
33  	 
34  	/**
35  	 * @see test.crispy.example.service.Echo#echo(java.lang.String)
36  	 */
37  	public String echo(String pvEchoString) {
38  		if (log.isDebugEnabled()) { log.debug("Echo String: " + pvEchoString); }
39  		return pvEchoString;
40  	}
41  	
42  	public Object echoObject(Object pvEchoObject) {
43  		return pvEchoObject;
44  	}
45  	
46  	/**
47  	 * @see test.crispy.example.service.Echo#renameKunde(test.crispy.example.model.Kunde, java.lang.String)
48  	 */
49  	public Kunde renameKunde(Kunde pvKunde, String pvNewName) {
50  		if (pvKunde == null) { return null; }
51  		pvKunde.setName(pvNewName);
52  		return pvKunde;
53  	}
54  
55  	public Node addNode(Node pvMainNode, Node pvAddNode) {
56  		// System.out.println("-- SERVER-addNode: " + pvMainNode + " --> " + pvAddNode);
57  		pvMainNode.getChildren().add(pvAddNode);
58  		return pvMainNode;
59  	}
60  
61  	public String[] echoArray(String[] pvArray) { return pvArray; }
62  	public Integer[] echoArray(Integer[] pvArray) { return pvArray; }
63  	public Long[] echoArray(Long[] pvArray) { return pvArray; }	
64  	public Object[] echoArray(Object[] pvArray) { return pvArray; }
65  
66  	public Primitive echoPrimitive(Primitive pvPrimitive) { return pvPrimitive; }
67  
68  	public String throwException(String pvMessage) {
69  		throw new JUnitTestException("Test Exception: " + pvMessage);
70  	}
71  	
72  	public String throwComplexException (String pvMessage, List pvValidationErrors) {
73  		JUnitTestException2 lvException = new JUnitTestException2("Test Exception: " + pvMessage);
74  		lvException.setValidationErrors(pvValidationErrors);
75  		throw lvException;
76  	}
77  	
78  	public String throwError (String pvMessage) {
79  		throw new Error(pvMessage);
80  	}
81  	
82  	public String doLongExecution(String pvReturnEchoValue) {
83  		try {
84  			Thread.sleep(WAIT_BY_LONG_EXECUTION);
85  		} catch (Exception e) {
86  			e.printStackTrace();
87  		}
88  		return pvReturnEchoValue;
89  	}
90  	
91  }