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