Reputation: 11257
In the following example, how to inject a class from third-party library? For example
@Stateless
class MyStatelessService
{
@Inject Gson gson;
...
}
I suppose that I must create some bean injector class responsible for all third party classes. How to do that?
Upvotes: 2
Views: 827
Reputation: 5792
You would have to create a specialized producer for the type you want to inject. Perfect example already exists for you - it is a Logger injection using the weld extensions.
@Inject
Logger log;
You can have a look into the weld extension here:
https://github.com/weld/extensions/blob/master/impl/src/main/java/org/jboss/weld/extensions/log/
and the Producer.java itself here:
Upvotes: 3