com.alibaba.dubbo.config.utils
Class ReferenceConfigCache

java.lang.Object
  extended by com.alibaba.dubbo.config.utils.ReferenceConfigCache

public class ReferenceConfigCache
extends Object

a simple util class for cache ReferenceConfig.

ReferenceConfig is a heavy Object, it's necessary to cache these object for the framework which create ReferenceConfig frequently.

You can implement and use your own ReferenceConfig cache if you need use complicate strategy.

Author:
ding.lid

Nested Class Summary
static interface ReferenceConfigCache.KeyGenerator
           
 
Field Summary
static ReferenceConfigCache.KeyGenerator DEFAULT_KEY_GENERATOR
          Create the key with the Group, Interface and version attribute of ReferenceConfig.
static String DEFAULT_NAME
           
 
Method Summary
<T> void
destroy(ReferenceConfig<T> referenceConfig)
          clear and destroy one ReferenceConfig in the cache.
 void destroyAll()
          clear and destroy all ReferenceConfig in the cache.
<T> T
get(ReferenceConfig<T> referenceConfig)
           
static ReferenceConfigCache getCache()
          Get the cache use default name and DEFAULT_KEY_GENERATOR to generate cache key.
static ReferenceConfigCache getCache(String name)
          Get the cache use specified name and ReferenceConfigCache.KeyGenerator.
static ReferenceConfigCache getCache(String name, ReferenceConfigCache.KeyGenerator keyGenerator)
          Get the cache use specified ReferenceConfigCache.KeyGenerator.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_NAME

public static final String DEFAULT_NAME
See Also:
Constant Field Values

DEFAULT_KEY_GENERATOR

public static final ReferenceConfigCache.KeyGenerator DEFAULT_KEY_GENERATOR
Create the key with the Group, Interface and version attribute of ReferenceConfig.

key example: group1/com.alibaba.foo.FooService:1.0.0.

Method Detail

getCache

public static ReferenceConfigCache getCache()
Get the cache use default name and DEFAULT_KEY_GENERATOR to generate cache key. Create cache if not existed yet.


getCache

public static ReferenceConfigCache getCache(String name)
Get the cache use specified name and ReferenceConfigCache.KeyGenerator. Create cache if not existed yet.


getCache

public static ReferenceConfigCache getCache(String name,
                                            ReferenceConfigCache.KeyGenerator keyGenerator)
Get the cache use specified ReferenceConfigCache.KeyGenerator. Create cache if not existed yet.


get

public <T> T get(ReferenceConfig<T> referenceConfig)

destroy

public <T> void destroy(ReferenceConfig<T> referenceConfig)
clear and destroy one ReferenceConfig in the cache.

Parameters:
referenceConfig - use for create key.

destroyAll

public void destroyAll()
clear and destroy all ReferenceConfig in the cache.


toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012–2017 Alibaba. All rights reserved.