Fastjson2Plugin.java

package com.alibaba.fastjson2.support.solon.integration;

import com.alibaba.fastjson2.support.solon.Fastjson2ActionExecutor;
import com.alibaba.fastjson2.support.solon.Fastjson2RenderFactory;
import com.alibaba.fastjson2.support.solon.Fastjson2RenderTypedFactory;
import org.noear.solon.Solon;
import org.noear.solon.core.AppContext;
import org.noear.solon.core.Plugin;
import org.noear.solon.serialization.prop.JsonProps;

/**
 * Fastjson2 for solon extension integration plugin
 *
 * @author noear
 * */
public class Fastjson2Plugin
        implements Plugin {
    @Override
    public void start(AppContext context) {
        JsonProps jsonProps = JsonProps.create(context);

        //::renderFactory
        Fastjson2RenderFactory renderFactory = new Fastjson2RenderFactory(jsonProps); //������������
        context.wrapAndPut(Fastjson2RenderFactory.class, renderFactory); //���������������������������
        Solon.app().renderManager().register(renderFactory);

        //::renderTypedFactory
        Fastjson2RenderTypedFactory renderTypedFactory = new Fastjson2RenderTypedFactory();
        context.wrapAndPut(Fastjson2RenderTypedFactory.class, renderTypedFactory); //���������������������������
        Solon.app().renderManager().register(renderTypedFactory);

        //::actionExecutor
        Fastjson2ActionExecutor actionExecutor = new Fastjson2ActionExecutor(); //������ json ������������������
        context.wrapAndPut(Fastjson2ActionExecutor.class, actionExecutor); //���������������������������
        Solon.app().chainManager().addExecuteHandler(actionExecutor);
    }
}