Posts

Showing posts with the label CronText

Creating the scheduler dynamically in liferay

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...

Creating Scheduler in liferay - creating the scheduler dynamically based on the user inputs

As we know creating the static scheduler  is very easy as we  defined in the following url as    http://liferaytutorial.blogspot.com/2013/08/creating-scheduler-in-liferay.html Sometimes it may require to create dynamic schedule. Liferay had some created predefined class. Scheduling : In Messageboard portlet , Take a look at the MBMailingListLocalServiceImpl of  " protected void scheduleMailingList(MBMailingList mailingList) " method               Calendar startDate = CalendarFactoryUtil.getCalendar(); CronText cronText = new CronText(startDate, CronText.MINUTELY_FREQUENCY, mailingList.getInReadInterval()); Trigger trigger = new CronTrigger(groupName, groupName, startDate.getTime(), null, cronText.toString());                 SchedulerEngineUtil.schedule( trigger , StorageType.MEMORY_CLUSTERED, null, DestinationNames.MESSAGE_BOARDS_MAILING_LIST, mailingLi...