01: package org.objectweb.celtix.systest.handlers;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05: import javax.annotation.Resource;
06: import javax.jws.HandlerChain;
07: import javax.jws.WebService;
08: import javax.xml.ws.WebServiceContext;
09: import javax.xml.ws.handler.MessageContext;
10: import org.objectweb.handler_test.HandlerTest;
11: import org.objectweb.handler_test.PingException;
12: import org.objectweb.handler_test.types.PingFaultDetails;
13:
14: @WebService(serviceName="HandlerTestService",portName="SoapPort",endpointInterface="org.objectweb.handler_test.HandlerTest",targetNamespace="http://objectweb.org/handler_test")
15: @HandlerChain(file="./handlers.xml",name="TestHandlerChain")
16: public class HandlerTestImpl implements HandlerTest {
17:
18: private WebServiceContext context;
19:
20: public final List<String> ping() {
21:
22: try {
23: List<String> handlerInfoList = getHandlersInfo(context
24: .getMessageContext());
25: handlerInfoList.add("servant");
26: context.getMessageContext().remove("handler.info");
27: System.out.println(">> servant returning list: "
28: + handlerInfoList);
29: return handlerInfoList;
30:
31: } catch (Exception e) {
32: e.printStackTrace();
33:
34: }
35: return null;
36: }
37:
38: public final void pingOneWay() {
39: }
40:
41: public final List<String> pingWithArgs(String handlerCommand)
42: throws PingException {
43:
44: List<String> ret = new ArrayList<String>();
45: ret.add(handlerCommand);
46: ret.addAll(getHandlersInfo(context.getMessageContext()));
47:
48: if (handlerCommand.contains("throw exception")) {
49: PingFaultDetails details = new PingFaultDetails();
50: details.setDetail(ret.toString());
51: throw new PingException("from servant", details);
52: }
53:
54: return ret;
55: }
56:
57: @Resource
58: public void setWebServiceContext(WebServiceContext ctx) {
59: context = ctx;
60: }
61:
62: @SuppressWarnings("unchecked")
63: private List<String> getHandlersInfo(MessageContext ctx) {
64: List<String> ret = (List<String>) ctx.get("handler.info");
65: if (ret == null) {
66: ret = new ArrayList<String>();
67: }
68: return ret;
69: }
70:
71: }
|