Package: ConnectorFactoryImpl
ConnectorFactoryImpl
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ConnectorFactoryImpl(StorageConnector) |
|
|
|
|
|
||||||||||||||||||||
close() |
|
|
|
|
|
||||||||||||||||||||
createStorageConnector() |
|
|
|
|
|
||||||||||||||||||||
ensureOpen() |
|
|
|
|
|
||||||||||||||||||||
isOpen() |
|
|
|
|
|
||||||||||||||||||||
setRepository(Repository) |
|
|
|
|
|
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: }