使用 EmbeddedGraphDatabase 在服务器模式下访问 Neo4j? [英] Access Neo4j in server mode with EmbeddedGraphDatabase?

查看:12
本文介绍了使用 EmbeddedGraphDatabase 在服务器模式下访问 Neo4j?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在服务器模式下运行 neo4j 以便可以使用 REST API 访问它,我可以使用 EmbeddedGraphDatabase-class 访问同一个 neo4j 实例吗?

If I run neo4j in server mode so it is accessible using the REST API, can I access the same neo4j instance with EmbeddedGraphDatabase-class?

我正在考虑一个生产设置,其中使用 EmbeddedGraphDatabase 的 Java 应用程序正在驱动逻辑,但其他客户端可能会在只读模式下使用 REST 导航数据.

I am thinking of a production setup where a Java-app using EmbeddedGraphDatabase is driving the logic, but other clients might navigate the data with REST in readonly mode.

推荐答案

您所描述的是服务器插件或扩展.这样您就可以通过 REST API 公开您的数据库,但同时您可以从您的自定义插件/扩展代码访问嵌入式图形数据库.

What you are describing is a server plugin or extension. That way you expose your database via the REST API but at the same time you can access the embedded graph db hihgly performant from your custom plugin/extension code.

在您的自定义代码中,您可以获得一个注入您操作的 GraphDatabaseService.

In your custom code you can get a GraphDatabaseService injected on which you operate.

您使用 neo4j 服务器将自定义扩展部署为 jar,并让客户端代码通过面向域的 Restful API 运行.

You deploy your custom extensions as jars with your neo4j-server and have client code operate over a domain oriented restful API with it.

// extension sample
@Path( "/helloworld" )
public class HelloWorldResource {

private final GraphDatabaseService database;

public HelloWorldResource( @Context GraphDatabaseService database) {
  this.database = database;
}

@GET
@Produces( MediaType.TEXT_PLAIN )
@Path( "/{nodeId}" )
public Response hello( @PathParam( "nodeId" ) long nodeId ) {
    // Do stuff with the database
    return Response.status( Status.OK ).entity(
            ( "Hello World, nodeId=" + nodeId).getBytes() ).build();
}
}

用于编写插件扩展.

这篇关于使用 EmbeddedGraphDatabase 在服务器模式下访问 Neo4j?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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