@Test(expectedExceptions = { JobLockException.class }) public void testInvalidJobLockType_ThrowsException() throws JobLockException, IOException { Closer closer = Closer.create(); try { Properties properties = new Properties(); properties.setProperty(ConfigurationKeys.JOB_LOCK_TYPE, "ThisIsATest"); JobLock jobLock = closer.register(LegacyJobLockFactoryManager.getJobLock(properties, new JobLockEventListener())); MatcherAssert.assertThat(jobLock, Matchers.instanceOf(FileBasedJobLock.class)); } finally { closer.close(); } }
public static JobLock getJobLock(Properties properties, JobLockEventListener jobLockEventListener) throws JobLockException { Preconditions.checkNotNull(properties); Preconditions.checkNotNull(jobLockEventListener); JobLock jobLock; if (properties.containsKey(ConfigurationKeys.JOB_LOCK_TYPE)) { try { Class<?> jobLockClass = Class.forName( properties.getProperty(ConfigurationKeys.JOB_LOCK_TYPE, FileBasedJobLock.class.getName())); jobLock = (JobLock) ConstructorUtils.invokeConstructor(jobLockClass, properties); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new JobLockException(e); } } else { jobLock = new FileBasedJobLock(properties); } if (jobLock instanceof ListenableJobLock) { ((ListenableJobLock)jobLock).setEventListener(jobLockEventListener); } return jobLock; }
LegacyJobLockFactoryManager { public static JobLock getJobLock(Properties properties, JobLockEventListener jobLockEventListener) throws JobLockException { Preconditions.checkNotNull(properties); Preconditions.checkNotNull(jobLockEventListener); JobLock jobLock; if (properties.containsKey(ConfigurationKeys.JOB_LOCK_TYPE)) { try { Class<?> jobLockClass = Class.forName( properties.getProperty(ConfigurationKeys.JOB_LOCK_TYPE, FileBasedJobLock.class.getName())); jobLock = (JobLock) ConstructorUtils.invokeConstructor(jobLockClass, properties); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new JobLockException(e); } } else { jobLock = new FileBasedJobLock(properties); } if (jobLock instanceof ListenableJobLock) { ((ListenableJobLock)jobLock).setEventListener(jobLockEventListener); } return jobLock; } }
LegacyJobLockFactoryManager { public static JobLock getJobLock(Properties properties, JobLockEventListener jobLockEventListener) throws JobLockException { Preconditions.checkNotNull(properties); Preconditions.checkNotNull(jobLockEventListener); JobLock jobLock; if (properties.containsKey(ConfigurationKeys.JOB_LOCK_TYPE)) { try { Class<?> jobLockClass = Class.forName( properties.getProperty(ConfigurationKeys.JOB_LOCK_TYPE, FileBasedJobLock.class.getName())); jobLock = (JobLock) ConstructorUtils.invokeConstructor(jobLockClass, properties); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new JobLockException(e); } } else { jobLock = new FileBasedJobLock(properties); } if (jobLock instanceof ListenableJobLock) { ((ListenableJobLock)jobLock).setEventListener(jobLockEventListener); } return jobLock; }  }
LegacyJobLockFactoryManager { public static JobLock getJobLock(Properties properties, JobLockEventListener jobLockEventListener) throws JobLockException { Preconditions.checkNotNull(properties); Preconditions.checkNotNull(jobLockEventListener); JobLock jobLock; if (properties.containsKey(ConfigurationKeys.JOB_LOCK_TYPE)) { try { Class<?> jobLockClass = Class.forName( properties.getProperty(ConfigurationKeys.JOB_LOCK_TYPE, FileBasedJobLock.class.getName())); jobLock = (JobLock) ConstructorUtils.invokeConstructor(jobLockClass, properties); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new JobLockException(e); } } else { jobLock = new FileBasedJobLock(properties); } if (jobLock instanceof ListenableJobLock) { ((ListenableJobLock)jobLock).setEventListener(jobLockEventListener); } return jobLock; }  static JobLock getJobLock(Properties properties, JobLockEventListener jobLockEventListener); }
LegacyJobLockFactoryManager { public static JobLock getJobLock(Properties properties, JobLockEventListener jobLockEventListener) throws JobLockException { Preconditions.checkNotNull(properties); Preconditions.checkNotNull(jobLockEventListener); JobLock jobLock; if (properties.containsKey(ConfigurationKeys.JOB_LOCK_TYPE)) { try { Class<?> jobLockClass = Class.forName( properties.getProperty(ConfigurationKeys.JOB_LOCK_TYPE, FileBasedJobLock.class.getName())); jobLock = (JobLock) ConstructorUtils.invokeConstructor(jobLockClass, properties); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new JobLockException(e); } } else { jobLock = new FileBasedJobLock(properties); } if (jobLock instanceof ListenableJobLock) { ((ListenableJobLock)jobLock).setEventListener(jobLockEventListener); } return jobLock; }  static JobLock getJobLock(Properties properties, JobLockEventListener jobLockEventListener);  }