Let nacos-server.jar import external jar package

This commit is contained in:
XCXCXCXCX 2019-05-08 09:14:54 +08:00
parent ef7e250675
commit 6695805c69
4 changed files with 12 additions and 6 deletions

View File

@ -104,6 +104,7 @@
<version>2.1.1.RELEASE</version>
<configuration>
<mainClass>com.alibaba.nacos.Nacos</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>

View File

@ -35,9 +35,8 @@ if not "%2" == "cluster" (
set "JAVA_OPT=%JAVA_OPT% -XX:-UseLargePages"
)
set "JAVA_OPT=%JAVA_OPT% -Xbootclasspath/a:%BASE_DIR%\plugins\cmdb"
set "JAVA_OPT=%JAVA_OPT% -Dnacos.home=%BASE_DIR%"
set "JAVA_OPT=%JAVA_OPT% -jar %BASE_DIR%\target\nacos-server.jar"
set "JAVA_OPT=%JAVA_OPT% -Dloader.path=%BASE_DIR%/plugins/health/nacos-health-plugin-example-1.0.jar -jar %BASE_DIR%\target\nacos-server.jar"
set "JAVA_OPT=%JAVA_OPT% --spring.config.location=%CUSTOM_SEARCH_LOCATIONS%"
set "JAVA_OPT=%JAVA_OPT% --logging.config=%BASE_DIR%/conf/nacos-logback.xml"

View File

@ -102,7 +102,7 @@ else
fi
JAVA_OPT="${JAVA_OPT} -Dnacos.home=${BASE_DIR}"
JAVA_OPT="${JAVA_OPT} -jar ${BASE_DIR}/target/nacos-server.jar"
JAVA_OPT="${JAVA_OPT} -Dloader.path=${BASE_DIR}/plugins/health/nacos-health-plugin-example-1.0.jar -jar ${BASE_DIR}/target/nacos-server.jar"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} --spring.config.location=${CUSTOM_SEARCH_LOCATIONS}"
JAVA_OPT="${JAVA_OPT} --logging.config=${BASE_DIR}/conf/nacos-logback.xml"

View File

@ -19,6 +19,8 @@ import com.alibaba.nacos.api.naming.pojo.AbstractHealthChecker;
import com.alibaba.nacos.naming.healthcheck.HealthCheckProcessor;
import com.alibaba.nacos.naming.healthcheck.HealthCheckType;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
@ -36,6 +38,8 @@ import java.util.Set;
@Component
public class HealthCheckExtendProvider implements BeanFactoryAware {
private static final Logger LOGGER = LoggerFactory.getLogger(HealthCheckExtendProvider.class);
private ServiceLoader<HealthCheckProcessor> processorLoader
= ServiceLoader.load(HealthCheckProcessor.class);
@ -75,16 +79,18 @@ public class HealthCheckExtendProvider implements BeanFactoryAware {
AbstractHealthChecker checker = healthCheckerIt.next();
String type = checker.getType();
if(healthCheckerType.contains(type)){
if(processorType.contains(type)){
throw new RuntimeException("More than one healthChecker of the same type was found : [type=\"" + type + "\"]");
}
}
healthCheckerType.add(type);
HealthCheckType.registerHealthChecker(checker.getType(), checker.getClass());
}
if(!processorType.equals(healthCheckerType)){
throw new RuntimeException("An unmatched processor and healthChecker are detected in the extension package.");
}
if(processorType.size() > origin.size()){
processorType.removeAll(origin);
LOGGER.debug("init health plugin : types=" + processorType);
}
}
private String lowerFirstChar(String simpleName) {