Message Boards
How to Inject OSGi Dependencies in Custom Portlets in Liferay 7.1
ali yeganeh, modified 4 Years ago.
How to Inject OSGi Dependencies in Custom Portlets in Liferay 7.1
Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
I create 2 modules using Gradle-based Liferay projects ( moduleA and moduleB )
moduleB is a dependency for moduleA
And it works correctly
I can correctly call methods of moduleB in moduleA
But when make any change in moduleB methods, changes not applied after deploy
moduleB is a dependency for moduleA
And it works correctly
I can correctly call methods of moduleB in moduleA
But when make any change in moduleB methods, changes not applied after deploy
Attachments:
Christoph Rabel, modified 4 Years ago.
RE: How to Inject OSGi Dependencies in Custom Portlets in Liferay 7.1
Liferay Legend Posts: 1554 Join Date: 9/24/09 Recent Posts
Do you deploy module B?
How do you inject module B into module A? Or how do you instance it? Can you show a minimal example?
How do you inject module B into module A? Or how do you instance it? Can you show a minimal example?
ali yeganeh, modified 4 Years ago.
RE: How to Inject OSGi Dependencies in Custom Portlets in Liferay 7.1
Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Hi
Yes
After the settings I sent as an attachment in the previous post, i make an ordinary object and call my method
any change in moduleB methods not applied after deploy
Module B has the same behavior as before
but after deploy, i remove modules using telnet and then redeploy modules, it will be correct!!!
Yes
After the settings I sent as an attachment in the previous post, i make an ordinary object and call my method
any change in moduleB methods not applied after deploy
Module B has the same behavior as before
but after deploy, i remove modules using telnet and then redeploy modules, it will be correct!!!
Olaf Kock, modified 4 Years ago.
RE: How to Inject OSGi Dependencies in Custom Portlets in Liferay 7.1
Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Postsali yeganeh:
OSGi only will update @Reference(s) to @Component(s). If you introduce dependencies yourself, e.g. through instanciating an object, OSGi won't magically deploy (and garbage collect) a bundle as long as there are still references to it.
After the settings I sent as an attachment in the previous post, i make an ordinary object and call my method
any change in moduleB methods not applied after deploy
Module B has the same behavior as before
but after deploy, i remove modules using telnet and then redeploy modules, it will be correct!!!
I'm assuming that you're instantiating the object from module B yourself. Don't do that. If you let OSGi do the dependency management, it'll automatically restart the required modules.
ali yeganeh, modified 4 Years ago.
RE: How to Inject OSGi Dependencies in Custom Portlets in Liferay 7.1
Regular Member Posts: 148 Join Date: 5/1/19 Recent Posts
Hi Mr. Olaf Kock
You gave the perfect answer
Thank you very much
You gave the perfect answer
Thank you very much