HadoopWorkflowUtils { public static void processAndRegisterWorkflow(File parentFolder, ApplicationContext context) { try { WorkflowArtifacts artifacts = processUploadedFile(parentFolder); if (artifacts == null) { return; } boolean isSpringBatchJob = HadoopWorkflowUtils.isSpringBatchJob(context, artifacts); logger.info("uploaded workflow artifacts is spring batch job? " + isSpringBatchJob); if (isSpringBatchJob) { registerSpringBatchJob(artifacts, context); } else { HadoopWorkflowUtils.createAndRegisterSpringBatchJob(context, artifacts); } } catch (Exception e) { logger.error("handle uploaded file failed", e); } }  static WorkflowArtifacts getWorkflowArtifacts(File workflowArtifactFolder); static String[] getWorkflowDescriptor(File workflowArtifactFolder); static boolean isValidWorkflow(List<FileInfo> files); static URL[] getWorkflowLibararies(File workflowArtifactFolder); static ClassLoader getWorkflowClassLoader(File workflowArtifactFolder); static boolean isSpringBatchJob(ApplicationContext context, WorkflowArtifacts artifacts); static void createAndRegisterSpringBatchJob(ApplicationContext context, final WorkflowArtifacts artifacts); static String generateSpringBatchJobName(final WorkflowArtifacts artifacts); static void unregisterSpringBatchJob(ApplicationContext context, String springBatchJobName); static String getWorkflowDescriptor(final WorkflowArtifacts artifacts); static void processAndRegisterWorkflow(File parentFolder, ApplicationContext context); static WorkflowArtifacts processUploadedFile(final File parentFolder); static void registerSpringBatchJob(WorkflowArtifacts artifacts, ApplicationContext context); static String fileURLPrefix; static String springHadoopJobPrefix; static String springHadoopTaskName; }
@Test public void testprocessAndRegisterWorkflow() { ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "classpath:org/springframework/data/hadoop/admin/env-context.xml", "classpath:org/springframework/data/hadoop/admin/data-source-context.xml", "classpath:org/springframework/data/hadoop/admin/execution-context.xml", }); File folder = new File("src/test/resources/org/springframework/data/hadoop/admin/workflow"); HadoopWorkflowUtils.processAndRegisterWorkflow(folder, context); JobRegistry jobRegistry = context.getBean("jobRegistry", JobRegistry.class); Collection<String> jobNames = jobRegistry.getJobNames(); Assert.assertEquals(1, jobNames.size()); Assert.assertTrue(jobNames.contains("wordcount-withscript-job")); }