public QueueEntry addEntry(
      ProcessingQueue queue, String targetClass, String targetMethod, String arguments) {
    QueueEntry entry = QueueEntry.newQueueEntry(queue, targetClass, targetMethod, arguments);
    entryDao.save(entry);

    return entry;
  }
  public QueueEntry addEntry(
      String queueName, String targetClass, String targetMethod, String arguments) {
    ProcessingQueue queue = getOrCreateQueue(queueName);

    QueueEntry entry = QueueEntry.newQueueEntry(queue, targetClass, targetMethod, arguments);
    entryDao.save(entry);

    return entry;
  }
  @Transactional(propagation = Propagation.NOT_SUPPORTED)
  public void processQueue(ProcessingQueue queue) throws BaseException {
    List<QueueEntry> entries =
        getEntriesByEntryState(queue, Constants.QueueConstants.ENTRY_STATE_READY);
    for (QueueEntry entry : entries) {
      logger.info("processing entry:" + entry);
      String targetClass = entry.getTargetClass();
      String targetMethod = entry.getTargetMethod();
      String arguments = entry.getArguments();
      try {
        Class<?> clazz = Class.forName(targetClass);
        Class<?>[] interfaces = clazz.getInterfaces();
        Class<?> beanType = null;
        for (Class<?> itf : interfaces) {
          Method tempMethod = clazz.getMethod(targetMethod, String.class);
          if (tempMethod != null) { // 这里应该找到直接接口
            beanType = itf;
            break;
          }
        }
        Object invokeTester =
            SpringContextUtil.getBean(beanType); // 只能从spring容器获取实例,否则自动装配的bean不会实例化
        Method method = clazz.getMethod(targetMethod, String.class);
        method.invoke(invokeTester, arguments);
        // Method method =
        // ReflectionUtils.findMethod(clazz,targetMethod,String.class);
        // ReflectionUtils.invokeMethod(method,invokeTester, arguments);
      } catch (Exception e) {
        e.printStackTrace();
        throw new BaseException(e);
      }

      entry.setEntryState(Constants.QueueConstants.ENTRY_STATE_CLOSED);
      updateEntry(entry);

      Integer interval = queue.getExecuteInterval();
      try {
        logger.info("sleep period:" + interval);
        Thread.sleep(interval);
      } catch (InterruptedException e) {
        throw new BaseException(e);
      }
    }
  }
 public void updateEntry(QueueEntry entry) {
   Boolean delete = entry.getDeleteWhenExecuted();
   if (delete) {
     logger.info("deleting entry:" + entry);
     entryDao.delete(entry);
   } else {
     entryDao.save(entry);
     logger.info("update entry:" + entry);
   }
 }