-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from linkedfactory/kvin-config
Add factory for creating Kvin instances based on RDF configurations
- Loading branch information
Showing
7 changed files
with
127 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<plugin> | ||
<extension point="net.enilink.komma.model.modules"> | ||
<module class="io.github.linkedfactory.service.config.ConfigModule" | ||
uri="plugin://io.github.linkedfactory.service/"> | ||
</module> | ||
</extension> | ||
</plugin> |
11 changes: 11 additions & 0 deletions
11
...kedfactory.service/src/main/java/io/github/linkedfactory/service/config/ConfigModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.github.linkedfactory.service.config; | ||
|
||
import net.enilink.komma.core.KommaModule; | ||
|
||
public class ConfigModule extends KommaModule { | ||
{ | ||
// specify dummy type to make KOMMA happy | ||
addConcept(IKvinFactory.class, "plugin://io.github.linkedfactory.service/data/Kvin"); | ||
addBehaviour(KvinLevelDbFactory.class); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...kedfactory.service/src/main/java/io/github/linkedfactory/service/config/IKvinFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.github.linkedfactory.service.config; | ||
|
||
import io.github.linkedfactory.core.kvin.Kvin; | ||
|
||
/** | ||
* Factory for creating {@link Kvin} instances. | ||
*/ | ||
public interface IKvinFactory { | ||
/** | ||
* Creates a {@link Kvin} instance | ||
* @return an instance of a {@link Kvin} store | ||
*/ | ||
Kvin create(); | ||
} |
41 changes: 41 additions & 0 deletions
41
...tory.service/src/main/java/io/github/linkedfactory/service/config/KvinLevelDbFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.github.linkedfactory.service.config; | ||
|
||
import io.github.linkedfactory.core.kvin.Kvin; | ||
import io.github.linkedfactory.core.kvin.leveldb.KvinLevelDb; | ||
import net.enilink.composition.annotations.Iri; | ||
import org.eclipse.core.runtime.Platform; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.File; | ||
import java.net.URISyntaxException; | ||
|
||
@Iri("plugin://io.github.linkedfactory.service/data/KvinLevelDb") | ||
public abstract class KvinLevelDbFactory implements IKvinFactory { | ||
private static final Logger log = LoggerFactory.getLogger(KvinLevelDbFactory.class); | ||
|
||
public static String TYPE = "plugin://io.github.linkedfactory.service/data/KvinLevelDb"; | ||
|
||
@Override | ||
public Kvin create() { | ||
String dirName = getDirName(); | ||
if (dirName == null) { | ||
dirName = "linkedfactory-valuestore"; | ||
} | ||
File valueStorePath; | ||
if (new File(dirName).isAbsolute()) { | ||
valueStorePath = new File(dirName); | ||
} else { | ||
try { | ||
valueStorePath = new File(new File(Platform.getInstanceLocation().getURL().toURI()), dirName); | ||
} catch (URISyntaxException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
log.info("Using store path: {}", valueStorePath); | ||
return new KvinLevelDb(valueStorePath); | ||
} | ||
|
||
@Iri("plugin://io.github.linkedfactory.service/data/dirName") | ||
public abstract String getDirName(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters