Skip to content

Package: ConnectorFactoryImpl

ConnectorFactoryImpl

nameinstructionbranchcomplexitylinemethod
ConnectorFactoryImpl(StorageConnector)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
close()
M: 1 C: 16
94%
M: 2 C: 2
50%
M: 2 C: 1
33%
M: 1 C: 6
86%
M: 0 C: 1
100%
createStorageConnector()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
ensureOpen()
M: 0 C: 9
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
isOpen()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
setRepository(Repository)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * JOPA
3: * Copyright (C) 2023 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.ontodriver.rdf4j.connector;
19:
20: import cz.cvut.kbss.ontodriver.exception.OntoDriverException;
21: import org.eclipse.rdf4j.repository.Repository;
22:
23: public final class ConnectorFactoryImpl implements ConnectorFactory {
24:
25: private boolean open;
26:
27: private StorageConnector centralConnector;
28:
29: public ConnectorFactoryImpl(StorageConnector connector) {
30: this.open = true;
31: this.centralConnector = connector;
32: }
33:
34: @Override
35: public Connector createStorageConnector() {
36: ensureOpen();
37: return new PoolingStorageConnector(centralConnector);
38: }
39:
40: private void ensureOpen() {
41:• if (!open) {
42: throw new IllegalStateException("The factory is closed!");
43: }
44: }
45:
46: @Override
47: public void setRepository(Repository repository) {
48: ensureOpen();
49: centralConnector.setRepository(repository);
50: }
51:
52: @Override
53: public synchronized void close() throws OntoDriverException {
54:• if (!open) {
55: return;
56: }
57:• if (centralConnector != null) {
58: centralConnector.close();
59: this.centralConnector = null;
60: }
61: this.open = false;
62: }
63:
64: @Override
65: public boolean isOpen() {
66: return open;
67: }
68: }