You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.2 KiB
89 lines
2.2 KiB
11 months ago
|
package com.fr.start;
|
||
|
|
||
|
import com.fanruan.boot.DiscoveryProperties;
|
||
|
import com.fanruan.carina.Carina;
|
||
|
import com.fanruan.carina.context.CarinaApplicationContext;
|
||
|
import com.fanruan.carina.exceptions.CarinaException;
|
||
|
import com.fanruan.carina.launch.XmlCarinaLauncher;
|
||
|
import com.fanruan.carina.lifecycle.bootstrap.BootstrapFactory;
|
||
|
import com.fanruan.discovery.DiscoveryFactory;
|
||
|
|
||
|
import javax.servlet.ServletContext;
|
||
|
import java.util.Properties;
|
||
|
|
||
|
/**
|
||
|
* 设计器启动的launcher,用来自定义具体的launcher逻辑
|
||
|
*
|
||
|
* @author Destiny.Lin
|
||
|
* @since 11.0
|
||
|
* Created on 2024/5/27
|
||
|
*/
|
||
|
public class DesignLauncher extends XmlCarinaLauncher {
|
||
|
private static CarinaApplicationContext context;
|
||
|
public DesignLauncher(String path) {
|
||
|
super(context.getPartitionManager(), context.getServletContext(), context.getCarinaApplicationProperties(), path);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected boolean validate(Class<?> clz) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected CarinaApplicationContext createApplicationContext(ServletContext servletContext, Properties carinaApplicationProperties) {
|
||
|
return context;
|
||
|
}
|
||
|
|
||
|
|
||
|
@Override
|
||
|
protected void initServiceDiscovery() throws CarinaException {
|
||
|
try {
|
||
|
Carina.properties(DiscoveryProperties.class).setServer("local");
|
||
|
// 服务发现初始化
|
||
|
DiscoveryFactory.initialize();
|
||
|
} catch (Exception e) {
|
||
|
throw new CarinaException(e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void initializeSpring() throws CarinaException {
|
||
|
// do nothing
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void startListening() {
|
||
|
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void setGlobalInformation() {
|
||
|
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void startComponentsAndServices() throws CarinaException {
|
||
|
try {
|
||
|
BootstrapFactory.get().supplement();
|
||
|
BootstrapFactory.get().start("design_init");
|
||
|
} catch (Exception e) {
|
||
|
throw new RuntimeException(e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 获取context
|
||
|
*/
|
||
|
public static CarinaApplicationContext getContext() {
|
||
|
return context;
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* 设置context
|
||
|
*/
|
||
|
public static void setContext(CarinaApplicationContext context) {
|
||
|
DesignLauncher.context = context;
|
||
|
}
|
||
|
}
|