Last active
August 29, 2015 14:13
-
-
Save AlBaker/decb9874f7060d8a041f to your computer and use it in GitHub Desktop.
Stardog Spring embedded server configuration
This file contains hidden or 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
<bean name="embeddedProvider" class="com.complexible.stardog.ext.spring.EmbeddedProvider"></bean> | |
<bean name="dataSource" class="com.complexible.stardog.ext.spring.DataSourceFactoryBean"> | |
<property name="to" value="testdb"/> | |
<property name="provider" ref="embeddedProvider"/> | |
<property name="username" value="admin"/> | |
<property name="password" value="admin"/> | |
</bean> |
This file contains hidden or 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
package com.complexible.stardog.ext.spring; | |
import com.complexible.common.protocols.server.ServerException; | |
import com.complexible.stardog.Stardog; | |
import com.complexible.stardog.StardogException; | |
import com.complexible.stardog.api.admin.AdminConnection; | |
import com.complexible.stardog.api.admin.AdminConnectionConfiguration; | |
import com.complexible.stardog.protocols.snarl.SNARLProtocolConstants; | |
public class EmbeddedProvider implements Provider { | |
@Override | |
public void execute(String to, String url, String user, String pass) { | |
try { | |
Stardog.buildServer() | |
.bind(SNARLProtocolConstants.EMBEDDED_ADDRESS) | |
.start(); | |
AdminConnection dbms = AdminConnectionConfiguration.toEmbeddedServer().credentials(user, pass).connect(); | |
if (dbms.list().contains(to)) { | |
dbms.drop(to); | |
dbms.createMemory(to); | |
} else { | |
dbms.createMemory(to); | |
} | |
dbms.close(); | |
} catch (StardogException e) { | |
} catch (ServerException e) { | |
} finally { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment