com.dc.gameserver.launcher.java Source code

Java tutorial

Introduction

Here is the source code for com.dc.gameserver.launcher.java

Source

/*
 * Copyright (c) 2014. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package com.dc.gameserver;

import com.dc.gameserver.baseConfig.Config;
import net.NettyEngine4.ServerHandler;
import net.NettyEngine4.ServerServiceImpl;
import org.apache.log4j.xml.DOMConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.FileSystemXmlApplicationContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author : <br/>
 *         Date: 13-3-15
 *         Time: ?11:31
 *         connectMethod:13638363871@163.com<br/>
 *         ?????????
 *         ?readme.properties
 *         ?spring?beanbeanspring?bean
 */
@SuppressWarnings("unchecked")
@Service("gameServer")
public class launcher {

    private static final Logger LOG = LoggerFactory.getLogger(launcher.class);

    @Resource
    private ServerServiceImpl serverService;

    public static void main(String[] args) {
        try {

            DOMConfigurator.configure(Config.DEFAULT_VALUE.FILE_PATH.LOG4J);

            System.setProperty("java.net.preferIPv4Stack", "true"); //Disable IPv6 in JVM
            /**?spring*/
            BeanFactory springContext = new FileSystemXmlApplicationContext(
                    Config.DEFAULT_VALUE.FILE_PATH.SPRING_CONFIG_PATH);
            launcher gameServer = (launcher) springContext.getBean("gameServer");
            /**set  spring context**/
            ServerHandler.setSpringContext(springContext);

            /**???*/
            gameServer.serverService.IntiServer();

            gameServer.serverService.run();

        } catch (Exception e) {
            LOG.error("server start error", e);
        }

    }

}