View Javadoc
1   /*
2    * This file is part of Waarp Project (named also Waarp or GG).
3    *
4    *  Copyright (c) 2019, Waarp SAS, 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 Waarp Project is free software: you can redistribute it and/or
9    * modify it under the terms of the GNU General Public License as published by
10   * the Free Software Foundation, either version 3 of the License, or (at your
11   * option) any later version.
12   *
13   * Waarp is distributed in the hope that it will be useful, but WITHOUT ANY
14   * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15   * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16   *
17   *  You should have received a copy of the GNU General Public License along with
18   * Waarp . If not, see <http://www.gnu.org/licenses/>.
19   */
20  
21  package org.waarp.http.protocol;
22  
23  import org.waarp.common.logging.WaarpLogger;
24  import org.waarp.common.logging.WaarpLoggerFactory;
25  import org.waarp.openr66.server.R66Server;
26  
27  import javax.servlet.ServletException;
28  import java.io.File;
29  import java.util.concurrent.atomic.AtomicBoolean;
30  
31  /**
32   * Point to startup Waarp R66 server a unique time
33   */
34  public class WaarpStartup {
35    private static final WaarpLogger logger =
36        WaarpLoggerFactory.getLogger(WaarpStartup.class);
37    private static final AtomicBoolean STARTED = new AtomicBoolean(false);
38  
39    private WaarpStartup() {
40      // Empty and private
41    }
42  
43    /**
44     * Will try to start the Waarp R66 server (next calls will be ignored)
45     *
46     * @throws ServletException
47     */
48    public static void startupWaarp(final File configurationFile)
49        throws ServletException {
50      if (STARTED.compareAndSet(false, true)) {
51        R66Server.main(new String[] { configurationFile.getAbsolutePath() });
52        logger.info("Start Done");
53      }
54    }
55  }