cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r784181 - /cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java
Date Fri, 12 Jun 2009 16:25:29 GMT
Author: dkulp
Date: Fri Jun 12 16:25:29 2009
New Revision: 784181

URL: http://svn.apache.org/viewvc?rev=784181&view=rev
Log:
[CXF-2278]  Implement serialize method on JaxbAssertions
Patch from   Dominic Harries applied
>From University of Southampton IT Innovation Centre

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java?rev=784181&r1=784180&r2=784181&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java Fri
Jun 12 16:25:29 2009
@@ -19,8 +19,14 @@
 
 package org.apache.cxf.ws.policy.builder.jaxb;
 
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion;
 import org.apache.neethi.PolicyComponent;
@@ -74,4 +80,17 @@
         return (JaxbAssertion<T>)a;
     }
 
+    @Override
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
+        try {
+            JAXBContext context = JAXBContext.newInstance(PackageUtils.getPackageName(data.getClass()),
+                                                          data.getClass().getClassLoader());
+            Marshaller marshaller = context.createMarshaller();
+            marshaller.setProperty("jaxb.fragment", Boolean.TRUE);
+            marshaller.marshal(data, writer);
+        } catch (JAXBException ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+
 }



Mime
View raw message