Package be.demmel.jgws.cfg.jaxb

Examples of be.demmel.jgws.cfg.jaxb.Configuration


  public static void main(String... parameters) {
    Thread.currentThread().setName("Startup");
    LOGGER.info("The \"Java Guild Wars (Login)Server\" (version {}) is starting", Version.getVersion());

    try {
      Configuration loginServerConfiguration = getLoginServerConfiguration();

      // Retrieve the PacketDeserializers for every outgoing (login) packet
      Map<Integer, PacketDeserializer> packetDeserializers = GeneralUtils.getPacketDeserializers("be.demmel.jgws.packets.loginserver.inbound");
      // Retrieve the PacketSerializer for every incoming (login) packet
      Map<Class<? extends Packet>, PacketSerializer> packetSerializers = GeneralUtils.getPacketSerializers("be.demmel.jgws.packets.loginserver.outbound");

      // Retrieve the PacketHandlers for every incoming (login) packet
      Map<Class<? extends Packet>, PacketHandler> packetHandlers = GeneralUtils.getPacketHandlers("be.demmel.jgws.packets.handlers.login");

      Jpa jpaConfiguration = loginServerConfiguration.getJpa();

      Map<String, String> properties = new HashMap<>();
      properties.put("javax.persistence.jdbc.driver", jpaConfiguration.getDriver());
      properties.put("javax.persistence.jdbc.url", jpaConfiguration.getUrl());
      properties.put("javax.persistence.jdbc.user", jpaConfiguration.getUser());
      properties.put("javax.persistence.jdbc.password", jpaConfiguration.getPassword());

      final EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("jgws", properties);
     
      EntityManagerFactoryTool.setEntityManagerFactory(entityManagerFactory);

      Binding bindingConfiguration = loginServerConfiguration.getBinding();
      String bindingIp = bindingConfiguration.getIp();
      int bindingPort = bindingConfiguration.getPort();
     
      ChannelGroup channels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
     
      final InboundPacketHandler<LoginServerSession> inboundPacketHandler = new InboundPacketHandler<LoginServerSession>(channels, packetHandlers, SessionKey.SESSSION_KEY);
     
      LogBlackList logBlackList = loginServerConfiguration.getLogBlackList();
      if(loginServerConfiguration.getLogBlackList() != null) { // don't log some inbound and outbound packets
        Set<Class<? extends Packet>> inboundPacketsLogBlackList = new HashSet<Class<? extends Packet>>(), outboundPacketsLogBlackList = new HashSet<Class<? extends Packet>>();
       
        for(String packet : logBlackList.getInbound().getPacket()) {
          inboundPacketsLogBlackList.add( (Class<? extends Packet>)Class.forName(packet));
        }
       
        for(String packet : logBlackList.getOutbound().getPacket()) {
          outboundPacketsLogBlackList.add( (Class<? extends Packet>)Class.forName(packet));
        }
       
        LoginServerChannelInitializer defaultChannelInitializer = new LoginServerChannelInitializer(packetDeserializers, inboundPacketHandler, packetSerializers, SessionKey.SESSSION_KEY, inboundPacketsLogBlackList, outboundPacketsLogBlackList);
       
        Thread serverThread = new Thread(new NettyServer<LoginServerSession>(new InetSocketAddress(bindingIp, bindingPort), defaultChannelInitializer));
        serverThread.start();
      } else {
        LoginServerChannelInitializer defaultChannelInitializer = new LoginServerChannelInitializer(packetDeserializers, inboundPacketHandler, packetSerializers, SessionKey.SESSSION_KEY);
       
        Thread serverThread = new Thread(new NettyServer<LoginServerSession>(new InetSocketAddress(bindingIp, bindingPort), defaultChannelInitializer));
        serverThread.start();
      }

      // Start the RMI server
      String portalUri = loginServerConfiguration.getPortalUri();
      URI serviceRmiUri = new URI(portalUri);
      RmiRegistry.INSTANCE.start(serviceRmiUri);
      LoginServerPortal gameServerPortal = new LoginServerPortalImpl();
      RmiRegistry.INSTANCE.bind(gameServerPortal);
      LOGGER.info("Login Server Commands RMI service ready");
View Full Code Here

TOP

Related Classes of be.demmel.jgws.cfg.jaxb.Configuration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.