Search in sources :

Example 1 with CachedLazyInit

use of org.polymap.core.runtime.CachedLazyInit in project polymap4-core by Polymap4.

the class FeatureRenderProcessor2 method init.

@Override
public void init(@SuppressWarnings("hiding") PipelineProcessorSite site) throws Exception {
    this.site = site;
    // styleSupplier
    style = STYLE_SUPPLIER.rawopt(site).orElseGet(() -> {
        log.warn("No style for resource: " + site.dsd.get().resourceName.get());
        return () -> DefaultStyles.findStyle(fs.get());
    });
    // pipeline
    this.pipeline = new CachedLazyInit(() -> {
        try {
            PipelineBuilder builder = site.builder.get();
            DataSourceDescriptor dsd = new DataSourceDescriptor(site.dsd.get());
            return builder.createPipeline(site.layerId.get(), FeaturesProducer.class, dsd).get();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
    // fs
    this.fs = new CachedLazyInit(() -> {
        try {
            return new PipelineDataStore(pipeline.get()).getFeatureSource();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    });
}
Also used : CachedLazyInit(org.polymap.core.runtime.CachedLazyInit) IOException(java.io.IOException) PipelineBuilder(org.polymap.core.data.pipeline.PipelineBuilder) IOException(java.io.IOException) DataSourceDescriptor(org.polymap.core.data.pipeline.DataSourceDescriptor) PipelineDataStore(org.polymap.core.data.PipelineDataStore)

Aggregations

IOException (java.io.IOException)1 PipelineDataStore (org.polymap.core.data.PipelineDataStore)1 DataSourceDescriptor (org.polymap.core.data.pipeline.DataSourceDescriptor)1 PipelineBuilder (org.polymap.core.data.pipeline.PipelineBuilder)1 CachedLazyInit (org.polymap.core.runtime.CachedLazyInit)1