12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package com.primeton.dgs.workspace.quartz;
- import com.eos.common.connection.DataSourceHelper;
- import lombok.NonNull;
- import org.quartz.utils.ConnectionProvider;
- import org.quartz.utils.DBConnectionManager;
- import javax.sql.DataSource;
- import java.sql.Connection;
- import java.sql.SQLException;
- /**
- *
- * 使 Quartz 的数据源,共享使用 EOS 中的
- *
- * <pre>
- *
- * Created by zhaopx.
- * User: zhaopx
- * Date: 2020/4/7
- * Time: 13:54
- *
- * </pre>
- *
- * @author zhaopx
- */
- public class EosQuartzConnectionProvider implements ConnectionProvider {
- /**
- * 数据源
- */
- private final DataSource ds;
- /**
- * 必须提供默认的构造方法
- */
- public EosQuartzConnectionProvider() {
- this.ds = DataSourceHelper.getDataSource();
- // 给 Quartz 中添加数据源提供者
- DBConnectionManager.getInstance().addConnectionProvider("default",
- this);
- }
- @Override
- public Connection getConnection() throws SQLException {
- return this.ds.getConnection();
- }
- @Override
- public void shutdown() throws SQLException {
- // datasource 不能关闭
- }
- }
|