Former-commit-id: efcb6b7b2643a3d396256be9c17916c51b583211
master
wangbing 5 years ago
parent dc677002db
commit 475dbd3e5f

@ -59,6 +59,7 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
private int registryScreen(String basePackage, BeanDefinitionRegistry beanDefinitionRegistry) {
ClassPathBeanDefinitionScanner classPathBeanDefinitionScanner = new ClassPathBeanDefinitionScanner(beanDefinitionRegistry);
classPathBeanDefinitionScanner.resetFilters(false);
classPathBeanDefinitionScanner.addIncludeFilter(new AssignableTypeFilter(Screen.class));
classPathBeanDefinitionScanner.setBeanNameGenerator(new BeanNameGenerator() {
@Override
@ -74,6 +75,7 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
private int registryControl(String basePackage, BeanDefinitionRegistry beanDefinitionRegistry) {
ClassPathBeanDefinitionScanner classPathBeanDefinitionScanner = new ClassPathBeanDefinitionScanner(beanDefinitionRegistry);
classPathBeanDefinitionScanner.resetFilters(false);
classPathBeanDefinitionScanner.addIncludeFilter(new AssignableTypeFilter(Control.class));
classPathBeanDefinitionScanner.setBeanNameGenerator(new BeanNameGenerator() {
@Override
@ -89,6 +91,7 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
private int registryAjax(String basePackage, BeanDefinitionRegistry beanDefinitionRegistry) {
ClassPathBeanDefinitionScanner classPathBeanDefinitionScanner = new ClassPathBeanDefinitionScanner(beanDefinitionRegistry);
classPathBeanDefinitionScanner.resetFilters(false);
classPathBeanDefinitionScanner.addIncludeFilter(new TypeFilter() {
@Override
public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) throws IOException {

@ -58,7 +58,7 @@ public class ScheduleConfig extends ThreadPoolTaskScheduler implements BeanDefin
Matcher matcher = compile.matcher(aPackage);
if (matcher.find()) {
String basePackage = matcher.group(1);
registryTask(basePackage + ".task", beanDefinitionRegistry);
registryTask(basePackage, beanDefinitionRegistry);
}
}

@ -1,11 +1,40 @@
package ${basePackage}.frame.schedule;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import ${basePackage}.frame.auth.LocalData;
import ${basePackage}.frame.utils.LogUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public abstract class RunSqlTask extends RunFixRepeatTask {
public abstract String getSql();
private Connection connection;
@Override
public void run() {
//exec sql
try {
if (connection == null || connection.isClosed()) {
SqlSessionFactory factory = LocalData.getBean(SqlSessionFactory.class);
SqlSession sqlSession = factory.openSession(true);
connection = sqlSession.getConnection();
}
} catch (Exception e) {
e.printStackTrace();
LogUtil.e("schedule: get connection failed!");
return;
}
try {
PreparedStatement preparedStatement = connection.prepareStatement(getSql());
preparedStatement.execute();
preparedStatement.close();
} catch (SQLException e) {
e.printStackTrace();
LogUtil.e("RunSqlTask exec failed! SQL:[" + getSql() + "]");
}
}
public abstract String getSql();
}

Loading…
Cancel
Save

Powered by TurnKey Linux.