This commit is contained in:
Redkale
2018-03-12 21:41:36 +08:00
parent 3a13d242f6
commit e223548b23
20 changed files with 76 additions and 4 deletions

View File

@@ -124,6 +124,19 @@ public abstract class Server<K extends Serializable, C extends Context, R extend
this.responsePoolSize = config.getIntValue("responsePoolSize", this.threads * 2);
this.name = config.getValue("name", "Server-" + protocol + "-" + this.address.getPort());
if (!this.name.matches("^[a-zA-Z][\\w_-]{1,64}$")) throw new RuntimeException("server.name (" + this.name + ") is illegal");
AnyValue sslConf = config.getAnyValue("ssl");
if (sslConf != null) {
String creatorClass = sslConf.getValue("creator", SSLCreator.class.getName());
if (SSLCreator.class.getName().equals(creatorClass) || creatorClass.isEmpty()) {
this.sslContext = new SSLCreator() {
}.create(this, sslConf);
} else {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
@SuppressWarnings("unchecked")
SSLCreator creator = ((SSLCreator) classLoader.loadClass(creatorClass).getDeclaredConstructor().newInstance());
this.sslContext = creator.create(this, sslConf);
}
}
final AtomicInteger counter = new AtomicInteger();
final Format f = createFormat();
final String n = name;