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

com.fastchar.extjs.systemtool.FastSystemToolWeb Maven / Gradle / Ivy

The newest version!
package com.fastchar.extjs.systemtool;

import com.fastchar.core.FastChar;
import com.fastchar.core.FastEngine;
import com.fastchar.extjs.FastExtConfig;
import com.fastchar.extjs.systemtool.provider.*;
import com.fastchar.interfaces.IFastWeb;
import com.fastchar.extjs.systemtool.interceptor.FastSystemToolAfterInterceptor;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author 沈建(Janesen)
 */
public class FastSystemToolWeb implements IFastWeb {

    @Override
    public void onInit(FastEngine engine) throws Exception {
        engine.getOverrides()
                .add(FastExceptionProvider.class)
                .add(FastBaseMenuProvider.class);

    }

    @Override
    public void onRun(FastEngine engine) throws Exception {
        FastSystemToolConfig config = engine.getConfig(FastSystemToolConfig.class);
        if (config.isLogActionRequest() && !config.getLogActionRequestUrlPatterns().isEmpty()) {
            engine.getInterceptors()
                    .addAfter(FastSystemToolAfterInterceptor.class,
                            config.getLogActionRequestUrlPatterns().toArray(new String[]{}));
        }
        if (config.isLogSql()) {
            engine.getOverrides()
                    .add(FastSqlListener.class);
        }

        if (config.isLogHttp()) {
            if (engine.getFindClass().test("com.fastchar.http.core.FastHttpRequest")) {
                engine.getOverrides()
                        .add(FastHttpListener.class);
            }
        }

        if (config.isLogSelenium()) {
            if (engine.getFindClass().test("com.fastchar.selenium.FastSeleniumConfig")) {
                engine.getOverrides()
                        .add(FastSeleniumListener.class);
            }
        }

        if (config.isLogSocket()) {
            if (engine.getFindClass().test("com.fastchar.socket.FastSocketServerConfig")) {
                engine.getOverrides()
                        .add(FastWebSocketListener.class)
                        .add(FastTcpSocketListener.class);
            }
        }
    }


    @Override
    public void onFinish(FastEngine engine) throws Exception {
        IFastWeb.super.onFinish(engine);
        injectConfigJson();
    }

    private void injectConfigJson() {
        FastBaseMenuProvider menuProvider = new FastBaseMenuProvider();

        String[] menusTitle = new String[]{"任务计划日志", "系统HTTP日志", "系统WebDriver日志", "系统Socket连接列表", "系统Socket消息日志", "任务计划日志", "系统请求日志", "系统SQL日志"};

        Map configMap = new LinkedHashMap<>();
        for (String title : menusTitle) {
            configMap.put(title, menuProvider.onShowMenu(title));
        }
        FastExtConfig.getInstance().addInjectConfigJson("systemToolMenu", configMap);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy