Dear all,
Probably it already has been done, but it took me some time to figure out, so
why not share my solution...
With the current OWLIM implementations you have to use a wrapper class which I
added in attachment. This class works with SwiftOWLIM, but I also have
successfully used this technique with BigOWLIM (altough you have to change
the Sail implementation class).
In your Spring applicationContext.xml, put the following beans. Of course, do
not forget to change "/tmp/repositories" to your effective dataDir.
<!-- Local SwiftOWLIM repository -->
<bean id="owlimSail" class="be.ugent.twing.owlim.SpringSailImpl">
<property name="properties">
<map>
<entry key="storage-folder" value="owlim-storage"/>
<entry key="ruleset" value="owl-horst"/>
</map>
</property>
<property name="dataDir">
<bean class="java.io.File">
<constructor-arg value="/tmp/repositories"/>
</bean>
</property>
</bean>
<bean id="owlimRepository" class="org.openrdf.repository.sail.SailRepository">
<constructor-arg ref="owlimSail"/>
</bean>
If everything is set up correctly, you can get access to the local repository
in code using:
BeanFactory beanFactory = new
ClassPathXmlApplicationContext("applicationContext.xml");
Repository rep = (Repository) beanFactory.getBean("owlimRepository");
The advantage of this is that you make your code independent of the effective
Repository configured; you can switch to a remote repository by replacing the
beans above with this:
<bean id="owlimRepository" class="org.openrdf.repository.http.HTTPRepository">
<!-- Server: -->
<constructor-arg value="http://localhost:8080/openrdf-sesame"/>
<!-- Repository: -->
<constructor-arg value="repositoryName"/>
</bean>
Any comments greatly appreciated.
Kind regards,
Bert Verslyppe
package be.ugent.twing.owlim;
import java.util.Map;
import com.ontotext.trree.owlim_ext.SailImpl;
/**
* Wrapper around {...@link SailImpl} to make it usable in Spring. This class is to
* be used with SwiftOWLIM, but can also be modified to fit BigOWLIM. In this case,
* change SailImpl to OwlimSchemaRepository.
*
* SwiftOWLIM: import com.ontotext.trree.owlim_ext.SailImpl;
* BigOWLIM: import com.ontotext.trree.OwlimSchemaRepository;
*
* @author [email protected]
*/
public class SpringSailImpl extends SailImpl {
public void setProperties(Map<String,String> properties) {
for (String key : properties.keySet())
setParameter(key, properties.get(key));
}
}
_______________________________________________
OWLIM-discussion mailing list
[email protected]
http://ontotext.com/mailman/listinfo/owlim-discussion