我在嵌入式 Java 中使用 neo4j。
我想通过我拥有的应用程序启动一个进程中的服务器管理实例。我无法在 Eclipse 中编译应用程序,因为它一开始就说
“WrappingNeoServerBootstrapper 无法解析为类型”。它无法解决下面的行
私有 WrappingNeoServerBootstrapper srv;
我很感激在这件事上的任何帮助。
请参阅下面的课程
import org.neo4j.graphalgo.GraphAlgoFactory;
import org.neo4j.graphalgo.PathFinder;
import org.neo4j.graphdb.DynamicRelationshipType;
import org.neo4j.graphdb.Expander;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Path;
import org.neo4j.kernel.Traversal;
import org.neo4j.server.plugins.Description;
import org.neo4j.server.plugins.Parameter;
import org.neo4j.server.plugins.PluginTarget;
import org.neo4j.server.plugins.ServerPlugin;
import org.neo4j.server.plugins.Source;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.graphdb.RelationshipType; // interface
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.GraphDatabaseService; // interface
import org.neo4j.graphdb.Transaction;
import org.neo4j.server.*;
public class DBFacade {
private static enum RelTypes implements RelationshipType { KNOWS }
private GraphDatabaseService graphDb;
private WrappingNeoServerBootstrapper srv;
public void WriteNode(java.lang.String message)
{
Transaction tx = graphDb.beginTx();
try
{
// Updating operations go here
Node node = graphDb.createNode();
node.setProperty( "message", message );
tx.success();
}
finally
{
tx.finish();
}
}
public void WriteRelationship(Node firstNode, Node secondNode, RelTypes type)
{
Relationship relationship = firstNode.createRelationshipTo( secondNode, RelTypes.KNOWS );
relationship.setProperty( "message", "brave Neo4j " );
}
public void CreateDB(java.lang.String path)
{
//newEmbeddedDatabase is an implemetation of GraphDatabaseService
this.graphDb = new GraphDatabaseFactory().newEmbeddedDatabase( path );
}
public void Close()
{
graphDb.shutdown();
}
public void StartAdminInstance()
{
// start web admin in process
srv = new WrappingNeoServerBootstrapper( this.graphDb );
srv.start(); // The server is now running //
//until we stop it:
srv.stop();
}
public void StopAdminInstance()
{
srv.stop();
}
}