Tabnine Logo
JsrXmlApplicationContext
Code IndexAdd Tabnine to your IDE (free)

How to use
JsrXmlApplicationContext
in
org.springframework.batch.core.jsr.configuration.xml

Best Java code snippets using org.springframework.batch.core.jsr.configuration.xml.JsrXmlApplicationContext (Showing top 20 results out of 315)

origin: spring-projects/spring-batch

public long start(String jobName, Properties params) throws JobStartException,
JobSecurityException {
  final JsrXmlApplicationContext batchContext = new JsrXmlApplicationContext(params);
  batchContext.setValidating(false);
    batchContext.load(batchXml);
    batchContext.load(jobXml);
  batchContext.registerBeanDefinition(JSR_JOB_CONTEXT_BEAN_NAME, beanDefinition);
    batchContext.setParent(baseContext);
  } else {
    batchContext.getBeanFactory().registerSingleton("jobExplorer", jobExplorer);
    batchContext.getBeanFactory().registerSingleton("jobRepository", jobRepository);
    batchContext.getBeanFactory().registerSingleton("jobParametersConverter", jobParametersConverter);
    batchContext.getBeanFactory().registerSingleton("transactionManager", transactionManager);
    batchContext.refresh();
  } catch (BeanCreationException e) {
    throw new JobStartException(e);
    String [] jobNames = batchContext.getBeanNamesForType(Job.class);
    if(batchContext.isActive()) {
      batchContext.close();
origin: spring-projects/spring-batch

  @Test
  @SuppressWarnings({"resource", "rawtypes"})
  public void testOverrideBeansLast() {
    JsrXmlApplicationContext context = new JsrXmlApplicationContext();
    Resource overrideXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/override_batch.xml");
    Resource batchXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/batch.xml");

    context.setValidating(false);
    context.load(batchXml, overrideXml);
    context.refresh();

    ItemProcessor processor = (ItemProcessor) context.getBean("itemProcessor");

    assertNotNull(processor);
    assertTrue(processor instanceof DummyItemProcessor);
    context.close();
  }
}
origin: spring-projects/spring-batch

  @Override
  public void run() {
    JsrJobContextFactoryBean factoryBean = null;
    try {
      factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME);
      factoryBean.setJobExecution(jobExecution);
      final Job job = batchContext.getBean(Job.class);
      semaphore.release();
      // Initialization of the JobExecution for job level dependencies
      jobRegistry.register(job, jobExecution);
      job.execute(jobExecution);
      jobRegistry.remove(jobExecution);
    }
    catch (Exception e) {
      exceptionHolder.add(e);
    } finally {
      if(factoryBean != null) {
        factoryBean.close();
      }
      batchContext.close();
      if(semaphore.availablePermits() == 0) {
        semaphore.release();
      }
    }
  }
});
origin: spring-projects/spring-batch

@SuppressWarnings("resource")
@Test
public void testGenerationOfBeanDefinitionsForMultipleReferences() throws Exception {
  JsrXmlApplicationContext applicationContext = new JsrXmlApplicationContext(new Properties());
  applicationContext.setValidating(false);
  applicationContext.load(new ClassPathResource("jsrBaseContext.xml"),
      new ClassPathResource("/META-INF/batch.xml"),
      new ClassPathResource("/META-INF/batch-jobs/jsrUniqueInstanceTests.xml"));
  applicationContext.refresh();
  assertTrue("exitStatusSettingStepListener bean definition not found", applicationContext.containsBeanDefinition("exitStatusSettingStepListener"));
  assertTrue("exitStatusSettingStepListener1 bean definition not found", applicationContext.containsBeanDefinition("exitStatusSettingStepListener1"));
  assertTrue("exitStatusSettingStepListener2 bean definition not found", applicationContext.containsBeanDefinition("exitStatusSettingStepListener2"));
  assertTrue("exitStatusSettingStepListener3 bean definition not found", applicationContext.containsBeanDefinition("exitStatusSettingStepListener3"));
  assertTrue("exitStatusSettingStepListenerClassBeanDefinition bean definition not found", applicationContext.containsBeanDefinition("org.springframework.batch.core.jsr.step.listener.ExitStatusSettingStepListener"));
  assertTrue("exitStatusSettingStepListener1ClassBeanDefinition bean definition not found", applicationContext.containsBeanDefinition("org.springframework.batch.core.jsr.step.listener.ExitStatusSettingStepListener1"));
  assertTrue("exitStatusSettingStepListener2ClassBeanDefinition bean definition not found", applicationContext.containsBeanDefinition("org.springframework.batch.core.jsr.step.listener.ExitStatusSettingStepListener2"));
  assertTrue("exitStatusSettingStepListener3ClassBeanDefinition bean definition not found", applicationContext.containsBeanDefinition("org.springframework.batch.core.jsr.step.listener.ExitStatusSettingStepListener3"));
  assertTrue("testBatchlet bean definition not found", applicationContext.containsBeanDefinition("testBatchlet"));
  assertTrue("testBatchlet1 bean definition not found", applicationContext.containsBeanDefinition("testBatchlet1"));
}
origin: spring-projects/spring-batch

  @Test
  @SuppressWarnings("resource")
  public void testWithProperties() {
    Properties properties = new Properties();
    properties.put("prop1key", "prop1val");

    JsrXmlApplicationContext applicationContext = new JsrXmlApplicationContext(properties);

    BeanDefinition beanDefinition = applicationContext.getBeanDefinition(JOB_PARAMETERS_BEAN_DEFINITION_NAME);
    Properties storedProperties = (Properties) beanDefinition.getConstructorArgumentValues().getGenericArgumentValue(Properties.class).getValue();

    assertNotNull("Properties should not be null", storedProperties);
    assertFalse("Properties not be empty", storedProperties.isEmpty());
    assertEquals("prop1val", storedProperties.getProperty("prop1key"));
  }
}
origin: spring-projects/spring-batch

@Test
public void testGetJobProperties() {
  Document document = getDocument("/META-INF/batch-jobs/jsrPropertyPreparseTestJob.xml");
  @SuppressWarnings("resource")
  JsrXmlApplicationContext applicationContext = new JsrXmlApplicationContext();
  JsrBeanDefinitionDocumentReader documentReader = new JsrBeanDefinitionDocumentReader(applicationContext);
  documentReader.initProperties(document.getDocumentElement());
  Properties documentJobProperties = documentReader.getJobProperties();
  assertNotNull(documentJobProperties);
  assertTrue("Wrong number of job properties", documentJobProperties.size() == 3);
  assertEquals("jobProperty1Value", documentJobProperties.getProperty("jobProperty1"));
  assertEquals("jobProperty1Value", documentJobProperties.getProperty("jobProperty2"));
  assertEquals("", documentJobProperties.getProperty("jobProperty3"));
}
origin: spring-projects/spring-batch

@Test
@SuppressWarnings("resource")
public void testGenerationOfSpringBeanDefinitionsForMultipleReferences() {
  JsrXmlApplicationContext applicationContext = new JsrXmlApplicationContext(new Properties());
  applicationContext.setValidating(false);
  applicationContext.load(new ClassPathResource("jsrBaseContext.xml"),
      new ClassPathResource("/META-INF/batch-jobs/jsrSpringInstanceTests.xml"));
  applicationContext.refresh();
  assertTrue("exitStatusSettingStepListener bean definition not found", applicationContext.containsBeanDefinition("exitStatusSettingStepListener"));
  assertTrue("scopedTarget.exitStatusSettingStepListener bean definition not found", applicationContext.containsBeanDefinition("scopedTarget.exitStatusSettingStepListener"));
  BeanDefinition exitStatusSettingStepListenerBeanDefinition = applicationContext.getBeanDefinition("scopedTarget.exitStatusSettingStepListener");
  assertTrue("step".equals(exitStatusSettingStepListenerBeanDefinition.getScope()));
  assertTrue("Should not contain bean definition for exitStatusSettingStepListener1", !applicationContext.containsBeanDefinition("exitStatusSettingStepListener1"));
  assertTrue("Should not contain bean definition for exitStatusSettingStepListener2", !applicationContext.containsBeanDefinition("exitStatusSettingStepListener2"));
  assertTrue("Should not contain bean definition for exitStatusSettingStepListener3", !applicationContext.containsBeanDefinition("exitStatusSettingStepListener3"));
  assertTrue("Should not contain bean definition for testBatchlet1", !applicationContext.containsBeanDefinition("testBatchlet1"));
  assertTrue("Should not contain bean definition for testBatchlet2", !applicationContext.containsBeanDefinition("testBatchlet2"));
  assertTrue("testBatchlet bean definition not found", applicationContext.containsBeanDefinition("testBatchlet"));
  BeanDefinition testBatchletBeanDefinition = applicationContext.getBeanDefinition("testBatchlet");
  assertTrue("singleton".equals(testBatchletBeanDefinition.getScope()));
}
origin: spring-projects/spring-batch

  @Override
  public void run() {
    JsrJobContextFactoryBean factoryBean = null;
    try {
      factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME);
      factoryBean.setJobExecution(jobExecution);
      final Job job = batchContext.getBean(Job.class);
      if(!job.isRestartable()) {
        throw new JobRestartException("Job " + jobName + " is not restartable");
      }
      semaphore.release();
      // Initialization of the JobExecution for job level dependencies
      jobRegistry.register(job, jobExecution);
      job.execute(jobExecution);
      jobRegistry.remove(jobExecution);
    }
    catch (Exception e) {
      exceptionHolder.add(e);
    } finally {
      if(factoryBean != null) {
        factoryBean.close();
      }
      batchContext.close();
      if(semaphore.availablePermits() == 0) {
        semaphore.release();
      }
    }
  }
});
origin: spring-projects/spring-batch

