Hi, IgniteSpringBean encapsulates lifecycle management and in general provides a more convenient way of Ignite instance creation. For more details please refer to the Java docs of the class.
Kind regards, Alex 10 июля 2017 г. 8:05 PM пользователь "Humphrey [via Apache Ignite Users]" < [email protected]> написал: > Thanks, actually I got both ways working. > But I prefer to use the IgniteSpringBean. > > In my DAO where Ignite is being used, I implemented the interfaces > InitializingBean and DisposableBean and used the IgniteSpringBean to get my > Cache. Now when my DAO is being initialized it initializes the > IgniteSpringBean as well. > > What is so special about the IgniteSpringBean vs a spring bean instance of > Ignition.ignite()? In the spring application context there will always be > one instance of the "ignite" bean (singleton). So all DAO who uses > @Autowired will receive the same instance of Ignite right? > > > @Configuration > @EnableWebMvc > @ComponentScan(basePackages = {"mypackage"}) > public class AppConfig { > > @Bean > public IgniteSpringBean igniteInstance() { > IgniteSpringBean ignite = new IgniteSpringBean(); > ignite.setConfiguration(getIgniteConfiguration()); > return ignite; > } > ... > > > And my DAO > > > @Component > public class myDAO implements InitializingBean, DisposableBean, AutoCloseable > { > > @Autowired > private IgniteSpringBean ignite; > .... > .... > > @Override > public void afterPropertiesSet() throws Exception { > myCache = ignite.cache(MY_CACHE_NAME); > sequence = ignite.atomicSequence(MY_CACHE_NAME, 1, true); > } > > @Override > public void destroy() throws Exception { > close(); > } > > > Before I had the methods now in the afterPropertiesSet in the constructor > of the Dao which gave error on startup. Now I have the constructor empty. > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > http://apache-ignite-users.70518.x6.nabble.com/Using- > AbstractAnnotationConfigDispatcherServletInitializer-tp14592p14600.html > To start a new topic under Apache Ignite Users, email > [email protected] > To unsubscribe from Apache Ignite Users, click here > <http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=1&code=YWxleGFuZGVyLmZlZG90b2ZmQGdtYWlsLmNvbXwxfC0xMzYxNTU0NTg=> > . > NAML > <http://apache-ignite-users.70518.x6.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > -- View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Using-AbstractAnnotationConfigDispatcherServletInitializer-tp14592p14621.html Sent from the Apache Ignite Users mailing list archive at Nabble.com.
