use of org.talend.components.pubsub.runtime.IPubSubDatasetRuntime in project components by Talend.
the class PubSubDatasetProperties method beforeSubscription.
public ValidationResult beforeSubscription() {
PubSubDatasetDefinition definition = new PubSubDatasetDefinition();
RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
IPubSubDatasetRuntime runtime = (IPubSubDatasetRuntime) sandboxedInstance.getInstance();
runtime.initialize(null, this);
List<NamedThing> topics = new ArrayList<>();
for (String topicName : runtime.listSubscriptions()) {
topics.add(new SimpleNamedThing(topicName, topicName));
}
subscription.setPossibleValues(topics);
return ValidationResult.OK;
} catch (Exception e) {
return new ValidationResult(new ComponentException(e));
}
}
use of org.talend.components.pubsub.runtime.IPubSubDatasetRuntime in project components by Talend.
the class PubSubDatasetProperties method beforeTopic.
public ValidationResult beforeTopic() {
PubSubDatasetDefinition definition = new PubSubDatasetDefinition();
RuntimeInfo runtimeInfo = definition.getRuntimeInfo(this);
try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, getClass().getClassLoader())) {
IPubSubDatasetRuntime runtime = (IPubSubDatasetRuntime) sandboxedInstance.getInstance();
runtime.initialize(null, this);
List<NamedThing> topics = new ArrayList<>();
for (String topicName : runtime.listTopics()) {
topics.add(new SimpleNamedThing(topicName, topicName));
}
topic.setPossibleValues(topics);
return ValidationResult.OK;
} catch (Exception e) {
return new ValidationResult(new ComponentException(e));
}
}
Aggregations