« Back

Liferay modules communication

Company Blogs April 22, 2010 By Juan Fernández Staff

 

Hi guys:

when you start developing in Liferay you notice that there are many modules and libraries in its core, but there are not accessible from everywhere.

I recently found a problem developing an improvement for the workflow system (see http://issues.liferay.com/browse/LPS-8821), where I needed to use a class that I couldn't access... and I realized that I needed to know which concrete classes were reachable from where I was. 

I have done a little research and I've written a wiki article explaining this, and I have created a diagram to make it easier to understand:

diagram2

 

I hope it'll be useful for you, developers!

Regards

 

Juan Fernández

 

[IMPORTANT UPDATE: This has recently changed for the current Liferay version - 6.0.2. portal-service and portal-kernel have been merged, so that it's much easier now to develop. See http://issues.liferay.com/browse/LPS-9370 for further information]

Threaded Replies Author Date
Good article. I have found out that many utils... Sampsa Sohlman April 22, 2010 3:50 AM
Hey, so the kernel.util.PropsUtil via "... Jakub Liska October 6, 2010 4:37 PM
Hi Jakub If all applications would run under... Sampsa Sohlman October 7, 2010 5:43 AM
I understand this fact, what I meant was: why... Jakub Liska October 7, 2010 6:29 AM
I forgot considering the fact, that using... Jakub Liska October 7, 2010 12:40 PM
You are on correct track. PropsUtil is very... Sampsa Sohlman October 7, 2010 1:04 PM
The link to the wiki article is broken. The... Ismael Ferrer April 22, 2010 4:01 AM
Fixed! Thanks Ismael Juan Fernández April 22, 2010 4:03 AM
Nice feature! Thank you, Juan. It would be... Jonas Yuan April 22, 2010 8:56 AM
Hi Jonas: thanks for your comment. You have a... Juan Fernández April 22, 2010 9:01 AM
Sir, article is very good and wiki link... Bavithra Rajendran April 25, 2010 10:59 PM
Thanks Juan for informative blog Nidhi Singh April 27, 2010 4:35 AM
Hi Juan, You were helping me out for some... Balu Sasidharan October 21, 2010 5:46 AM
Sorry for posting the query here.I'm really... Balu Sasidharan October 21, 2010 5:49 AM
@Balu Sasidharan: I believe you should check... Binh Thanh Le November 29, 2010 8:46 AM

Good article.

I have found out that many utils can be called in from "portal-impl" using com.liferay.portal.kernel.util.PortalClassInvoker. Good example how to do this is com.liferay.portal.kernel.util.PropsUtil, which is delegating calls to com.liferay.portal.util.PropsUtil.
Posted on 4/22/10 3:50 AM.
The link to the wiki article is broken. The correct URL is
http://www.liferay.com/community/wiki/-/wiki/Main/Liferay+modules+communicatio­n
Posted on 4/22/10 4:01 AM.
Fixed! Thanks Ismael
Posted on 4/22/10 4:03 AM in reply to Ismael Ferrer.
Nice feature! Thank you, Juan.

It would be nice that you could add a practical example for CLP.
Posted on 4/22/10 8:56 AM.
Hi Jonas: thanks for your comment.
You have a wiki article I created explaining how to use CLP communication here: http://www.liferay.com/community/wiki/-/wiki/Main/Using+Class+Loader+Proxy+class­es+to+share+plugins+services
Posted on 4/22/10 9:01 AM in reply to Jonas Yuan.
Sir, article is very good and wiki link explained as how to use CLP communication. Thanks for the diagram as it made very easier to understand emoticon
Posted on 4/25/10 10:59 PM.
Thanks Juan for informative blog
Posted on 4/27/10 4:35 AM.
Hey,
so the kernel.util.PropsUtil via " PortalClassInvoker.invoke() > PortalClassLoaderUtil.getClassLoader() " gets liferayPortalClassloader for a moment just to load util.PropsUtil and call methods on it ?

I'm not sure I'f I get it, why wouldn't we then just get the liferayPortalClassloader from PortalClassLoaderUtil and load whatever class we'd wanted ?
Posted on 10/6/10 4:37 PM in reply to Sampsa Sohlman.
Hi Jakub

If all applications would run under same classloader there would be class version conflicts. Then you could safely use only classes provided by liferay and when they upgrade their libs you should too.

You would loose modularity.
Posted on 10/7/10 5:43 AM in reply to Jakub Liska.
I understand this fact, what I meant was: why this way of loading classes from root liferay context by LiferayPortalClassloader isn't used for 3rd party portlets, instead of using LiferayPortalClassloader as a primary (and the only one) classloader. Because usually when people do it, they just need to load a few classes from portal context, which could be easily done the way you described.
Posted on 10/7/10 6:29 AM in reply to Sampsa Sohlman.
I forgot considering the fact, that using another classloader (portal) is very restricted as to what we are calling, because the living object instances would have to be serialized and instantiated again in local context to be used. That's why portlets need to use Portal classloader if they want to use portal-impl classes. Is this the point ? In this case, could you please explain more specifically what did you mean by the first comment ? Thanks Sampsa
Posted on 10/7/10 12:40 PM in reply to Sampsa Sohlman.
You are on correct track. PropsUtil is very simple case because parameter and return classes are globally available. If I recall correct (might be mistaking at this point) - if the return values are interfaces which are availabe at portal-service.jar (and older portal-kernel.jar), you should be return those too with PortalClassInvoker.

Liferay has also more complex cross classloader features and instead of serializing objects they are using java's Proxy object feature. Look example BeanLocatorImpl. Hooks have been implemented by using Proxy objects.
Posted on 10/7/10 1:04 PM in reply to Jakub Liska.
Hi Juan,

You were helping me out for some previous issues .Thanks for all your help Please help me out in this .

I have one more problem decribed below

I have a web application and I changed it as a portlet by adding the required files
Now I want use the com.liferay.model.impl.UserImpl class in my WebApp.
When I used it I'm getting ClassNot found Exception.I added portal-impl.jar entry into liferay-plugin-package.prpeties file and started tomcat . Still I'm getting the same Exception.

I have tried severel methods to get rid of this problem ,But none of them seems to work.

I don't know where I'm going wrong? Its been 7 days I stuck with this problem.


Please help me out
I'm very much in need

Thanks
Posted on 10/21/10 5:46 AM.
Sorry for posting the query here.I'm really desperate with this problem.I couldn't find a solution
Posted on 10/21/10 5:49 AM in reply to Balu Sasidharan.
@Balu Sasidharan:
I believe you should check your classpath.
Posted on 11/29/10 8:46 AM in reply to Balu Sasidharan.