@@ -133,3 +133,79 @@ Once the procedure has been deployed to the _plugins_ directory of each Neo4j in
133133</build>
134134----
135135
136+ [[extending-neo4j-plugin-seed-provider]]
137+ == Implement custom seed providers
138+
139+ The _Seed from URI_ feature provides the ability to dynamically discover additional seed provider implementations from the class path.
140+
141+ Seed providers should be implemented in Java and this guide provides instructions on how to do this using Maven as the build tool.
142+
143+ === Set up a Maven project
144+
145+ Include this dependency to build against the Neo4j-provided API:
146+
147+ [source, xml, subs="attributes, specialcharacters"]
148+ ----
149+ <dependency>
150+ <groupId>com.neo4j</groupId>
151+ <artifactId>neo4j-dbms-api</artifactId>
152+ <version>${project.version}</version>
153+ <scope>compile</scope>
154+ </dependency>
155+ ----
156+
157+ === Implement Java class
158+
159+ [source, java]
160+ ----
161+ import com.neo4j.dbms.seeding.ParsedSeedProviderConfig;
162+ import com.neo4j.dbms.seeding.SeedProvider;
163+
164+ public class CustomSeedProvider extends SeedProvider {
165+
166+ public boolean matches(String uri) {
167+ // return true if uri is supported by this
168+ // provider
169+ }
170+
171+ public Path download(
172+ String uri,
173+ Optional<String> credentials,
174+ Optional<String> config,
175+ Path destinationFolder ) throws Exception {
176+ // This method should obtain the downloaded in an
177+ // implementation specific way and copy it to a
178+ // file within the destinationFolder directory.
179+ }
180+ }
181+ ----
182+
183+ To implement the custom seed provider, you must implement two methods.
184+ One method to match the URIs it can manage and one to download backups or dumps from the given URI.
185+
186+ 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.
187+ For example, `file`, `http`, `https` etc.
188+
189+ The download method should implement a scheme-specific way to obtain the backup or dump and place it into a file in the supplied destination folder.
190+ It should then return the path of the created file.
191+
192+ Both credentials and configurations are passed through from options specified in the `CREATE DATABASE` command.
193+ `ParsedSeedProviderConfig` provides a convenient way to parse and access the comma-separated configuration string.
194+
195+ === Deploy
196+
197+ Build a jar file from Maven and place this onto the Neo4j classpath.
198+
199+ The jar must include a META-INF file to enable discovery of the providers with the path:
200+
201+ [source, none]
202+ ----
203+ /META_INF/services/com.neo4j.dbms.seeding.SeedProvider
204+ ----
205+
206+ It should be a plain text file with one line for each provider contained within the jar, the line should contain the fully qualified name of the provider class.
207+
208+ [NOTE]
209+ ====
210+ If you need assistance with custom seed providers, please contact Professional Services.
211+ ====
0 commit comments