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.server.schema; 16 : 17 : import static com.google.inject.Scopes.SINGLETON; 18 : 19 : import com.google.common.collect.ImmutableSet; 20 : import com.google.gerrit.extensions.config.FactoryModule; 21 : import com.google.gerrit.server.GerritPersonIdent; 22 : import com.google.gerrit.server.GerritPersonIdentProvider; 23 : import com.google.gerrit.server.config.AllProjectsName; 24 : import com.google.gerrit.server.config.AllProjectsNameProvider; 25 : import com.google.gerrit.server.config.AllUsersName; 26 : import com.google.gerrit.server.config.AllUsersNameProvider; 27 : import com.google.gerrit.server.config.AnonymousCowardName; 28 : import com.google.gerrit.server.config.AnonymousCowardNameProvider; 29 : import com.google.gerrit.server.config.GerritImportedServerIds; 30 : import com.google.gerrit.server.config.GerritImportedServerIdsProvider; 31 : import com.google.gerrit.server.config.GerritServerId; 32 : import com.google.gerrit.server.config.GerritServerIdProvider; 33 : import com.google.gerrit.server.index.group.GroupIndexCollection; 34 : import com.google.inject.TypeLiteral; 35 : import org.eclipse.jgit.lib.PersonIdent; 36 : 37 : /** Bindings for low-level Gerrit schema data. */ 38 138 : public class SchemaModule extends FactoryModule { 39 : @Override 40 : protected void configure() { 41 138 : bind(PersonIdent.class) 42 138 : .annotatedWith(GerritPersonIdent.class) 43 138 : .toProvider(GerritPersonIdentProvider.class); 44 : 45 138 : bind(AllProjectsName.class).toProvider(AllProjectsNameProvider.class).in(SINGLETON); 46 : 47 138 : bind(AllUsersName.class).toProvider(AllUsersNameProvider.class).in(SINGLETON); 48 : 49 138 : bind(String.class) 50 138 : .annotatedWith(AnonymousCowardName.class) 51 138 : .toProvider(AnonymousCowardNameProvider.class); 52 : 53 138 : bind(String.class) 54 138 : .annotatedWith(GerritServerId.class) 55 138 : .toProvider(GerritServerIdProvider.class) 56 138 : .in(SINGLETON); 57 : 58 138 : bind(new TypeLiteral<ImmutableSet<String>>() {}) 59 138 : .annotatedWith(GerritImportedServerIds.class) 60 138 : .toProvider(GerritImportedServerIdsProvider.class) 61 138 : .in(SINGLETON); 62 : 63 : // It feels wrong to have this binding in a seemingly unrelated module, but it's a dependency of 64 : // SchemaCreatorImpl, so it's needed. 65 : // TODO(dborowitz): Is there any way to untangle this? 66 138 : bind(GroupIndexCollection.class); 67 138 : bind(SchemaCreator.class).to(SchemaCreatorImpl.class); 68 138 : } 69 : }