001/*
002 * Copyright 2012-2016 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.autoconfigure.couchbase;
018
019import java.util.List;
020
021import org.springframework.boot.context.properties.ConfigurationProperties;
022import org.springframework.boot.context.properties.NestedConfigurationProperty;
023import org.springframework.util.StringUtils;
024
025/**
026 * Configuration properties for Couchbase.
027 *
028 * @author Eddú Meléndez
029 * @author Stephane Nicoll
030 * @since 1.4.0
031 */
032@ConfigurationProperties(prefix = "spring.couchbase")
033public class CouchbaseProperties {
034
035        /**
036         * Couchbase nodes (host or IP address) to bootstrap from.
037         */
038        private List<String> bootstrapHosts;
039
040        private final Bucket bucket = new Bucket();
041
042        private final Env env = new Env();
043
044        public List<String> getBootstrapHosts() {
045                return this.bootstrapHosts;
046        }
047
048        public void setBootstrapHosts(List<String> bootstrapHosts) {
049                this.bootstrapHosts = bootstrapHosts;
050        }
051
052        public Bucket getBucket() {
053                return this.bucket;
054        }
055
056        public Env getEnv() {
057                return this.env;
058        }
059
060        public static class Bucket {
061
062                /**
063                 * Name of the bucket to connect to.
064                 */
065                private String name = "default";
066
067                /**
068                 * Password of the bucket.
069                 */
070                private String password = "";
071
072                public String getName() {
073                        return this.name;
074                }
075
076                public void setName(String name) {
077                        this.name = name;
078                }
079
080                public String getPassword() {
081                        return this.password;
082                }
083
084                public void setPassword(String password) {
085                        this.password = password;
086                }
087
088        }
089
090        public static class Env {
091
092                @NestedConfigurationProperty
093                private final Endpoints endpoints = new Endpoints();
094
095                @NestedConfigurationProperty
096                private final Ssl ssl = new Ssl();
097
098                @NestedConfigurationProperty
099                private final Timeouts timeouts = new Timeouts();
100
101                public Endpoints getEndpoints() {
102                        return this.endpoints;
103                }
104
105                public Ssl getSsl() {
106                        return this.ssl;
107                }
108
109                public Timeouts getTimeouts() {
110                        return this.timeouts;
111                }
112
113        }
114
115        public static class Endpoints {
116
117                /**
118                 * Number of sockets per node against the key/value service.
119                 */
120                private int keyValue = 1;
121
122                /**
123                 * Number of sockets per node against the query (N1QL) service.
124                 */
125                private int query = 1;
126
127                /**
128                 * Number of sockets per node against the view service.
129                 */
130                private int view = 1;
131
132                public int getKeyValue() {
133                        return this.keyValue;
134                }
135
136                public void setKeyValue(int keyValue) {
137                        this.keyValue = keyValue;
138                }
139
140                public int getQuery() {
141                        return this.query;
142                }
143
144                public void setQuery(int query) {
145                        this.query = query;
146                }
147
148                public int getView() {
149                        return this.view;
150                }
151
152                public void setView(int view) {
153                        this.view = view;
154                }
155
156        }
157
158        public static class Ssl {
159
160                /**
161                 * Enable SSL support. Enabled automatically if a "keyStore" is provided unless
162                 * specified otherwise.
163                 */
164                private Boolean enabled;
165
166                /**
167                 * Path to the JVM key store that holds the certificates.
168                 */
169                private String keyStore;
170
171                /**
172                 * Password used to access the key store.
173                 */
174                private String keyStorePassword;
175
176                public Boolean getEnabled() {
177                        return (this.enabled != null ? this.enabled
178                                        : StringUtils.hasText(this.keyStore));
179                }
180
181                public void setEnabled(Boolean enabled) {
182                        this.enabled = enabled;
183                }
184
185                public String getKeyStore() {
186                        return this.keyStore;
187                }
188
189                public void setKeyStore(String keyStore) {
190                        this.keyStore = keyStore;
191                }
192
193                public String getKeyStorePassword() {
194                        return this.keyStorePassword;
195                }
196
197                public void setKeyStorePassword(String keyStorePassword) {
198                        this.keyStorePassword = keyStorePassword;
199                }
200
201        }
202
203        public static class Timeouts {
204
205                /**
206                 * Bucket connections timeout in milliseconds.
207                 */
208                private long connect = 5000;
209
210                /**
211                 * Blocking operations performed on a specific key timeout in milliseconds.
212                 */
213                private long keyValue = 2500;
214
215                /**
216                 * N1QL query operations timeout in milliseconds.
217                 */
218                private long query = 7500;
219
220                /**
221                 * Socket connect connections timeout in milliseconds.
222                 */
223                private int socketConnect = 1000;
224
225                /**
226                 * Regular and geospatial view operations timeout in milliseconds.
227                 */
228                private long view = 7500;
229
230                public long getConnect() {
231                        return this.connect;
232                }
233
234                public void setConnect(long connect) {
235                        this.connect = connect;
236                }
237
238                public long getKeyValue() {
239                        return this.keyValue;
240                }
241
242                public void setKeyValue(long keyValue) {
243                        this.keyValue = keyValue;
244                }
245
246                public long getQuery() {
247                        return this.query;
248                }
249
250                public void setQuery(long query) {
251                        this.query = query;
252                }
253
254                public int getSocketConnect() {
255                        return this.socketConnect;
256                }
257
258                public void setSocketConnect(int socketConnect) {
259                        this.socketConnect = socketConnect;
260                }
261
262                public long getView() {
263                        return this.view;
264                }
265
266                public void setView(long view) {
267                        this.view = view;
268                }
269
270        }
271
272}