@Test
@SuppressWarnings("resource")
public void testNullProperties() {
  JsrXmlApplicationContext applicationContext = new JsrXmlApplicationContext(null);
  BeanDefinition beanDefinition = applicationContext.getBeanDefinition(JOB_PARAMETERS_BEAN_DEFINITION_NAME);
  Properties properties = (Properties) beanDefinition.getConstructorArgumentValues().getGenericArgumentValue(Properties.class).getValue();
  assertNotNull("Properties should not be null", properties);
  assertTrue("Properties should be empty", properties.isEmpty());
}
origin: spring-projects/spring-batch

final JsrXmlApplicationContext batchContext = new JsrXmlApplicationContext(jobRestartProperties);
batchContext.setValidating(false);
  batchContext.load(batchXml);
  batchContext.load(jobXml);
batchContext.registerBeanDefinition(JSR_JOB_CONTEXT_BEAN_NAME, beanDefinition);
batchContext.setParent(baseContext);
  batchContext.refresh();
} catch (BeanCreationException e) {
  throw new JobRestartException(e);
  if(batchContext.isActive()) {
    batchContext.close();
origin: spring-projects/spring-batch

@Test
@SuppressWarnings("unchecked")
public void testOverrideBeansFirst() throws Exception {
  JsrXmlApplicationContext context = new JsrXmlApplicationContext();
  Resource overrideXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/override_batch.xml");
  Resource batchXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/batch.xml");
  context.setValidating(false);
  context.load(overrideXml, batchXml);
  context.refresh();
  ItemProcessor<String, String> itemProcessor = context.getBean("itemProcessor", ItemProcessor.class);
  assertNotNull(itemProcessor);
  StepSynchronizationManager.register(new StepExecution("step1", new JobExecution(5l)));
  assertEquals("Test", itemProcessor.process("Test"));
  StepSynchronizationManager.close();
  context.close();
}
origin: spring-projects/spring-batch

@Test
@SuppressWarnings("resource")
public void testGetJobParameters() {
  Properties jobParameters = new Properties();
  jobParameters.setProperty("jobParameter1", "jobParameter1Value");
  jobParameters.setProperty("jobParameter2", "jobParameter2Value");
  JsrXmlApplicationContext applicationContext = new JsrXmlApplicationContext(jobParameters);
  applicationContext.setValidating(false);
  applicationContext.load(new ClassPathResource("jsrBaseContext.xml"),
      new ClassPathResource("/META-INF/batch.xml"),
      new ClassPathResource("/META-INF/batch-jobs/jsrPropertyPreparseTestJob.xml"));
  applicationContext.refresh();
  BeanDefinition beanDefinition = applicationContext.getBeanDefinition(JOB_PARAMETERS_BEAN_DEFINITION_NAME);
  Properties processedJobParameters = (Properties) beanDefinition.getConstructorArgumentValues().getGenericArgumentValue(Properties.class).getValue();
  assertNotNull(processedJobParameters);
  assertTrue("Wrong number of job parameters", processedJobParameters.size() == 2);
  assertEquals("jobParameter1Value", processedJobParameters.getProperty("jobParameter1"));
  assertEquals("jobParameter2Value", processedJobParameters.getProperty("jobParameter2"));
}
origin: org.springframework.batch/spring-batch-core

  @Override
  public void run() {
    JsrJobContextFactoryBean factoryBean = null;
    try {
      factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME);
      factoryBean.setJobExecution(jobExecution);
      final Job job = batchContext.getBean(Job.class);
      semaphore.release();
      // Initialization of the JobExecution for job level dependencies
      jobRegistry.register(job, jobExecution);
      job.execute(jobExecution);
      jobRegistry.remove(jobExecution);
    }
    catch (Exception e) {
      exceptionHolder.add(e);
    } finally {
      if(factoryBean != null) {
        factoryBean.close();
      }
      batchContext.close();
      if(semaphore.availablePermits() == 0) {
        semaphore.release();
      }
    }
  }
});
origin: org.springframework.batch/spring-batch-core

