private DataAdapter<?> getAdapterInternal(final ByteArrayId adapterId) {
    // first try to get it from the job context
    DataAdapter<?> adapter = getDataAdapter(context, adapterId);
    if (adapter == null) {
      // then try to get it from the persistent store
      adapter = persistentAdapterStore.getAdapter(adapterId);
    }

    if (adapter != null) {
      adapterCache.put(adapterId, adapter);
    }
    return adapter;
  }
  @Override
  public CloseableIterator<DataAdapter<?>> getAdapters() {
    final CloseableIterator<DataAdapter<?>> it = persistentAdapterStore.getAdapters();
    // cache any results
    return new CloseableIteratorWrapper<DataAdapter<?>>(
        it,
        IteratorUtils.transformedIterator(
            it,
            new Transformer() {

              @Override
              public Object transform(final Object obj) {
                if (obj instanceof DataAdapter) {
                  adapterCache.put(((DataAdapter) obj).getAdapterId(), (DataAdapter) obj);
                }
                return obj;
              }
            }));
  }
Пример #3
0
 public void addAdapter(DataAdapter<?> adapter) {
   adapterCache.addAdapter(adapter);
 }