[ 
https://issues.apache.org/jira/browse/JCR-2687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12897657#action_12897657
 ] 

Jukka Zitting commented on JCR-2687:
------------------------------------

Agreed, composition over inheritance. This approach will also make it more 
convenient to provide useful constants for common cases like when all the 
created types should be nt:unstructured or nt:folder.

Instead of the separate getNodeType and nodeCreated parts, I'd use a more 
generic strategy interface like this:

    interface ChildNodeCreator {
        Node addChildNode(Node parent, String name)
            throws RepositoryException;
    }

This would allow more complete customization of the child node creation part. 
We could provide default implementations in constants like 
ChildNodeCreator.DEFAULT (that just does parent.addNode(name)) and 
.UNSTRUCTURED or .FOLDER (that set the specific type) as well as in factory 
methods like .withType(String primary, String... mixins) that allows a custom 
node type and any number of mixins to be specified for the child nodes.

> [PATCH] DeepNodeCreator utility
> -------------------------------
>
>                 Key: JCR-2687
>                 URL: https://issues.apache.org/jira/browse/JCR-2687
>             Project: Jackrabbit Content Repository
>          Issue Type: New Feature
>          Components: jackrabbit-jcr-commons
>    Affects Versions: 2.1.0
>            Reporter: Bertrand Delacretaz
>            Priority: Minor
>         Attachments: JCR-2687.patch
>
>
> The attached patch supplies a DeepNodeCreator utility, to create nodes and 
> their parents recursively.
> I've seen lots of such utilities flying around, it might be good to have a 
> basic one as standard.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to