Skip to content

Commit 9b43a10

Browse files
committed
Introduce DatabaseSeedProvider and deprecated SeedProvider
1 parent 3ff4731 commit 9b43a10

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

modules/ROOT/pages/extending-neo4j/project-setup.adoc

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,59 @@ Include this dependency to build against the Neo4j-provided API:
156156

157157
=== Implement Java class
158158

159+
==== `DatabaseSeedProvider` label:new[Introduced in 5.26]
160+
161+
The `DatabaseSeedProvider` was introduced in 5.26 in favour of `SeedProvider` which is now deprecated.
162+
163+
[source, java]
164+
----
165+
import com.neo4j.dbms.seeding.DatabaseSeedProvider;
166+
167+
public class CustomDatabaseSeedProvider implements DatabaseSeedProvider {
168+
169+
@Override
170+
public boolean matches(String uri) {
171+
// Return true if uri is supported by this
172+
// provider.
173+
}
174+
175+
@Override
176+
public InputStream stream(
177+
String uri,
178+
Map<String, Object> options) throws IOException {
179+
// This method should obtain an input stream in an
180+
// implementation specific way.
181+
}
182+
183+
@Override
184+
public void inject(Dependencies dependencies) {
185+
// This method should provide implementation
186+
// specific dependencies to the provider.
187+
}
188+
189+
public static class CustomDependencies implements Dependencies {
190+
@Override
191+
public <T> T resolveDependency(Class<T> type) {
192+
// This method should resolve dependencies
193+
// required by the provider.
194+
}
195+
}
196+
}
197+
----
198+
199+
To implement the custom database seed provider, you must implement three methods on the top-level `DatabaseSeedProvider` interface.
200+
One method to match the URIs it can manage, one to stream backups or dumps from the given URI, and one to inject dependencies in the provider.
201+
Additionally you must implement one method on the nested `Dependencies` interface, to resolve any dependencies required by your seed provider implementation.
202+
203+
Typically, the match method uses the URI scheme (the part specified before the first colon) to determine whether it can support the given URI or not.
204+
For example, `file`, `http`, `https` etc.
205+
206+
The stream method should implement a scheme-specific way to obtain an input stream for the backup or dump.
207+
208+
Implementation specific seed configuration can be passed through from options specified in the `CREATE DATABASE` command using `seedConfig`.
209+
210+
==== `SeedProvider` label:deprecated[Deprecated in 5.26]
211+
159212
[source, java]
160213
----
161214
import com.neo4j.dbms.seeding.ParsedSeedProviderConfig;

0 commit comments

Comments
 (0)