5.5. Using the server with an embedded database

5.5.1. Providing custom configuration

Even if you are using the Neo4j Java API directly, for instance via EmbeddedGraphDatabase or HighlyAvailableGraphDatabase, you can still use the features the server provides.

The neo4j server exposes a class called WrappingNeoServerBootstrapper, which is capable of starting a neo4j server in the same process as your application, using an AbstractGraphDatabase instance you provide.

This gives your application, among other things, the REST API, statistics gathering and the web administration interface that comes with the server.

Usage example. 

WrappingNeoServerBootstrapper srv = new WrappingNeoServerBootstrapper( myDb );

srv.start();

// Server is now running in background threads

srv.stop();

5.5.1. Providing custom configuration

You can modify the server settings programmatically and, within reason, the same settings are available to you here as those outlined in the Server Configuration chapter.

The settings that are not available (or rather, that are ignored) are those that concern the underlying database, such as database location and database configuration path.

Custom config example. 

EmbeddedServerConfigurator config = new EmbeddedServerConfigurator( myDb );
config.configuration()
        .setProperty( Configurator.WEBSERVER_PORT_PROPERTY_KEY, 7575 );

WrappingNeoServerBootstrapper srv = new WrappingNeoServerBootstrapper( myDb, config );

srv.start();