Question

I have two internal client libraries. One uses JAX-WS RI (I think its Metro now) and the other Apache CXF. Both of these clients need to be loaded in the same Web App. The reason both cannot use Metro is because one of the clients needs XmlBeans (despite my best attempts at XJB transforming the schema I could not get JAXB to work).

The obvious solution I guess is to port the other client to CXF however what if I create a custom fake Provider that uses ThreadLocal variable that says which real provider to use then have a static method to set the ThreadLocal variable before using the client.

Is that a bad idea?

Était-ce utile?

La solution

I ended up creating ThreadLocal based provider which works quite nicely.

You can see the code at this gist.

You can switch from JAXWS and CXF like:

To force a provider

   ThreadLocalProvider.setProvider(ThreadLocalProvider.JAXWS_RI_PROVIDER);

OR

   ThreadLocalProvider.setProvider(ThreadLocalProvider.CXF_PROVIDER);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top