List of usage examples for com.liferay.portal.kernel.scheduler StorageType MEMORY_CLUSTERED
StorageType MEMORY_CLUSTERED
To view the source code for com.liferay.portal.kernel.scheduler StorageType MEMORY_CLUSTERED.
Click Source Link
From source file:com.liferay.alloy.mvc.AlloyPortlet.java
License:Open Source License
@Override public void destroy() { for (BaseAlloyControllerImpl baseAlloyControllerImpl : _alloyControllers.values()) { Indexer indexer = baseAlloyControllerImpl.indexer; if (indexer != null) { IndexerRegistryUtil.unregister(indexer); }//from w w w . j a v a 2s .co m MessageListener controllerMessageListener = baseAlloyControllerImpl.controllerMessageListener; if (controllerMessageListener != null) { MessageBusUtil.removeDestination(baseAlloyControllerImpl.getControllerDestinationName()); } MessageListener schedulerMessageListener = baseAlloyControllerImpl.schedulerMessageListener; if (schedulerMessageListener != null) { try { SchedulerEngineHelperUtil.unschedule(baseAlloyControllerImpl.getSchedulerJobName(), baseAlloyControllerImpl.getMessageListenerGroupName(), StorageType.MEMORY_CLUSTERED); MessageBusUtil.removeDestination(baseAlloyControllerImpl.getSchedulerDestinationName()); } catch (Exception e) { _log.error(e, e); } } } }
From source file:com.liferay.alloy.mvc.BaseAlloyControllerImpl.java
License:Open Source License
protected void initMessageListener(String destinationName, MessageListener messageListener, boolean enableScheduler) { MessageBus messageBus = MessageBusUtil.getMessageBus(); Destination destination = messageBus.getDestination(destinationName); if (destination != null) { Set<MessageListener> messageListeners = destination.getMessageListeners(); for (MessageListener curMessageListener : messageListeners) { if (!(curMessageListener instanceof InvokerMessageListener)) { continue; }/*from w w w.j a v a 2s . c o m*/ InvokerMessageListener invokerMessageListener = (InvokerMessageListener) curMessageListener; curMessageListener = invokerMessageListener.getMessageListener(); if (messageListener == curMessageListener) { return; } Class<?> messageListenerClass = messageListener.getClass(); String messageListenerClassName = messageListenerClass.getName(); Class<?> curMessageListenerClass = curMessageListener.getClass(); if (!messageListenerClassName.equals(curMessageListenerClass.getName())) { continue; } try { if (enableScheduler) { SchedulerEngineHelperUtil.unschedule(getSchedulerJobName(), getMessageListenerGroupName(), StorageType.MEMORY_CLUSTERED); } MessageBusUtil.unregisterMessageListener(destinationName, curMessageListener); } catch (Exception e) { log.error(e, e); } break; } } else { SerialDestination serialDestination = new SerialDestination(); serialDestination.setName(destinationName); serialDestination.open(); MessageBusUtil.addDestination(serialDestination); } try { MessageBusUtil.registerMessageListener(destinationName, messageListener); if (enableScheduler) { SchedulerEngineHelperUtil.schedule(getSchedulerTrigger(), StorageType.MEMORY_CLUSTERED, null, destinationName, null, 0); } } catch (Exception e) { log.error(e, e); } }
From source file:com.liferay.portlet.messageboards.service.impl.MBMailingListLocalServiceImpl.java
License:Open Source License
protected void scheduleMailingList(MBMailingList mailingList) throws PortalException { String groupName = getSchedulerGroupName(mailingList); 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()); MailingListRequest mailingListRequest = new MailingListRequest(); mailingListRequest.setCompanyId(mailingList.getCompanyId()); mailingListRequest.setUserId(mailingList.getUserId()); mailingListRequest.setGroupId(mailingList.getGroupId()); mailingListRequest.setCategoryId(mailingList.getCategoryId()); mailingListRequest.setInProtocol(mailingList.getInProtocol()); mailingListRequest.setInServerName(mailingList.getInServerName()); mailingListRequest.setInServerPort(mailingList.getInServerPort()); mailingListRequest.setInUseSSL(mailingList.getInUseSSL()); mailingListRequest.setInUserName(mailingList.getInUserName()); mailingListRequest.setInPassword(mailingList.getInPassword()); mailingListRequest.setAllowAnonymous(mailingList.getAllowAnonymous()); SchedulerEngineUtil.schedule(trigger, StorageType.MEMORY_CLUSTERED, null, DestinationNames.MESSAGE_BOARDS_MAILING_LIST, mailingListRequest, 0); }
From source file:com.liferay.portlet.messageboards.service.impl.MBMailingListLocalServiceImpl.java
License:Open Source License
protected void unscheduleMailingList(MBMailingList mailingList) throws PortalException { String groupName = getSchedulerGroupName(mailingList); SchedulerEngineUtil.unschedule(groupName, StorageType.MEMORY_CLUSTERED); }
From source file:com.liferay.portlet.PortletBagFactory.java
License:Open Source License
protected void initScheduler(SchedulerEntry schedulerEntry) throws Exception { String propertyKey = schedulerEntry.getPropertyKey(); if (Validator.isNotNull(propertyKey)) { String triggerValue = null; if (_warFile) { triggerValue = getPluginPropertyValue(propertyKey); } else {/*from w w w.j av a2s. c o m*/ triggerValue = PrefsPropsUtil.getString(propertyKey); } if (_log.isDebugEnabled()) { _log.debug("Scheduler property key " + propertyKey + " has trigger value " + triggerValue); } if (Validator.isNull(triggerValue)) { throw new SchedulerException("Property key " + propertyKey + " requires a value"); } schedulerEntry.setTriggerValue(triggerValue); } SchedulerEngineUtil.schedule(schedulerEntry, StorageType.MEMORY_CLUSTERED, _classLoader, 0); }
From source file:com.liferay.sync.servlet.SyncServletContextListener.java
License:Open Source License
protected void scheduleDLFileVersionDiffMessageListener() { try {// w ww . j av a 2 s . co m Calendar calendar = CalendarFactoryUtil.getCalendar(); CronText cronText = new CronText(calendar, CronText.HOURLY_FREQUENCY, PortletPropsValues.SYNC_FILE_DIFF_CACHE_DELETE_INTERVAL); Trigger trigger = new CronTrigger(SyncDLFileVersionDiffMessageListener.class.getName(), SyncDLFileVersionDiffMessageListener.class.getName(), cronText.toString()); SchedulerEngineHelperUtil.schedule(trigger, StorageType.MEMORY_CLUSTERED, null, SyncDLFileVersionDiffMessageListener.DESTINATION_NAME, null, 0); } catch (Exception e) { _log.error(e, e); } }