001package fr.ifremer.adagio.core; 002 003/* 004 * #%L 005 * SIH-Adagio :: Core for Allegro 006 * $Id:$ 007 * $HeadURL:$ 008 * %% 009 * Copyright (C) 2012 - 2014 Ifremer 010 * %% 011 * This program is free software: you can redistribute it and/or modify 012 * it under the terms of the GNU Affero General Public License as published by 013 * the Free Software Foundation, either version 3 of the License, or 014 * (at your option) any later version. 015 * 016 * This program is distributed in the hope that it will be useful, 017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 019 * GNU General Public License for more details. 020 * 021 * You should have received a copy of the GNU Affero General Public License 022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 023 * #L% 024 */ 025 026import java.util.Arrays; 027 028import org.apache.commons.io.IOUtils; 029import org.apache.commons.logging.Log; 030import org.apache.commons.logging.LogFactory; 031 032import fr.ifremer.adagio.core.config.AdagioConfiguration; 033import fr.ifremer.adagio.core.service.ServiceLocator; 034 035public class RunAdagioCore { 036 037 /* Logger */ 038 private static final Log log = LogFactory.getLog(RunAdagioCore.class); 039 040 public static final int DELETE_DB_EXIT_CODE = 89; 041 042 public static final int UPATE_EXIT_CODE = 88; 043 044 public static final int NORMAL_EXIT_CODE = 0; 045 046 public static void main(String[] args) { 047 if (log.isInfoEnabled()) { 048 log.info("Starting SIH-Adagio :: Core with arguments: " + Arrays.toString(args)); 049 } 050 051 // By default, display help 052 if (args == null || args.length == 0) { 053 args = new String[] { "-h" }; 054 } 055 056 String configFile = "adagio-core.config"; 057 if (System.getProperty(configFile) != null) { 058 configFile = System.getProperty(configFile); 059 configFile = configFile.replaceAll("\\\\", "/"); 060 } 061 062 // Create configuration 063 AdagioConfiguration config = new AdagioConfiguration(configFile, args); 064 AdagioConfiguration.setInstance(config); 065 066 try { 067 config.getApplicationConfig().doAllAction(); 068 } catch (Exception e) { 069 e.printStackTrace(); 070 } 071 072 IOUtils.closeQuietly(ServiceLocator.instance()); 073 } 074}