Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Apache Dolphinscheduler DataSourceChannelFactory Implementation

From Leeroopedia


Knowledge Sources
Domains Plugin_Architecture, Data_Integration
Last Updated 2026-02-10 00:00 GMT

Overview

Concrete tool for creating datasource client instances through the DataSourceChannelFactory and DataSourceChannel SPI interfaces.

Description

DataSourceChannelFactory is an SPI interface that each plugin implements to provide its DataSourceChannel. The channel factory is annotated with @AutoService(DataSourceChannelFactory.class) and extends PrioritySPI for ordered loading. DataSourceChannel is a simple interface with two factory methods: createAdHocDataSourceClient and createPooledDataSourceClient.

Usage

Implement DataSourceChannelFactory and DataSourceChannel in your plugin module to register with the DolphinScheduler plugin system. The DataSourcePluginManager uses PrioritySPIFactory to discover and load all channel factories.

Code Reference

Source Location

  • Repository: dolphinscheduler
  • File: dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/datasource/DataSourceChannelFactory.java (L24-36)
  • File: dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/datasource/DataSourceChannel.java (L24-32)
  • File: dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-mysql/src/main/java/org/apache/dolphinscheduler/plugin/datasource/mysql/MySQLDataSourceChannelFactory.java (L27-35)

Signature

public interface DataSourceChannelFactory extends PrioritySPI {
    DataSourceChannel create();
    String getName();
    default String getIdentify() { return getName(); }
}

public interface DataSourceChannel {
    AdHocDataSourceClient createAdHocDataSourceClient(
        BaseConnectionParam baseConnectionParam,
        DbType dbType
    );
    PooledDataSourceClient createPooledDataSourceClient(
        BaseConnectionParam baseConnectionParam,
        DbType dbType
    );
}

Import

import org.apache.dolphinscheduler.spi.datasource.DataSourceChannelFactory;
import org.apache.dolphinscheduler.spi.datasource.DataSourceChannel;
import com.google.auto.service.AutoService;

I/O Contract

Inputs

Name Type Required Description
baseConnectionParam BaseConnectionParam Yes Resolved connection parameters with JDBC URL
dbType DbType Yes Database type enum value

Outputs

Name Type Description
DataSourceChannel Interface Channel instance for creating clients
AdHocDataSourceClient Interface Single-use connection client
PooledDataSourceClient Interface Connection-pooled client

Usage Examples

MySQL Channel Factory

@AutoService(DataSourceChannelFactory.class)
public class MySQLDataSourceChannelFactory implements DataSourceChannelFactory {

    @Override
    public String getName() {
        return DbType.MYSQL.name();
    }

    @Override
    public DataSourceChannel create() {
        return new MySQLDataSourceChannel();
    }
}

MySQL Channel

public class MySQLDataSourceChannel implements DataSourceChannel {

    @Override
    public AdHocDataSourceClient createAdHocDataSourceClient(
            BaseConnectionParam baseConnectionParam, DbType dbType) {
        return new MySQLAdHocDataSourceClient(baseConnectionParam, dbType);
    }

    @Override
    public PooledDataSourceClient createPooledDataSourceClient(
            BaseConnectionParam baseConnectionParam, DbType dbType) {
        return new MySQLPooledDataSourceClient(baseConnectionParam, dbType);
    }
}

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment