(888) 685-3101 ext. 2

Liferay has a robust service-layer API for developers to use. However, sometimes there are cases when you need to use methods in the internal Liferay API. You can’t use the internal API directly, but you can invoke it indirectly with the PortalClassInvoker class.

Caveat: Use of this class should be the exception rather than the rule. You should always attempt to find a solution using the Liferay service-level API before resorting to the use of PortalClassInvoker.

That said, here is a simple example:

Stack<JournalArticle> recentArticleStack = (Stack<JournalArticle>)
  PortalClassInvoker.invoke(
  false, "com.liferay.portlet.journal.util.JournalUtil", 
  "getRecentArticles", new String[] {"javax.portlet.PortletRequest"}, 
  actionRequest);
Here is the method signature for PortalClassInvoker.invoke( ) :
invoke(boolean newInstance, String className, String methodName, 
    String[] parameterTypeNames, Object... arguments)
It’s fairly self-explanatory. Be sure to fully qualify the class names.
More documentation is available here:

 

Share This