1
2
3
4
5
6 package net.kwfgrid.gwes.uiproxy;
7
8 import java.util.Properties;
9
10 import org.doomdark.uuid.UUIDGenerator;
11
12
13
14
15 public class DefaultBufferFactory implements BufferFactory {
16 private static BufferFactory _i;
17
18
19
20
21 private DefaultBufferFactory() {
22
23 }
24
25 public synchronized static BufferFactory getInstance() {
26 if (_i==null) _i = new DefaultBufferFactory();
27 return _i;
28 }
29
30
31
32
33
34
35
36
37 public Buffer createBuffer(String type, Properties props) throws InstantiationException {
38 try {
39 AbstractBuffer buffer = (AbstractBuffer)Class.forName(type).newInstance();
40 buffer.setProperties(props);
41 buffer.setID(UUIDGenerator.getInstance().generateRandomBasedUUID().toString());
42 return buffer;
43 } catch (IllegalAccessException x) {
44 InstantiationException ix = new InstantiationException("Instatiation of buffer failed.");
45 ix.initCause(x);
46 throw ix;
47 } catch (ClassNotFoundException x) {
48 InstantiationException ix = new InstantiationException("Instatiation of buffer failed.");
49 ix.initCause(x);
50 throw ix;
51 } catch (ClassCastException x) {
52 InstantiationException ix = new InstantiationException("Instatiation of buffer failed.");
53 ix.initCause(x);
54 throw ix;
55 } catch (BufferException x) {
56 InstantiationException ix = new InstantiationException("Instatiation of buffer failed. Could not set properties of new instance.");
57 ix.initCause(x);
58 throw ix;
59 }
60 }
61 }