Line data Source code
1 : // Copyright (C) 2011 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.rules; 16 : 17 : import com.google.gerrit.extensions.annotations.Exports; 18 : import com.google.gerrit.extensions.config.FactoryModule; 19 : import com.google.gerrit.extensions.registration.DynamicSet; 20 : import com.google.gerrit.server.rules.RulesCache.RulesCacheModule; 21 : import org.eclipse.jgit.lib.Config; 22 : 23 : public class PrologModule extends FactoryModule { 24 : protected final Config config; 25 : 26 152 : public PrologModule(Config config) { 27 152 : this.config = config; 28 152 : } 29 : 30 : @Override 31 : protected void configure() { 32 152 : install(new EnvironmentModule()); 33 152 : install(new RulesCacheModule(config)); 34 152 : bind(PrologEnvironment.Args.class); 35 152 : factory(PrologRuleEvaluator.Factory.class); 36 : 37 152 : bind(SubmitRule.class).annotatedWith(Exports.named("PrologRule")).to(PrologRule.class); 38 152 : } 39 : 40 153 : static class EnvironmentModule extends FactoryModule { 41 : @Override 42 : protected void configure() { 43 153 : DynamicSet.setOf(binder(), PredicateProvider.class); 44 153 : factory(PrologEnvironment.Factory.class); 45 153 : } 46 : } 47 : }