GatewayModule.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Licensed to Elasticsearch under one or more contributor
  3. * license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright
  5. * ownership. Elasticsearch licenses this file to you under
  6. * the Apache License, Version 2.0 (the "License"); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. package org.elasticsearch.gateway;
  20. import com.google.common.collect.ImmutableList;
  21. import org.elasticsearch.common.inject.AbstractModule;
  22. import org.elasticsearch.common.inject.Module;
  23. import org.elasticsearch.common.inject.Modules;
  24. import org.elasticsearch.common.inject.SpawnModules;
  25. import org.elasticsearch.common.settings.Settings;
  26. import org.elasticsearch.gateway.local.LocalGatewayModule;
  27. /**
  28. *
  29. */
  30. public class GatewayModule extends AbstractModule implements SpawnModules {
  31. public static String GATEWAY_TYPE_SETTING = "gateway.type";
  32. private final Settings settings;
  33. public GatewayModule(Settings settings) {
  34. this.settings = settings;
  35. }
  36. @Override
  37. public Iterable<? extends Module> spawnModules() {
  38. Class gateway = settings.getAsClass(GATEWAY_TYPE_SETTING, LocalGatewayModule.class, "org.elasticsearch.gateway.", "GatewayModule");
  39. return ImmutableList.of(Modules.createModule(gateway, settings));
  40. }
  41. @Override
  42. protected void configure() {
  43. bind(GatewayService.class).asEagerSingleton();
  44. }
  45. }