- if (candidates.isEmpty()) {
- return Futures.immediateFailedFuture(new SchemaSourceTransformationException(
- String.format("No matching source/transformer pair for source %s representation %s found", id, representation)));
- }
-
- Collections.sort(candidates, TRANSFORMER_COST_COMPARATOR);
- // return transform(candidates.iterator(), id);
- return null;
- }
-
- /**
- * Obtain a SchemaSource is selected representation
- */
- protected <T extends SchemaSourceRepresentation> ListenableFuture<Optional<T>> getSchemaSource(final SourceIdentifier id, final Class<T> representation) {
- final Multimap<Class<?>, AbstractSchemaSourceRegistration> srcs = sources.get(id);
- if (srcs == null) {
- LOG.debug("No providers registered for source {}", id);
- return Futures.immediateFuture(Optional.<T>absent());
- }
-
- final Collection<AbstractSchemaSourceRegistration> candidates = srcs.get(representation);
- return Futures.transform(AbstractSchemaRepository.<T>fetchSource(id, candidates.iterator()), new AsyncFunction<Optional<T>, Optional<T>>() {
+ CheckedFuture<T, SchemaSourceException> fetchSourceFuture = fetchSource(id, regs);
+ // Add callback to notify cache listeners about encountered schema
+ Futures.addCallback(fetchSourceFuture, new FutureCallback<T>() {