Search in sources :

Example 1 with ModuleContext

use of io.crnk.core.module.Module.ModuleContext in project crnk-framework by crnk-project.

the class MetaLookup method addProvider.

public void addProvider(MetaProvider provider) {
    providers.add(provider);
    provider.init(new MetaProviderContext() {

        @Override
        public ModuleContext getModuleContext() {
            return moduleContext;
        }

        @Override
        public Optional<MetaElement> getMetaElement(String id) {
            return Optional.ofNullable(idElementMap.get(id));
        }

        @Override
        public void checkInitialized() {
            MetaLookup.this.checkInitialized();
        }

        @Override
        public <T> T runDiscovery(Callable<T> callable) {
            return discover(callable);
        }
    });
    for (MetaFilter filter : provider.getFilters()) {
        addFilter(filter);
    }
    for (MetaPartition partition : provider.getPartitions()) {
        addPartition(partition);
    }
    metaTypes.addAll(provider.getMetaTypes());
}
Also used : Optional(io.crnk.core.utils.Optional) ModuleContext(io.crnk.core.module.Module.ModuleContext) BaseMetaPartition(io.crnk.meta.internal.BaseMetaPartition)

Aggregations

ModuleContext (io.crnk.core.module.Module.ModuleContext)1 Optional (io.crnk.core.utils.Optional)1 BaseMetaPartition (io.crnk.meta.internal.BaseMetaPartition)1