All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nhl.link.move.runtime.extractor.ExtractorService Maven / Gradle / Ivy

There is a newer version: 3.0.M6
Show newest version
package com.nhl.link.move.runtime.extractor;

import com.nhl.link.move.extractor.Extractor;
import com.nhl.link.move.extractor.model.ExtractorName;
import com.nhl.link.move.runtime.connect.IConnectorService;
import com.nhl.link.move.runtime.extractor.model.IExtractorModelService;
import org.apache.cayenne.di.Inject;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ExtractorService implements IExtractorService {

    private final IExtractorModelService modelService;
    private final IConnectorService connectorService;
    private final Map factories;
    private final Map extractorCache;

    public ExtractorService(
            @Inject IExtractorModelService modelService,
            @Inject IConnectorService connectorService,
            @Inject Map factories) {

        this.factories = factories;
        this.modelService = modelService;
        this.connectorService = connectorService;
        this.extractorCache = new ConcurrentHashMap<>();
    }

    @Override
    public Extractor getExtractor(ExtractorName name) {
        return extractorCache.computeIfAbsent(name, n
                        -> new ExtractorReloader(modelService, connectorService, factories, n))
                .getOrReload();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy