@Override protected TaskTracker build0() { TaskTrackerProperties properties = PropertiesConfigurationFactory.createPropertiesConfiguration(TaskTrackerProperties.class, locations); return buildByProperties(properties); }
@Override protected JobTracker build0() { JobTrackerProperties properties = PropertiesConfigurationFactory.createPropertiesConfiguration(JobTrackerProperties.class, locations); return buildByProperties(properties); }
public static <T> T createPropertiesConfiguration(Class<T> clazz, Map<String, String> propMap) { if (clazz == null) { throw new IllegalArgumentException("clazz should not be null"); } if (!clazz.isAnnotationPresent(ConfigurationProperties.class)) { throw new IllegalArgumentException(clazz.getName() + " must annotation with @" + ConfigurationProperties.class.getName()); } ConfigurationProperties annotation = clazz.getAnnotation(ConfigurationProperties.class); String prefix = annotation.prefix(); return createPropertiesConfiguration(clazz, prefix, propMap); }
public static <T> T createPropertiesConfiguration(Class<T> clazz, Map<String, String> propMap) { if (clazz == null) { throw new IllegalArgumentException("clazz should not be null"); } if (!clazz.isAnnotationPresent(ConfigurationProperties.class)) { throw new IllegalArgumentException(clazz.getName() + " must annotation with @" + ConfigurationProperties.class.getName()); } ConfigurationProperties annotation = clazz.getAnnotation(ConfigurationProperties.class); String prefix = annotation.prefix(); return createPropertiesConfiguration(clazz, prefix, propMap); }
@Override protected JobTracker build0() { JobTrackerProperties properties = PropertiesConfigurationFactory.createPropertiesConfiguration(JobTrackerProperties.class, locations); return buildByProperties(properties); }
public static <T> T createPropertiesConfiguration(Class<T> clazz) { if (clazz == null) { throw new IllegalArgumentException("clazz should not be null"); } if (!clazz.isAnnotationPresent(ConfigurationProperties.class)) { throw new IllegalArgumentException(clazz.getName() + " must annotation with @" + ConfigurationProperties.class.getName()); } ConfigurationProperties annotation = clazz.getAnnotation(ConfigurationProperties.class); String[] locations = annotation.locations(); return createPropertiesConfiguration(clazz, locations); }
@Override protected TaskTracker build0() { TaskTrackerProperties properties = PropertiesConfigurationFactory.createPropertiesConfiguration(TaskTrackerProperties.class, locations); return buildByProperties(properties); }
public static <T> T createPropertiesConfiguration(Class<T> clazz) { if (clazz == null) { throw new IllegalArgumentException("clazz should not be null"); } if (!clazz.isAnnotationPresent(ConfigurationProperties.class)) { throw new IllegalArgumentException(clazz.getName() + " must annotation with @" + ConfigurationProperties.class.getName()); } ConfigurationProperties annotation = clazz.getAnnotation(ConfigurationProperties.class); String[] locations = annotation.locations(); return createPropertiesConfiguration(clazz, locations); }
public static <T> T createPropertiesConfiguration(Class<T> clazz, String[] locations) { if (clazz == null) { throw new IllegalArgumentException("clazz should not be null"); } if (!clazz.isAnnotationPresent(ConfigurationProperties.class)) { throw new IllegalArgumentException(clazz.getName() + " must annotation with @" + ConfigurationProperties.class.getName()); } if (locations == null || locations.length == 0) { throw new IllegalArgumentException(clazz.getName() + " must specified the properties locations"); } Properties properties = new Properties(); for (String location : locations) { try { properties.load(PropertiesConfigurationFactory.class.getClassLoader().getResourceAsStream(location.trim())); } catch (IOException e) { throw new IllegalStateException("Load properties [" + location + "] error", e); } } Map<String, String> map = new HashMap<String, String>(properties.size()); for (Map.Entry<Object, Object> entry : properties.entrySet()) { String key = entry.getKey().toString(); String value = entry.getValue() == null ? null : entry.getValue().toString(); if (value != null) { map.put(key, value); } } return createPropertiesConfiguration(clazz, map); } }
public static <T> T createPropertiesConfiguration(Class<T> clazz, String[] locations) { if (clazz == null) { throw new IllegalArgumentException("clazz should not be null"); } if (!clazz.isAnnotationPresent(ConfigurationProperties.class)) { throw new IllegalArgumentException(clazz.getName() + " must annotation with @" + ConfigurationProperties.class.getName()); } if (locations == null || locations.length == 0) { throw new IllegalArgumentException(clazz.getName() + " must specified the properties locations"); } Properties properties = new Properties(); for (String location : locations) { try { properties.load(PropertiesConfigurationFactory.class.getClassLoader().getResourceAsStream(location.trim())); } catch (IOException e) { throw new IllegalStateException("Load properties [" + location + "] error", e); } } Map<String, String> map = new HashMap<String, String>(properties.size()); for (Map.Entry<Object, Object> entry : properties.entrySet()) { String key = entry.getKey().toString(); String value = entry.getValue() == null ? null : entry.getValue().toString(); if (value != null) { map.put(key, value); } } return createPropertiesConfiguration(clazz, map); } }
@Override protected JobClient build0() { JobClientProperties properties = PropertiesConfigurationFactory .createPropertiesConfiguration(JobClientProperties.class, locations); JobClient jobClient = buildByProperties(properties); if (jobCompletedHandler != null) { jobClient.setJobCompletedHandler(jobCompletedHandler); } return jobClient; }
@Override protected JobClient build0() { JobClientProperties properties = PropertiesConfigurationFactory .createPropertiesConfiguration(JobClientProperties.class, locations); JobClient jobClient = buildByProperties(properties); if (jobCompletedHandler != null) { jobClient.setJobCompletedHandler(jobCompletedHandler); } return jobClient; }
@Override public void resolve(AutoConfigContext context, PropertyDescriptor descriptor, Class<?> propertyType) { final Map<String, String> includeMap = new HashMap<String, String>(); doFilter(context, descriptor, new Filter() { @Override public boolean onCondition(String name, String key, String value) { return key.startsWith(name); } @Override public boolean call(String name, String key, String value) { String subKey = key.substring(name.length() + 1); includeMap.put(subKey, value); return true; } }); Object value = PropertiesConfigurationFactory.createPropertiesConfiguration(propertyType, null, includeMap); if (value != null) { writeProperty(context, descriptor, value); } } }
@Override public void resolve(AutoConfigContext context, PropertyDescriptor descriptor, Class<?> propertyType) { final Map<String, String> includeMap = new HashMap<String, String>(); doFilter(context, descriptor, new Filter() { @Override public boolean onCondition(String name, String key, String value) { return key.startsWith(name); } @Override public boolean call(String name, String key, String value) { String subKey = key.substring(name.length() + 1); includeMap.put(subKey, value); return true; } }); Object value = PropertiesConfigurationFactory.createPropertiesConfiguration(propertyType, null, includeMap); if (value != null) { writeProperty(context, descriptor, value); } } }
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (ltsEnable) { // 如果启用才进行代理 LOGGER.info("========LTS====== Proxy Quartz Scheduler"); JobClientProperties jobClientProperties = PropertiesConfigurationFactory.createPropertiesConfiguration(JobClientProperties.class, locations); jobClientProperties.checkProperties(); TaskTrackerProperties taskTrackerProperties = PropertiesConfigurationFactory.createPropertiesConfiguration(TaskTrackerProperties.class, locations); taskTrackerProperties.checkProperties(); QuartzLTSConfig quartzLTSConfig = new QuartzLTSConfig(); quartzLTSConfig.setJobClientProperties(jobClientProperties); quartzLTSConfig.setTaskTrackerProperties(taskTrackerProperties); QuartzLTSConfig.JobProperties jobProperties = PropertiesConfigurationFactory.createPropertiesConfiguration(QuartzLTSConfig.JobProperties.class, locations); quartzLTSConfig.setJobProperties(jobProperties); QuartzLTSProxyAgent agent = new QuartzLTSProxyAgent(quartzLTSConfig); QuartzProxyContext context = new QuartzProxyContext(quartzLTSConfig, agent); QuartzSchedulerBeanRegistrar registrar = new QuartzSchedulerBeanRegistrar(context); beanFactory.addPropertyEditorRegistrar(registrar); } }
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { if (ltsEnable) { // 如果启用才进行代理 LOGGER.info("========LTS====== Proxy Quartz Scheduler"); JobClientProperties jobClientProperties = PropertiesConfigurationFactory.createPropertiesConfiguration(JobClientProperties.class, locations); jobClientProperties.checkProperties(); TaskTrackerProperties taskTrackerProperties = PropertiesConfigurationFactory.createPropertiesConfiguration(TaskTrackerProperties.class, locations); taskTrackerProperties.checkProperties(); QuartzLTSConfig quartzLTSConfig = new QuartzLTSConfig(); quartzLTSConfig.setJobClientProperties(jobClientProperties); quartzLTSConfig.setTaskTrackerProperties(taskTrackerProperties); QuartzLTSConfig.JobProperties jobProperties = PropertiesConfigurationFactory.createPropertiesConfiguration(QuartzLTSConfig.JobProperties.class, locations); quartzLTSConfig.setJobProperties(jobProperties); QuartzLTSProxyAgent agent = new QuartzLTSProxyAgent(quartzLTSConfig); QuartzProxyContext context = new QuartzProxyContext(quartzLTSConfig, agent); QuartzSchedulerBeanRegistrar registrar = new QuartzSchedulerBeanRegistrar(context); beanFactory.addPropertyEditorRegistrar(registrar); } }
@Override public void afterPropertiesSet() throws Exception { JobTrackerProperties properties = null; if (locations == null || locations.length == 0) { properties = new JobTrackerProperties(); properties.setListenPort(listenPort); properties.setClusterName(clusterName); properties.setRegistryAddress(registryAddress); properties.setBindIp(bindIp); properties.setIdentity(identity); properties.setConfigs(CollectionUtils.toMap(configs)); } else { properties = PropertiesConfigurationFactory.createPropertiesConfiguration(JobTrackerProperties.class, locations); } jobTracker = JobTrackerBuilder.buildByProperties(properties); if (oldDataHandler != null) { jobTracker.setOldDataHandler(oldDataHandler); } if (masterChangeListeners != null) { for (MasterChangeListener masterChangeListener : masterChangeListeners) { jobTracker.addMasterChangeListener(masterChangeListener); } } }
@Override public void afterPropertiesSet() throws Exception { JobTrackerProperties properties = null; if (locations == null || locations.length == 0) { properties = new JobTrackerProperties(); properties.setListenPort(listenPort); properties.setClusterName(clusterName); properties.setRegistryAddress(registryAddress); properties.setBindIp(bindIp); properties.setIdentity(identity); properties.setConfigs(CollectionUtils.toMap(configs)); } else { properties = PropertiesConfigurationFactory.createPropertiesConfiguration(JobTrackerProperties.class, locations); } jobTracker = JobTrackerBuilder.buildByProperties(properties); if (oldDataHandler != null) { jobTracker.setOldDataHandler(oldDataHandler); } if (masterChangeListeners != null) { for (MasterChangeListener masterChangeListener : masterChangeListeners) { jobTracker.addMasterChangeListener(masterChangeListener); } } }
@Override public void afterPropertiesSet() throws Exception { JobClientProperties properties = null; if (locations == null || locations.length == 0) { properties = new JobClientProperties(); properties.setUseRetryClient(useRetryClient); properties.setClusterName(clusterName); properties.setDataPath(dataPath); properties.setNodeGroup(nodeGroup); properties.setRegistryAddress(registryAddress); properties.setBindIp(bindIp); properties.setIdentity(identity); properties.setConfigs(CollectionUtils.toMap(configs)); } else { properties = PropertiesConfigurationFactory.createPropertiesConfiguration(JobClientProperties.class, locations); } jobClient = JobClientBuilder.buildByProperties(properties); if (jobCompletedHandler != null) { jobClient.setJobCompletedHandler(jobCompletedHandler); } if (masterChangeListeners != null) { for (MasterChangeListener masterChangeListener : masterChangeListeners) { jobClient.addMasterChangeListener(masterChangeListener); } } }
@Override public void afterPropertiesSet() throws Exception { JobClientProperties properties = null; if (locations == null || locations.length == 0) { properties = new JobClientProperties(); properties.setUseRetryClient(useRetryClient); properties.setClusterName(clusterName); properties.setDataPath(dataPath); properties.setNodeGroup(nodeGroup); properties.setRegistryAddress(registryAddress); properties.setBindIp(bindIp); properties.setIdentity(identity); properties.setConfigs(CollectionUtils.toMap(configs)); } else { properties = PropertiesConfigurationFactory.createPropertiesConfiguration(JobClientProperties.class, locations); } jobClient = JobClientBuilder.buildByProperties(properties); if (jobCompletedHandler != null) { jobClient.setJobCompletedHandler(jobCompletedHandler); } if (masterChangeListeners != null) { for (MasterChangeListener masterChangeListener : masterChangeListeners) { jobClient.addMasterChangeListener(masterChangeListener); } } }