Foren
Usage of @Inject or @EJB within AssetRendererFactory
Martin Jonik, geändert vor 9 Jahren.
Usage of @Inject or @EJB within AssetRendererFactory
Junior Member Beiträge: 69 Beitrittsdatum: 14.08.12 Neueste Beiträge
Hi all.
I developed a custom JSF Portlet and now I want to make use of Liferays Kaleo Worklflow Engine.
I added my own AssetRendererFactory and my own WorkflowHandler to liferay-portlet.xml.
The problem is I cannot use my own Services from these classes. Neither EJB nor CDI works.
Any hints?
I developed a custom JSF Portlet and now I want to make use of Liferays Kaleo Worklflow Engine.
I added my own AssetRendererFactory and my own WorkflowHandler to liferay-portlet.xml.
The problem is I cannot use my own Services from these classes. Neither EJB nor CDI works.
Any hints?
public class CustomAssetRendererFactory extends BasesAssetRendererFactory {
@EJB
private CustomService ejbService;
@Inject
private CustomService cdiService;
}
Juan Gonzalez, geändert vor 9 Jahren.
RE: Usage of @Inject or @EJB within AssetRendererFactory
Liferay Legend Beiträge: 3089 Beitrittsdatum: 28.10.08 Neueste Beiträge
Hi Martin,
did you try reading this Wiki entry about developing CDI portlets?
https://www.liferay.com/community/wiki/-/wiki/Main/Developing+JSF+Portlets+with+CDI
did you try reading this Wiki entry about developing CDI portlets?
https://www.liferay.com/community/wiki/-/wiki/Main/Developing+JSF+Portlets+with+CDI
Neil Griffin, geändert vor 9 Jahren.
RE: Usage of @Inject or @EJB within AssetRendererFactory (Antwort)
Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Also, please refer to my comment about CDIBeanManagerUtil in the thread titled CDI injection in 6.2 CE Tomcat.
Martin Jonik, geändert vor 9 Jahren.
RE: Usage of @Inject or @EJB within AssetRendererFactory
Junior Member Beiträge: 69 Beitrittsdatum: 14.08.12 Neueste Beiträge
Thank you, Neil. Works brilliant after I wrapped the EJB into a CDI bean.
It is also possible to make a normal InitialContext().lookup() call but anyway it would be nice to make use of all the annotations.
It is also possible to make a normal InitialContext().lookup() call but anyway it would be nice to make use of all the annotations.
Neil Griffin, geändert vor 9 Jahren.
RE: Usage of @Inject or @EJB within AssetRendererFactory
Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Martin,
When you get a chance, could you provide updated code that shows how you wrapped the EJB into a CDI bean? I would be interested to see that.
Thank you,
Neil
When you get a chance, could you provide updated code that shows how you wrapped the EJB into a CDI bean? I would be interested to see that.
Thank you,
Neil
Martin Jonik, geändert vor 9 Jahren.
RE: Usage of @Inject or @EJB within AssetRendererFactory
Junior Member Beiträge: 69 Beitrittsdatum: 14.08.12 Neueste Beiträge
it's nothing special. just that way:
Maybe it would work that way as well...
@ApplicationScoped
public class CustomCdiBean {
@EJB
private CustomService;
public CustomService getService() {
return service;
}
}
public class CustomAssetRendererFactory extends BasesAssetRendererFactory {
public void anyMethod() {
CustomCdiBean bean = CDIBeanManagerUtil.getManagedBeanReference(CustomCdiBean.class);
CustomService service = bean.getService();
}
}
Maybe it would work that way as well...
@Stateless
@Local
@ApplicationScoped
public class CustomService() {
}
Neil Griffin, geändert vor 9 Jahren.
RE: Usage of @Inject or @EJB within AssetRendererFactory
Liferay Legend Beiträge: 2655 Beitrittsdatum: 27.07.05 Neueste Beiträge
Hi Martin,
Thanks for posting the code.
Kind Regards,
Neil
Thanks for posting the code.
Kind Regards,
Neil