use of org.apache.gobblin.broker.ImmediatelyInvalidResourceEntry in project incubator-gobblin by apache.
the class DataPublisherFactory method createResource.
@Override
public SharedResourceFactoryResponse<DataPublisher> createResource(SharedResourcesBroker<S> broker, ScopedConfigView<S, DataPublisherKey> config) throws NotConfiguredException {
try {
DataPublisherKey key = config.getKey();
String publisherClassName = key.getPublisherClassName();
State state = key.getState();
Class<? extends DataPublisher> dataPublisherClass = (Class<? extends DataPublisher>) Class.forName(publisherClassName);
log.info("Creating data publisher with class {} in scope {}. ", publisherClassName, config.getScope().toString());
DataPublisher publisher = DataPublisher.getInstance(dataPublisherClass, state);
// once from the broker.
if (isPublisherCacheable(publisher)) {
return new ResourceInstance<>(publisher);
} else {
return new ImmediatelyInvalidResourceEntry<>(publisher);
}
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}
Aggregations