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

javax.web.skeleton4j.spring.Skeleton4jConfigureFactory Maven / Gradle / Ivy

There is a newer version: 1.0.0-PRE7
Show newest version
package javax.web.skeleton4j.spring;

import lombok.Setter;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import javax.web.doc.DocScanner;
import javax.web.doc.DocScannerFactory;
import javax.web.skeleton4j.Skeleton4jConfigService;
import javax.web.skeleton4j.Skeleton4jConfigServiceFactory;
import javax.web.skeleton4j.Skeleton4jService;
import javax.web.skeleton4j.Skeleton4jServiceFactory;
import javax.web.skeleton4j.config.Skeleton4jConfig;
import javax.web.skeleton4j.pool.ModulePool;
import javax.web.skeleton4j.registry.WebComponentRegistryFactory;
import java.util.*;

/**
 * Created by devops4j on 2017/12/16.
 * Skeleton4j配置工厂
 */
public class Skeleton4jConfigureFactory implements ApplicationContextAware, InitializingBean{

    ApplicationContext applicationContext;
    /**
     * 模块池
     */
    @Setter
    ModulePool modulePool;

    @Setter
    DocScanner docScanner;

    @Setter
    String configClassName;

    Skeleton4jService skeleton4jService;

    Skeleton4jConfigService skeleton4jConfigService;


    @Override
    public void afterPropertiesSet() throws Exception {
        if (docScanner == null) {
            docScanner = DocScannerFactory.newInstance();
        }
        if(skeleton4jService == null){
            skeleton4jService = Skeleton4jServiceFactory.getInstance();
        }
        if(skeleton4jConfigService == null){
            skeleton4jConfigService = Skeleton4jConfigServiceFactory.getInstance(configClassName);
        }

        Skeleton4jConfig config = skeleton4jConfigService.load();

        Set pagePaths = new HashSet(Arrays.asList(Skeleton4jService.DEFAULT_PAGES));
        String pagePathsParam = config.getString("pagePackages", "");
        if(!pagePathsParam.isEmpty()){
            String[] pagePaths0 = pagePathsParam.split(";");
            for (String path : pagePaths0){
                pagePaths.add(path);
            }
        }
        Set themePaths = new HashSet(Arrays.asList(Skeleton4jService.DEFAULT_THEMES));
        String themePathsParam = config.getString("themePackages", "");
        if(!themePathsParam.isEmpty()){
            String[] themePaths0 = themePathsParam.split(";");
            for (String path : themePaths0){
                themePaths.add(path);
            }
        }
        docScanner.setComponentRegistry(WebComponentRegistryFactory.getInstance());
        skeleton4jService.init(config, docScanner, modulePool, pagePaths, themePaths);
        skeleton4jService.scan();
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy