001: /*
002: * Created on 29.04.2005 from Linke
003: *
004: */
005: package test.crispy.example.service;
006:
007: import java.util.List;
008:
009: import org.apache.commons.logging.Log;
010: import org.apache.commons.logging.LogFactory;
011:
012: import test.crispy.JUnitTestException;
013: import test.crispy.JUnitTestException2;
014: import test.crispy.example.model.Kunde;
015: import test.crispy.example.model.Node;
016: import test.crispy.example.model.Primitive;
017:
018: /**
019: * @author Linke
020: *
021: */
022: public class EchoImpl implements Echo {
023:
024: private static Log log = LogFactory.getLog(Echo.class);
025:
026: public static final int WAIT_BY_LONG_EXECUTION = 200;
027:
028: /**
029: * @see test.crispy.example.service.Echo#ping()
030: */
031: public String ping() {
032: return PING_STRING;
033: }
034:
035: /**
036: * @see test.crispy.example.service.Echo#echo(java.lang.String)
037: */
038: public String echo(String pvEchoString) {
039: if (log.isDebugEnabled()) {
040: log.debug("Echo String: " + pvEchoString);
041: }
042: return pvEchoString;
043: }
044:
045: public Object echoObject(Object pvEchoObject) {
046: return pvEchoObject;
047: }
048:
049: /**
050: * @see test.crispy.example.service.Echo#renameKunde(test.crispy.example.model.Kunde, java.lang.String)
051: */
052: public Kunde renameKunde(Kunde pvKunde, String pvNewName) {
053: if (pvKunde == null) {
054: return null;
055: }
056: pvKunde.setName(pvNewName);
057: return pvKunde;
058: }
059:
060: public Node addNode(Node pvMainNode, Node pvAddNode) {
061: // System.out.println("-- SERVER-addNode: " + pvMainNode + " --> " + pvAddNode);
062: pvMainNode.getChildren().add(pvAddNode);
063: return pvMainNode;
064: }
065:
066: public String[] echoArray(String[] pvArray) {
067: return pvArray;
068: }
069:
070: public Integer[] echoArray(Integer[] pvArray) {
071: return pvArray;
072: }
073:
074: public Long[] echoArray(Long[] pvArray) {
075: return pvArray;
076: }
077:
078: public Object[] echoArray(Object[] pvArray) {
079: return pvArray;
080: }
081:
082: public Primitive echoPrimitive(Primitive pvPrimitive) {
083: return pvPrimitive;
084: }
085:
086: public String throwException(String pvMessage) {
087: throw new JUnitTestException("Test Exception: " + pvMessage);
088: }
089:
090: public String throwComplexException(String pvMessage,
091: List pvValidationErrors) {
092: JUnitTestException2 lvException = new JUnitTestException2(
093: "Test Exception: " + pvMessage);
094: lvException.setValidationErrors(pvValidationErrors);
095: throw lvException;
096: }
097:
098: public String throwError(String pvMessage) {
099: throw new Error(pvMessage);
100: }
101:
102: public String doLongExecution(String pvReturnEchoValue) {
103: try {
104: Thread.sleep(WAIT_BY_LONG_EXECUTION);
105: } catch (Exception e) {
106: e.printStackTrace();
107: }
108: return pvReturnEchoValue;
109: }
110:
111: }
|