Package javax.batch.operations

Examples of javax.batch.operations.JobStartException


            } else if (parentBatchlet != null) {
                child.setBatchlet(parentBatchlet.clone());
            }
        } else //if child contains both chunk and batchlet
            BatchLogger.LOGGER.cannotContainBothChunkAndBatchlet(child.getId());
            throw new JobStartException();
        }

        //if child has no partition, use parent partition
        //if child has partition, always use child partition and ignore parent partition
        final Partition parentPartition = parent.getPartition();
View Full Code Here


                    final JobInstanceImpl jobInstance = repository.createJobInstance(jobDefined, getApplicationName(), classLoader);
                    return startJobExecution(jobInstance, jobParameters, null);
                }
            });
        } catch (InvalidTransactionException e) {
            throw new JobStartException(e);
        } catch (SystemException e) {
            throw new JobStartException(e);
        }
    }
View Full Code Here

        }
        try {
            cloner.reset();
            return (T) cloner.clone(original);
        } catch (IOException e) {
            throw new JobStartException(e);
        } catch (ClassNotFoundException e) {
            throw new JobStartException(e);
        }
    }
View Full Code Here

                    final JobInstanceImpl jobInstance = repository.createJobInstance(jobDefined, getApplicationName(), classLoader);
                    return startJobExecution(jobInstance, jobParameters, null);
                }
            });
        } catch (InvalidTransactionException e) {
            throw new JobStartException(e);
        } catch (SystemException e) {
            throw new JobStartException(e);
        }
    }
View Full Code Here

        }
        try {
            cloner.reset();
            return (T) cloner.clone(original);
        } catch (IOException e) {
            throw new JobStartException(e);
        } catch (ClassNotFoundException e) {
            throw new JobStartException(e);
        }
    }
View Full Code Here

    public static <T> T clone(T original) throws JobStartException {
        try {
            cloner.reset();
            return (T) cloner.clone(original);
        } catch (IOException e) {
            throw new JobStartException(e);
        } catch (ClassNotFoundException e) {
            throw new JobStartException(e);
        }
    }
View Full Code Here

            oos.flush();
            ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
            ois = new ObjectInputStream(bis);
            clone = (T) ois.readObject();
        } catch (IOException e) {
            throw new JobStartException(e);
        } catch (ClassNotFoundException e) {
            throw new JobStartException(e);
        } finally {
            if (oos != null) {
                try {
                    oos.close();
                } catch (IOException e) {
View Full Code Here

    batchContext.setParent(baseContext);

    try {
      batchContext.refresh();
    } catch (BeanCreationException e) {
      throw new JobStartException(e);
    }

    Assert.notNull(jobName, "The job name must not be null.");

    final org.springframework.batch.core.JobExecution jobExecution;

    try {
      JobParameters jobParameters = jobParametersConverter.getJobParameters(params);
      String [] jobNames = batchContext.getBeanNamesForType(Job.class);

      if(jobNames == null || jobNames.length <= 0) {
        throw new BatchRuntimeException("No Job defined in current context");
      }

      org.springframework.batch.core.JobInstance jobInstance = jobRepository.createJobInstance(jobNames[0], jobParameters);
      jobExecution = jobRepository.createJobExecution(jobInstance, jobParameters, jobConfigurationLocation);
    } catch (Exception e) {
      throw new JobStartException(e);
    }

    try {
      final Semaphore semaphore = new Semaphore(1);
      final List<Exception> exceptionHolder = Collections.synchronizedList(new ArrayList<Exception>());
      semaphore.acquire();

      taskExecutor.execute(new Runnable() {

        @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();
            }
          }
        }
      });

      semaphore.acquire();
      if(exceptionHolder.size() > 0) {
        semaphore.release();
        throw new JobStartException(exceptionHolder.get(0));
      }
    }
    catch (Exception e) {
      if(jobRegistry.exists(jobExecution.getId())) {
        jobRegistry.remove(jobExecution);
      }
      jobExecution.upgradeStatus(BatchStatus.FAILED);
      if (jobExecution.getExitStatus().equals(ExitStatus.UNKNOWN)) {
        jobExecution.setExitStatus(ExitStatus.FAILED.addExitDescription(e));
      }
      jobRepository.update(jobExecution);

      if(batchContext.isActive()) {
        batchContext.close();
      }

      throw new JobStartException(e);
    }
    return jobExecution.getId();
  }
View Full Code Here

                    final JobInstanceImpl jobInstance = repository.createJobInstance(jobDefined, getApplicationName(), classLoader);
                    return startJobExecution(jobInstance, jobParameters, null);
                }
            });
        } catch (InvalidTransactionException e) {
            throw new JobStartException(e);
        } catch (SystemException e) {
            throw new JobStartException(e);
        }
    }
View Full Code Here

                    final JobInstanceImpl jobInstance = repository.createJobInstance(jobDefined, getApplicationName(), classLoader);
                    return startJobExecution(jobInstance, jobParameters, null);
                }
            });
        } catch (InvalidTransactionException e) {
            throw new JobStartException(e);
        } catch (SystemException e) {
            throw new JobStartException(e);
        }
    }
View Full Code Here

TOP

Related Classes of javax.batch.operations.JobStartException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.