<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Is it possible to use CDI injection or Spring injection in Ivy Project?</title><link>https://answers.axonivy.com/questions/1496/is-it-possible-to-use-cdi-injection-or-spring-injection-in-ivy-project</link><description>&lt;p&gt;As the title said that I just wonder if we have some way to use CDI injection or Spring  in Ivy Project? FYI, I'm using Ivy Designer v6 s16.&lt;/p&gt;
&lt;p&gt;I did try to use CDI in my bean, it acknowledged the bean with &lt;strong&gt;@Named&lt;/strong&gt; annotation; however, the service that I try to inject return null (throwing InvokeException &amp;amp; NullPointerException). Though I know that Ivy Engine not yet supported CDI injection, I just want to know if there is any trick to go around it?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/1496/is-it-possible-to-use-cdi-injection-or-spring-injection-in-ivy-project" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 30 Sep 2015 16:14:22 -0400</lastBuildDate><item><title>Answer by Reto Weiss</title><link>https://answers.axonivy.com/questions/1496/is-it-possible-to-use-cdi-injection-or-spring-injection-in-ivy-project/1497</link><description>&lt;p&gt;As you said the Ivy Engine does not support CDI injection. &lt;/p&gt;
&lt;p&gt;If you try to setup and use Spring then I think you will get into troubles with incompatible jars and or versions.&lt;/p&gt;
&lt;p&gt;In Ivy internally we use Google Guice for DI. This allows us to use @Inject, @Named annotations. To get an instance of a root class you can use:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import ch.ivyteam.di.restricted.DiCore;
DiCore.getGlobalInjector().getInstance(YourService.class);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that this is not Public API and will be changed in future! If you want to use it I strongly suggest that you encapsulate the code in a project specific helper class, so that you only have to change the helper class once we change the internal API.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Reto Weiss</dc:creator><pubDate>Wed, 30 Sep 2015 16:14:22 -0400</pubDate><guid>https://answers.axonivy.com/questions/1496/is-it-possible-to-use-cdi-injection-or-spring-injection-in-ivy-project/1497</guid></item></channel></rss>