1 /* 2 * Copyright 2019 LINE Corporation 3 * 4 * LINE Corporation licenses this file to you under the Apache License, 5 * version 2.0 (the "License"); you may not use this file except in compliance 6 * with the License. You may obtain a copy of the License at: 7 * 8 * https://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations 14 * under the License. 15 */ 16 package com.linecorp.centraldogma.server.plugin; 17 18 import java.util.concurrent.CompletionStage; 19 20 import com.linecorp.centraldogma.server.CentralDogmaConfig; 21 22 /** 23 * An interface which defines callbacks for a plug-in. If you want to initialize a {@link Plugin} by configuring 24 * the Central Dogma server (e.g. adding a service for your plugin), use {@link AllReplicasPlugin}. 25 */ 26 public interface Plugin { 27 /** 28 * Returns the {@link PluginTarget} which specifies the replicas that this {@link Plugin} is applied to. 29 */ 30 PluginTarget target(); 31 32 /** 33 * Invoked when this {@link Plugin} is supposed to be started. 34 * 35 * @param context the context which consists of the objects required to execute this {@link Plugin} 36 */ 37 CompletionStage<Void> start(PluginContext context); 38 39 /** 40 * Invoked when this {@link Plugin} is supposed to be stopped. 41 * 42 * @param context the context which consists of the objects required to execute this {@link Plugin} 43 */ 44 CompletionStage<Void> stop(PluginContext context); 45 46 /** 47 * Returns {@code true} if this {@link Plugin} is enabled. 48 */ 49 default boolean isEnabled(CentralDogmaConfig config) { 50 return true; 51 } 52 }