IClientConfig.java 2.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
*
* Copyright 2013 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
18
package com.netflix.client.config;
19 20 21

import java.util.Map;

A
Allen Wang 已提交
22 23 24 25 26 27
/**
 * Defines the client configuration used by various APIs to initialize clients or load balancers.
 * 
 * @author awang
 *
 */
28

29
public interface IClientConfig {
A
Allen Wang 已提交
30
	
A
Allen Wang 已提交
31 32 33
	public String getClientName();
		
	public String getNameSpace();
34 35

	/**
A
Allen Wang 已提交
36 37
	 * Load the properties for a given client and/or load balancer. 
	 * @param clientName
38
	 */
A
Allen Wang 已提交
39
	public void loadProperties(String clientName);
40

A
Allen Wang 已提交
41
	public Map<String, Object> getProperties();
42

43 44 45 46
    /**
     * @deprecated use {@link #setPropertyWithType(IClientConfigKey, Object)} 
     */
	@Deprecated
A
Allen Wang 已提交
47
	public void setProperty(IClientConfigKey key, Object value);
48

49 50 51 52
    /**
     * @deprecated use {@link #getPropertyWithType(IClientConfigKey)}
     */
    @Deprecated
A
Allen Wang 已提交
53
	public Object getProperty(IClientConfigKey key);
54

A
Allen Wang 已提交
55 56 57
	public Object getProperty(IClientConfigKey key, Object defaultVal);

	public boolean containsProperty(IClientConfigKey key);
58
	
A
Allen Wang 已提交
59 60 61
	/**
	 * Returns the applicable virtual addresses ("vip") used by this client configuration.
	 */
62
	public String resolveDeploymentContextbasedVipAddresses();
63 64 65 66 67 68
	
	public int getPropertyAsInteger(IClientConfigKey key, int defaultValue);

    public String getPropertyAsString(IClientConfigKey key, String defaultValue);
    
    public boolean getPropertyAsBoolean(IClientConfigKey key, boolean defaultValue);
69 70
    
    /**
71 72
     * Returns a typed property. This property must be set by {@link #setPropertyWithType(IClientConfigKey, Object)}.
     * If the property of IClientConfigKey is not set, it returns null.
73
     */
74 75 76 77 78 79 80 81
    public <T> T getPropertyWithType(IClientConfigKey<T> key);
    
    /**
     * Returns a typed property. This property must be set by {@link #setPropertyWithType(IClientConfigKey, Object)}.
     * If the property of IClientConfigKey is not set, it returns the default value passed in as the parameter.
     */
    public <T> T getPropertyWithType(IClientConfigKey<T> key, T defaultValue);

82
    
83
    public <T> IClientConfig setPropertyWithType(IClientConfigKey<T> key, T value);
84
}