Search in sources :

Example 1 with IKafkaDatasetRuntime

use of org.talend.components.kafka.runtime.IKafkaDatasetRuntime in project components by Talend.

the class KafkaDatasetProperties method beforeTopic.

public ValidationResult beforeTopic() {
    KafkaDatasetDefinition definition = new KafkaDatasetDefinition();
    RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
    try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
        IKafkaDatasetRuntime runtime = (IKafkaDatasetRuntime) sandboxedInstance.getInstance();
        runtime.initialize(null, this);
        this.topic.setPossibleValues(new ArrayList(runtime.listTopic()));
        return ValidationResult.OK;
    } catch (Exception e) {
        return new ValidationResult(new ComponentException(e));
    }
}
Also used : SandboxedInstance(org.talend.daikon.sandbox.SandboxedInstance) RuntimeInfo(org.talend.daikon.runtime.RuntimeInfo) ArrayList(java.util.ArrayList) ComponentException(org.talend.components.api.exception.ComponentException) IKafkaDatasetRuntime(org.talend.components.kafka.runtime.IKafkaDatasetRuntime) ValidationResult(org.talend.daikon.properties.ValidationResult) ComponentException(org.talend.components.api.exception.ComponentException)

Aggregations

ArrayList (java.util.ArrayList)1 ComponentException (org.talend.components.api.exception.ComponentException)1 IKafkaDatasetRuntime (org.talend.components.kafka.runtime.IKafkaDatasetRuntime)1 ValidationResult (org.talend.daikon.properties.ValidationResult)1 RuntimeInfo (org.talend.daikon.runtime.RuntimeInfo)1 SandboxedInstance (org.talend.daikon.sandbox.SandboxedInstance)1