Skip to content

Commit ad28f83

Browse files
author
mielvds
committed
Merge pull request #16 from hartig/ClosableDataSources
Closable data sources
2 parents ac7c78c + 1133e4e commit ad28f83

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/org/linkeddatafragments/datasource/DataSource.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ public String getDescription() {
3737
public String getTitle() {
3838
return this.title;
3939
};
40+
41+
@Override
42+
public void close() {}
4043
}

src/org/linkeddatafragments/datasource/IDataSource.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.linkeddatafragments.datasource;
22

3+
import java.io.Closeable;
4+
35
import com.hp.hpl.jena.rdf.model.Property;
46
import com.hp.hpl.jena.rdf.model.RDFNode;
57
import com.hp.hpl.jena.rdf.model.Resource;
@@ -8,7 +10,7 @@
810
* A data source of Basic Linked Data Fragments.
911
* @author Ruben Verborgh
1012
*/
11-
public interface IDataSource {
13+
public interface IDataSource extends Closeable {
1214
/**
1315
* Gets a page of the Basic Linked Data Fragment matching the specified triple pattern.
1416
* @param subject the subject (null to match any subject)

src/org/linkeddatafragments/servlet/TriplePatternFragmentServlet.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ public void init(ServletConfig servletConfig) throws ServletException {
114114
}
115115
}
116116

117+
@Override
118+
public void destroy()
119+
{
120+
for ( IDataSource dataSource : dataSources.values() ) {
121+
try {
122+
dataSource.close();
123+
}
124+
catch( Exception e ) {
125+
// ignore
126+
}
127+
}
128+
}
129+
117130
/**
118131
* Get the datasource
119132
*

0 commit comments

Comments
 (0)