2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.infra.distro.cfgattrs;
19 import com.google.common.base.MoreObjects;
20 import java.util.Optional;
21 import net.jmob.guice.conf.core.BindConfig;
22 import net.jmob.guice.conf.core.InjectConfig;
23 import net.jmob.guice.conf.core.Syntax;
26 * This is the Java equivalent for honeyconb.json file. We use guice-config library to load all the config attributes
27 * into this class instance.
29 * The BindConfig annotation tells that honeycomb.json file should be looked up on classpath root.
31 @BindConfig(value = "honeycomb", syntax = Syntax.JSON)
32 public class HoneycombConfiguration {
34 @InjectConfig("persist-context")
35 public Optional<String> persistContext = Optional.of("true");
36 @InjectConfig("persisted-context-path")
37 public String peristContextPath;
38 @InjectConfig("persisted-context-restoration-type")
39 public String persistedContextRestorationType;
40 @InjectConfig("persist-config")
41 public Optional<String> persistConfig = Optional.of("true");
42 @InjectConfig("persisted-config-path")
43 public String peristConfigPath;
44 @InjectConfig("persisted-config-restoration-type")
45 public String persistedConfigRestorationType;
46 @InjectConfig("notification-service-queue-depth")
47 public int notificationServiceQueueDepth;
49 public boolean isConfigPersistenceEnabled() {
50 return persistConfig.isPresent() && Boolean.valueOf(persistConfig.get());
53 public boolean isContextPersistenceEnabled() {
54 return persistContext.isPresent() && Boolean.valueOf(persistContext.get());
58 public String toString() {
59 return MoreObjects.toStringHelper(this)
60 .add("peristContextPath", peristContextPath)
61 .add("persistedContextRestorationType", persistedContextRestorationType)
62 .add("peristConfigPath", peristConfigPath)
63 .add("persistedConfigRestorationType", persistedConfigRestorationType)
64 .add("notificationServiceQueueDepth", notificationServiceQueueDepth)