Dienstag, 29. März 2016

Liferay Reflection

MethodKey methodKey =
new MethodKey(ClassResolverUtil.
resolveByPortalClassLoader("com.liferay.portal.util.WebAppPool"),
"get", new Class[]{Long.class,String.class});

PortletCategory portletCategory =(PortletCategory)PortalClassInvoker.invoke(false, methodKey, new Object[] {new Long(user.getCompanyId()),"PORTLET_CATEGORY"});


For custom bean defined in a portlet

Object obj =PortletBeanLocatorUtil.locate("Injector-portlet", "your.portlets.ItemTool");
Class<?> claz = obj.getClass();
Object instance = claz.newInstance();
claz.getMethod("methodName").invoke(instance);

Keine Kommentare:

Kommentar veröffentlichen