use of com.tvd12.ezyfoxserver.EzyServerBootstrap in project ezyfox-server by youngmonkeys.
the class EzyServerBootstrapTest method test.
@SuppressWarnings("rawtypes")
@Test
public void test() throws Exception {
EzyServerBootstrap bt = new MyTestServerBootstrapBuilder().server(newServer()).build();
bt.destroy();
assert MethodInvoker.create().object(bt).method("getServer").invoke() != null;
assert MethodInvoker.create().object(bt).method("getServerSettings").invoke() != null;
assert MethodInvoker.create().object(bt).method("getHttpSetting").invoke() != null;
assert MethodInvoker.create().object(bt).method("getSocketSetting").invoke() != null;
assert MethodInvoker.create().object(bt).method("getWebSocketSetting").invoke() != null;
EzyServerBootstrap bootstrap = new EzyServerBootstrap() {
@Override
protected void startOtherBootstraps(Runnable callback) {
callback.run();
}
};
EzyServerContext serverContext = mock(EzyServerContext.class);
EzySimpleServer server = new EzySimpleServer();
EzySimpleConfig config = new EzySimpleConfig();
server.setConfig(config);
when(serverContext.getServer()).thenReturn(server);
EzySimpleSettings settings = new EzySimpleSettings();
server.setSettings(settings);
EzySessionManager sessionManager = new ExEzySimpleSessionManager.Builder().objectFactory(() -> spy(EzyAbstractSession.class)).build();
server.setSessionManager(sessionManager);
EzyBootstrap localBootstrap = EzyBootstrap.builder().context(serverContext).build();
bootstrap.setContext(serverContext);
bootstrap.setLocalBootstrap(localBootstrap);
bootstrap.start();
}
use of com.tvd12.ezyfoxserver.EzyServerBootstrap in project ezyfox-server by youngmonkeys.
the class EzyStarter method startEzyFox.
protected void startEzyFox(EzyServer server) throws Exception {
EzyConfig config = server.getConfig();
if (config.isPrintSettings()) {
getLogger().info("settings: \n{}", server);
}
EzyServerBootstrap serverBoostrap = newServerBoostrap(server);
serverBoostrap.start();
serverContext = serverBoostrap.getContext();
serverContext.setProperty(EzyServerBootstrap.class, serverBoostrap);
}
use of com.tvd12.ezyfoxserver.EzyServerBootstrap in project ezyfox-server by youngmonkeys.
the class EzyAbstractServerBootstrapBuilder method buildServerBootstrap.
protected EzyServerBootstrap buildServerBootstrap() {
EzyServerBootstrap answer = newServerBootstrap();
answer.setContext(serverContext);
answer.setLocalBootstrap(newLocalBoostrap());
return answer;
}
use of com.tvd12.ezyfoxserver.EzyServerBootstrap in project ezyfox-server by youngmonkeys.
the class EzyServerBootstrapTest method commonTest.
@Test
public void commonTest() {
// given
EzySimpleConfig config = new EzySimpleConfig();
config.setPrintBanner(false);
EzySimpleSettings settings = new EzySimpleSettings();
EzySimpleServer server = new EzySimpleServer();
server.setSettings(settings);
server.setConfig(config);
EzyServerContext serverContext = mock(EzyServerContext.class);
when(serverContext.getServer()).thenReturn(server);
EzyServerBootstrap sut = new EzyServerBootstrap() {
@Override
protected void startOtherBootstraps(Runnable callback) {
callback.run();
}
};
sut.setContext(serverContext);
// when
ReflectMethodUtil.invokeMethod("printBanner", sut);
EzyUdpSetting udpSetting = (EzyUdpSetting) ReflectMethodUtil.invokeMethod("getUdpSetting", sut);
EzyThreadPoolSizeSetting threadPoolSizeSetting = (EzyThreadPoolSizeSetting) ReflectMethodUtil.invokeMethod("getThreadPoolSizeSetting", sut);
// then
Asserts.assertEquals(server.getSettings().getUdp(), udpSetting);
Asserts.assertEquals(server.getSettings().getThreadPoolSize(), threadPoolSizeSetting);
}
use of com.tvd12.ezyfoxserver.EzyServerBootstrap in project ezyfox-server by youngmonkeys.
the class EzyNioServerBootstrapBuilderImpl method newServerBootstrap.
@Override
protected EzyServerBootstrap newServerBootstrap() {
ExecutorService statsThreadPool = newStatsThreadPool();
EzyCodecFactory codecFactory = newCodecFactory();
EzyStreamingApi streamingApi = newStreamingApi();
EzyResponseApi responseApi = newResponseApi(codecFactory);
EzySocketStreamQueue streamQueue = newStreamQueue();
EzySessionTicketsQueue socketSessionTicketsQueue = newSocketSessionTicketsQueue();
EzySessionTicketsQueue websocketSessionTicketsQueue = newWebSocketSessionTicketsQueue();
EzySocketDisconnectionQueue socketDisconnectionQueue = newSocketDisconnectionQueue();
EzySessionTicketsRequestQueues sessionTicketsRequestQueues = newSessionTicketsRequestQueues();
EzyHandlerGroupBuilderFactory handlerGroupBuilderFactory = newHandlerGroupBuilderFactory(statsThreadPool, codecFactory, streamQueue, socketDisconnectionQueue, socketSessionTicketsQueue, websocketSessionTicketsQueue, sessionTicketsRequestQueues);
EzyHandlerGroupManager handlerGroupManager = newHandlerGroupManager(handlerGroupBuilderFactory);
EzySocketDataReceiver socketDataReceiver = newSocketDataReceiver(handlerGroupManager);
EzyNioServerBootstrap bootstrap = new EzyNioServerBootstrap();
bootstrap.setResponseApi(responseApi);
bootstrap.setStreamingApi(streamingApi);
bootstrap.setStreamQueue(streamQueue);
bootstrap.setSocketDataReceiver(socketDataReceiver);
bootstrap.setHandlerGroupManager(handlerGroupManager);
bootstrap.setSocketDisconnectionQueue(socketDisconnectionQueue);
bootstrap.setSocketSessionTicketsQueue(socketSessionTicketsQueue);
bootstrap.setWebsocketSessionTicketsQueue(websocketSessionTicketsQueue);
bootstrap.setSocketSessionTicketsRequestQueues(sessionTicketsRequestQueues);
bootstrap.setSslContext(newSslContext(getWebsocketSetting().getSslConfig()));
return bootstrap;
}
Aggregations