use of com.generallycloud.baseio.common.Properties in project baseio by generallycloud.
the class ApplicationBootstrapEngine method bootstrap.
@Override
public void bootstrap(String rootPath, boolean deployModel) throws Exception {
ClassLoader classLoader = getClass().getClassLoader();
Properties serverProperties = FileUtil.readPropertiesByCls("server.properties");
ServerConfiguration sc = new ServerConfiguration();
new PropertiesSCLoader("SERVER").loadConfiguration(sc, serverProperties);
ApplicationContext applicationContext = new ApplicationContext(rootPath);
applicationContext.setDeployModel(deployModel);
SocketChannelContext channelContext = new NioSocketChannelContext(sc);
// SocketChannelContext channelContext = new AioSocketChannelContext(sc);
SocketChannelAcceptor acceptor = new SocketChannelAcceptor(channelContext);
try {
Properties intfProperties = FileUtil.readPropertiesByCls("intf.properties");
applicationContext.setBlackIPs(loadBlackIPs());
applicationContext.setChannelContext(channelContext);
ApplicationConfigurationLoader acLoader = loadConfigurationLoader(intfProperties.getProperty("intf.ApplicationConfigurationLoader"));
ApplicationExtLoader applicationExtLoader = loadApplicationExtLoader(intfProperties.getProperty("intf.ApplicationExtLoader"));
ApplicationContextEnricher enricher = loadApplicationContextEnricher(intfProperties.getProperty("intf.ApplicationContextEnricher"));
applicationContext.setApplicationExtLoader(applicationExtLoader);
applicationContext.setApplicationConfigurationLoader(acLoader);
enricher.enrich(applicationContext);
channelContext.setIoEventHandleAdaptor(new ApplicationIoEventHandle(applicationContext));
if (sc.isSERVER_ENABLE_SSL()) {
if (!StringUtil.isNullOrBlank(sc.getSERVER_CERT_KEY())) {
File certificate = FileUtil.readFileByCls(sc.getSERVER_CERT_CRT(), classLoader);
File privateKey = FileUtil.readFileByCls(sc.getSERVER_CERT_KEY(), classLoader);
SslContext sslContext = SSLUtil.initServer(privateKey, certificate);
channelContext.setSslContext(sslContext);
} else {
String keystoreInfo = sc.getSERVER_SSL_KEYSTORE();
if (StringUtil.isNullOrBlank(keystoreInfo)) {
throw new IllegalArgumentException("ssl enabled,but no config for");
}
String[] params = keystoreInfo.split(";");
if (params.length != 4) {
throw new IllegalArgumentException("SERVER_SSL_KEYSTORE config error");
}
File storeFile = FileUtil.readFileByCls(params[0], classLoader);
SslContext sslContext = SSLUtil.initServer(storeFile, params[1], params[2], params[3]);
channelContext.setSslContext(sslContext);
}
}
sc.setSERVER_PORT(getServerPort(sc.getSERVER_PORT(), sc.isSERVER_ENABLE_SSL()));
acceptor.bind();
} catch (Throwable e) {
Logger logger = LoggerFactory.getLogger(getClass());
logger.error(e.getMessage(), e);
CloseUtil.unbind(acceptor);
}
}
use of com.generallycloud.baseio.common.Properties in project baseio by generallycloud.
the class AuthorityLoginCenter method initialize.
@Override
public void initialize(ApplicationContext context, Configuration config) throws Exception {
Properties fixedProperties = FileUtil.readPropertiesByCls("server.properties");
String username = fixedProperties.getProperty("SERVER.USERNAME", "admin");
String password = fixedProperties.getProperty("SERVER.PASSWORD", "admin100");
String UUID = fixedProperties.getProperty("SERVER.UUID", "uuid");
int roleId = fixedProperties.getIntegerProperty("SERVER.ROLEID");
Authority authority = new Authority();
authority.setUsername(username);
authority.setPassword(password);
authority.setRoleId(roleId);
authority.setUuid(UUID);
/* ------------------------------------------------------------- */
this.authorities.put(authority.getUsername(), authority);
authority = new Authority();
authority.setUsername("udp1");
authority.setPassword(MD5Util.get32("udp1", context.getEncoding()));
authority.setRoleId(0);
authority.setUuid("udp1");
this.authorities.put(authority.getUsername(), authority);
authority = new Authority();
authority.setUsername("udp2");
authority.setPassword(MD5Util.get32("udp2", context.getEncoding()));
authority.setRoleId(0);
authority.setUuid("udp2");
this.authorities.put(authority.getUsername(), authority);
}
use of com.generallycloud.baseio.common.Properties in project baseio by generallycloud.
the class AbstractACLoader method loadConfiguration.
@Override
public ApplicationConfiguration loadConfiguration(ClassLoader classLoader) throws Exception {
ApplicationConfiguration configuration = new ApplicationConfiguration();
Properties properties = FileUtil.readPropertiesByCls("app.properties", Encoding.UTF8, classLoader);
new PropertiesSCLoader("APP").loadConfiguration(configuration, properties);
configuration.setFiltersConfiguration(loadFiltersConfiguration(classLoader));
configuration.setPluginsConfiguration(loadPluginsConfiguration(classLoader));
configuration.setServletsConfiguration(loadServletsConfiguration(classLoader));
return configuration;
}
Aggregations