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

com.cloudimpl.outstack.spring.component.ResourcesLoaderEx Maven / Gradle / Ivy

There is a newer version: 4.0.551
Show newest version
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cloudimpl.outstack.spring.component;

import com.cloudimpl.outstack.app.ResourcesLoader;
import com.cloudimpl.outstack.app.ServiceMeta;
import com.cloudimpl.outstack.coreImpl.ServiceEndpointPlugin;
import com.cloudimpl.outstack.runtime.ResourceHelper;
import com.cloudimpl.outstack.spring.service.IReactiveService;
import com.cloudimpl.outstack.spring.util.SpringUtil;
import com.cloudimpl.outstack.util.SrvUtil;
import io.github.classgraph.ClassInfoList;
import io.github.classgraph.ScanResult;

import java.lang.reflect.Modifier;
import java.util.stream.Collectors;

/**
 *
 * @author nuwan
 */
public class ResourcesLoaderEx extends ResourcesLoader{
    
    private final ResourceHelper resourceHelper;

    public ResourcesLoaderEx(ResourceHelper resourceHelper) {
        this.resourceHelper = resourceHelper;
    }
    
    @Override
    protected ServiceMeta toServiceMeta(Class serviceType)
    {
        if(SpringService.class.isAssignableFrom(serviceType))
        {
            return SpringUtil.serviceProviderMeta(resourceHelper,(Class) serviceType);
        }
        else if(SpringQueryService.class.isAssignableFrom(serviceType))
        {
            return SpringUtil.serviceQueryProviderMeta(resourceHelper,(Class) serviceType);
        }
        else if(IReactiveService.class.isAssignableFrom(serviceType))
        {
            return SpringUtil.reactiveServiceMeta((Class) serviceType);
        }
        return SrvUtil.serviceMeta(serviceType);
    }

    @Override
    public void preload(ScanResult rs)
    {
        super.preload(rs);
        ClassInfoList list = rs.getClassesImplementing(IReactiveService.class.getName());
        metaList.addAll(list.loadClasses().stream().filter(cls -> !cls.isInterface()).filter(cls -> !Modifier.isAbstract(cls.getModifiers())).map(this::toServiceMeta).collect(Collectors.toList()));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy