Hi,
On 24/01/12 18:35, hdave wrote:
Inline
Sergey Beryozkin-5 wrote
@Provider is the annotation introduced by JAX-RS to facilitate the
scanning of class resources for custom providers be loaded automatically.
I've never implemented that in CXF because it's kind of non-practical
IMHO. It can not work well in complex environments and is too
coarse-grained (ex, not possible to register multiple instances
configured differently) and it can not be customized. Narrowing down the
class path to scan for the providers is usually more of an effort than
registering a provider from Spring or CXFNonSpringJAXRSServlet :-)
But having said it's something CXF (JAX-RS) lacks even though I do not
see using this feature myself (at the moment at least :-))...
I agree with you completely, I much prefer explicit registering of my
providers rather than class path scanning. In this way, I can also control
which providers are used within particular contexts.
Sergey Beryozkin-5 wrote
Custom (JAXB) providers may want to check custom JAXBContexts and
ContextResolver is something that can be used. They need to be
registered as providers and in CXF case this means they have to be
referenced from jaxrs:providers (alongside with other providers)
Just to be clear then, the<jaxrs:providers> stanza holds both providers as
well as well as custom ContextResolvers?
Yes
I'm planning on using something like this as a custom ContextResolver:
----------------------------------
import org.eclipse.persistence.jaxb.JAXBContextFactory;
@Provider
public class MoxyJaxbContextResolver implements ContextResolver<JAXBContext>
{
public JAXBContext getContext(Class<?> type) {
try {
JAXBContext jc = JAXBContextFactory.createContext(new Class[]
{Animals.class}, null);
return jc
} catch (JAXBException e) {
e.printStackTrace();
}
return null;
}
Yes, that should do it
Let me know please if it works
Sergey
----------------------------------
--
View this message in context:
http://cxf.547215.n5.nabble.com/How-to-configure-CXF-to-use-different-JAXBContextFactory-tp5281773p5324425.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com