From 9b43a1083ca520337a322d38a57616bc55c27853 Mon Sep 17 00:00:00 2001 From: Jack Waudby Date: Mon, 11 Nov 2024 10:51:45 +0000 Subject: [PATCH 1/8] Introduce DatabaseSeedProvider and deprecated SeedProvider --- .../pages/extending-neo4j/project-setup.adoc | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/modules/ROOT/pages/extending-neo4j/project-setup.adoc b/modules/ROOT/pages/extending-neo4j/project-setup.adoc index 919991b..930dac5 100644 --- a/modules/ROOT/pages/extending-neo4j/project-setup.adoc +++ b/modules/ROOT/pages/extending-neo4j/project-setup.adoc @@ -156,6 +156,59 @@ Include this dependency to build against the Neo4j-provided API: === Implement Java class +==== `DatabaseSeedProvider` label:new[Introduced in 5.26] + +The `DatabaseSeedProvider` was introduced in 5.26 in favour of `SeedProvider` which is now deprecated. + +[source, java] +---- +import com.neo4j.dbms.seeding.DatabaseSeedProvider; + +public class CustomDatabaseSeedProvider implements DatabaseSeedProvider { + + @Override + public boolean matches(String uri) { + // Return true if uri is supported by this + // provider. + } + + @Override + public InputStream stream( + String uri, + Map options) throws IOException { + // This method should obtain an input stream in an + // implementation specific way. + } + + @Override + public void inject(Dependencies dependencies) { + // This method should provide implementation + // specific dependencies to the provider. + } + + public static class CustomDependencies implements Dependencies { + @Override + public T resolveDependency(Class type) { + // This method should resolve dependencies + // required by the provider. + } + } +} +---- + +To implement the custom database seed provider, you must implement three methods on the top-level `DatabaseSeedProvider` interface. +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. +Additionally you must implement one method on the nested `Dependencies` interface, to resolve any dependencies required by your seed provider implementation. + +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. +For example, `file`, `http`, `https` etc. + +The stream method should implement a scheme-specific way to obtain an input stream for the backup or dump. + +Implementation specific seed configuration can be passed through from options specified in the `CREATE DATABASE` command using `seedConfig`. + +==== `SeedProvider` label:deprecated[Deprecated in 5.26] + [source, java] ---- import com.neo4j.dbms.seeding.ParsedSeedProviderConfig; From bd78e3278f612ead3eabb4988842bd500c5dc6be Mon Sep 17 00:00:00 2001 From: Jack Waudby <33488812+jackwaudby@users.noreply.github.com> Date: Wed, 13 Nov 2024 10:59:33 +0000 Subject: [PATCH 2/8] Update modules/ROOT/pages/extending-neo4j/project-setup.adoc Co-authored-by: NataliaIvakina <82437520+NataliaIvakina@users.noreply.github.com> --- modules/ROOT/pages/extending-neo4j/project-setup.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ROOT/pages/extending-neo4j/project-setup.adoc b/modules/ROOT/pages/extending-neo4j/project-setup.adoc index 930dac5..f7b5f38 100644 --- a/modules/ROOT/pages/extending-neo4j/project-setup.adoc +++ b/modules/ROOT/pages/extending-neo4j/project-setup.adoc @@ -156,7 +156,8 @@ Include this dependency to build against the Neo4j-provided API: === Implement Java class -==== `DatabaseSeedProvider` label:new[Introduced in 5.26] +[role=label--new-5.26] +==== `DatabaseSeedProvider` The `DatabaseSeedProvider` was introduced in 5.26 in favour of `SeedProvider` which is now deprecated. From ba315641b1b1ad27a2651a0c3a4862670697a743 Mon Sep 17 00:00:00 2001 From: Jack Waudby <33488812+jackwaudby@users.noreply.github.com> Date: Wed, 13 Nov 2024 10:59:43 +0000 Subject: [PATCH 3/8] Update modules/ROOT/pages/extending-neo4j/project-setup.adoc Co-authored-by: NataliaIvakina <82437520+NataliaIvakina@users.noreply.github.com> --- modules/ROOT/pages/extending-neo4j/project-setup.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/extending-neo4j/project-setup.adoc b/modules/ROOT/pages/extending-neo4j/project-setup.adoc index f7b5f38..584096f 100644 --- a/modules/ROOT/pages/extending-neo4j/project-setup.adoc +++ b/modules/ROOT/pages/extending-neo4j/project-setup.adoc @@ -199,7 +199,7 @@ public class CustomDatabaseSeedProvider implements DatabaseSeedProvider { To implement the custom database seed provider, you must implement three methods on the top-level `DatabaseSeedProvider` interface. 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. -Additionally you must implement one method on the nested `Dependencies` interface, to resolve any dependencies required by your seed provider implementation. +Additionally, you must implement a method on the nested `Dependencies` interface to resolve any dependencies required by your seed provider implementation. 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. For example, `file`, `http`, `https` etc. From e989cd2e4aab7d00a4c3b2f552840e69af28a871 Mon Sep 17 00:00:00 2001 From: Jack Waudby <33488812+jackwaudby@users.noreply.github.com> Date: Wed, 13 Nov 2024 10:59:50 +0000 Subject: [PATCH 4/8] Update modules/ROOT/pages/extending-neo4j/project-setup.adoc Co-authored-by: NataliaIvakina <82437520+NataliaIvakina@users.noreply.github.com> --- modules/ROOT/pages/extending-neo4j/project-setup.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/extending-neo4j/project-setup.adoc b/modules/ROOT/pages/extending-neo4j/project-setup.adoc index 584096f..fb9b294 100644 --- a/modules/ROOT/pages/extending-neo4j/project-setup.adoc +++ b/modules/ROOT/pages/extending-neo4j/project-setup.adoc @@ -159,7 +159,7 @@ Include this dependency to build against the Neo4j-provided API: [role=label--new-5.26] ==== `DatabaseSeedProvider` -The `DatabaseSeedProvider` was introduced in 5.26 in favour of `SeedProvider` which is now deprecated. +In Neo4j 5.26, the `DatabaseSeedProvider` was introduced to replace the now-deprecated `SeedProvider`. [source, java] ---- From e0c55a430fe3e27b5b42794144ffcc381ab86f10 Mon Sep 17 00:00:00 2001 From: Jack Waudby <33488812+jackwaudby@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:00:12 +0000 Subject: [PATCH 5/8] Update modules/ROOT/pages/extending-neo4j/project-setup.adoc Co-authored-by: NataliaIvakina <82437520+NataliaIvakina@users.noreply.github.com> --- modules/ROOT/pages/extending-neo4j/project-setup.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ROOT/pages/extending-neo4j/project-setup.adoc b/modules/ROOT/pages/extending-neo4j/project-setup.adoc index fb9b294..a2f7d8c 100644 --- a/modules/ROOT/pages/extending-neo4j/project-setup.adoc +++ b/modules/ROOT/pages/extending-neo4j/project-setup.adoc @@ -208,7 +208,8 @@ The stream method should implement a scheme-specific way to obtain an input stre Implementation specific seed configuration can be passed through from options specified in the `CREATE DATABASE` command using `seedConfig`. -==== `SeedProvider` label:deprecated[Deprecated in 5.26] +[role=label--deprecated-5.26] +==== `SeedProvider` [source, java] ---- From 1c1f7da5adef921ea8a5a005957949c7a36f79ae Mon Sep 17 00:00:00 2001 From: Jack Waudby <33488812+jackwaudby@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:00:51 +0000 Subject: [PATCH 6/8] Update modules/ROOT/pages/extending-neo4j/project-setup.adoc Co-authored-by: NataliaIvakina <82437520+NataliaIvakina@users.noreply.github.com> --- modules/ROOT/pages/extending-neo4j/project-setup.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/extending-neo4j/project-setup.adoc b/modules/ROOT/pages/extending-neo4j/project-setup.adoc index a2f7d8c..016e82e 100644 --- a/modules/ROOT/pages/extending-neo4j/project-setup.adoc +++ b/modules/ROOT/pages/extending-neo4j/project-setup.adoc @@ -206,7 +206,7 @@ For example, `file`, `http`, `https` etc. The stream method should implement a scheme-specific way to obtain an input stream for the backup or dump. -Implementation specific seed configuration can be passed through from options specified in the `CREATE DATABASE` command using `seedConfig`. +Implementation-specific seed configuration can be passed through from options specified in the `CREATE DATABASE` command using `seedConfig`. [role=label--deprecated-5.26] ==== `SeedProvider` From c471558ba235968bde7bb65b6d3b9d579e074013 Mon Sep 17 00:00:00 2001 From: Jack Waudby <33488812+jackwaudby@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:00:58 +0000 Subject: [PATCH 7/8] Update modules/ROOT/pages/extending-neo4j/project-setup.adoc Co-authored-by: NataliaIvakina <82437520+NataliaIvakina@users.noreply.github.com> --- modules/ROOT/pages/extending-neo4j/project-setup.adoc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/ROOT/pages/extending-neo4j/project-setup.adoc b/modules/ROOT/pages/extending-neo4j/project-setup.adoc index 016e82e..2107647 100644 --- a/modules/ROOT/pages/extending-neo4j/project-setup.adoc +++ b/modules/ROOT/pages/extending-neo4j/project-setup.adoc @@ -198,7 +198,10 @@ public class CustomDatabaseSeedProvider implements DatabaseSeedProvider { ---- To implement the custom database seed provider, you must implement three methods on the top-level `DatabaseSeedProvider` interface. -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. +* A method to match the URIs that the provider can manage. +* A method to stream backups or dumps from a specified URI. +* A method to inject dependencies in the provider. + Additionally, you must implement a method on the nested `Dependencies` interface to resolve any dependencies required by your seed provider implementation. 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. From 87a96913841bb95589f02c22d38e01e257a4d21d Mon Sep 17 00:00:00 2001 From: Jack Waudby <33488812+jackwaudby@users.noreply.github.com> Date: Wed, 13 Nov 2024 11:01:03 +0000 Subject: [PATCH 8/8] Update modules/ROOT/pages/extending-neo4j/project-setup.adoc Co-authored-by: NataliaIvakina <82437520+NataliaIvakina@users.noreply.github.com> --- modules/ROOT/pages/extending-neo4j/project-setup.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/ROOT/pages/extending-neo4j/project-setup.adoc b/modules/ROOT/pages/extending-neo4j/project-setup.adoc index 2107647..87746ea 100644 --- a/modules/ROOT/pages/extending-neo4j/project-setup.adoc +++ b/modules/ROOT/pages/extending-neo4j/project-setup.adoc @@ -197,7 +197,8 @@ public class CustomDatabaseSeedProvider implements DatabaseSeedProvider { } ---- -To implement the custom database seed provider, you must implement three methods on the top-level `DatabaseSeedProvider` interface. +To implement the custom database seed provider, you must define three methods on the top-level `DatabaseSeedProvider` interface: + * A method to match the URIs that the provider can manage. * A method to stream backups or dumps from a specified URI. * A method to inject dependencies in the provider.