Application.singleton多加一个参数,指定其他Service也被加载
This commit is contained in:
@@ -812,14 +812,22 @@ public final class Application {
|
||||
sercdl.await();
|
||||
}
|
||||
|
||||
public static <T extends Service> T singleton(Class<T> serviceClass) throws Exception {
|
||||
return singleton("", serviceClass);
|
||||
public static <T extends Service> T singleton(Class<T> serviceClass, Class<? extends Service>... extServiceClasses) throws Exception {
|
||||
return singleton("", serviceClass, extServiceClasses);
|
||||
}
|
||||
|
||||
public static <T extends Service> T singleton(String name, Class<T> serviceClass) throws Exception {
|
||||
public static <T extends Service> T singleton(String name, Class<T> serviceClass, Class<? extends Service>... extServiceClasses) throws Exception {
|
||||
if (serviceClass == null) throw new IllegalArgumentException("serviceClass is null");
|
||||
final Application application = Application.create(true);
|
||||
System.setProperty("red" + "kale-singleton-serviceclass", serviceClass.getName());
|
||||
if (extServiceClasses != null && extServiceClasses.length > 0) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Class clazz : extServiceClasses) {
|
||||
if (sb.length() > 0) sb.append(',');
|
||||
sb.append(clazz.getName());
|
||||
}
|
||||
System.setProperty("red" + "kale-singleton-extserviceclasses", sb.toString());
|
||||
}
|
||||
application.init();
|
||||
application.start();
|
||||
for (NodeServer server : application.servers) {
|
||||
|
||||
@@ -156,7 +156,17 @@ public abstract class NodeServer {
|
||||
ClassFilter<Service> serviceFilter = createServiceClassFilter();
|
||||
if (application.singletonrun) { //singleton模式下只加载指定的Service
|
||||
final String ssc = System.getProperty("red" + "kale-singleton-serviceclass");
|
||||
if (ssc != null) serviceFilter.setExpectPredicate(c -> !ssc.equals(c));
|
||||
final String extssc = System.getProperty("red" + "kale-singleton-extserviceclasses");
|
||||
if (ssc != null) {
|
||||
final List<String> sscList = new ArrayList<>();
|
||||
sscList.add(ssc);
|
||||
if (extssc != null && !extssc.isEmpty()) {
|
||||
for (String s : extssc.split(",")) {
|
||||
if (!s.isEmpty()) sscList.add(s);
|
||||
}
|
||||
}
|
||||
serviceFilter.setExpectPredicate(c -> !sscList.contains(c));
|
||||
}
|
||||
}
|
||||
ClassFilter<Filter> filterFilter = createFilterClassFilter();
|
||||
ClassFilter<Servlet> servletFilter = createServletClassFilter();
|
||||
|
||||
@@ -878,7 +878,7 @@ public final class EntityInfo<T> {
|
||||
*
|
||||
* @return Object
|
||||
*/
|
||||
public Object getSQLValue(String fieldname, Object fieldvalue) {
|
||||
public Object getSQLValue(String fieldname, Serializable fieldvalue) {
|
||||
if (this.cryptmap == null) return fieldvalue;
|
||||
CryptHandler handler = this.cryptmap.get(fieldname);
|
||||
if (handler == null) return fieldvalue;
|
||||
|
||||
@@ -389,7 +389,7 @@ public class FilterNode { //FilterNode 不能实现Serializable接口, 否则
|
||||
.append(' ').append(fv.getExpress().value()).append(' ').append(fv.getDestvalue());
|
||||
}
|
||||
final boolean fk = (val0 instanceof FilterKey);
|
||||
CharSequence val = fk ? info.getSQLColumn(talis, ((FilterKey) val0).getColumn()) : formatToString(express, info.getSQLValue(column, val0));
|
||||
CharSequence val = fk ? info.getSQLColumn(talis, ((FilterKey) val0).getColumn()) : formatToString(express, info.getSQLValue(column, (Serializable) val0));
|
||||
if (val == null) return null;
|
||||
StringBuilder sb = new StringBuilder(32);
|
||||
if (express == CONTAIN) return info.containSQL.replace("${column}", info.getSQLColumn(talis, column)).replace("${keystr}", val);
|
||||
|
||||
Reference in New Issue
Block a user