View Javadoc

1   /**
2      This file is part of GoldenGate Project (named also GoldenGate or GG).
3   
4      Copyright 2009, Frederic Bregier, and individual contributors by the @author
5      tags. See the COPYRIGHT.txt in the distribution for a full listing of
6      individual contributors.
7   
8      All GoldenGate Project is free software: you can redistribute it and/or 
9      modify it under the terms of the GNU General Public License as published 
10     by the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12  
13     GoldenGate is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17  
18     You should have received a copy of the GNU General Public License
19     along with GoldenGate .  If not, see <http://www.gnu.org/licenses/>.
20   */
21  package openr66.server;
22  
23  import goldengate.common.database.exception.GoldenGateDatabaseException;
24  import goldengate.common.logging.GgInternalLogger;
25  import goldengate.common.logging.GgInternalLoggerFactory;
26  import goldengate.common.logging.GgSlf4JLoggerFactory;
27  import openr66.configuration.FileBasedConfiguration;
28  import openr66.protocol.configuration.Configuration;
29  import openr66.protocol.exception.OpenR66ProtocolPacketException;
30  import openr66.protocol.utils.OpenR66SignalHandler;
31  
32  import org.jboss.netty.logging.InternalLoggerFactory;
33  
34  /**
35   * R66Server startup main class
36   *
37   * @author Frederic Bregier
38   */
39  public class R66Server {
40  
41      /**
42       * @param args as first argument the configuration file
43       * @throws OpenR66ProtocolPacketException
44       */
45      public static void main(String[] args)
46              throws OpenR66ProtocolPacketException {
47          InternalLoggerFactory.setDefaultFactory(new GgSlf4JLoggerFactory(null));
48          final GgInternalLogger logger = GgInternalLoggerFactory
49                  .getLogger(R66Server.class);
50          if (args.length < 1) {
51              logger
52                      .error("Needs the configuration file as first argument");
53              return;
54          }
55          if (! FileBasedConfiguration
56                  .setConfigurationServerFromXml(Configuration.configuration, args[0])) {
57              logger
58                      .error("Needs a correct configuration file as first argument");
59              return;
60          }
61          try {
62              Configuration.configuration.serverStartup();
63          } catch (GoldenGateDatabaseException e) {
64              logger
65                  .error("Startup of server is in error");
66              OpenR66SignalHandler.terminate(false);
67          }
68          logger.warn("Server OpenR66 starts for "+Configuration.configuration.HOST_ID);
69          System.err.println("Server OpenR66 starts for "+Configuration.configuration.HOST_ID);
70      }
71  
72  }