1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.apache.xmlrpc.jaxb; |
17 |
|
|
18 |
|
import javax.xml.bind.Element; |
19 |
|
import javax.xml.bind.JAXBContext; |
20 |
|
|
21 |
|
import org.apache.ws.commons.util.NamespaceContextImpl; |
22 |
|
import org.apache.xmlrpc.common.TypeFactoryImpl; |
23 |
|
import org.apache.xmlrpc.common.XmlRpcController; |
24 |
|
import org.apache.xmlrpc.common.XmlRpcStreamConfig; |
25 |
|
import org.apache.xmlrpc.parser.TypeParser; |
26 |
|
import org.apache.xmlrpc.serializer.TypeSerializer; |
27 |
|
import org.apache.xmlrpc.serializer.XmlRpcWriter; |
28 |
|
import org.xml.sax.SAXException; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
public class JaxbTypeFactory extends TypeFactoryImpl { |
34 |
|
private final JAXBContext context; |
35 |
|
private final JaxbSerializer serializer; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
public JaxbTypeFactory(XmlRpcController pController, JAXBContext pContext) { |
44 |
0 |
super(pController); |
45 |
0 |
context = pContext; |
46 |
0 |
serializer = new JaxbSerializer(context); |
47 |
0 |
} |
48 |
|
|
49 |
|
public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI, String pLocalName) { |
50 |
0 |
TypeParser tp = super.getParser(pConfig, pContext, pURI, pLocalName); |
51 |
0 |
if (tp == null) { |
52 |
0 |
if (XmlRpcWriter.EXTENSIONS_URI.equals(pURI) && JaxbSerializer.JAXB_TAG.equals(pLocalName)) { |
53 |
0 |
return new JaxbParser(context); |
54 |
|
} |
55 |
|
} |
56 |
0 |
return tp; |
57 |
|
} |
58 |
|
|
59 |
|
public TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object pObject) throws SAXException { |
60 |
0 |
TypeSerializer ts = super.getSerializer(pConfig, pObject); |
61 |
0 |
if (ts == null) { |
62 |
0 |
if (pObject instanceof Element) { |
63 |
0 |
return serializer; |
64 |
|
} |
65 |
|
} |
66 |
0 |
return ts; |
67 |
|
} |
68 |
|
} |