1
2
3
4
5
6 package net.kwfgrid.gworkflowdl.protocol.xupdate;
7
8 import net.kwfgrid.gworkflowdl.protocol.util.ObjectPool;
9
10 import org.xmlpull.v1.XmlSerializer;
11 import org.xmlpull.mxp1_serializer.MXSerializer;
12
13 /***
14 A pool for instances of <code>XmlSerializer</code>. Singleton design-pattern.
15 */
16 public class XmlSerializerPool extends ObjectPool {
17 private final static String PROPERTY_SERIALIZER_INDENTATION =
18 "http://xmlpull.org/v1/doc/properties.html#serializer-indentation";
19 private static int SIZE = 100;
20 private static XmlSerializerPool INSTANCE;
21
22 static {
23
24
25 }
26
27 public static synchronized final XmlSerializerPool getInstance() {
28 if (INSTANCE == null) INSTANCE = new XmlSerializerPool();
29 return INSTANCE;
30 }
31
32 private XmlSerializerPool() {
33 super(SIZE);
34 }
35
36 protected Object createObject() {
37 XmlSerializer s = new MXSerializer();
38 s.setProperty(PROPERTY_SERIALIZER_INDENTATION, " ");
39 return s;
40 }
41
42 /***
43 This is a copy of the <code>getObject</code> method just casting the return value
44 to the correct type of this pool.
45 */
46 public XmlSerializer getSerializer() throws InterruptedException {
47 return (XmlSerializer)getObject();
48 }
49 }