[
https://issues.apache.org/jira/browse/SOLR-8097?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15485839#comment-15485839
]
Shawn Heisey commented on SOLR-8097:
------------------------------------
bq. the Builder could be extended instead of extending the constructor itself
I tried to extend the client in this way, adding a new setting to the derived
client class and exposing it in the derived Builder, but ultimately it comes
down to the same problem -- the "all parameters" constructor, which is the only
one that will survive the transition to 7.0, cannot be used in an extended
Client/Builder because it's private.
One option, which I would not want to employ because it would involve duplicate
code that will quickly become stale, is to copy all the code in the private
constructor and paste it into the subclass, then add parameters as required and
use that constructor in a derived Builder class.
IMHO, the only sane option for experienced developers is to change the internal
constructor from private to protected, allowing derivative classes to utilize
it after doing class-specific setup. The developer will usually also need to
extend the internal Builder class to expose configuration of any new capability.
I like what we've done with the Builder, and I agree that after 7.0 removes
deprecated code, the constructor should not be public ... but making it private
is too limiting.
> Implement a builder pattern for constructing a Solrj client
> -----------------------------------------------------------
>
> Key: SOLR-8097
> URL: https://issues.apache.org/jira/browse/SOLR-8097
> Project: Solr
> Issue Type: Improvement
> Components: SolrJ
> Affects Versions: 6.0
> Reporter: Hrishikesh Gadre
> Assignee: Anshum Gupta
> Fix For: 6.1, master (7.0)
>
> Attachments: SOLR-8097.patch, SOLR-8097.patch, SOLR-8097.patch,
> SOLR-8097.patch, SOLR-8097.patch, SOLR-8097.patch, SOLR-8097.patch,
> SOLR-8097.patch, SOLR-8097.patch, SOLR-8097.patch, SOLR-8097.patch,
> SOLR-8097.patch, SOLR-8097.patch, SOLR-8097.patch
>
>
> Currently Solrj clients (e.g. CloudSolrClient) supports multiple constructors
> as follows,
> public CloudSolrClient(String zkHost)
> public CloudSolrClient(String zkHost, HttpClient httpClient)
> public CloudSolrClient(Collection<String> zkHosts, String chroot)
> public CloudSolrClient(Collection<String> zkHosts, String chroot, HttpClient
> httpClient)
> public CloudSolrClient(String zkHost, boolean updatesToLeaders)
> public CloudSolrClient(String zkHost, boolean updatesToLeaders, HttpClient
> httpClient)
> It is kind of problematic while introducing an additional parameters (since
> we need to introduce additional constructors). Instead it will be helpful to
> provide SolrClient Builder which can provide either default values or support
> overriding specific parameter.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]