Foros de discusión
Usage of @Inject or @EJB within AssetRendererFactory
Martin Jonik, modificado hace 9 años.
Usage of @Inject or @EJB within AssetRendererFactory
Junior Member Mensajes: 69 Fecha de incorporación: 14/08/12 Mensajes recientes
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, modificado hace 9 años.
RE: Usage of @Inject or @EJB within AssetRendererFactory
Liferay Legend Mensajes: 3089 Fecha de incorporación: 28/10/08 Mensajes recientes
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, modificado hace 9 años.
RE: Usage of @Inject or @EJB within AssetRendererFactory (Respuesta)
Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
Also, please refer to my comment about CDIBeanManagerUtil in the thread titled CDI injection in 6.2 CE Tomcat.
Martin Jonik, modificado hace 9 años.
RE: Usage of @Inject or @EJB within AssetRendererFactory
Junior Member Mensajes: 69 Fecha de incorporación: 14/08/12 Mensajes recientes
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, modificado hace 9 años.
RE: Usage of @Inject or @EJB within AssetRendererFactory
Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
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, modificado hace 9 años.
RE: Usage of @Inject or @EJB within AssetRendererFactory
Junior Member Mensajes: 69 Fecha de incorporación: 14/08/12 Mensajes recientes
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, modificado hace 9 años.
RE: Usage of @Inject or @EJB within AssetRendererFactory
Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
Hi Martin,
Thanks for posting the code.
Kind Regards,
Neil
Thanks for posting the code.
Kind Regards,
Neil