public long start(String jobName, Properties params) throws JobStartException,
JobSecurityException {
  final JsrXmlApplicationContext batchContext = new JsrXmlApplicationContext(params);
  batchContext.setValidating(false);
    batchContext.load(batchXml);
    batchContext.load(jobXml);
  batchContext.registerBeanDefinition(JSR_JOB_CONTEXT_BEAN_NAME, beanDefinition);
    batchContext.setParent(baseContext);
  } else {
    batchContext.getBeanFactory().registerSingleton("jobExplorer", jobExplorer);
    batchContext.getBeanFactory().registerSingleton("jobRepository", jobRepository);
    batchContext.getBeanFactory().registerSingleton("jobParametersConverter", jobParametersConverter);
    batchContext.getBeanFactory().registerSingleton("transactionManager", transactionManager);
    batchContext.refresh();
  } catch (BeanCreationException e) {
    throw new JobStartException(e);
    String [] jobNames = batchContext.getBeanNamesForType(Job.class);
    if(batchContext.isActive()) {
      batchContext.close();
origin: spring-projects/spring-batch

@Test
@SuppressWarnings("unchecked")
public void testRoseyScenario() throws Exception {
  JsrXmlApplicationContext context = new JsrXmlApplicationContext();
  Resource batchXml = new ClassPathResource("/org/springframework/batch/core/jsr/configuration/xml/batch.xml");
  context.setValidating(false);
  context.load(batchXml);
  GenericBeanDefinition stepScope = new GenericBeanDefinition();
  stepScope.setBeanClass(StepScope.class);
  context.registerBeanDefinition("stepScope", stepScope);
  GenericBeanDefinition bd = new GenericBeanDefinition();
  bd.setBeanClass(AutowiredAnnotationBeanPostProcessor.class);
  context.registerBeanDefinition("postProcessor", bd);
  context.refresh();
  ItemProcessor<String, String> itemProcessor = context.getBean(ItemProcessor.class);
  assertNotNull(itemProcessor);
  StepSynchronizationManager.register(new StepExecution("step1", new JobExecution(5l)));
  assertEquals("Test", itemProcessor.process("Test"));
  StepSynchronizationManager.close();
  context.close();
}
origin: spring-projects/spring-batch

@Test
public void testJobParametersResolution() {
  Properties jobParameters = new Properties();
  jobParameters.setProperty("jobParameter1", "myfile.txt");
  jobParameters.setProperty("jobParameter2", "#{jobProperties['jobProperty2']}");
  jobParameters.setProperty("jobParameter3", "#{jobParameters['jobParameter1']}");
  @SuppressWarnings("resource")
  JsrXmlApplicationContext applicationContext = new JsrXmlApplicationContext(jobParameters);
  applicationContext.setValidating(false);
  applicationContext.load(new ClassPathResource("jsrBaseContext.xml"),
      new ClassPathResource("/META-INF/batch.xml"),
      new ClassPathResource("/META-INF/batch-jobs/jsrPropertyPreparseTestJob.xml"));
  applicationContext.refresh();
  Document document = getDocument("/META-INF/batch-jobs/jsrPropertyPreparseTestJob.xml");
  JsrBeanDefinitionDocumentReader documentReader = new JsrBeanDefinitionDocumentReader(applicationContext);
  documentReader.initProperties(document.getDocumentElement());
  Properties resolvedParameters = documentReader.getJobParameters();
  assertNotNull(resolvedParameters);
  assertTrue("Wrong number of job parameters", resolvedParameters.size() == 3);
  assertEquals("myfile.txt", resolvedParameters.getProperty("jobParameter1"));
  assertEquals("jobProperty1Value", resolvedParameters.getProperty("jobParameter2"));
  assertEquals("myfile.txt", resolvedParameters.getProperty("jobParameter3"));
}
origin: org.springframework.batch.core/org.motechproject.org.springframework.batch.core

  @Override
  public void run() {
    JsrJobContextFactoryBean factoryBean = null;
    try {
      factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME);
      factoryBean.setJobExecution(jobExecution);
      final Job job = batchContext.getBean(Job.class);
      semaphore.release();
      // Initialization of the JobExecution for job level dependencies
      jobRegistry.register(job, jobExecution);
      job.execute(jobExecution);
      jobRegistry.remove(jobExecution);
    }
    catch (Exception e) {
      exceptionHolder.add(e);
    } finally {
      if(factoryBean != null) {
        factoryBean.close();
      }
      batchContext.close();
      if(semaphore.availablePermits() == 0) {
        semaphore.release();
      }
    }
  }
});
origin: apache/servicemix-bundles

