@Test public void testIsSpringBatchJob() throws SpringHadoopAdminWorkflowException { File folder = new File("src/test/resources/org/springframework/data/hadoop/admin/util/test"); WorkflowArtifacts artifacts = HadoopWorkflowUtils.getWorkflowArtifacts(folder); 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", }); boolean isSpringBatchJob = HadoopWorkflowUtils.isSpringBatchJob(context, artifacts); Assert.assertFalse(isSpringBatchJob); }
public static boolean isSpringBatchJob(ApplicationContext context, WorkflowArtifacts artifacts) throws SpringHadoopAdminWorkflowException { if (context == null) { logger.warn("root applicaton context is null"); throw new SpringHadoopAdminWorkflowException("root applicaton context is null"); } if (artifacts == null) { logger.warn("workflow artifacts is null"); throw new SpringHadoopAdminWorkflowException("workflow artifacts is null"); } boolean result = true; FileSystemApplicationContextFactory factory = new FileSystemApplicationContextFactory(); factory.setApplicationContext(context); factory.setBeanClassLoader(artifacts.getWorkflowClassLoader()); factory.setResource(artifacts.getWorkflowDescriptor()); ConfigurableApplicationContext appContext = factory.createApplicationContext(); Map<String, Job> springBatchJobs = appContext.getBeansOfType(Job.class); result = springBatchJobs.size() > 0; return result; }
HadoopWorkflowUtils { public static boolean isSpringBatchJob(ApplicationContext context, WorkflowArtifacts artifacts) throws SpringHadoopAdminWorkflowException { if (context == null) { logger.warn("root applicaton context is null"); throw new SpringHadoopAdminWorkflowException("root applicaton context is null"); } if (artifacts == null) { logger.warn("workflow artifacts is null"); throw new SpringHadoopAdminWorkflowException("workflow artifacts is null"); } boolean result = true; FileSystemApplicationContextFactory factory = new FileSystemApplicationContextFactory(); factory.setApplicationContext(context); factory.setBeanClassLoader(artifacts.getWorkflowClassLoader()); factory.setResource(artifacts.getWorkflowDescriptor()); ConfigurableApplicationContext appContext = factory.createApplicationContext(); Map<String, Job> springBatchJobs = appContext.getBeansOfType(Job.class); result = springBatchJobs.size() > 0; return result; } }
HadoopWorkflowUtils { public static boolean isSpringBatchJob(ApplicationContext context, WorkflowArtifacts artifacts) throws SpringHadoopAdminWorkflowException { if (context == null) { logger.warn("root applicaton context is null"); throw new SpringHadoopAdminWorkflowException("root applicaton context is null"); } if (artifacts == null) { logger.warn("workflow artifacts is null"); throw new SpringHadoopAdminWorkflowException("workflow artifacts is null"); } boolean result = true; FileSystemApplicationContextFactory factory = new FileSystemApplicationContextFactory(); factory.setApplicationContext(context); factory.setBeanClassLoader(artifacts.getWorkflowClassLoader()); factory.setResource(artifacts.getWorkflowDescriptor()); ConfigurableApplicationContext appContext = factory.createApplicationContext(); Map<String, Job> springBatchJobs = appContext.getBeansOfType(Job.class); result = springBatchJobs.size() > 0; return result; }  }
HadoopWorkflowUtils { public static boolean isSpringBatchJob(ApplicationContext context, WorkflowArtifacts artifacts) throws SpringHadoopAdminWorkflowException { if (context == null) { logger.warn("root applicaton context is null"); throw new SpringHadoopAdminWorkflowException("root applicaton context is null"); } if (artifacts == null) { logger.warn("workflow artifacts is null"); throw new SpringHadoopAdminWorkflowException("workflow artifacts is null"); } boolean result = true; FileSystemApplicationContextFactory factory = new FileSystemApplicationContextFactory(); factory.setApplicationContext(context); factory.setBeanClassLoader(artifacts.getWorkflowClassLoader()); factory.setResource(artifacts.getWorkflowDescriptor()); ConfigurableApplicationContext appContext = factory.createApplicationContext(); Map<String, Job> springBatchJobs = appContext.getBeansOfType(Job.class); result = springBatchJobs.size() > 0; return result; }  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); }
HadoopWorkflowUtils { public static boolean isSpringBatchJob(ApplicationContext context, WorkflowArtifacts artifacts) throws SpringHadoopAdminWorkflowException { if (context == null) { logger.warn("root applicaton context is null"); throw new SpringHadoopAdminWorkflowException("root applicaton context is null"); } if (artifacts == null) { logger.warn("workflow artifacts is null"); throw new SpringHadoopAdminWorkflowException("workflow artifacts is null"); } boolean result = true; FileSystemApplicationContextFactory factory = new FileSystemApplicationContextFactory(); factory.setApplicationContext(context); factory.setBeanClassLoader(artifacts.getWorkflowClassLoader()); factory.setResource(artifacts.getWorkflowDescriptor()); ConfigurableApplicationContext appContext = factory.createApplicationContext(); Map<String, Job> springBatchJobs = appContext.getBeansOfType(Job.class); result = springBatchJobs.size() > 0; return result; }  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; }