如何使用Apache Jena Java API创建Fuseki SPARQL服务器? [英] How do you create a Fuseki SPARQL server using the Apache Jena Java API?

查看:499
本文介绍了如何使用Apache Jena Java API创建Fuseki SPARQL服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在机器上创建Fuseki SPARQL服务器. Jena网站上的文档描述了如何通过命令行在以下位置创建这样的服务器: http://jena.apache.org/documentation/serving_data/.我正在寻找一种仅使用Jena Java API创建和初始化这样的服务器的方法.我已经查看了Jena API,但在确定如何进行方面没有任何进展.有人做过吗?

I am trying to create a Fuseki SPARQL server on my machine. The documentation on the Jena website describes how to create such a server from the command-line, here: http://jena.apache.org/documentation/serving_data/. I am looking for a way of creating and initializing such a server just using the Jena Java API. I have looked over the Jena API but have not made any progress in working out how to proceed. Has anyone done this before?

推荐答案

是可以的,但是Fuseki的设计工作方式并非如此,后果自负.

Yes this is possible but it is not how Fuseki was designed to operate so do so at your own risk.

您将需要通过依赖将Fuseki作为依赖项,如下所示:

You will need to pull in Fuseki as a dependency, via maven this would be the following:

<dependency>
  <groupId>org.apache.jena</groupId>
  <artifactId>jena-fuseki</artifactId>
  <version>0.2.7</version>
</dependency>

然后,您可以使用SPARQLServer类创建服务器,并在完成后调用start()实际运行服务器,并调用stop(). (位于org.apache.jena.fuseki.server包中)

Then you can use the SPARQLServer class to create a server and call start() to actually run the server and stop() when you are done. (This is located in the org.apache.jena.fuseki.server package)

重要说明,如果执行此操作,则服务器将嵌入到启动该服务器的JVM中,而当该JVM关闭时,服务器也会关闭.这可能是您的意图,但可能不是.

It is important to note that if you do this the server is embedded in the JVM from which you start it, when that JVM shuts down the server shuts down. This may be your intention but it may not.

请问您不清楚为什么要这样做?如果您进一步解释目标,则可能有其他方法可以实现而无需嵌入Fuseki

Btw you question is unclear as to exactly why you want to do this? There may be alternative ways to achieve your goal without embedding Fuseki if you explain your goals further

这篇关于如何使用Apache Jena Java API创建Fuseki SPARQL服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