public interface Task
org.embulk.config.ConfigSource
and org.embulk.config.TaskSource
.
Embulk plugins usually need to define their own interface extending this Task
. Then,
org.embulk.config.ConfigSource
and org.embulk.config.TaskSource
are mapped into
the extended interface with ConfigMapper
and TaskMapper
, respectively. See the
example below.
public class ExampleInputPlugin implements InputPlugin {
public ExampleInputPlugin() {
this.configMapperFactory = org.embulk.util.config.ConfigMapperFactory.withDefault();
}
public interface PluginTask extends org.embulk.util.config.Task {
@Config("config")
String getConfigAsString();
@Config("config")
int getConfigAsInteger();
@Config("someone")
@ConfigDefault("any")
String getSomeone();
}
public ConfigDiff transaction(final ConfigSource config, final InputPlugin.Control control) {
final org.embulk.util.config.ConfigMapper configMapper = this.configMapperFactory.createConfigMapper();
final PluginTask task = configMapper.map(config, PluginTask.class);
// ...
}
public TaskReport run(TaskSource taskSource, Schema schema, int taskIndex, PageOutput output) {
final org.embulk.util.config.TaskMapper taskMapper = this.configMapperFactory.createTaskMapper();
final PluginTask task = taskMapper.map(taskSource, PluginTask.class);
// ...
}
// ...
private org.embulk.util.config.ConfigMapperFactory configMapperFactory;
}
The Task
object generated by ConfigMapper
and TaskMapper
is implemented
with Proxy
, the dynamic proxy mechanism with reflection.
Modifier and Type | Method and Description |
---|---|
TaskSource |
dump()
Deprecated.
Replaced with
toTaskSource() . |
ObjectNode |
toObjectNode()
Dumps this
Task as a ObjectNode . |
TaskSource |
toTaskSource()
Dumps this
Task as a org.embulk.config.TaskSource . |
void |
validate()
|
void validate()
TaskValidationException
- if this Task
is invalid@Deprecated TaskSource dump()
toTaskSource()
.Task
as a org.embulk.config.TaskSource
.org.embulk.config.TaskSource
dumpedTaskSource toTaskSource()
Task
as a org.embulk.config.TaskSource
.org.embulk.config.TaskSource
dumpedObjectNode toObjectNode()
Task
as a ObjectNode
.ObjectNode
dumped