HadoopWorkflowUtils { public static ClassLoader getWorkflowClassLoader(File workflowArtifactFolder) { ClassLoader parentLoader = HadoopWorkflowUtils.class.getClassLoader(); if (!workflowArtifactFolder.exists()) { return parentLoader; } URL[] urls = getWorkflowLibararies(workflowArtifactFolder); if (urls != null && urls.length > 0) { ClassLoader loader = new URLClassLoader(urls, parentLoader); return loader; } else { return parentLoader; } }  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 testGetWorkflowClassLoader() { File folder = new File("src/test/resources/org/springframework/data/hadoop/admin/util/test"); ClassLoader loader = HadoopWorkflowUtils.getWorkflowClassLoader(folder); Assert.assertNotNull(loader); boolean isURLClassLoader = false; if (loader instanceof URLClassLoader) { isURLClassLoader = true; } Assert.assertTrue(isURLClassLoader); ClassLoader parent = HadoopWorkflowUtils.class.getClassLoader(); Assert.assertNotSame(parent, loader); }
@Test public void testGetWorkflowClassLoader_withoutJars() { File folder = new File("src/test/resources/org/springframework/data/hadoop/admin/util/testWithoutJars"); ClassLoader loader = HadoopWorkflowUtils.getWorkflowClassLoader(folder); Assert.assertNotNull(loader); ClassLoader parent = HadoopWorkflowUtils.class.getClassLoader(); Assert.assertSame(parent, loader); }