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.

I did try to use CDI in my bean, it acknowledged the bean with @Named annotation; however, the service that I try to inject return null (throwing InvokeException & 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?

asked 30.09.2015 at 09:27

ToanLC's gravatar image

ToanLC
(suspended)
accept rate: 16%


As you said the Ivy Engine does not support CDI injection.

If you try to setup and use Spring then I think you will get into troubles with incompatible jars and or versions.

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:

import ch.ivyteam.di.restricted.DiCore;
DiCore.getGlobalInjector().getInstance(YourService.class);

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.

link

answered 30.09.2015 at 16:14

Reto%20Weiss's gravatar image

Reto Weiss ♦♦
4.9k202857
accept rate: 74%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×147

Asked: 30.09.2015 at 09:27

Seen: 1,889 times

Last updated: 30.09.2015 at 16:14