-
Improvement
-
Resolution: Won't Do
-
Neutral
-
None
-
5.3.7
-
-
Yes
-
Empty show more show less
Hi. Whenever I use this great class, I miss a feature that could easily be added with no harm.
--> Make it possible to override the NodeOperations by a subclass.
Just add a (protected?) getter for the operations field and use it in the doExecute method. Like this:
@Override protected void doExecute(InstallContext ctx) throws RepositoryException, TaskExecutionException { final Node root = getRootNode(ctx); final ErrorHandler errorHandler = newErrorHandler(ctx); final NodeBuilder nodeBuilder = new NodeBuilder(errorHandler, root, getOperations()); try { nodeBuilder.exec(); } catch (NodeOperationException e) { throw new TaskExecutionException(e.getMessage(), e); } } protected NodeOperation[] getOperations() { return operations; }
This little change enables users to override the getter an build node operations with more complex logic if needed. The problem actually is, that in constructors you cannot use instance methods yet. So if you want to generate part of your NodeOperations in a nicely separated method, you have to make that method static and break the possibility to override it again.
Cheers,
Stefan
Acceptance criteria