@Test public void testGetObject() throws Exception { File descriptor = new File("src/test/resources/org/springframework/data/hadoop/admin/workflow/support/context.xml"); File folder = descriptor.getParentFile(); HadoopWorkflowUtils.processUploadedFile(folder); WorkflowArtifacts artifacts = HadoopWorkflowUtils.getWorkflowArtifacts(folder); contextFactoryBean.setWorkflowArtifacts(new WorkflowArtifacts[] { artifacts }); ApplicationContext rootContext = 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", }); contextFactoryBean.setApplicationContext(rootContext); ApplicationContextFactory[] contextFactories = (ApplicationContextFactory[]) contextFactoryBean.getObject(); Assert.assertEquals(1, contextFactories.length); }
public Object getObject() throws Exception { if (workflowArtifacts == null) { return new ApplicationContextFactory[0]; } List<ApplicationContextFactory> applicationContextFactories = new ArrayList<ApplicationContextFactory>(); for (WorkflowArtifacts artifacts : workflowArtifacts) { logger.info("workflow artifacts:" + artifacts.getWorkflowDescriptor().getFile().getAbsolutePath() + ",classloader:" + artifacts.getWorkflowClassLoader()); if (HadoopWorkflowUtils.isSpringBatchJob(applicationContext, artifacts)) { logger.info("is spring batch job, will be loaded automatically"); FileSystemApplicationContextFactory factory = new FileSystemApplicationContextFactory(); factory.setCopyConfiguration(copyConfiguration); if (beanFactoryPostProcessorClasses != null) { factory.setBeanFactoryPostProcessorClasses(beanFactoryPostProcessorClasses); } if (beanPostProcessorExcludeClasses != null) { factory.setBeanPostProcessorExcludeClasses(beanPostProcessorExcludeClasses); } factory.setBeanClassLoader(artifacts.getWorkflowClassLoader()); factory.setResource(artifacts.getWorkflowDescriptor()); factory.setApplicationContext(applicationContext); applicationContextFactories.add(factory); } else { logger.info("not spring batch job, will create new spring batch job"); HadoopWorkflowUtils.createAndRegisterSpringBatchJob(applicationContext, artifacts); } } return applicationContextFactories.toArray(new ApplicationContextFactory[applicationContextFactories.size()]); }
FileSystemApplicationContextsFactoryBean implements FactoryBean<Object>, ApplicationContextAware { public Object getObject() throws Exception { if (workflowArtifacts == null) { return new ApplicationContextFactory[0]; } List<ApplicationContextFactory> applicationContextFactories = new ArrayList<ApplicationContextFactory>(); for (WorkflowArtifacts artifacts : workflowArtifacts) { logger.info("workflow artifacts:" + artifacts.getWorkflowDescriptor().getFile().getAbsolutePath() + ",classloader:" + artifacts.getWorkflowClassLoader()); if (HadoopWorkflowUtils.isSpringBatchJob(applicationContext, artifacts)) { logger.info("is spring batch job, will be loaded automatically"); FileSystemApplicationContextFactory factory = new FileSystemApplicationContextFactory(); factory.setCopyConfiguration(copyConfiguration); if (beanFactoryPostProcessorClasses != null) { factory.setBeanFactoryPostProcessorClasses(beanFactoryPostProcessorClasses); } if (beanPostProcessorExcludeClasses != null) { factory.setBeanPostProcessorExcludeClasses(beanPostProcessorExcludeClasses); } factory.setBeanClassLoader(artifacts.getWorkflowClassLoader()); factory.setResource(artifacts.getWorkflowDescriptor()); factory.setApplicationContext(applicationContext); applicationContextFactories.add(factory); } else { logger.info("not spring batch job, will create new spring batch job"); HadoopWorkflowUtils.createAndRegisterSpringBatchJob(applicationContext, artifacts); } } return applicationContextFactories.toArray(new ApplicationContextFactory[applicationContextFactories.size()]); } }
FileSystemApplicationContextsFactoryBean implements FactoryBean<Object>, ApplicationContextAware { public Object getObject() throws Exception { if (workflowArtifacts == null) { return new ApplicationContextFactory[0]; } List<ApplicationContextFactory> applicationContextFactories = new ArrayList<ApplicationContextFactory>(); for (WorkflowArtifacts artifacts : workflowArtifacts) { logger.info("workflow artifacts:" + artifacts.getWorkflowDescriptor().getFile().getAbsolutePath() + ",classloader:" + artifacts.getWorkflowClassLoader()); if (HadoopWorkflowUtils.isSpringBatchJob(applicationContext, artifacts)) { logger.info("is spring batch job, will be loaded automatically"); FileSystemApplicationContextFactory factory = new FileSystemApplicationContextFactory(); factory.setCopyConfiguration(copyConfiguration); if (beanFactoryPostProcessorClasses != null) { factory.setBeanFactoryPostProcessorClasses(beanFactoryPostProcessorClasses); } if (beanPostProcessorExcludeClasses != null) { factory.setBeanPostProcessorExcludeClasses(beanPostProcessorExcludeClasses); } factory.setBeanClassLoader(artifacts.getWorkflowClassLoader()); factory.setResource(artifacts.getWorkflowDescriptor()); factory.setApplicationContext(applicationContext); applicationContextFactories.add(factory); } else { logger.info("not spring batch job, will create new spring batch job"); HadoopWorkflowUtils.createAndRegisterSpringBatchJob(applicationContext, artifacts); } } return applicationContextFactories.toArray(new ApplicationContextFactory[applicationContextFactories.size()]); }  }
FileSystemApplicationContextsFactoryBean implements FactoryBean<Object>, ApplicationContextAware { public Object getObject() throws Exception { if (workflowArtifacts == null) { return new ApplicationContextFactory[0]; } List<ApplicationContextFactory> applicationContextFactories = new ArrayList<ApplicationContextFactory>(); for (WorkflowArtifacts artifacts : workflowArtifacts) { logger.info("workflow artifacts:" + artifacts.getWorkflowDescriptor().getFile().getAbsolutePath() + ",classloader:" + artifacts.getWorkflowClassLoader()); if (HadoopWorkflowUtils.isSpringBatchJob(applicationContext, artifacts)) { logger.info("is spring batch job, will be loaded automatically"); FileSystemApplicationContextFactory factory = new FileSystemApplicationContextFactory(); factory.setCopyConfiguration(copyConfiguration); if (beanFactoryPostProcessorClasses != null) { factory.setBeanFactoryPostProcessorClasses(beanFactoryPostProcessorClasses); } if (beanPostProcessorExcludeClasses != null) { factory.setBeanPostProcessorExcludeClasses(beanPostProcessorExcludeClasses); } factory.setBeanClassLoader(artifacts.getWorkflowClassLoader()); factory.setResource(artifacts.getWorkflowDescriptor()); factory.setApplicationContext(applicationContext); applicationContextFactories.add(factory); } else { logger.info("not spring batch job, will create new spring batch job"); HadoopWorkflowUtils.createAndRegisterSpringBatchJob(applicationContext, artifacts); } } return applicationContextFactories.toArray(new ApplicationContextFactory[applicationContextFactories.size()]); }  void setWorkflowArtifacts(WorkflowArtifacts[] workflowArtifacts); void setCopyConfiguration(boolean copyConfiguration); void setBeanFactoryPostProcessorClasses(Class<? extends BeanFactoryPostProcessor>[] beanFactoryPostProcessorClasses); void setBeanPostProcessorExcludeClasses(Class<?>[] beanPostProcessorExcludeClasses); Object getObject(); Class<?> getObjectType(); boolean isSingleton(); void setApplicationContext(ApplicationContext applicationContext); }
FileSystemApplicationContextsFactoryBean implements FactoryBean<Object>, ApplicationContextAware { public Object getObject() throws Exception { if (workflowArtifacts == null) { return new ApplicationContextFactory[0]; } List<ApplicationContextFactory> applicationContextFactories = new ArrayList<ApplicationContextFactory>(); for (WorkflowArtifacts artifacts : workflowArtifacts) { logger.info("workflow artifacts:" + artifacts.getWorkflowDescriptor().getFile().getAbsolutePath() + ",classloader:" + artifacts.getWorkflowClassLoader()); if (HadoopWorkflowUtils.isSpringBatchJob(applicationContext, artifacts)) { logger.info("is spring batch job, will be loaded automatically"); FileSystemApplicationContextFactory factory = new FileSystemApplicationContextFactory(); factory.setCopyConfiguration(copyConfiguration); if (beanFactoryPostProcessorClasses != null) { factory.setBeanFactoryPostProcessorClasses(beanFactoryPostProcessorClasses); } if (beanPostProcessorExcludeClasses != null) { factory.setBeanPostProcessorExcludeClasses(beanPostProcessorExcludeClasses); } factory.setBeanClassLoader(artifacts.getWorkflowClassLoader()); factory.setResource(artifacts.getWorkflowDescriptor()); factory.setApplicationContext(applicationContext); applicationContextFactories.add(factory); } else { logger.info("not spring batch job, will create new spring batch job"); HadoopWorkflowUtils.createAndRegisterSpringBatchJob(applicationContext, artifacts); } } return applicationContextFactories.toArray(new ApplicationContextFactory[applicationContextFactories.size()]); }  void setWorkflowArtifacts(WorkflowArtifacts[] workflowArtifacts); void setCopyConfiguration(boolean copyConfiguration); void setBeanFactoryPostProcessorClasses(Class<? extends BeanFactoryPostProcessor>[] beanFactoryPostProcessorClasses); void setBeanPostProcessorExcludeClasses(Class<?>[] beanPostProcessorExcludeClasses); Object getObject(); Class<?> getObjectType(); boolean isSingleton(); void setApplicationContext(ApplicationContext applicationContext);  }