1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.exolab.castor.xml.wls8;
15
16 import java.io.IOException;
17 import java.io.OutputStream;
18 import java.io.Writer;
19 import java.lang.reflect.Method;
20
21
22
23
24
25
26
27
28 public class WeblogicXercesSerializer extends WeblogicXercesImplementation
29 implements org.exolab.castor.xml.Serializer {
30
31 private static Class _serializerClass;
32 private static Method _asDocumentHandler;
33 private static Method _setOutputByteStream;
34 private static Method _setOutputCharStream;
35 private static Method _setOutputFormat;
36
37
38 private Object _serializer;
39 static {
40
41
42
43 Class weblogicOutputFormat = null;
44 try {
45 _serializerClass = Class.forName("weblogic.apache.xml.serialize.XMLSerializer");
46 weblogicOutputFormat = Class.forName("weblogic.apache.xml.serialize.OutputFormat");
47 } catch (ClassNotFoundException e) {
48 handleStaticInitException(e);
49 }
50
51
52 _asDocumentHandler = getMethod(_serializerClass, "asDocumentHandler", new Class[0]);
53
54
55 Class[] parameterOutputStream = {OutputStream.class};
56 _setOutputByteStream =
57 getMethod(_serializerClass, "setOutputByteStream", parameterOutputStream);
58
59
60 Class[] parameterWriter = {Writer.class};
61 _setOutputCharStream = getMethod(_serializerClass, "setOutputCharStream", parameterWriter);
62
63
64 Class[] parameterOutputFormat = {weblogicOutputFormat};
65 _setOutputFormat = getMethod(_serializerClass, "setOutputFormat", parameterOutputFormat);
66
67 }
68
69
70
71
72 public WeblogicXercesSerializer() {
73 try {
74 _serializer = _serializerClass.newInstance();
75 } catch (InstantiationException e) {
76 throw new RuntimeException(e.toString());
77 } catch (IllegalAccessException e) {
78 throw new RuntimeException(e.toString());
79 }
80 }
81
82
83
84
85
86 public org.xml.sax.DocumentHandler asDocumentHandler() throws IOException {
87 return (org.xml.sax.DocumentHandler) invoke(_asDocumentHandler, new Object[0]);
88 }
89
90
91
92
93 public void setOutputByteStream(OutputStream output) {
94 Object[] params = {output};
95 invoke(_setOutputByteStream, params);
96 }
97
98
99
100
101 public void setOutputCharStream(Writer out) {
102 Object[] params = {out};
103 invoke(_setOutputCharStream, params);
104 }
105
106
107
108
109 public void setOutputFormat(org.exolab.castor.xml.OutputFormat format) {
110 Object[] params = {format.getFormat()};
111 invoke(_setOutputFormat, params);
112 }
113
114 private Object invoke(Method method, Object[] params) {
115 return invoke(_serializer, method, params);
116 }
117 }