| 60 | } |
| 61 | |
| 62 | public void store(FtnAddress ftnAddress, ConnectionStatDataElement element) { |
| 63 | synchronized (ConnectionStatData.class) { |
| 64 | List<ConnectionStatDataElement> elements = internalLoad(); |
| 65 | int pos = findPos(ftnAddress, elements); |
| 66 | if (pos == -1) { |
| 67 | elements.add(element); |
| 68 | } else { |
| 69 | elements.set(pos, element); |
| 70 | } |
| 71 | try { |
| 72 | XMLSerializer.write(elements, statPath); |
| 73 | } catch (FileNotFoundException e) { |
| 74 | logger.l2(MessageFormat.format("file {0} not found, fail store data", statPath), e); |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | public int findPos(FtnAddress ftnAddress, List<ConnectionStatDataElement> elements) { |
| 80 | int pos = -1; |