@Resource
private WebServiceContext context;
public String sayHi(String firstName, String secondName) {
Continuation continuation = getContinuation(firstName);
if (continuation == null) {
throw new RuntimeException("Failed to get continuation");
}
synchronized (continuation) {
if (continuation.isNew()) {
Object userObject = secondName != null && secondName.length() > 0
? secondName : null;
continuation.setObject(userObject);
suspendInvocation(firstName, continuation);
} else {
if (!continuation.isResumed() && !"Fred".equals(firstName)) {
throw new RuntimeException("No timeout expected");
}
StringBuilder sb = new StringBuilder();
sb.append(firstName);
// if the actual parameter is not null
if (secondName != null && secondName.length() > 0) {
String surname = continuation.getObject().toString();
sb.append(' ').append(surname);
}
//System.out.println("Saying hi to " + sb.toString());
return "Hi " + sb.toString();
}