java - How to use javax.ws.rs.core.Feature with CXF? -
i use jax-rs feature created cxf.
i prefer use jax-rs feature (javax.ws.rs.core.feature
) if possible , not cxf feature (org.apache.cxf.feature.feature
). prefer use springcomponentscanserver (org.apache.cxf.jaxrs.spring.springcomponentscanserver
) configure cxf rather having create server factory or servers manually.
here how tried configure cxf:
import com.fasterxml.jackson.jaxrs.json.jacksonjsonprovider; import com.mycustomapp.restexception.providers.restexceptionfeature; import org.apache.cxf.jaxrs.spring.springcomponentscanserver; import org.springframework.context.annotation.bean; import org.springframework.context.annotation.configuration; import org.springframework.context.annotation.import; @configuration @import(springcomponentscanserver.class) public class cxfconfiguration { @bean public restexceptionfeature restexceptionfeature() { return new restexceptionfeature(); } @bean public jacksonjsonprovider jacksonjsonprovider() { return new jacksonjsonprovider(); } }
here custom feature:
import javax.ws.rs.core.feature; import javax.ws.rs.core.featurecontext; import javax.ws.rs.ext.provider; @provider public class restexceptionfeature implements feature { @override public boolean configure(featurecontext context) { context.register(restexceptionbodyreader.class); context.register(restexceptionmapper.class); context.register(restexceptioncxfclientmapper.class); return true; } }
restexceptionfeature.configure()
never called.
created ticket https://issues.apache.org/jira/browse/cxf-6879 code should work in cxf 3.1.7 when released.
it working if use cxf 3.1.7-snapshot or cxf 3.2.0-snapshot http://repository.apache.org/snapshots/
Comments
Post a Comment