Support using Session in standalone
-----------------------------------

                 Key: CXF-750
                 URL: https://issues.apache.org/jira/browse/CXF-750
             Project: CXF
          Issue Type: Bug
          Components: JAX-WS Runtime
            Reporter: Jervis Liu


Following code snippet should work when cxf is deployed in standalone mode 
(Jetty):

    @Resource
    private WebServiceContext context;

    public final List<String> ping() {
        MessageContext mc = context.getMessageContext();
        HttpSession session = 
((javax.servlet.http.HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST))
            .getSession();
        // Get a session property "counter" from context
        if (session == null) {
            throw new WebServiceException("No session in WebServiceContext");
        }
        Integer counter = (Integer)session.getAttribute("counter");
        if (counter == null) {
            counter = new Integer(0);
            System.out.println("Starting the Session");
        }
        counter = new Integer(counter.intValue() + 1);
        session.setAttribute("counter", counter);
        System.out.println("------------" + counter);
        return counter;
    }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to