use of org.apollo.net.ServiceChannelInitializer in project apollo by apollo-rsps.
the class Server method init.
/**
* Initialises the server.
*
* @param releaseName The class name of the current active {@link Release}.
* @throws Exception If an error occurs.
*/
public void init(String releaseName) throws Exception {
Class<?> clazz = Class.forName(releaseName);
Release release = (Release) clazz.newInstance();
int version = release.getReleaseNumber();
logger.info("Initialized " + release + ".");
serviceBootstrap.group(loopGroup);
httpBootstrap.group(loopGroup);
jaggrabBootstrap.group(loopGroup);
World world = new World();
ServiceManager services = new ServiceManager(world);
IndexedFileSystem fs = new IndexedFileSystem(Paths.get("data/fs", Integer.toString(version)), true);
ServerContext context = new ServerContext(release, services, fs);
ApolloHandler handler = new ApolloHandler(context);
ChannelInitializer<SocketChannel> service = new ServiceChannelInitializer(handler);
serviceBootstrap.channel(NioServerSocketChannel.class);
serviceBootstrap.childHandler(service);
ChannelInitializer<SocketChannel> http = new HttpChannelInitializer(handler);
httpBootstrap.channel(NioServerSocketChannel.class);
httpBootstrap.childHandler(http);
ChannelInitializer<SocketChannel> jaggrab = new JagGrabChannelInitializer(handler);
jaggrabBootstrap.channel(NioServerSocketChannel.class);
jaggrabBootstrap.childHandler(jaggrab);
PluginManager manager = new PluginManager(world, new PluginContext(context));
services.startAll();
world.init(version, fs, manager);
}
Aggregations