zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.changhong.epc.constter.system.run;
 
import com.changhong.epc.constter.system.SystemClients;
import com.iemsoft.framework.cloud.core.run.IEMApplication;
import com.iemsoft.framework.cloud.core.run.param.ParamInst;
import com.iemsoft.framework.cloud.core.tools.SpringUtil;
import com.iemsoft.framework.cloud.ribbon.ServerDefine;
import com.iemsoft.framework.cloud.ribbon.run.AppNameParamFilter;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.context.ConfigurableApplicationContext;
 
public class EpcApplication extends IEMApplication implements SystemClients{
 
    private ServerDefine serverDefine;
    
    public EpcApplication(ServerDefine serverDefine, Object... sources) {
        super(sources);
        this.serverDefine = serverDefine;
    }
 
    public ConfigurableApplicationContext run(String... args) {
        try{
            super.web(true);
            return super.runStart(new AppNameParamFilter(new ParamInst(args), serverDefine).start());
        }finally {
            for(ServerDefine sd : REST_SERVERS){
                SpringUtil.register(
                        sd.getBeanName()
                        , BeanDefinitionBuilder.genericBeanDefinition(EpcRestInterface.class)
                            .addConstructorArgValue(sd.getAppName())
                                .getRawBeanDefinition());
            }
        }
    }
    
}