Thursday, 7 June 2012

Access portal impl classes.

 Access portal impl classes.

If we want to access the portal-impl class we are not able to use it directly. 

For example if we want to use the RSSUtil class which is in portal-impl we are not able to access it.

To Over come this liferay comes with a solution which is portalclassinvoker.

Example: want to access getFeed() of the RSSUtil in the portal-impl which has String as parameter.

For this we are defining Method key which is used to access the method.

Here we passed the class name with the package,method name and the type of the parameter.In this accessing the getFeed method of the RSSUtil which has the String as a parameter.


final MethodKey GETFEEDS = new MethodKey("com.liferay.portlet.rss.util.RSSUtil", "getFeed",String.class);

 Now called the getFeed by using the PortalClassInvoker, in which we have passed three parameters,first is the if we want to create new instance  , second is method key and third is the parameter for the method we want to pass.Here the getFeed returns the ObjectValuePair<String, SyndFeed> type of the object.


ovp = (ObjectValuePair<String, SyndFeed>) PortalClassInvoker.invoke(false, GETFEEDS, "http://rss.news.yahoo.com/rss/tech"); 

That's  All Now u are able to access the portal-impl class.








No comments:

Post a Comment