Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
56 lines (41 sloc) 1.68 KB
#parse("velocity/tpl/inc/macros.vm")
package ${packageName};
import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.ClassLoaderProxy;
import com.liferay.portal.kernel.util.MethodCache;
import com.liferay.portal.kernel.util.ReferenceRegistry;
import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
public class ${className}Util {
private static Log _log = LogFactoryUtil.getLog(${className}Util.class);
private static ${className} service;
public static ${className} getService() {
_log.debug("Call to get service ${classLoader}");
if (service == null) {
Object object = PortalBeanLocatorUtil.locate(${className}.class.getName());
ClassLoader ${classLoader} = (ClassLoader) #if(${classLoader} == "portalClassLoader") PortalClassLoaderUtil.getClassLoader() #else PortalBeanLocatorUtil.locate("${classLoader}")#end;
ClassLoaderProxy clp = new ClassLoaderProxy(object, ${className}.class.getName(), ${classLoader});
service = new ${className}Clp(clp);
ReferenceRegistry.registerReference(${className}Util.class, "service");
MethodCache.remove(${className}.class);
}
return service;
}
public void setService(${className} _service) {
service = _service;
}
#foreach($method in $methods)
public static #method(${method.returnType} ${method.simpleName} ${method.parameters} ${method.thrownTypes})
{
#return(${method.returnType}) getService().${method.simpleName}( #args($method.parameters) );
}
#end
#if($initMethod)
public void $initMethod() {
if (_log.isDebugEnabled()) {
_log.debug("Created instance");
}
}
#end
}