Commit 591de910 authored by bseeger's avatar bseeger
Browse files

Merge branch 'remove_ldcache' into 'master'

remove the ldcache code

The code in fcrepo-camel-toolbox/fcrepo-ldpath is better and we should start using that instead.

See merge request !79
parents 1723cc2c f0495dc7
......@@ -28,8 +28,6 @@ These modules provide particular services, independent of Fedora Resources.
* [`acrepo-services-activemq`](acrepo-services-activemq): This service creates a ActiveMQ connection for other modules to use
* [`acrepo-services-inference`](acrepo-services-inference): An OSGi-based structural typing service using owl inference
* [`acrepo-services-jsonld`](acrepo-services-jsonld): This service creates expanded or compact JSON-LD representations of input documents
* [`acrepo-services-ldcache`](acrepo-services-ldcache): This service dereferences and caches URIs, retrieving the `object` of particular triples on demand
* [`acrepo-services-ldcache-file`](acrepo-services-ldcache-file): A file-based backend for the `acrepo-services-ldcache` service
* [`acrepo-services-mint`](acrepo-services-mint): This mints random (public) URIs for use with Fedora resources
* [`acrepo-services-pcdm`](acrepo-services-pcdm): This makes it easy to work with PCDM objects
......@@ -52,8 +50,6 @@ sets of related bundles in an OSGi container.
* `acrepo-libs-jackson`: The [Jackson](http://wiki.fasterxml.com/JacksonHome) JSON libraries
* `acrepo-libs-jena`: The [Jena 3.x](http://jena.apache.org/) libraries
* `acrepo-libs-jsonld`: The [JSON-LD](https://github.com/jsonld-java/jsonld-java) libraries
* `acrepo-libs-marmotta`: The [Marmotta](http://marmotta.apache.org) libraries
* `acrepo-libs-sesame`: The [Sesame 2.x](http://rdf4j.org/) libraries
Building
--------
......@@ -89,8 +85,6 @@ command from its shell:
feature:install acrepo-services-inference
feature:install acrepo-services-jsonld
feature:install acrepo-services-ldcache
feature:install acrepo-services-ldcache-file
feature:install acrepo-services-mint
feature:install acrepo-services-pcdm
......
......@@ -51,8 +51,6 @@ dependencies {
testCompile project(':acrepo-services-activemq')
testCompile project(':acrepo-services-inference')
testCompile project(':acrepo-services-jsonld')
testCompile project(':acrepo-services-ldcache-file')
testCompile project(':acrepo-services-ldcache')
testCompile project(':acrepo-services-mint')
testCompile project(':acrepo-services-pcdm')
testCompile project(':acrepo-exts-jsonld')
......
/*
* Copyright 2016 Amherst College
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package edu.amherst.acdc.itests;
import static edu.amherst.acdc.services.ldcache.file.LDCacheFileBackendFactory.createBackend;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
import static org.slf4j.LoggerFactory.getLogger;
import java.io.File;
import java.util.List;
import edu.amherst.acdc.services.ldcache.LDCacheService;
import edu.amherst.acdc.services.ldcache.LDCacheServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.ConfigurationManager;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
import org.slf4j.Logger;
/**
* @author Aaron Coburn
* @since May 2, 2016
*/
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class AcrepoLdCacheIT extends AbstractOSGiIT {
private static final String PREF_LABEL = "http://www.w3.org/2004/02/skos/core#prefLabel";
private static final String LABEL = "http://www.w3.org/2000/01/rdf-schema#label";
private static final String OFFICIAL_NAME = "http://www.geonames.org/ontology#officialName";
private static final Logger LOGGER = getLogger(AcrepoLdCacheIT.class);
private static final LDCacheService svc = new LDCacheServiceImpl(createBackend("build/ldcache"), 100000);
@Configuration
public Option[] config() {
final ConfigurationManager cm = new ConfigurationManager();
final String fcrepoPort = cm.getProperty("fcrepo.dynamic.test.port");
final String rmiRegistryPort = cm.getProperty("karaf.rmiRegistry.port");
final String rmiServerPort = cm.getProperty("karaf.rmiServer.port");
final String fcrepoBaseUrl = "localhost:" + fcrepoPort + "/fcrepo/rest";
final String sshPort = cm.getProperty("karaf.ssh.port");
return new Option[] {
karafDistributionConfiguration()
.frameworkUrl(maven().groupId("org.apache.karaf").artifactId("apache-karaf")
.version(cm.getProperty("karaf.version")).type("zip"))
.unpackDirectory(new File("build", "exam"))
.useDeployFolder(false),
logLevel(LogLevel.INFO),
keepRuntimeFolder(),
configureConsole().ignoreLocalConsole(),
features(maven().groupId("org.apache.karaf.features").artifactId("standard")
.versionAsInProject().classifier("features").type("xml"), "scr", "wrap"),
features(maven().groupId("org.apache.camel.karaf").artifactId("apache-camel")
.type("xml").classifier("features").versionAsInProject()),
features(maven().groupId("edu.amherst.acdc").artifactId("acrepo-karaf")
.type("xml").classifier("features").versionAsInProject(),
"acrepo-services-ldcache", "acrepo-services-ldcache-file"),
systemProperty("fcrepo.port").value(fcrepoPort),
editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiRegistryPort", rmiRegistryPort),
editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", rmiServerPort),
editConfigurationFilePut("etc/org.apache.karaf.shell.cfg", "sshPort", sshPort)
};
}
@Test
public void testInstallation() throws Exception {
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-ldcache")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-ldcache-file")));
}
@Test
public void testFetchDbpedia() throws Exception {
final List<String> dbpedia = svc.get("http://dbpedia.org/resource/Berlin", LABEL);
assumeTrue(dbpedia.size() > 0);
assertTrue(dbpedia.contains("Berlin"));
}
@Test
public void testFetchGeonames() throws Exception {
final List<String> geonames = svc.get("http://sws.geonames.org/2658434/", OFFICIAL_NAME);
assumeTrue(geonames.size() > 0);
assertTrue(geonames.contains("Switzerland"));
}
@Test
public void testFetchGetty() throws Exception {
final List<String> getty = svc.get("http://vocab.getty.edu/tgn/7003712", PREF_LABEL);
assumeTrue(getty.size() > 0);
assertTrue(getty.contains("Berlin"));
}
@Test
public void testFetchResourceTypes() throws Exception {
final List<String> types = svc.get("http://id.loc.gov/vocabulary/resourceTypes/txt", PREF_LABEL);
assumeTrue(types.size() > 0);
assertTrue(types.contains("Text"));
}
@Test
public void testFetchLocName() throws Exception {
final List<String> name = svc.get("http://id.loc.gov/authorities/names/n79006936", PREF_LABEL);
assumeTrue(name.size() > 0);
assertTrue(name.contains("Melville, Herman, 1819-1891"));
}
@Test
public void testDcmiTypes() throws Exception {
final List<String> types = svc.get("http://purl.org/dc/dcmitype/StillImage", LABEL);
assumeTrue(types.size() > 0);
assertTrue(types.contains("Still Image"));
}
@Test
public void testFetchDbpediaWithLang() throws Exception {
final List<String> dbpedia = svc.get("http://dbpedia.org/resource/Berlin", LABEL, "en");
assumeTrue(dbpedia.size() > 0);
assertEquals(dbpedia.size(), 1);
assertTrue(dbpedia.contains("Berlin"));
}
@Test
public void testFetchGeonamesWithLang() throws Exception {
final List<String> geonames = svc.get("http://sws.geonames.org/2658434/", OFFICIAL_NAME, "en");
assumeTrue(geonames.size() > 0);
assertEquals(geonames.size(), 1);
assertTrue(geonames.contains("Switzerland"));
}
@Test
public void testFetchGettyWithLang() throws Exception {
final List<String> getty = svc.get("http://vocab.getty.edu/tgn/7003712", PREF_LABEL, "en");
assumeTrue(getty.size() > 0);
assertEquals(getty.size(), 1);
assertTrue(getty.contains("Berlin"));
}
@Test
public void testFetchResourceTypesWithLang() throws Exception {
final List<String> types = svc.get("http://id.loc.gov/vocabulary/resourceTypes/txt", PREF_LABEL, "en");
assumeTrue(types.size() > 0);
assertEquals(types.size(), 1);
assertTrue(types.contains("Text"));
}
@Test
public void testFetchLocNameWithLang() throws Exception {
final List<String> name = svc.get("http://id.loc.gov/authorities/names/n79006936", PREF_LABEL, "en");
assumeTrue(name.size() > 0);
assertEquals(name.size(), 1);
assertTrue(name.contains("Melville, Herman, 1819-1891"));
}
@Test
public void testDcmiTypesWithLang() throws Exception {
final List<String> types = svc.get("http://purl.org/dc/dcmitype/StillImage", LABEL, "en");
assumeTrue(types.size() > 0);
assertEquals(types.size(), 1);
assertTrue(types.contains("Still Image"));
}
}
......@@ -90,8 +90,7 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
"acrepo-libs-jackson", "acrepo-libs-marmotta",
"acrepo-services-activemq", "acrepo-services-inference", "acrepo-services-jsonld",
"acrepo-services-ldcache", "acrepo-services-ldcache-file", "acrepo-services-mint",
"acrepo-services-pcdm"),
"acrepo-services-mint", "acrepo-services-pcdm"),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.fits.cfg", "rest.port", fitsPort),
editConfigurationFilePut("etc/edu.amherst.acdc.exts.image.cfg", "rest.port", imagePort),
......@@ -119,12 +118,9 @@ public class AcrepoServicesIT extends AbstractOSGiIT {
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-jackson")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-jena")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-jsonld")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-marmotta")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-libs-sesame")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-activemq")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-inference")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-jsonld")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-ldcache")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-mint")));
assertTrue(featuresService.isInstalled(featuresService.getFeature("acrepo-services-pcdm")));
}
......
......@@ -90,28 +90,6 @@
<configfile finalname="/etc/edu.amherst.acdc.services.activemq.cfg">mvn:edu.amherst.acdc/acrepo-services-activemq/${project.version}/cfg/configuration</configfile>
</feature>
<feature name="acrepo-services-ldcache" version="${project.version}">
<details>Installs the LDCache service</details>
<bundle>mvn:edu.amherst.acdc/acrepo-services-ldcache/${project.version}</bundle>
<feature version="${project.version}">acrepo-libs-marmotta</feature>
<configfile finalname="/etc/edu.amherst.acdc.services.ldcache.cfg">mvn:edu.amherst.acdc/acrepo-services-ldcache/${project.version}/cfg/configuration</configfile>
</feature>
<feature name="acrepo-services-ldcache-file" version="${project.version}">
<details>Installs the LDCache service</details>
<bundle>mvn:edu.amherst.acdc/acrepo-services-ldcache-file/${project.version}</bundle>
<feature version="${project.version}">acrepo-libs-marmotta</feature>
<bundle>wrap:mvn:org.apache.marmotta/ldcache-backend-file/${marmottaVersion}</bundle>
<configfile finalname="/etc/edu.amherst.acdc.services.ldcache.file.cfg">mvn:edu.amherst.acdc/acrepo-services-ldcache-file/${project.version}/cfg/configuration</configfile>
</feature>
<feature name="acrepo-services-mint" version="${project.version}">
<details>Installs the id minter</details>
......@@ -217,93 +195,6 @@
<bundle dependency="true">mvn:com.github.andrewoma.dexx/collection/${dexxVersion}</bundle>
</feature>
<feature name="acrepo-libs-sesame" version="${project.version}">
<details>Installs the OpenRDF libraries</details>
<feature prerequisite="true" dependency="false">wrap</feature>
<feature version="${project.version}" dependency="true">acrepo-libs-jackson</feature>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-repository-event/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-sail-memory/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-model/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-util/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-repository-api/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-rio-api/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-query/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-queryresultio-api/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-rio-rdfjson/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-rio-rdfxml/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-rio-turtle/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-rio-n3/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-repository-sail/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-queryparser-api/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-queryalgebra-model/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-rio-trig/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-sail-api/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-sail-nativerdf/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-sail-inferencer/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-queryalgebra-evaluation/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-repository-sparql/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-queryparser-sparql/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-queryresultio-sparqlxml/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-http-client/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-http-protocol/${sesameVersion}</bundle>
<bundle>wrap:mvn:org.openrdf.sesame/sesame-rio-ntriples/${sesameVersion}</bundle>
<bundle>mvn:com.github.jsonld-java/jsonld-java-sesame/${jsonldSesameVersion}</bundle>
<bundle>mvn:com.github.jsonld-java/jsonld-java/${jsonldSesameVersion}</bundle>
<bundle dependency="true">wrap:mvn:commons-httpclient/commons-httpclient/${commonsHttpclientVersion}</bundle>
<bundle dependency="true">mvn:org.apache.httpcomponents/httpclient-osgi/${httpclientVersion}</bundle>
<bundle dependency="true">mvn:org.apache.httpcomponents/httpcore-osgi/${httpcoreVersion}</bundle>
<bundle dependency="true">mvn:commons-codec/commons-codec/${commonsCodecVersion}</bundle>
<bundle dependency="true">mvn:commons-io/commons-io/${commonsIoVersion}</bundle>
</feature>
<feature name="acrepo-libs-marmotta" version="${project.version}">
<details>Installs the Marmotta libraries</details>
<feature version="${project.version}" dependency="true">acrepo-libs-sesame</feature>
<feature version="${project.version}" dependency="true">acrepo-libs-jsonld</feature>
<feature version="${project.version}" dependency="true">acrepo-libs-jackson</feature>
<bundle>mvn:org.apache.marmotta/ldcache-api/${marmottaVersion}</bundle>
<bundle>mvn:org.apache.marmotta/marmotta-commons/${marmottaVersion}</bundle>
<!-- locally wrapped OSGi bundles -->
<bundle>${wrappedBundleLocation}/org.apache.marmotta.ldclient-api-${marmottaVersion}.jar</bundle>
<bundle>wrap:mvn:org.apache.marmotta/ldcache-core/${marmottaVersion}</bundle>
<bundle>wrap:mvn:org.apache.marmotta/ldclient-core/${marmottaVersion}</bundle>
<bundle>wrap:mvn:org.apache.marmotta/ldclient-provider-rdf/${marmottaVersion}</bundle>
<bundle>wrap:mvn:org.apache.marmotta/ldclient-provider-rdfa/${marmottaVersion}</bundle>
<bundle>wrap:mvn:org.apache.marmotta/ldclient-provider-xml/${marmottaVersion}</bundle>
<bundle dependency="true">mvn:commons-collections/commons-collections/${commonsCollectionsVersion}</bundle>
<bundle dependency="true">mvn:com.google.guava/guava/16.0</bundle>
<bundle dependency="true">mvn:joda-time/joda-time/${jodaTimeVersion}</bundle>
<bundle dependency="true">mvn:commons-validator/commons-validator/${commonsValidatorVersion}</bundle>
<bundle dependency="true">mvn:commons-beanutils/commons-beanutils/${commonsBeanutilsVersion}</bundle>
<bundle dependency="true">mvn:org.apache.commons/commons-lang3/${commonsLangVersion}</bundle>
<bundle dependency="true">mvn:ch.qos.cal10n/cal10n-api/${cal10nVersion}</bundle>
<bundle dependency="true">mvn:org.apache.httpcomponents/httpclient-osgi/${httpclientVersion}</bundle>
<bundle dependency="true">mvn:org.apache.httpcomponents/httpcore-osgi/${httpcoreVersion}</bundle>
<bundle dependency="true">mvn:jaxen/jaxen/${jaxenVersion}</bundle>
<bundle dependency="true">wrap:mvn:commons-digester/commons-digester/${commonsDigesterVersion}</bundle>
<bundle dependency="true">wrap:mvn:org.apache.httpcomponents/fluent-hc/${fluentHcVersion}</bundle>
<bundle dependency="true">wrap:mvn:org.apache.httpcomponents/httpclient-cache/${httpclientCacheVersion}</bundle>
<bundle dependency="true">wrap:mvn:org.apache.httpcomponents/httpcore-nio/${httpcoreNioVersion}</bundle>
<bundle dependency="true">wrap:mvn:org.apache.httpcomponents/httpmime/${httpmimeVersion}</bundle>
<bundle dependency="true">wrap:mvn:org.jdom/jdom2/${jdom2Version}</bundle>
<bundle dependency="true">wrap:mvn:org.semarglproject/semargl-rdfa/${semarglVersion}</bundle>
<bundle dependency="true">wrap:mvn:org.semarglproject/semargl-core/${semarglVersion}</bundle>
<bundle dependency="true">wrap:mvn:org.semarglproject/semargl-rdf/${semarglVersion}</bundle>
<bundle dependency="true">wrap:mvn:org.semarglproject/semargl-sesame/${semarglVersion}</bundle>
</feature>
<feature name="acrepo-libs-jsonld" version="${project.version}">
<details>Installs the JSON-LD related bundles</details>
......
File Backend for the Linked Data Cache Service
==============================================
This module provides access to a linked data caching service.
Building
--------
To build this project use
gradle install
Deploying in OSGi
-----------------
Each of these projects can be deployed in an OSGi container. For example using
[Apache Karaf](http://karaf.apache.org) version 4.x and above, you can run the following
command from its shell:
feature:repo-add mvn:edu.amherst.acdc/acrepo-karaf/LATEST/xml/features
feature:install acrepo-services-ldcache-file
Configuration
-------------
The application can be configured by creating the following configuration
file `$KARAF_HOME/etc/edu.amherst.acdc.services.ldcache.file.cfg`. The following values
are available for configuration:
The directory in which to store the cache files
ldcache.cacheDir=/tmp/ldcache
By editing this file, this service will be immediately redeployed
with the new configuration.
For more help see the [Apache Camel](http://camel.apache.org/) documentation
apply plugin: 'osgi'
description = 'File backend for the Linked Data Caching Service'
dependencies {
compile group: 'org.apache.marmotta', name: 'ldcache-api', version: marmottaVersion
compile group: 'org.apache.marmotta', name: 'ldcache-backend-file', version: marmottaVersion
compile group: 'org.slf4j', name: 'slf4j-api', version: slf4jVersion
testCompile group: 'junit', name: 'junit', version: junitVersion
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: logbackVersion
}
jar {
manifest {
description project.description
docURL project.docURL
vendor project.vendor
license project.license
instruction 'Import-Package', defaultOsgiImports
instruction 'Export-Package', "edu.amherst.acdc.services.ldcache.file;version=${projectOsgiVersion}"
}
}
artifacts {
archives (file('build/cfg/main/edu.amherst.acdc.services.ldcache.file.cfg')) {
classifier 'configuration'
type 'cfg'
}
}
/*
* Copyright 2016 Amherst College
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package edu.amherst.acdc.services.ldcache.file;
import static org.slf4j.LoggerFactory.getLogger;
import java.io.File;
import org.apache.marmotta.ldcache.api.LDCachingBackend;
import org.apache.marmotta.ldcache.backend.file.LDCachingFileBackend;
import org.slf4j.Logger;
/**
* @author acoburn
* @since 6/27/16
*/
public class LDCacheFileBackendFactory {
private static Logger LOGGER = getLogger(LDCacheFileBackendFactory.class);
/**
* Create a File-based LDCachingBackend
* @param storageDir the location where files will be stored
* @return a backend for linked data caching
*/
public static LDCachingBackend createBackend(final String storageDir) {
try {
final LDCachingBackend backend = new LDCachingFileBackend(new File(storageDir));
backend.initialize();
return backend;
} catch (final Exception ex) {
LOGGER.error("Error creating LDCachingBackend: {}", ex.getMessage());
throw new RuntimeException(ex);
}
}
private LDCacheFileBackendFactory() {
// prevent instantiation
}
}
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd"
default-activation="lazy">
<cm:property-placeholder persistent-id="edu.amherst.acdc.services.ldcache.file" update-strategy="reload" >
<cm:default-properties>
<cm:property name="ldcache.cacheDir" value="/tmp/ldcache"/>
</cm:default-properties>
</cm:property-placeholder>
<bean id="ldcacheBackendBean" class="edu.amherst.acdc.services.ldcache.file.LDCacheFileBackendFactory" factory-method="createBackend">
<argument value="${ldcache.cacheDir}"/>
</bean>
<service ref="ldcacheBackendBean" interface="org.apache.marmotta.ldcache.api.LDCachingBackend">
<service-properties>
<entry key="osgi.jndi.service.name" value="acrepo/LDCacheBackend"/>
</service-properties>
</service>
</blueprint>
/*
* Copyright 2016 Amherst College
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package edu.amherst.acdc.services.ldcache.file;
import static org.junit.Assert.assertNotNull;