Пример #1
0
  @Override
  public Object run(Session session, String dbName, Object... input) {

    if (input.length != 3) {
      throw new IllegalArgumentException("Expected input of length 3");
    }

    if (!(input[0] instanceof Object[])) {
      throw new IllegalArgumentException("Expected input[0] to be an Object array");
    }

    if (!(input[1] instanceof Task)) {
      throw new IllegalArgumentException("Expected input[1] to be a Task");
    }

    if (!(input[2] instanceof TaskManager)) {
      throw new IllegalArgumentException("Expected input[2] to be a TaskManager");
    }

    Object[] args = (Object[]) input[0];

    Task taskToRun = (Task) input[1];

    TaskManager taskMgr = (TaskManager) input[2];

    if (taskToRun == taskMgr.getInsertTask()) {
      return dfltTaskMgr.getMergeForInsertTask().run(session, dbName, args);
    } else if (taskToRun == taskMgr.getUpdateTask()) {
      return dfltTaskMgr.getMergeForUpdateTask().run(session, dbName, args);
    } else {
      return args;
    }
  }
  public SpringDataServiceManager(
      String configurationName,
      HibernateTemplate hibernateTemplate,
      PlatformTransactionManager txMgr) {

    this(
        configurationName,
        hibernateTemplate,
        txMgr,
        DefaultTaskManager.getInstance(),
        Collections.<String, String>emptyMap());
  }
Пример #3
0
/** @author Simon Toens */
public class PreProcessorRouterTask extends BaseTask implements Task {

  private static final DefaultTaskManager dfltTaskMgr = DefaultTaskManager.getInstance();

  @Override
  public Object run(Session session, String dbName, Object... input) {

    if (input.length != 3) {
      throw new IllegalArgumentException("Expected input of length 3");
    }

    if (!(input[0] instanceof Object[])) {
      throw new IllegalArgumentException("Expected input[0] to be an Object array");
    }

    if (!(input[1] instanceof Task)) {
      throw new IllegalArgumentException("Expected input[1] to be a Task");
    }

    if (!(input[2] instanceof TaskManager)) {
      throw new IllegalArgumentException("Expected input[2] to be a TaskManager");
    }

    Object[] args = (Object[]) input[0];

    Task taskToRun = (Task) input[1];

    TaskManager taskMgr = (TaskManager) input[2];

    if (taskToRun == taskMgr.getInsertTask()) {
      return dfltTaskMgr.getMergeForInsertTask().run(session, dbName, args);
    } else if (taskToRun == taskMgr.getUpdateTask()) {
      return dfltTaskMgr.getMergeForUpdateTask().run(session, dbName, args);
    } else {
      return args;
    }
  }

  @Override
  public String getName() {
    return "Built-in PreProcessor Router Task";
  }
}