com.netflix.hystrix.strategy
Class HystrixPlugins

java.lang.Object
  extended by com.netflix.hystrix.strategy.HystrixPlugins

public class HystrixPlugins
extends java.lang.Object

Registry for plugin implementations that allows global override and handles the retrieval of correct implementation based on order of precedence:

  1. plugin registered globally via register methods in this class
  2. injected via HystrixCommand and HystrixCollapser constructors
  3. default implementations

The injection approach is effective for HystrixCommand and HystrixCollapser implementations where you wish to have a different implementation without overriding all implementations. It is also useful when distributing a library where static override should not be used.

The globally registered plugin is useful when using commands from 3rd party libraries and you want to override all implementations in your entire system.


Method Summary
 HystrixConcurrencyStrategy getConcurrencyStrategy(HystrixConcurrencyStrategy injected)
          Retrieve instance of HystrixConcurrencyStrategy to use based on order of precedence as defined in HystrixPlugins class header.
 HystrixEventNotifier getEventNotifier(HystrixEventNotifier injected)
          Retrieve instance of HystrixEventNotifier to use based on order of precedence as defined in HystrixPlugins class header.
static HystrixPlugins getInstance()
           
 HystrixMetricsPublisher getMetricsPublisher(HystrixMetricsPublisher injected)
          Retrieve instance of HystrixMetricsPublisher to use based on order of precedence as defined in HystrixPlugins class header.
 HystrixPropertiesStrategy getPropertiesStrategy(HystrixPropertiesStrategy injected)
          Retrieve instance of HystrixPropertiesStrategy to use based on order of precedence as defined in HystrixPlugins class header.
 void registerConcurrencyStrategy(HystrixConcurrencyStrategy impl)
          Register a HystrixConcurrencyStrategy implementation as a global override of any injected or default implementations.
 void registerEventNotifier(HystrixEventNotifier impl)
          Register a HystrixEventNotifier implementation as a global override of any injected or default implementations.
 void registerMetricsPublisher(HystrixMetricsPublisher impl)
          Register a HystrixMetricsPublisher implementation as a global override of any injected or default implementations.
 void registerPropertiesStrategy(HystrixPropertiesStrategy impl)
          Register a HystrixPropertiesStrategy implementation as a global override of any injected or default implementations.
 void resetToDefaults()
          Allow resetting all strategies back to defaults.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static HystrixPlugins getInstance()

getEventNotifier

public HystrixEventNotifier getEventNotifier(HystrixEventNotifier injected)
Retrieve instance of HystrixEventNotifier to use based on order of precedence as defined in HystrixPlugins class header.

Parameters:
injected - HystrixEventNotifier implementation as injected via HystrixCommand
Returns:
HystrixEventNotifier implementation to use

registerEventNotifier

public void registerEventNotifier(HystrixEventNotifier impl)
Register a HystrixEventNotifier implementation as a global override of any injected or default implementations.

Parameters:
impl - HystrixEventNotifier implementation

resetToDefaults

public void resetToDefaults()
Allow resetting all strategies back to defaults.


getConcurrencyStrategy

public HystrixConcurrencyStrategy getConcurrencyStrategy(HystrixConcurrencyStrategy injected)
Retrieve instance of HystrixConcurrencyStrategy to use based on order of precedence as defined in HystrixPlugins class header.

Parameters:
injected - HystrixConcurrencyStrategy implementation as injected via HystrixCommand
Returns:
HystrixConcurrencyStrategy implementation to use

registerConcurrencyStrategy

public void registerConcurrencyStrategy(HystrixConcurrencyStrategy impl)
Register a HystrixConcurrencyStrategy implementation as a global override of any injected or default implementations.

Parameters:
impl - HystrixConcurrencyStrategy implementation

getMetricsPublisher

public HystrixMetricsPublisher getMetricsPublisher(HystrixMetricsPublisher injected)
Retrieve instance of HystrixMetricsPublisher to use based on order of precedence as defined in HystrixPlugins class header.

Parameters:
injected - HystrixMetricsPublisher implementation as injected via HystrixCommand
Returns:
HystrixMetricsPublisher implementation to use

registerMetricsPublisher

public void registerMetricsPublisher(HystrixMetricsPublisher impl)
Register a HystrixMetricsPublisher implementation as a global override of any injected or default implementations.

Parameters:
impl - HystrixMetricsPublisher implementation

getPropertiesStrategy

public HystrixPropertiesStrategy getPropertiesStrategy(HystrixPropertiesStrategy injected)
Retrieve instance of HystrixPropertiesStrategy to use based on order of precedence as defined in HystrixPlugins class header.

Parameters:
injected - HystrixPropertiesStrategy implementation as injected via HystrixCommand
Returns:
HystrixPropertiesStrategy implementation to use

registerPropertiesStrategy

public void registerPropertiesStrategy(HystrixPropertiesStrategy impl)
Register a HystrixPropertiesStrategy implementation as a global override of any injected or default implementations.

Parameters:
impl - HystrixPropertiesStrategy implementation