public static void addLTSBean(Object bean) { Class<?> clazz = bean.getClass(); Method[] methods = clazz.getMethods(); if (methods != null && methods.length > 0) { for (final Method method : methods) { if (method.isAnnotationPresent(JobRunnerItem.class)) { JobRunnerItem jobRunnerItem = method.getAnnotation(JobRunnerItem.class); String shardValue = jobRunnerItem.shardValue(); if (StringUtils.isEmpty(shardValue)) { LOGGER.error(clazz.getName() + ":" + method.getName() + " " + JobRunnerItem.class.getName() + " shardValue can not be null"); continue; } JobRunnerHolder.add(shardValue, JobRunnerBuilder.build(bean, method, method.getParameterTypes())); } } } } }
@Override public Object postProcessAfterInitialization(final Object bean, String beanName) throws BeansException { Class<?> clazz = bean.getClass(); if (!isMatchPackage(clazz)) { return bean; } if (!clazz.isAnnotationPresent(LTS.class)) { return bean; } JobRunnerHolder.addLTSBean(bean); return bean; }
@Override public Result run(JobContext jobContext) throws Throwable { Job job = jobContext.getJob(); String value; if (shardField.equals("taskId")) { value = job.getTaskId(); } else { value = job.getParam(shardField); } JobRunner jobRunner = null; if (StringUtils.isNotEmpty(value)) { jobRunner = JobRunnerHolder.getJobRunner(value); } if (jobRunner == null) { jobRunner = JobRunnerHolder.getJobRunner("_LTS_DEFAULT"); if (jobRunner == null) { throw new JobDispatchException("Can not find JobRunner by Shard Value : [" + value + "]"); } } return jobRunner.run(jobContext); }
@Override public Object postProcessAfterInitialization(final Object bean, String beanName) throws BeansException { Class<?> clazz = bean.getClass(); if (!isMatchPackage(clazz)) { return bean; } if (!clazz.isAnnotationPresent(LTS.class)) { return bean; } JobRunnerHolder.addLTSBean(bean); return bean; }
@Override public void afterPropertiesSet() throws Exception { if (targetObject == null) { throw new IllegalArgumentException("targetObject can not be null"); } if (StringUtils.isEmpty(targetMethod)) { throw new IllegalArgumentException("targetMethod can not be null"); } if (StringUtils.isEmpty(shardValue)) { throw new IllegalArgumentException("shardValue can not be null"); } Class<?> clazz = targetObject.getClass(); Method[] methods = clazz.getMethods(); Method method = null; if (methods != null && methods.length > 0) { for (Method m : methods) { if (m.getName().equals(targetMethod)) { if (method != null) { throw new IllegalArgumentException("Duplicate targetMethod can not be found in " + targetObject.getClass().getName()); } method = m; } } } if (method == null) { throw new IllegalArgumentException("targetMethod can not be found in " + targetObject.getClass().getName()); } JobRunnerHolder.add(shardValue, JobRunnerBuilder.build(targetObject, method, method.getParameterTypes())); }
@Override public Result run(JobContext jobContext) throws Throwable { Job job = jobContext.getJob(); String value; if (shardField.equals("taskId")) { value = job.getTaskId(); } else { value = job.getParam(shardField); } JobRunner jobRunner = null; if (StringUtils.isNotEmpty(value)) { jobRunner = JobRunnerHolder.getJobRunner(value); } if (jobRunner == null) { jobRunner = JobRunnerHolder.getJobRunner("_LTS_DEFAULT"); if (jobRunner == null) { throw new JobDispatchException("Can not find JobRunner by Shard Value : [" + value + "]"); } } return jobRunner.run(jobContext); }
for (Map.Entry<String, Object> entry : ltsBeanMap.entrySet()) { Object bean = entry.getValue(); JobRunnerHolder.addLTSBean(bean);
public static void addLTSBean(Object bean) { Class<?> clazz = bean.getClass(); Method[] methods = clazz.getMethods(); if (methods != null && methods.length > 0) { for (final Method method : methods) { if (method.isAnnotationPresent(JobRunnerItem.class)) { JobRunnerItem jobRunnerItem = method.getAnnotation(JobRunnerItem.class); String shardValue = jobRunnerItem.shardValue(); if (StringUtils.isEmpty(shardValue)) { LOGGER.error(clazz.getName() + ":" + method.getName() + " " + JobRunnerItem.class.getName() + " shardValue can not be null"); continue; } JobRunnerHolder.add(shardValue, JobRunnerBuilder.build(bean, method, method.getParameterTypes())); } } } } }
@Override public Result run(JobContext jobContext) throws Throwable { Job job = jobContext.getJob(); String value; if (shardField.equals("taskId")) { value = job.getTaskId(); } else { value = job.getParam(shardField); } JobRunner jobRunner = null; if (StringUtils.isNotEmpty(value)) { jobRunner = JobRunnerHolder.getJobRunner(value); } if (jobRunner == null) { jobRunner = JobRunnerHolder.getJobRunner("_LTS_DEFAULT"); if (jobRunner == null) { throw new JobDispatchException("Can not find JobRunner by Shard Value : [" + value + "]"); } } return jobRunner.run(jobContext); }
for (Map.Entry<String, Object> entry : ltsBeanMap.entrySet()) { Object bean = entry.getValue(); JobRunnerHolder.addLTSBean(bean);
@Override public void afterPropertiesSet() throws Exception { if (targetObject == null) { throw new IllegalArgumentException("targetObject can not be null"); } if (StringUtils.isEmpty(targetMethod)) { throw new IllegalArgumentException("targetMethod can not be null"); } if (StringUtils.isEmpty(shardValue)) { throw new IllegalArgumentException("shardValue can not be null"); } Class<?> clazz = targetObject.getClass(); Method[] methods = clazz.getMethods(); Method method = null; if (methods != null && methods.length > 0) { for (Method m : methods) { if (m.getName().equals(targetMethod)) { if (method != null) { throw new IllegalArgumentException("Duplicate targetMethod can not be found in " + targetObject.getClass().getName()); } method = m; } } } if (method == null) { throw new IllegalArgumentException("targetMethod can not be found in " + targetObject.getClass().getName()); } JobRunnerHolder.add(shardValue, JobRunnerBuilder.build(targetObject, method, method.getParameterTypes())); }
@Override public Object postProcessAfterInitialization(final Object bean, String beanName) throws BeansException { Class<?> clazz = bean.getClass(); if (!isMatchPackage(clazz)) { return bean; } if (!clazz.isAnnotationPresent(LTS.class)) { return bean; } JobRunnerHolder.addLTSBean(bean); return bean; }
public static void addLTSBean(Object bean) { Class<?> clazz = bean.getClass(); Method[] methods = clazz.getMethods(); if (methods != null && methods.length > 0) { for (final Method method : methods) { if (method.isAnnotationPresent(JobRunnerItem.class)) { JobRunnerItem jobRunnerItem = method.getAnnotation(JobRunnerItem.class); String shardValue = jobRunnerItem.shardValue(); if (StringUtils.isEmpty(shardValue)) { LOGGER.error(clazz.getName() + ":" + method.getName() + " " + JobRunnerItem.class.getName() + " shardValue can not be null"); continue; } JobRunnerHolder.add(shardValue, JobRunnerBuilder.build(bean, method, method.getParameterTypes())); } } } } }
for (Map.Entry<String, Object> entry : ltsBeanMap.entrySet()) { Object bean = entry.getValue(); JobRunnerHolder.addLTSBean(bean);
@Override public void afterPropertiesSet() throws Exception { if (targetObject == null) { throw new IllegalArgumentException("targetObject can not be null"); } if (StringUtils.isEmpty(targetMethod)) { throw new IllegalArgumentException("targetMethod can not be null"); } if (StringUtils.isEmpty(shardValue)) { throw new IllegalArgumentException("shardValue can not be null"); } Class<?> clazz = targetObject.getClass(); Method[] methods = clazz.getMethods(); Method method = null; if (methods != null && methods.length > 0) { for (Method m : methods) { if (m.getName().equals(targetMethod)) { if (method != null) { throw new IllegalArgumentException("Duplicate targetMethod can not be found in " + targetObject.getClass().getName()); } method = m; } } } if (method == null) { throw new IllegalArgumentException("targetMethod can not be found in " + targetObject.getClass().getName()); } JobRunnerHolder.add(shardValue, JobRunnerBuilder.build(targetObject, method, method.getParameterTypes())); }