Skip to contentMethod: close()
1: /*
2: * JOPA
3: * Copyright (C) 2024 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:
21: import org.eclipse.rdf4j.common.iteration.CloseableIteration;
22: import org.eclipse.rdf4j.common.transaction.IsolationLevel;
23: import org.eclipse.rdf4j.model.IRI;
24: import org.eclipse.rdf4j.model.Namespace;
25: import org.eclipse.rdf4j.model.Resource;
26: import org.eclipse.rdf4j.model.Statement;
27: import org.eclipse.rdf4j.model.Value;
28: import org.eclipse.rdf4j.model.ValueFactory;
29: import org.eclipse.rdf4j.query.BooleanQuery;
30: import org.eclipse.rdf4j.query.GraphQuery;
31: import org.eclipse.rdf4j.query.Query;
32: import org.eclipse.rdf4j.query.QueryLanguage;
33: import org.eclipse.rdf4j.query.TupleQuery;
34: import org.eclipse.rdf4j.query.Update;
35: import org.eclipse.rdf4j.repository.Repository;
36: import org.eclipse.rdf4j.repository.RepositoryConnection;
37: import org.eclipse.rdf4j.repository.RepositoryException;
38: import org.eclipse.rdf4j.repository.RepositoryResult;
39: import org.eclipse.rdf4j.rio.ParserConfig;
40: import org.eclipse.rdf4j.rio.RDFFormat;
41: import org.eclipse.rdf4j.rio.RDFHandler;
42:
43: import java.io.File;
44: import java.io.IOException;
45: import java.io.InputStream;
46: import java.io.Reader;
47: import java.net.URL;
48:
49: /**
50: * Wraps a standard RFD4J {@link RepositoryConnection} and prevents its closing.
51: * <p>
52: * This is because the connector will handle closing when a transaction finishes or the connector is closed.
53: */
54: class TransactionalRepositoryConnection implements RepositoryConnection {
55:
56: private final RepositoryConnection wrappedConnection;
57:
58: TransactionalRepositoryConnection(RepositoryConnection wrappedConnection) {
59: this.wrappedConnection = wrappedConnection;
60: }
61:
62: @Override
63: public Repository getRepository() {
64: return wrappedConnection.getRepository();
65: }
66:
67: @Override
68: public void setParserConfig(ParserConfig config) {
69: wrappedConnection.setParserConfig(config);
70: }
71:
72: @Override
73: public ParserConfig getParserConfig() {
74: return wrappedConnection.getParserConfig();
75: }
76:
77: @Override
78: public ValueFactory getValueFactory() {
79: return wrappedConnection.getValueFactory();
80: }
81:
82: @Override
83: public boolean isOpen() {
84: return wrappedConnection.isOpen();
85: }
86:
87: @Override
88: public void close() {
89: // Do nothing !!!
90: }
91:
92: @Override
93: public Query prepareQuery(QueryLanguage ql, String query) {
94: return wrappedConnection.prepareQuery(ql, query);
95: }
96:
97: @Override
98: public Query prepareQuery(QueryLanguage ql, String query, String baseURI) {
99: return wrappedConnection.prepareQuery(ql, query, baseURI);
100: }
101:
102: @Override
103: public TupleQuery prepareTupleQuery(QueryLanguage ql, String query) {
104: return wrappedConnection.prepareTupleQuery(ql, query);
105: }
106:
107: @Override
108: public TupleQuery prepareTupleQuery(QueryLanguage ql, String query, String baseURI) {
109: return wrappedConnection.prepareTupleQuery(ql, query, baseURI);
110: }
111:
112: @Override
113: public GraphQuery prepareGraphQuery(QueryLanguage ql, String query) {
114: return wrappedConnection.prepareGraphQuery(ql, query);
115: }
116:
117: @Override
118: public GraphQuery prepareGraphQuery(QueryLanguage ql, String query, String baseURI) {
119: return wrappedConnection.prepareGraphQuery(ql, query, baseURI);
120: }
121:
122: @Override
123: public BooleanQuery prepareBooleanQuery(QueryLanguage ql, String query) {
124: return wrappedConnection.prepareBooleanQuery(ql, query);
125: }
126:
127: @Override
128: public BooleanQuery prepareBooleanQuery(QueryLanguage ql, String query, String baseURI) {
129: return wrappedConnection.prepareBooleanQuery(ql, query, baseURI);
130: }
131:
132: @Override
133: public Update prepareUpdate(QueryLanguage ql, String update) {
134: return wrappedConnection.prepareUpdate(ql, update);
135: }
136:
137: @Override
138: public Update prepareUpdate(QueryLanguage ql, String update, String baseURI) {
139: return wrappedConnection.prepareUpdate(ql, update, baseURI);
140: }
141:
142: @Override
143: public RepositoryResult<Resource> getContextIDs() {
144: return wrappedConnection.getContextIDs();
145: }
146:
147: @Override
148: public RepositoryResult<Statement> getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred,
149: Resource... contexts) {
150: return wrappedConnection.getStatements(subj, pred, obj, includeInferred, contexts);
151: }
152:
153: @Override
154: public boolean hasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) {
155: return wrappedConnection.hasStatement(subj, pred, obj, includeInferred, contexts);
156: }
157:
158: @Override
159: public boolean hasStatement(Statement st, boolean includeInferred, Resource... contexts) {
160: return wrappedConnection.hasStatement(st, includeInferred, contexts);
161: }
162:
163: @Override
164: public void exportStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler,
165: Resource... contexts) {
166: wrappedConnection.exportStatements(subj, pred, obj, includeInferred, handler, contexts);
167: }
168:
169: @Override
170: public void export(RDFHandler handler, Resource... contexts) {
171: wrappedConnection.export(handler, contexts);
172: }
173:
174: @Override
175: public long size(Resource... contexts) {
176: return wrappedConnection.size(contexts);
177: }
178:
179: @Override
180: public boolean isEmpty() {
181: return wrappedConnection.isEmpty();
182: }
183:
184: @Deprecated
185: @Override
186: public void setAutoCommit(boolean autoCommit) {
187: wrappedConnection.setAutoCommit(autoCommit);
188: }
189:
190: @Deprecated
191: @Override
192: public boolean isAutoCommit() {
193: return wrappedConnection.isAutoCommit();
194: }
195:
196: @Override
197: public boolean isActive() {
198: return wrappedConnection.isActive();
199: }
200:
201: @Override
202: public void setIsolationLevel(IsolationLevel level) {
203: wrappedConnection.setIsolationLevel(level);
204: }
205:
206: @Override
207: public IsolationLevel getIsolationLevel() {
208: return wrappedConnection.getIsolationLevel();
209: }
210:
211: @Override
212: public void begin() {
213: wrappedConnection.begin();
214: }
215:
216: @Override
217: public void begin(IsolationLevel level) {
218: wrappedConnection.begin(level);
219: }
220:
221: @Override
222: public void commit() {
223: wrappedConnection.commit();
224: }
225:
226: @Override
227: public void rollback() {
228: wrappedConnection.rollback();
229: }
230:
231: @Override
232: public void add(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts)
233: throws IOException {
234: wrappedConnection.add(in, baseURI, dataFormat, contexts);
235: }
236:
237: @Override
238: public void add(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts)
239: throws IOException {
240: wrappedConnection.add(reader, baseURI, dataFormat, contexts);
241: }
242:
243: @Override
244: public void add(URL url, String baseURI, RDFFormat dataFormat, Resource... contexts)
245: throws IOException {
246: wrappedConnection.add(url, baseURI, dataFormat, contexts);
247: }
248:
249: @Override
250: public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts)
251: throws IOException {
252: wrappedConnection.add(file, baseURI, dataFormat, contexts);
253: }
254:
255: @Override
256: public void add(Resource subject, IRI predicate, Value object, Resource... contexts) {
257: wrappedConnection.add(subject, predicate, object, contexts);
258: }
259:
260: @Override
261: public void add(Statement st, Resource... contexts) {
262: wrappedConnection.add(st, contexts);
263: }
264:
265: @Override
266: public void add(Iterable<? extends Statement> statements, Resource... contexts) {
267: wrappedConnection.add(statements, contexts);
268: }
269:
270: @Override
271: public void add(CloseableIteration<? extends Statement> closeableIteration,
272: Resource... resources) throws RepositoryException {
273: wrappedConnection.add(closeableIteration, resources);
274: }
275:
276: @Override
277: public void remove(Resource subject, IRI predicate, Value object, Resource... contexts) {
278: wrappedConnection.remove(subject, predicate, object, contexts);
279: }
280:
281: @Override
282: public void remove(Statement st, Resource... contexts) {
283: wrappedConnection.remove(st, contexts);
284: }
285:
286: @Override
287: public void remove(Iterable<? extends Statement> statements, Resource... contexts) {
288: wrappedConnection.remove(statements, contexts);
289: }
290:
291: @Override
292: public void remove(CloseableIteration<? extends Statement> closeableIteration,
293: Resource... resources) throws RepositoryException {
294: wrappedConnection.remove(closeableIteration, resources);
295: }
296:
297: @Override
298: public void clear(Resource... contexts) {
299: wrappedConnection.clear(contexts);
300: }
301:
302: @Override
303: public RepositoryResult<Namespace> getNamespaces() {
304: return wrappedConnection.getNamespaces();
305: }
306:
307: @Override
308: public String getNamespace(String prefix) {
309: return wrappedConnection.getNamespace(prefix);
310: }
311:
312: @Override
313: public void setNamespace(String prefix, String name) {
314: wrappedConnection.setNamespace(prefix, name);
315: }
316:
317: @Override
318: public void removeNamespace(String prefix) {
319: wrappedConnection.removeNamespace(prefix);
320: }
321:
322: @Override
323: public void clearNamespaces() {
324: wrappedConnection.clearNamespaces();
325: }
326: }