/**
   * Register listener.
   *
   * @param trigger the trigger
   */
  private void registerListener(Trigger trigger) {
    String jobKey = getJobKey(trigger);

    if (jobs.containsKey(jobKey)) {
      _log.fatal("Listener already exists for " + jobKey);
      jobs.get(jobKey);
    } else {
      SchedulerEventMessageListenerWrapper schedulerEventMessageListenerWrapper =
          new SchedulerEventMessageListenerWrapper();

      SchedulerEntryImpl schedulerEntry = new SchedulerEntryImpl();

      schedulerEntry.setTrigger(trigger);
      schedulerEntry.setDescription("sample description");
      schedulerEntry.setEventListenerClass(LogMessageListener.class.getName());

      schedulerEventMessageListenerWrapper.setSchedulerEntry(schedulerEntry);
      schedulerEventMessageListenerWrapper.setMessageListener(new LogMessageListener());

      _log.fatal(
          "Register listener for:: jobName["
              + trigger.getJobName()
              + "] groupName["
              + trigger.getGroupName()
              + "] startDate["
              + trigger.getStartDate()
              + "]");

      MessageBusUtil.registerMessageListener(
          DestinationNames.SCHEDULER_DISPATCH, schedulerEventMessageListenerWrapper);

      jobs.put(jobKey, schedulerEventMessageListenerWrapper);
    }
  }
  /* (non-Javadoc)
   * @see com.liferay.support.task.TaskManager#addTask(java.lang.String, java.lang.String, com.liferay.portal.kernel.scheduler.Trigger, java.lang.String)
   */
  public void addTask(String jobName, String groupName, Trigger trigger, String logMessage) {
    try {
      Message message = new Message();
      message.put("info", "Hello world!");
      message.put("logMessage", logMessage);

      SchedulerEntryImpl schedulerEntry = new SchedulerEntryImpl();

      schedulerEntry.setTrigger(trigger);
      schedulerEntry.setDescription("This is the schedulerEntry description");
      schedulerEntry.setEventListenerClass(LogMessageListener.class.getName());

      _log.fatal(
          "Scheduling new task:: jobName["
              + jobName
              + "] groupName["
              + PersistedTaskConstants.GROUP_NAME
              + "]");

      _schedulerEngineHelper.schedule(
          trigger,
          StorageType.PERSISTED,
          "This is an example of persisted task",
          DestinationNames.SCHEDULER_DISPATCH,
          message,
          10);

      registerListener(trigger);

    } catch (Exception e) {
      _log.error(e);
    }
  }