cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r933860 - in /websites/production/cxf/content: cache/docs.pageCache docs/jax-rs-data-bindings.html
Date Wed, 24 Dec 2014 11:47:29 GMT
Author: buildbot
Date: Wed Dec 24 11:47:29 2014
New Revision: 933860

Log:
Production update by buildbot for cxf

Modified:
    websites/production/cxf/content/cache/docs.pageCache
    websites/production/cxf/content/docs/jax-rs-data-bindings.html

Modified: websites/production/cxf/content/cache/docs.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/cxf/content/docs/jax-rs-data-bindings.html
==============================================================================
--- websites/production/cxf/content/docs/jax-rs-data-bindings.html (original)
+++ websites/production/cxf/content/docs/jax-rs-data-bindings.html Wed Dec 24 11:47:29 2014
@@ -118,11 +118,11 @@ Apache CXF -- JAX-RS Data Bindings
            <!-- Content -->
            <div class="wiki-content">
 <div id="ConfluenceContent"><p>&#160;</p><p>&#160;</p><p>&#160;</p><p>&#160;<span
class="inline-first-p" style="font-size:2em;font-weight:bold">JAX-RS : Data Bindings</span>&#160;</p><p>&#160;</p><p>&#160;</p><p>&#160;</p><p><style
type="text/css">/*<![CDATA[*/
-div.rbtoc1419015817280 {padding: 0px;}
-div.rbtoc1419015817280 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1419015817280 li {margin-left: 0px;padding-left: 0px;}
+div.rbtoc1419421622000 {padding: 0px;}
+div.rbtoc1419421622000 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1419421622000 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style></p><div class="toc-macro rbtoc1419015817280">
+/*]]>*/</style></p><div class="toc-macro rbtoc1419421622000">
 <ul class="toc-indentation"><li><a shape="rect" href="#JAX-RSDataBindings-JAXBsupport">JAXB
support</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#JAX-RSDataBindings-ConfiguringJAXBprovider">Configuring
JAXB provider</a></li><li><a shape="rect" href="#JAX-RSDataBindings-JAXBandMoxy">JAXB
and Moxy</a></li></ul>
 </li><li><a shape="rect" href="#JAX-RSDataBindings-JSONsupport">JSON support</a>
@@ -212,15 +212,20 @@ public class CustomerService {
 ]]></script>
 </div></div><p>Individual marshal properties can be injected as simple
properties. At the moment, Marshaller.JAXB_SCHEMA_LOCATION can be injected as "schemaLocation"
property. Schema validation can be enabled and custom @Consume and @Produce media types can
be injected, see <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml">this
example</a> and "Customizing media types for message body providers" and "Schema Validation"
sections for more information.</p><p>One issue which one may need to be aware
of it is that an exception may occur during the JAXB serialization process, after some content
has already been processed and written to the output stream. By default, the output goes directly
to the output HTTP stream so if an exception occurs midway through the process then the output
will likely be malformed. If you set 'enableBuffering' property to 'true' then a JAXB provider
will write to the 
 efficient CXF CachedOutputStream instead and if an exception occurs then no text which has
already been written will make it to the outside world and it will be only this exception
that will be reported to the client.</p><p>When enabling buffering, you can also
control how the data being serialized will be buffered. By default, an instance of CXF CachedOutputStream
will be used. If you set an "enableStreaming" property on the JAXBElementProvider then it
will be a CXF CachingXMLEventWriter that will cache the serialization events.</p><p>If
you would like your own custom provider to write to a cached stream then you can either set
an "org.apache.cxf.output.buffering" property to 'true' on a jaxrs endpoint or "enableBuffering"
property on the provider. If this provider deals with XML and has a "getEnableStreaming" method
returning 'true' then CachingXMLEventWriter will be used, in all other cases CachedOutputStream
will be used.</p><p>Please note that if you don't have wrapper types fo
 r your methods and the classloader you are using does not allow you to call defineClass(),
you may need to set '-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize'</p><p>JAXB
Marshaller, Unmarshaller and context properties can be configured for both JAXB and JSON providers.
Both providers can also be configured to skip the isReadable() and isWriteable() checks to
do with asserting that a given instance is likely to be successfully read/written by setting
a 'skipChecks' property to true. This can be useful when it is known that only valid JAXB
instances are read or written.</p><p>Starting from CXF 2.4.3 it is possible to
have specific prefixes associated with XML namespaces. This might be needed to make the legacy
consumers able to consume the resulting XML. Use a "namespacePrefixes" map property (namespace
is a key, corresponding prefix is a value).</p><h2 id="JAX-RSDataBindings-JAXBandMoxy">JAXB
and Moxy</h2><p>For JAXBElementProvider to support <a shape="rect" class="external-l
 ink" href="http://www.eclipse.org/eclipselink/moxy.php" rel="nofollow">Moxy</a>
a custom Moxy-aware JAX-RS ContextProvider implementation needs to be registered in jaxrs:providers.
For example:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[import
javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
 import javax.ws.rs.ext.ContextResolver;
 import org.eclipse.persistence.jaxb.JAXBContextFactory;
 
 public class MoxyJaxbContextResolved implements ContextResolver&lt;JAXBContext&gt;
{
 
-  org.eclipse.persistence.jaxb.JAXBContextFactory factory = new JAXBContextFactory();
+  JAXBContextFactory factory = new JAXBContextFactory();
 
   public JAXBContext getContext(Class&lt;?&gt; cls) {
-       return factory.createContext(cls);
+      try {
+          return JAXBContextFactory.createContext(new Class[] {cls}, null);
+      } catch (JAXBException ex) {
+          throw new RuntimeException(ex);
+      }
   }
 
 }



Mime
View raw message