PortalClassInvoker

Necessary classes:

com.liferay.portal.kernel.util.PortalClassInvoker
com.liferay.portal.kernel.util.ClassResolverUtil
com.liferay.portal.kernel.util.MethodKey
If you want to invoke classes that are not directly accessible because they are contained in the portal-impl, you can use the PortalClassInvoker. For example if you want to encrypt a password you can use the class PasswordEncryptorUtil. Here is a example how to invoke the method encrypt in PasswordEncryptorUtil:
MethodKey methodKey = 
new MethodKey(ClassResolverUtil.resolveByPortalClassLoader
("com.liferay.portal.security.pwd.PasswordEncryptorUtil"), "encrypt", String.class);
String result = 
(String)PortalClassInvoker.invoke( false, methodKey, "test");

Leave a Reply