1 package org.csc.phynixx.tutorial;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import org.csc.phynixx.common.exceptions.DelegatedRuntimeException;
25 import org.csc.phynixx.common.generator.IDGenerator;
26 import org.csc.phynixx.common.generator.IDGenerators;
27
28 import java.io.File;
29
30
31
32
33 public class TAEnabledUTFWriterFactoryImpl implements TAEnabledUTFWriterFactory {
34
35 private static final IDGenerator<Long> idGenerator= IDGenerators.createLongGenerator(1,true);
36
37 private final UTFWriter sharedWriter;
38
39
40 public TAEnabledUTFWriterFactoryImpl(File sharedFile) {
41 this.sharedWriter = new UTFWriterImpl(sharedFile);
42 }
43
44 @Override
45 public TAEnabledUTFWriter getConnection() {
46 try {
47 return new TAEnabledUTFWriterImpl(Long.toString(idGenerator.generate()), this.sharedWriter);
48 } catch (Exception e) {
49 throw new DelegatedRuntimeException(e);
50 }
51 }
52
53 @Override
54 public Class<TAEnabledUTFWriter> getConnectionInterface() {
55 return TAEnabledUTFWriter.class;
56 }
57
58 @Override
59 public void close() {
60 this.sharedWriter.close();
61
62 }
63 }