Line data Source code
1 : // Copyright (C) 2009 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.pgm.init; 16 : 17 : import com.google.gerrit.extensions.config.FactoryModule; 18 : import com.google.gerrit.pgm.init.api.InitStep; 19 : import com.google.gerrit.pgm.init.api.Section; 20 : import com.google.gerrit.server.config.SitePaths; 21 : import com.google.inject.binder.LinkedBindingBuilder; 22 : import com.google.inject.internal.UniqueAnnotations; 23 : import java.lang.annotation.Annotation; 24 : 25 : /** Injection configuration for the site initialization process. */ 26 : public class InitModule extends FactoryModule { 27 : 28 : private final boolean standalone; 29 : 30 15 : public InitModule(boolean standalone) { 31 15 : this.standalone = standalone; 32 15 : } 33 : 34 : @Override 35 : protected void configure() { 36 15 : bind(SitePaths.class); 37 15 : factory(Section.Factory.class); 38 15 : factory(VersionedAuthorizedKeysOnInit.Factory.class); 39 : 40 : // Steps are executed in the order listed here. 41 : // 42 15 : step().to(InitGitManager.class); 43 15 : step().to(InitJGitConfig.class); 44 15 : step().to(InitLogging.class); 45 15 : step().to(InitIndex.class); 46 15 : step().to(InitAuth.class); 47 15 : step().to(InitAdminUser.class); 48 15 : step().to(InitLabels.class); 49 15 : step().to(InitSendEmail.class); 50 15 : if (standalone) { 51 15 : step().to(InitContainer.class); 52 : } 53 15 : step().to(InitSshd.class); 54 15 : step().to(InitHttpd.class); 55 15 : step().to(InitCache.class); 56 15 : step().to(InitPlugins.class); 57 15 : step().to(InitDev.class); 58 15 : } 59 : 60 : protected LinkedBindingBuilder<InitStep> step() { 61 15 : final Annotation id = UniqueAnnotations.create(); 62 15 : return bind(InitStep.class).annotatedWith(id); 63 : } 64 : }