/** * MailArchiver is an application that provides services for storing and managing e-mail messages through a Web Services SOAP interface. * Copyright (C) 2012 Marcio Andre Scholl Levien and Fernando Alberto Reuter Wendt and Jose Ronaldo Nogueira Fonseca Junior * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ /******************************************************************************\ * * This product was developed by * * SERVIÇO FEDERAL DE PROCESSAMENTO DE DADOS (SERPRO), * * a government company established under Brazilian law (5.615/70), * at Department of Development of Porto Alegre. * \******************************************************************************/ package serpro.mailarchiver; import java.util.UUID; import org.eclipse.jetty.server.Server; import org.springframework.beans.factory.annotation.Autowired; import serpro.mailarchiver.service.Settings; import serpro.mailarchiver.service.Utils; import serpro.mailarchiver.service.web.ServiceFault; import serpro.mailarchiver.util.Logger; public class MailArchiver { private static final Logger log = Logger.getLocalLogger(); @Autowired private Settings settings; @Autowired private Utils utils; @Autowired private Server jetty; public void init() throws Exception { log.info("Iniciando jetty"); jetty.start(); log.info("Jetty em execução"); utils.bootstrapJdoMetadata(); String dbid = settings.get("dbid"); if(dbid == null) { dbid = UUID.randomUUID().toString().replace('-', '_'); if(Character.isDigit(dbid.charAt(0))) { String head = dbid.substring(0, 1); String tail = dbid.substring(1); dbid = ((char)('g' + Integer.parseInt(head))) + tail; } settings.put("dbid", dbid); log.info("Generating database ID: %s", dbid); } else { log.info("Database ID: %s", dbid); } System.out.println("Database ID:" + dbid); utils.bootstrapServices(); jetty.join(); log.info("Jetty finalizado"); } public void destroy() { log.info("Finalizando mailArchiver"); } }