按照neo4j网站上有关构建服务器扩展的说明,我无法将该插件显示在可用扩展名列表中。
这是我放在neo4j的插件目录中的jar的内容:
META-INF / MANIFEST.MF
META-INF /
META-INF /服务/
META-INF /服务/ org.neo4j.server.plugins.ServerPlugin
例如/
例如/ GetAll.class
example / GetAll.java
文件org.neo4j.server.plugins.ServerPlugin包含字符串example.GetAll。 GetAll.java的代码直接来自Neo4j网站(见下文)。任何帮助将不胜感激。
Neo4j verison:2.1.3(在OSX上与Homebrew一起安装 - 10.8.5)
代码:
package example;
import java.util.ArrayList;
import java.util.List;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.server.plugins.Description;
import org.neo4j.server.plugins.Name;
import org.neo4j.server.plugins.PluginTarget;
import org.neo4j.server.plugins.ServerPlugin;
import org.neo4j.server.plugins.Source;
import org.neo4j.tooling.GlobalGraphOperations;
@Description( "An extension to the Neo4j Server for getting all nodes or relationships" )
public class GetAll extends ServerPlugin
{
@Name( "get_all_nodes" )
@Description( "Get all nodes from the Neo4j graph database" )
@PluginTarget( GraphDatabaseService.class )
public Iterable<Node> getAllNodes( @Source GraphDatabaseService graphDb )
{
ArrayList<Node> nodes = new ArrayList<>();
try (Transaction tx = graphDb.beginTx())
{
for ( Node node : GlobalGraphOperations.at( graphDb ).getAllNodes() )
{
nodes.add( node );
}
tx.success();
}
return nodes;
}
@Description( "Get all relationships from the Neo4j graph database" )
@PluginTarget( GraphDatabaseService.class )
public Iterable<Relationship> getAllRelationships( @Source GraphDatabaseService graphDb )
{
List<Relationship> rels = new ArrayList<>();
try (Transaction tx = graphDb.beginTx())
{
for ( Relationship rel : GlobalGraphOperations.at( graphDb ).getAllRelationships() )
{
rels.add( rel );
}
tx.success();
}
return rels;
}
}
启动服务器的日志条目 - 的console.log:
2014-08-09 13:46:27.743+0000 INFO [API] Setting startup timeout to: 120000ms based on -1
2014-08-09 13:46:28.869+0000 INFO [API] Successfully started database
2014-08-09 13:46:28.925+0000 INFO [API] Starting HTTP on port :7474 with 80 threads available
2014-08-09 13:46:29.097+0000 INFO [API] Enabling HTTPS on port :7473
2014-08-09 13:46:29.184+0000 INFO [API] Mounted discovery module at [/]
2014-08-09 13:46:29.192+0000 INFO [API] Mounted REST API at [/db/data/]
2014-08-09 13:46:29.195+0000 INFO [API] Mounted management API at [/db/manage/]
2014-08-09 13:46:29.195+0000 INFO [API] Mounted webadmin at [/webadmin]
2014-08-09 13:46:29.195+0000 INFO [API] Mounted Neo4j Browser at [/browser]
2014-08-09 13:46:29.247+0000 INFO [API] Mounting static content at [/webadmin] from [webadmin-html]
2014-08-09 13:46:29.292+0000 INFO [API] Mounting static content at [/browser] from [browser]
14:46:29.295 [main] WARN o.e.j.server.handler.ContextHandler - o.e.j.s.ServletContextHandler@40e74e3{/,null,null} contextPath ends with /
14:46:29.295 [main] WARN o.e.j.server.handler.ContextHandler - Empty contextPath
14:46:29.298 [main] INFO org.eclipse.jetty.server.Server - jetty-9.0.5.v20130815
14:46:29.324 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.s.h.MovedContextHandler@3d8c2eeb{/,null,AVAILABLE}
14:46:29.409 [main] INFO o.e.j.w.StandardDescriptorProcessor - NO JSP Support for /webadmin, did not find org.apache.jasper.servlet.JspServlet
14:46:29.419 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@24c32994{/webadmin,jar:file:/usr/local/Cellar/neo4j/2.1.3/libexec/system/lib/neo4j-server-2.1.3-static-web.jar!/webadmin-html,AVAILABLE}
14:46:29.810 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@3582d322{/db/manage,null,AVAILABLE}
14:46:30.054 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@558d60a3{/db/data,null,AVAILABLE}
14:46:30.072 [main] INFO o.e.j.w.StandardDescriptorProcessor - NO JSP Support for /browser, did not find org.apache.jasper.servlet.JspServlet
14:46:30.073 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.w.WebAppContext@7aa6ede2{/browser,jar:file:/usr/local/Cellar/neo4j/2.1.3/libexec/system/lib/neo4j-browser-2.1.3.jar!/browser,AVAILABLE}
14:46:30.155 [main] INFO o.e.j.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@40e74e3{/,null,AVAILABLE}
14:46:30.164 [main] INFO o.e.jetty.server.ServerConnector - Started ServerConnector@2e85a1ef{HTTP/1.1}{localhost:7474}
14:46:30.520 [main] INFO o.e.jetty.server.ServerConnector - Started ServerConnector@d4a4b67{SSL-HTTP/1.1}{localhost:7473}
2014-08-09 13:46:30.520+0000 INFO [API] Server started on: http://localhost:7474/
2014-08-09 13:46:30.521+0000 INFO [API] Remote interface ready and available at [http://localhost:7474/]
neo4j.0.0.log:
Aug 09, 2014 2:49:59 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'
Aug 09, 2014 2:50:00 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'
Aug 09, 2014 2:50:00 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'