Search code examples
springcxfjax-rscontinuations

cxf Continuation


How to get a org.apache.cxf.continuations.Continuation from a JAXRS ServiceEndpoint serviceBean or JAXWS ServiceEndpoint serviceBean.

My spring config look like that.

<bean id="myServiceContainer" class="cxfutils.endpoint.soap.JAXWSServiceEndpoint">
    <property name="serviceBean" ref="myReceiver" />
</bean>

for jaxrs it seam like you should add

import org.apache.cxf.continuations.ContinuationProvider;
import org.apache.cxf.jaxrs.ext.MessageContext;
import javax.annotation.Resource;
import org.apache.cxf.continuations.Continuation;

@Resource
private MessageContext context;

@GET
@Path("hello")
@Produces("text/plain")
public String hello(@Context final HttpServletRequest httpRequest){
  ContinuationProvider provider = (ContinuationProvider)context.get(ContinuationProvider.class.getName());
  Continuation conti = provider.getContinuation();
  ...
}

Solution

  • in the case of JAXWS the JAXWS MessageContext need to be found from WebServiceContext.getMessageContext().

    you can then call context.get() on the MessageContext