移除excludelibs配置功能
This commit is contained in:
@@ -7,9 +7,6 @@ redkale.lib = ./
|
||||
redkale.executor.threads = 4
|
||||
redkale.executor.hash = false
|
||||
|
||||
#\u3010excludelibs\u8282\u70b9\u5168\u5c40\u552f\u4e00\u3011
|
||||
redkale.excludelibs.value = ^.*mysql.*$;^.*kafka.*$
|
||||
|
||||
#\u3010cluster\u8282\u70b9\u5168\u5c40\u552f\u4e00\u3011
|
||||
redkale.cluster.type = org.redkalex.cluster.consul.ConsulClusterAgent
|
||||
redkale.cluster.waits= = false
|
||||
|
||||
@@ -40,14 +40,7 @@
|
||||
threads: 线程数,为0表示不启用workExecutor,只用IO线程。默认: CPU核数, 核数=1的情况下默认值为2
|
||||
-->
|
||||
<executor threads="4"/>
|
||||
|
||||
<!--
|
||||
【节点全局唯一】
|
||||
自动扫描时排除部分包路径
|
||||
value: 排除lib.path与excludes中的正则表达式匹配的路径, 多个正则表达式用分号;隔开
|
||||
-->
|
||||
<excludelibs value="^.*mysql.*$;^.*kafka.*$"/>
|
||||
|
||||
|
||||
<!--
|
||||
【节点全局唯一】
|
||||
第三方服务发现管理接口
|
||||
|
||||
@@ -207,9 +207,6 @@ public final class Application {
|
||||
//服务配置项
|
||||
final AnyValue config;
|
||||
|
||||
//排除的jar路径
|
||||
final String excludelibs;
|
||||
|
||||
//临时计数器
|
||||
CountDownLatch servicecdl; //会出现两次赋值
|
||||
|
||||
@@ -461,18 +458,13 @@ public final class Application {
|
||||
} catch (IOException e) {
|
||||
throw new RedkaleException(e);
|
||||
}
|
||||
//------------------------------------ 配置 <transport> 节点 ------------------------------------
|
||||
String excludelib0 = null;
|
||||
//------------------------------------ 配置 <xxxagent> 节点 ------------------------------------
|
||||
ClusterAgent cluster = null;
|
||||
MessageAgent[] mqs = null;
|
||||
int bufferCapacity = 32 * 1024;
|
||||
int bufferPoolSize = Utility.cpus() * 8;
|
||||
AnyValue executorConf = null;
|
||||
executorConf = config.getAnyValue("executor");
|
||||
AnyValue excludelibConf = config.getAnyValue("excludelibs");
|
||||
if (excludelibConf != null) {
|
||||
excludelib0 = excludelibConf.getValue("value");
|
||||
}
|
||||
|
||||
AnyValue clusterConf = config.getAnyValue("cluster");
|
||||
if (clusterConf != null) {
|
||||
@@ -601,7 +593,6 @@ public final class Application {
|
||||
this.resourceFactory.register(RESNAME_APP_CLIENT_ASYNCGROUP, AsyncGroup.class, this.clientAsyncGroup);
|
||||
this.resourceFactory.register(RESNAME_APP_CLIENT_ASYNCGROUP, AsyncIOGroup.class, this.clientAsyncGroup);
|
||||
|
||||
this.excludelibs = excludelib0;
|
||||
this.clusterAgent = cluster;
|
||||
this.messageAgents = mqs;
|
||||
{ //加载原生sql解析器
|
||||
@@ -795,7 +786,6 @@ public final class Application {
|
||||
System.getProperties().forEach((k, v) -> {
|
||||
if (k.toString().startsWith("redkale.executor.") //节点全局唯一
|
||||
|| k.toString().startsWith("redkale.transport.") //节点全局唯一
|
||||
|| k.toString().startsWith("redkale.excludelibs.") //节点全局唯一
|
||||
|| k.toString().startsWith("redkale.cluster.") //节点全局唯一
|
||||
|| k.toString().startsWith("redkale.mq.")
|
||||
|| k.toString().startsWith("redkale.mq[")
|
||||
@@ -1677,7 +1667,6 @@ public final class Application {
|
||||
logger.log(Level.FINE, MessageAgent.class.getSimpleName() + " starting");
|
||||
}
|
||||
long s = System.currentTimeMillis();
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
Set<String> names = new HashSet<>();
|
||||
ResourceFactory resourceFactory = this.resourceFactory.createChild();
|
||||
List<ResourceFactory> factorys = new ArrayList<>();
|
||||
@@ -1734,23 +1723,11 @@ public final class Application {
|
||||
}
|
||||
agent.start(consumers);
|
||||
}
|
||||
if (sb.length() > 0) {
|
||||
logger.info(sb.toString().trim());
|
||||
}
|
||||
logger.info("MessageAgent(names=" + JsonConvert.root().convertTo(names) + ") started in " + (System.currentTimeMillis() - s) + " ms");
|
||||
}
|
||||
|
||||
void loadClassesByFilters(String excludelibs, final ClassFilter... filters) throws IOException {
|
||||
ClassFilter.Loader.load(getHome(), this.serverClassLoader, ((this.excludelibs != null ? (this.excludelibs + ";") : "") + (excludelibs == null ? "" : excludelibs)).split(";"), filters);
|
||||
}
|
||||
|
||||
private String alignString(String value, int maxlen) {
|
||||
StringBuilder sb = new StringBuilder(maxlen);
|
||||
sb.append(value);
|
||||
for (int i = 0; i < maxlen - value.length(); i++) {
|
||||
sb.append(' ');
|
||||
}
|
||||
return sb.toString();
|
||||
void loadClassesByFilters(final ClassFilter... filters) throws IOException {
|
||||
ClassFilter.Loader.load(getHome(), this.serverClassLoader, filters);
|
||||
}
|
||||
|
||||
//使用了nohup或使用了后台&,Runtime.getRuntime().addShutdownHook失效
|
||||
@@ -1814,7 +1791,7 @@ public final class Application {
|
||||
try {
|
||||
if (!inited.getAndSet(true)) { //加载自定义的协议,如:SOCKS
|
||||
ClassFilter profilter = new ClassFilter(classLoader, NodeProtocol.class, NodeServer.class, (Class[]) null);
|
||||
ClassFilter.Loader.load(home, classLoader, ((excludelibs != null ? (excludelibs + ";") : "") + serconf.getValue("excludelibs", "")).replace(',', ';').split(";"), profilter);
|
||||
ClassFilter.Loader.load(home, classLoader, profilter);
|
||||
final Set<FilterEntry<NodeServer>> entrys = profilter.getFilterEntrys();
|
||||
for (FilterEntry<NodeServer> entry : entrys) {
|
||||
final Class<? extends NodeServer> type = entry.getType();
|
||||
@@ -2262,7 +2239,7 @@ public final class Application {
|
||||
Properties newLogProps = new Properties();
|
||||
newLogProps.putAll(this.loggingProperties);
|
||||
newLogProps.putAll(loggingChangedProps);
|
||||
loggingRemovedKeys.forEach(k -> newLogProps.remove(k));
|
||||
loggingRemovedKeys.forEach(newLogProps::remove);
|
||||
reconfigLogging(newLogProps);
|
||||
logger.log(Level.INFO, "Reconfig logging finished ");
|
||||
}
|
||||
@@ -2408,7 +2385,7 @@ public final class Application {
|
||||
}
|
||||
}
|
||||
}
|
||||
sourceRemovedKeys.forEach(k -> this.sourceProperties.remove(k));
|
||||
sourceRemovedKeys.forEach(this.sourceProperties::remove);
|
||||
this.sourceProperties.putAll(sourceChangedProps);
|
||||
}
|
||||
|
||||
@@ -2553,15 +2530,6 @@ public final class Application {
|
||||
+ " help, -h, --help show this help\r\n";
|
||||
}
|
||||
|
||||
NodeSncpServer findNodeSncpServer(final InetSocketAddress sncpAddr) {
|
||||
for (NodeServer node : servers) {
|
||||
if (node.isSNCP() && sncpAddr.equals(node.getSncpAddress())) {
|
||||
return (NodeSncpServer) node;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<Object> command(String cmd, String[] params) {
|
||||
List<NodeServer> localServers = new ArrayList<>(servers); //顺序sncps, others, watchs
|
||||
List<Object> results = new ArrayList<>();
|
||||
@@ -2778,21 +2746,4 @@ public final class Application {
|
||||
return singletonMode;
|
||||
}
|
||||
|
||||
private static int parseLenth(String value, int defValue) {
|
||||
if (value == null) {
|
||||
return defValue;
|
||||
}
|
||||
value = value.toUpperCase().replace("B", "");
|
||||
if (value.endsWith("G")) {
|
||||
return Integer.decode(value.replace("G", "")) * 1024 * 1024 * 1024;
|
||||
}
|
||||
if (value.endsWith("M")) {
|
||||
return Integer.decode(value.replace("M", "")) * 1024 * 1024;
|
||||
}
|
||||
if (value.endsWith("K")) {
|
||||
return Integer.decode(value.replace("K", "")) * 1024;
|
||||
}
|
||||
return Integer.decode(value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -576,27 +576,14 @@ public final class ClassFilter<T> {
|
||||
*
|
||||
* @throws IOException 异常
|
||||
*/
|
||||
public static void load(final File excludeFile, RedkaleClassLoader loader, final String[] excludeRegs, final ClassFilter... filters) throws IOException {
|
||||
public static void load(final File excludeFile, RedkaleClassLoader loader, final ClassFilter... filters) throws IOException {
|
||||
List<URL> urlfiles = new ArrayList<>(2);
|
||||
List<URL> urljares = new ArrayList<>(2);
|
||||
final URL exurl = excludeFile != null ? excludeFile.toURI().toURL() : null;
|
||||
final Pattern[] excludePatterns = toPattern(excludeRegs);
|
||||
for (URL url : loader.getAllURLs()) {
|
||||
if (exurl != null && exurl.sameFile(url)) {
|
||||
continue;
|
||||
}
|
||||
if (excludePatterns != null && url != RedkaleClassLoader.URL_NONE) {
|
||||
boolean skip = false;
|
||||
for (Pattern p : excludePatterns) {
|
||||
if (p.matcher(url.toString()).matches()) {
|
||||
skip = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (skip) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (url.getPath().endsWith(".jar")) {
|
||||
urljares.add(url);
|
||||
} else {
|
||||
|
||||
@@ -213,7 +213,7 @@ public abstract class NodeServer {
|
||||
filters.addAll(otherFilters);
|
||||
}
|
||||
long s = System.currentTimeMillis();
|
||||
application.loadClassesByFilters(serverConf.getValue("excludelibs", ""), filters.toArray(new ClassFilter[filters.size()]));
|
||||
application.loadClassesByFilters(filters.toArray(new ClassFilter[filters.size()]));
|
||||
long e = System.currentTimeMillis() - s;
|
||||
logger.info(this.getClass().getSimpleName() + " load filter class in " + e + " ms");
|
||||
loadService(serviceFilter); //必须在servlet之前
|
||||
|
||||
@@ -39,7 +39,6 @@ public class PrepareCompiler {
|
||||
}
|
||||
application.start();
|
||||
final boolean hasSncp = application.getNodeServers().stream().filter(v -> v instanceof NodeSncpServer).findFirst().isPresent();
|
||||
final String[] exlibs = (application.excludelibs != null ? (application.excludelibs + ";") : "").split(";");
|
||||
|
||||
final ClassFilter<?> entityFilter = new ClassFilter(application.getClassLoader(), Entity.class, Object.class, (Class[]) null);
|
||||
final ClassFilter<?> entityFilter2 = new ClassFilter(application.getClassLoader(), javax.persistence.Entity.class, Object.class, (Class[]) null);
|
||||
@@ -47,7 +46,7 @@ public class PrepareCompiler {
|
||||
final ClassFilter<?> beanFilter2 = new ClassFilter(application.getClassLoader(), org.redkale.util.Bean.class, Object.class, (Class[]) null);
|
||||
final ClassFilter<?> filterFilter = new ClassFilter(application.getClassLoader(), null, FilterBean.class, (Class[]) null);
|
||||
|
||||
ClassFilter.Loader.load(application.getHome(), application.getClassLoader(), exlibs, entityFilter, beanFilter, filterFilter);
|
||||
ClassFilter.Loader.load(application.getHome(), application.getClassLoader(), entityFilter, beanFilter, filterFilter);
|
||||
|
||||
for (FilterEntry en : entityFilter.getFilterEntrys()) {
|
||||
Class clz = en.getType();
|
||||
|
||||
Reference in New Issue
Block a user