001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel.model.cloud; 018 019import javax.xml.bind.annotation.XmlAccessType; 020import javax.xml.bind.annotation.XmlAccessorType; 021import javax.xml.bind.annotation.XmlAttribute; 022import javax.xml.bind.annotation.XmlRootElement; 023import javax.xml.bind.annotation.XmlTransient; 024 025import org.apache.camel.spi.Metadata; 026import org.apache.camel.util.jsse.SSLContextParameters; 027 028@Metadata(label = "routing,cloud,service-discovery") 029@XmlRootElement(name = "consulServiceDiscovery") 030@XmlAccessorType(XmlAccessType.FIELD) 031public class ConsulServiceCallServiceDiscoveryConfiguration extends ServiceCallServiceDiscoveryConfiguration { 032 @XmlAttribute 033 private String url; 034 @XmlAttribute 035 private String datacenter; 036 @XmlAttribute @Metadata(label = "security") 037 private String aclToken; 038 @XmlAttribute @Metadata(label = "security") 039 private String userName; 040 @XmlAttribute @Metadata(label = "security") 041 private String password; 042 @XmlAttribute 043 private Long connectTimeoutMillis; 044 @XmlAttribute 045 private Long readTimeoutMillis; 046 @XmlAttribute 047 private Long writeTimeoutMillis; 048 @XmlAttribute @Metadata(defaultValue = "10") 049 private Integer blockSeconds = 10; 050 @XmlTransient 051 private SSLContextParameters sslContextParameters; 052 053 public ConsulServiceCallServiceDiscoveryConfiguration() { 054 this(null); 055 } 056 057 public ConsulServiceCallServiceDiscoveryConfiguration(ServiceCallDefinition parent) { 058 super(parent, "consul-service-discovery"); 059 } 060 061 // ************************************************************************* 062 // Getter/Setter 063 // ************************************************************************* 064 065 /** 066 * The Consul agent URL 067 */ 068 public String getUrl() { 069 return url; 070 } 071 072 public void setUrl(String url) { 073 this.url = url; 074 } 075 076 /** 077 * @deprecated replaced by {@link #getDatacenter()} ()} 078 */ 079 @Deprecated 080 public String getDc() { 081 return datacenter; 082 } 083 084 /** 085 * The data center 086 * 087 * @deprecated replaced by {@link #setDatacenter(String)} ()} 088 */ 089 @Deprecated 090 public void setDc(String dc) { 091 this.datacenter = dc; 092 } 093 094 public String getDatacenter() { 095 return datacenter; 096 } 097 098 /** 099 * The data center 100 */ 101 public void setDatacenter(String datacenter) { 102 this.datacenter = datacenter; 103 } 104 105 public String getAclToken() { 106 return aclToken; 107 } 108 109 /** 110 * Sets the ACL token to be used with Consul 111 */ 112 public void setAclToken(String aclToken) { 113 this.aclToken = aclToken; 114 } 115 116 public String getUserName() { 117 return userName; 118 } 119 120 /** 121 * Sets the username to be used for basic authentication 122 */ 123 public void setUserName(String userName) { 124 this.userName = userName; 125 } 126 127 public String getPassword() { 128 return password; 129 } 130 131 /** 132 * Sets the password to be used for basic authentication 133 */ 134 public void setPassword(String password) { 135 this.password = password; 136 } 137 138 public Long getConnectTimeoutMillis() { 139 return connectTimeoutMillis; 140 } 141 142 /** 143 * Connect timeout for OkHttpClient 144 */ 145 public void setConnectTimeoutMillis(Long connectTimeoutMillis) { 146 this.connectTimeoutMillis = connectTimeoutMillis; 147 } 148 149 public Long getReadTimeoutMillis() { 150 return readTimeoutMillis; 151 } 152 153 /** 154 * Read timeout for OkHttpClient 155 */ 156 public void setReadTimeoutMillis(Long readTimeoutMillis) { 157 this.readTimeoutMillis = readTimeoutMillis; 158 } 159 160 public Long getWriteTimeoutMillis() { 161 return writeTimeoutMillis; 162 } 163 164 /** 165 * Write timeout for OkHttpClient 166 */ 167 public void setWriteTimeoutMillis(Long writeTimeoutMillis) { 168 this.writeTimeoutMillis = writeTimeoutMillis; 169 } 170 171 public Integer getBlockSeconds() { 172 return blockSeconds; 173 } 174 175 /** 176 * The seconds to wait for a watch event, default 10 seconds 177 */ 178 public void setBlockSeconds(Integer blockSeconds) { 179 this.blockSeconds = blockSeconds; 180 } 181 182 public SSLContextParameters getSslContextParameters() { 183 return sslContextParameters; 184 } 185 186 /** 187 * To configure security using SSLContextParameters. 188 */ 189 public void setSslContextParameters(SSLContextParameters sslContextParameters) { 190 this.sslContextParameters = sslContextParameters; 191 } 192 193 // ************************************************************************* 194 // Fluent API 195 // ************************************************************************* 196 197 /** 198 * The Consul agent URL 199 */ 200 public ConsulServiceCallServiceDiscoveryConfiguration url(String url) { 201 setUrl(url); 202 return this; 203 } 204 205 /** 206 * The data center 207 */ 208 public ConsulServiceCallServiceDiscoveryConfiguration dc(String dc) { 209 setDc(dc); 210 return this; 211 } 212 213 /** 214 * Sets the ACL token to be used with Consul 215 */ 216 public ConsulServiceCallServiceDiscoveryConfiguration aclToken(String aclToken) { 217 setAclToken(aclToken); 218 return this; 219 } 220 221 /** 222 * Sets the username to be used for basic authentication 223 */ 224 public ConsulServiceCallServiceDiscoveryConfiguration userName(String userName) { 225 setUserName(userName); 226 return this; 227 } 228 229 /** 230 * Sets the password to be used for basic authentication 231 */ 232 public ConsulServiceCallServiceDiscoveryConfiguration password(String password) { 233 setPassword(password); 234 return this; 235 } 236 237 /** 238 * Connect timeout for OkHttpClient 239 */ 240 public ConsulServiceCallServiceDiscoveryConfiguration connectTimeoutMillis(Long connectTimeoutMillis) { 241 setConnectTimeoutMillis(connectTimeoutMillis); 242 return this; 243 } 244 245 /** 246 * Read timeout for OkHttpClient 247 */ 248 public ConsulServiceCallServiceDiscoveryConfiguration readTimeoutMillis(Long readTimeoutMillis) { 249 setReadTimeoutMillis(readTimeoutMillis); 250 return this; 251 } 252 253 /** 254 * Write timeout for OkHttpClient 255 */ 256 public ConsulServiceCallServiceDiscoveryConfiguration writeTimeoutMillis(Long writeTimeoutMillis) { 257 setWriteTimeoutMillis(writeTimeoutMillis); 258 return this; 259 } 260 261 /** 262 * The seconds to wait for a watch event, default 10 seconds 263 */ 264 public ConsulServiceCallServiceDiscoveryConfiguration blockSeconds(Integer blockSeconds) { 265 setBlockSeconds(blockSeconds); 266 return this; 267 } 268 269 /** 270 * To configure security using SSLContextParameters. 271 */ 272 public ConsulServiceCallServiceDiscoveryConfiguration sslContextParameters(SSLContextParameters sslContextParameters) { 273 setSslContextParameters(sslContextParameters); 274 return this; 275 } 276}