/** * Take all the contexts from the factories provided and pass them to the {@link JobLoader}. * * @see Lifecycle#start() */ @Override public void start() { synchronized (this.lifecycleMonitor) { if (running) { return; } for (ApplicationContextFactory factory : applicationContextFactories) { try { jobLoader.load(factory); } catch (DuplicateJobException e) { throw new IllegalStateException(e); } } running = true; } }
/** * Unregister all the {@link Job} instances that were registered by this * post processor. * @see org.springframework.beans.factory.DisposableBean#destroy() */ private void destroy() throws Exception { jobLoader.clear(); }
@ServiceActivator public Collection<JobInfo> loadJobs(Resource resource) throws DuplicateJobException { Collection<JobInfo> result = new ArrayList<JobInfo>(); ApplicationContextFactory factory = createApplicationContextFactory(parent, resource); Collection<Job> jobs = jobLoader.reload(factory); for (Job job : jobs) { String name = job.getName(); int count = 0; try { count = jobService.countJobExecutionsForJob(name); } catch (NoSuchJobException e) { // shouldn't happen } boolean launchable = jobService.isLaunchable(name); boolean incrementable = jobService.isIncrementable(name); result.add(new JobInfo(name, count, null, launchable, incrementable)); } return result; }
private void register(String[] paths) throws DuplicateJobException, IOException { maybeCreateJobLoader(); for (int i = 0; i < paths.length; i++) { Resource[] resources = parentContext.getResources(paths[i]); for (int j = 0; j < resources.length; j++) { Resource path = resources[j]; logger.info("Registering Job definitions from " + Arrays.toString(resources)); GenericApplicationContextFactory factory = new GenericApplicationContextFactory(path); factory.setApplicationContext(parentContext); jobLoader.load(factory); } } }
/** * Delegates to {@link JobLoader#clear()}. * * @see Lifecycle#stop() */ @Override public void stop() { synchronized (this.lifecycleMonitor) { jobLoader.clear(); running = false; } }
@Test public void testNoStepRegistryAvailable() throws DuplicateJobException { final JobLoader loader = new DefaultJobLoader(jobRegistry); GenericApplicationContextFactory factory = new GenericApplicationContextFactory( new ClassPathResource("job-context-with-steps.xml", getClass())); loader.load(factory); // No step registry available so just registering the jobs assertEquals(2, jobRegistry.getJobNames().size()); }
/** * Delegates to {@link JobLoader#clear()}. * * @see Lifecycle#stop() */ @Override public void stop() { synchronized (this.lifecycleMonitor) { jobLoader.clear(); running = false; } }
@Test public void testLoadWithJobThatIsNotAStepLocatorNoStepRegistry() throws DuplicateJobException { final JobLoader loader = new DefaultJobLoader(jobRegistry); GenericApplicationContextFactory factory = new GenericApplicationContextFactory( new ByteArrayResource(BASIC_JOB_XML.getBytes())); try { loader.load(factory); } catch (UnsupportedOperationException e) { fail("Should not have failed with a [" + UnsupportedOperationException.class.getName() + "] as " + "stepRegistry is not available for this JobLoader instance."); } }
/** * Unregister all the {@link Job} instances that were registered by this * post processor. * @see org.springframework.beans.factory.DisposableBean#destroy() */ private void destroy() throws Exception { jobLoader.clear(); }
/** * Take all the contexts from the factories provided and pass them to teh * {@link JobLoader}. * * @see Lifecycle#start() */ public void start() { synchronized (this.lifecycleMonitor) { if (running) { return; } for (ApplicationContextFactory factory : applicationContextFactories) { try { jobLoader.load(factory); } catch (DuplicateJobException e) { throw new IllegalStateException(e); } } running = true; } }
/** * Delegates to {@link JobLoader#clear()}. * * @see Lifecycle#stop() */ @Override public void stop() { synchronized (this.lifecycleMonitor) { jobLoader.clear(); running = false; } }
/** * Take all the contexts from the factories provided and pass them to the {@link JobLoader}. * * @see Lifecycle#start() */ @Override public void start() { synchronized (this.lifecycleMonitor) { if (running) { return; } for (ApplicationContextFactory factory : applicationContextFactories) { try { jobLoader.load(factory); } catch (DuplicateJobException e) { throw new IllegalStateException(e); } } running = true; } }
/** * Unregister all the {@link Job} instances that were registered by this * post processor. * @see org.springframework.beans.factory.DisposableBean#destroy() */ private void destroy() throws Exception { jobLoader.clear(); }
/** * Take all the contexts from the factories provided and pass them to the {@link JobLoader}. * * @see Lifecycle#start() */ @Override public void start() { synchronized (this.lifecycleMonitor) { if (running) { return; } for (ApplicationContextFactory factory : applicationContextFactories) { try { jobLoader.load(factory); } catch (DuplicateJobException e) { throw new IllegalStateException(e); } } running = true; } }
/** * De-register all the {@link Job} instances that were regsistered by this * post processor. * @see org.springframework.beans.factory.DisposableBean#destroy() */ private void destroy() throws Exception { jobLoader.clear(); }
/** * Take all the contexts from the factories provided and pass them to the {@link JobLoader}. * * @see Lifecycle#start() */ @Override public void start() { synchronized (this.lifecycleMonitor) { if (running) { return; } for (ApplicationContextFactory factory : applicationContextFactories) { try { jobLoader.load(factory); } catch (DuplicateJobException e) { throw new IllegalStateException(e); } } running = true; } }
/** * Unregister all the {@link Job} instances that were registered by this * post processor. * @see org.springframework.beans.factory.DisposableBean#destroy() */ private void destroy() throws Exception { jobLoader.clear(); }
private void register(String[] paths) throws DuplicateJobException, IOException { maybeCreateJobLoader(); for (int i = 0; i < paths.length; i++) { Resource[] resources = parentContext.getResources(paths[i]); for (int j = 0; j < resources.length; j++) { Resource path = resources[j]; logger.info("Registering Job definitions from " + Arrays.toString(resources)); GenericApplicationContextFactory factory = new GenericApplicationContextFactory(path); factory.setApplicationContext(parentContext); jobLoader.load(factory); } } }
/** * Delegates to {@link JobLoader#clear()}. * * @see Lifecycle#stop() */ public void stop() { synchronized (this.lifecycleMonitor) { jobLoader.clear(); running = false; } }
private void register(String[] paths) throws DuplicateJobException, IOException { maybeCreateJobLoader(); for (int i = 0; i < paths.length; i++) { Resource[] resources = parentContext.getResources(paths[i]); for (int j = 0; j < resources.length; j++) { Resource path = resources[j]; logger.info("Registering Job definitions from " + Arrays.toString(resources)); GenericApplicationContextFactory factory = new GenericApplicationContextFactory(path); factory.setApplicationContext(parentContext); jobLoader.load(factory); } } }