[
https://issues.apache.org/jira/browse/ZOOKEEPER-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13062717#comment-13062717
]
Erez Mazor commented on ZOOKEEPER-92:
-------------------------------------
The problem with a FactoryBean for the Zookeeper object is that even if you set
the isSingleton to false the context will initialize a single bean (unless you
use Spring's
http://static.springsource.org/spring/docs/current/javadoc-api/org/springframework/beans/factory/config/ObjectFactoryCreatingFactoryBean.html),
which means you will have to obtain the appCtx reference in the code and
execute a getBean every time you want a new instance. The problem is that by
definition Zookeeper tells you to create a new Zookeeper instance after a
session has expired. Patrick's ZkClient (https://github.com/phunt/zkclient)
takes care of that for you so I went with the strategy of creating a factory
bean for ZkClient which can and should be a singleton (more on that here:
http://techo-ecco.com/blog/leader-election-with-zookeeper/). No idea if the
zkClient is going to be integrated into zookeeper trunk at some point, it is a
good abstraction to the connectivity aspect of Zookeeper. Regarding the deps
you can setup the factory bean stuff as a contrib project to prevent user from
having to depend on spring to get zookeeper.
> spring factory beans for ZooKeeper, ZooKeeperFacade and ZooKeeperServer
> -----------------------------------------------------------------------
>
> Key: ZOOKEEPER-92
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-92
> Project: ZooKeeper
> Issue Type: Sub-task
> Components: java client
> Reporter: james strachan
> Attachments: ZookeeperClientFactoryBean.java,
> ZookeeperServerFactoryBean.java, ZookeeperServerFactoryBean.java
>
>
> for folks who use Spring for Dependency Injection it might be handy to have a
> couple of factory beans to make it easier to create and configure the
> ZooKeeper, ZooKeeperFacade and ZooKeeperServer via the normal Spring
> dependency mechanism; via Java or XML code etc
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira