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

chao.java.tools.servicepool.cache.custom.Custom Maven / Gradle / Ivy

There is a newer version: 1.9.0
Show newest version
package chao.java.tools.servicepool.cache.custom;

import chao.java.tools.servicepool.IService;
import chao.java.tools.servicepool.IServiceFactory;
import chao.java.tools.servicepool.Sp;
import chao.java.tools.servicepool.cache.AbsServiceCacheStrategy;

/**
 * @author luqin
 * @since 2020-08-06
 */
public final class Custom extends AbsServiceCacheStrategy {

    private final int customScope;

    private IServiceFactory factory;

    public Custom(int customScope, IServiceFactory factory) {
        this.factory = factory;
        this.customScope = customScope;
    }

    /**
     *
     * @param serviceClass  经过 {@link chao.java.tools.servicepool.ServicePool} 查找后的class
     *
     * @param originClass   对应 {@link chao.java.tools.servicepool.ServicePool#getService(Class)}方法的参数class
     *
     */
    @SuppressWarnings("unchecked")
    @Override
    public T getService(Class serviceClass, Class originClass) {
        CustomCacheStrategy customCache =  Sp.getCombineService(CustomCacheStrategy.class, new CustomCombineStrategy(customScope));
        return getProxyService(originClass, customCache.getService(factory, originClass, serviceClass));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy