Skip to content

Commit f7acfc5

Browse files
authored
Merge pull request #231 from neo4j/5-database-seed-provider
Introduce `DatabaseSeedProvider`
2 parents 3ff4731 + 87a9691 commit f7acfc5

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

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

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

157157
=== Implement Java class
158158

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

0 commit comments

Comments
 (0)