public long start(String jobName, Properties params) throws JobStartException,
JobSecurityException {
  final JsrXmlApplicationContext batchContext = new JsrXmlApplicationContext(params);
  batchContext.setValidating(false);
    batchContext.load(batchXml);
    batchContext.load(jobXml);
  batchContext.registerBeanDefinition(JSR_JOB_CONTEXT_BEAN_NAME, beanDefinition);
    batchContext.setParent(baseContext);
  } else {
    batchContext.getBeanFactory().registerSingleton("jobExplorer", jobExplorer);
    batchContext.getBeanFactory().registerSingleton("jobRepository", jobRepository);
    batchContext.getBeanFactory().registerSingleton("jobParametersConverter", jobParametersConverter);
    batchContext.getBeanFactory().registerSingleton("transactionManager", transactionManager);
    batchContext.refresh();
  } catch (BeanCreationException e) {
    throw new JobStartException(e);
    String [] jobNames = batchContext.getBeanNamesForType(Job.class);
    if(batchContext.isActive()) {
      batchContext.close();
origin: spring-projects/spring-batch

@Test
public void testJobPropertyResolution() {
  Properties jobParameters = new Properties();
  jobParameters.setProperty("file.name", "myfile.txt");
  @SuppressWarnings("resource")
  JsrXmlApplicationContext applicationContext = new JsrXmlApplicationContext(jobParameters);
  applicationContext.setValidating(false);
  applicationContext.load(new ClassPathResource("jsrBaseContext.xml"),
      new ClassPathResource("/META-INF/batch.xml"),
      new ClassPathResource("/META-INF/batch-jobs/jsrPropertyPreparseTestJob.xml"));
  applicationContext.refresh();
  Document document = getDocument("/META-INF/batch-jobs/jsrPropertyPreparseTestJob.xml");
  JsrBeanDefinitionDocumentReader documentReader = new JsrBeanDefinitionDocumentReader(applicationContext);
  documentReader.initProperties(document.getDocumentElement());
  Properties resolvedProperties = documentReader.getJobProperties();
  assertNotNull(resolvedProperties);
  assertTrue("Wrong number of job properties", resolvedProperties.size() == 3);
  assertEquals("jobProperty1Value", resolvedProperties.getProperty("jobProperty1"));
  assertEquals("jobProperty1Value", resolvedProperties.getProperty("jobProperty2"));
  assertEquals("myfile.txt", resolvedProperties.getProperty("jobProperty3"));
}
origin: apache/servicemix-bundles

  @Override
  public void run() {
    JsrJobContextFactoryBean factoryBean = null;
    try {
      factoryBean = (JsrJobContextFactoryBean) batchContext.getBean("&" + JSR_JOB_CONTEXT_BEAN_NAME);
      factoryBean.setJobExecution(jobExecution);
      final Job job = batchContext.getBean(Job.class);
      semaphore.release();
      // Initialization of the JobExecution for job level dependencies
      jobRegistry.register(job, jobExecution);
      job.execute(jobExecution);
      jobRegistry.remove(jobExecution);
    }
    catch (Exception e) {
      exceptionHolder.add(e);
    } finally {
      if(factoryBean != null) {
        factoryBean.close();
      }
      batchContext.close();
      if(semaphore.availablePermits() == 0) {
        semaphore.release();
      }
    }
  }
});
org.springframework.batch.core.jsr.configuration.xmlJsrXmlApplicationContext

Javadoc

GenericApplicationContext implementation providing JSR-352 related context operations.

Most used methods

  • <init>
    Create a new context instance using the provided Properties representing job parameters when pre-pr
  • close
  • getBean
  • load
    Load bean definitions from the given XML resources.
  • refresh
  • registerBeanDefinition
  • setValidating
    Set whether to use XML validation. Default is true.
  • getBeanNamesForType
  • isActive
  • setParent
  • getEnvironment
  • storeJobParameters
  • getEnvironment,
  • storeJobParameters,
  • getBeanFactory,
  • containsBeanDefinition,
  • getBeanDefinition

Popular in Java

  • Start an intent from android
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getExternalFilesDir (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • String (java.lang)
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • BoxLayout (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now