Sometimes we have to know which liferay version we are using, so how can we know? We can know the liferay version in different ways. 1. Liferay has provided some utility methods to know the which liferay version we are using , Here is the utility method ReleaseInfo.getReleaseInfo() It prints this statement " Liferay Portal Community Edition 6.2 CE GA2 (Newton / Build 6201 / March 20, 2014) " as i am using community version it shoes as CE. 2. Also we can also identify by response headers as below screenshot. If your using the chrome, right click on the browser and click inscept element , and navigate to the network . you will see the URLS , click on the any url. 3. Also we can see during server startup as below statement Liferay Portal Community Edition 6.2 CE GA2 (Newton / Build 6201 / March 20, 2014)
In Liferay we can exceute the background task asynchrously. The Background Task framework allows the developers to create and manage any kind of tasks that need to be run in a separated thread without the need of knowing anything about JAVA threading or concurrency Here the code ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY); Map taskContextMap = null; String taskName = null; String servletContextNames [] = new String[1] ; Portlet portlet = PortletLocalServiceUtil.getPortletById(request.getAttribute(WebKeys.PORTLET_ID).toString()); servletContextNames[0] = portlet.getContextName(); try { BackgroundTaskLocalServiceUtil.addBackgroundTask(themeDisplay.getUserId(), themeDisplay.getScopeGroupId(), taskName, servletContextNames,TestBackgroundTaskExecutor.class, taskContextMap,new ServiceContext()); } catch (PortalException e) { e.printStackTrace(); } catch (SystemException e) { e.printStackTrace(); } ...
We can create the scheduler by defining the entries in the liferay-portlet.xml with specfying the only particular entries. what if scheduler what to change based on the user input. so here is the code, String cron = "0 0/1 * 1/1 * ? *"; Portlet portlet = PortletLocalServiceUtil.getPortletById("new_WAR_UserSearchportlet"); Trigger trigger = null; try { trigger = TriggerFactoryUtil.buildTrigger(TriggerType.CRON, Scheduler.class.getName(), Scheduler.class.getName(), new Date(), null, cron); } catch (SchedulerException e) { e.printStackTrace(); } Message message = new Message(); message.put(SchedulerEngine.CONTEXT_PATH, portlet.getContextPath()); message.put(SchedulerEngine.MESSAGE_LISTENER_CLASS_NAME, Scheduler.class.getName()); message.put(SchedulerEngine.PORTLET_ID, portlet.getPortletId()); try { SchedulerEngineUtil.schedule(trigger, StorageType.PERSISTED, "", "liferay/scheduler_dispatch", mes...
<3
ReplyDelete