001/* 002 * SonarQube 003 * Copyright (C) 2009-2016 SonarSource SA 004 * mailto:contact AT sonarsource DOT com 005 * 006 * This program is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 3 of the License, or (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public License 017 * along with this program; if not, write to the Free Software Foundation, 018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 019 */ 020package org.sonar.api; 021 022/** 023 * An interface which is implemented by classes annotated with {@link org.sonar.api.batch.ScannerSide ScannerSide}, 024 * {@link org.sonar.api.server.ServerSide ServerSide} and/or {@link org.sonar.api.ce.ComputeEngineSide ComputeEngineSide} 025 * (referred to below as "component") that can be started and stopped. 026 * <p> 027 * The method {@link #start()} is called at the begin of the component lifecycle. 028 * It can be called again only after a call to {@link #stop()}. The {@link #stop()} method is called at the end of the 029 * component lifecycle, and can further be called after every {@link Startable#start()}. 030 * </p> 031 * <p> 032 * In the WebServer, a component is started once: either right when the WebServer is started if there is no migration, 033 * otherwise only after Database has been successfully migrated. It is stopped once when the WebServer is shutdown. Any 034 * exception thrown by method {@link #start()} will make the WebServer startup fail. 035 * </p> 036 * <p> 037 * In the Compute Engine, a component is started once when the Compute Engine is started and stopped once when the 038 * ComputeEngine is shut down. Any exception thrown by method {@link #start()} will make the Compute Engine startup fail. 039 * </p> 040 * <p> 041 * On Scanner side, the lifecycle of a component depends on the value of the {@link org.sonar.api.batch.InstantiationStrategy 042 * InstantiationStrategy} annotation. 043 * </p> 044 */ 045public interface Startable { 046 /** 047 * Start this component. Called initially at the begin of the lifecycle. It can be called again after a stop. 048 */ 049 void start(); 050 051 /** 052 * Stop this component. Called near the end of the lifecycle. It can be called again after a further start. 053 */ 054 void stop(); 055}