Top Description Fields Constructors Methods
rx.plugins

public Class RxJavaPlugins

extends Object
Class Inheritance
Imports
java.util.*, java.util.concurrent.atomic.AtomicReference

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. plugin registered and retrieved using java.lang.System#getProperty(String) (see get methods for property names)
  3. default implementation

In addition to the rxjava.plugin.[simple class name].implementation system properties, you can define two system property:


rxjava.plugin.[index].class}
rxjava.plugin.[index].impl}
Where the .class property contains the simple class name from above and the .impl contains the fully qualified name of the implementation class. The [index] can be any short string or number of your choosing. For example, you can now define a custom RxJavaErrorHandler via two system property:

rxjava.plugin.1.class=RxJavaErrorHandler
rxjava.plugin.1.impl=some.package.MyRxJavaErrorHandler
See Also
RxJava Wiki: Plugins Use the RxJavaHooks features instead which let's you change individual handlers at runtime.

Field Summary

Modifier and TypeField and Description
private final AtomicReference<RxJavaCompletableExecutionHook>
pack-priv static final RxJavaErrorHandler
private final AtomicReference<RxJavaErrorHandler>
private static final RxJavaPlugins
private final AtomicReference<RxJavaObservableExecutionHook>
private final AtomicReference<RxJavaSchedulersHook>
private final AtomicReference<RxJavaSingleExecutionHook>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public RxJavaCompletableExecutionHook

Returns:

RxJavaCompletableExecutionHook implementation to use
getCompletableExecutionHook
()

Retrieves the instance of RxJavaCompletableExecutionHook to use based on order of precedence as defined in RxJavaPlugins class header.

public RxJavaErrorHandler

Returns:

RxJavaErrorHandler implementation to use
getErrorHandler
()

Retrieves an instance of RxJavaErrorHandler to use based on order of precedence as defined in RxJavaPlugins class header.

public static RxJavaPlugins

Returns:

the single RxJavaPlugins instance
getInstance
()

Deprecated use the static methods of RxJavaHooks.
Retrieves the single RxJavaPlugins instance.
public RxJavaObservableExecutionHook

Returns:

RxJavaObservableExecutionHook implementation to use
getObservableExecutionHook
()

Retrieves the instance of RxJavaObservableExecutionHook to use based on order of precedence as defined in RxJavaPlugins class header.

pack-priv static Object
public RxJavaSchedulersHook

Returns:

the RxJavaSchedulersHook implementation in use
getSchedulersHook
()

Retrieves the instance of RxJavaSchedulersHook to use based on order of precedence as defined in the RxJavaPlugins class header.

public RxJavaSingleExecutionHook

Returns:

RxJavaSingleExecutionHook implementation to use
getSingleExecutionHook
()

Retrieves the instance of RxJavaSingleExecutionHook to use based on order of precedence as defined in RxJavaPlugins class header.

pack-priv static Properties

Returns:

the Properties to use for looking up settings
getSystemPropertiesSafe
()

A security manager may prevent accessing the System properties entirely, therefore, the SecurityException is turned into an empty properties.

public void
registerCompletableExecutionHook(RxJavaCompletableExecutionHook impl)

Register an RxJavaCompletableExecutionHook implementation as a global override of any injected or default implementations.

public void
registerErrorHandler(RxJavaErrorHandler
RxJavaErrorHandler implementation
impl
)

Registers an RxJavaErrorHandler implementation as a global override of any injected or default implementations.

public void
registerObservableExecutionHook(RxJavaObservableExecutionHook impl)

Register an RxJavaObservableExecutionHook implementation as a global override of any injected or default implementations.

public void
registerSchedulersHook(RxJavaSchedulersHook
RxJavaSchedulersHook implementation
impl
)

Registers an RxJavaSchedulersHook implementation as a global override of any injected or default implementations.

public void
registerSingleExecutionHook(RxJavaSingleExecutionHook impl)

Register an RxJavaSingleExecutionHook implementation as a global override of any injected or default implementations.

public void
reset()

Reset RxJavaPlugins instance

This API is experimental.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

completableExecutionHookback to summary
private final AtomicReference<RxJavaCompletableExecutionHook> completableExecutionHook
DEFAULT_ERROR_HANDLERback to summary
pack-priv static final RxJavaErrorHandler DEFAULT_ERROR_HANDLER
errorHandlerback to summary
private final AtomicReference<RxJavaErrorHandler> errorHandler
INSTANCEback to summary
private static final RxJavaPlugins INSTANCE
observableExecutionHookback to summary
private final AtomicReference<RxJavaObservableExecutionHook> observableExecutionHook
schedulersHookback to summary
private final AtomicReference<RxJavaSchedulersHook> schedulersHook
singleExecutionHookback to summary
private final AtomicReference<RxJavaSingleExecutionHook> singleExecutionHook

Constructor Detail

RxJavaPluginsback to summary
pack-priv RxJavaPlugins()

Method Detail

getCompletableExecutionHookback to summary
public RxJavaCompletableExecutionHook getCompletableExecutionHook()

Retrieves the instance of RxJavaCompletableExecutionHook to use based on order of precedence as defined in RxJavaPlugins class header.

Override the default by calling registerCompletableExecutionHook(RxJavaCompletableExecutionHook) or by setting the property rxjava.plugin.RxJavaCompletableExecutionHook.implementation with the full class name to load.

Returns:RxJavaCompletableExecutionHook

RxJavaCompletableExecutionHook implementation to use

Since
1.3
getErrorHandlerback to summary
public RxJavaErrorHandler getErrorHandler()

Retrieves an instance of RxJavaErrorHandler to use based on order of precedence as defined in RxJavaPlugins class header.

Override the default by calling registerErrorHandler(RxJavaErrorHandler) or by setting the property rxjava.plugin.RxJavaErrorHandler.implementation with the full class name to load.

Returns:RxJavaErrorHandler

RxJavaErrorHandler implementation to use

getInstanceback to summary
public static RxJavaPlugins getInstance()

Deprecated

use the static methods of RxJavaHooks.

Retrieves the single RxJavaPlugins instance.

Returns:RxJavaPlugins

the single RxJavaPlugins instance

Annotations
@Deprecated
getObservableExecutionHookback to summary
public RxJavaObservableExecutionHook getObservableExecutionHook()

Retrieves the instance of RxJavaObservableExecutionHook to use based on order of precedence as defined in RxJavaPlugins class header.

Override the default by calling registerObservableExecutionHook(RxJavaObservableExecutionHook) or by setting the property rxjava.plugin.RxJavaObservableExecutionHook.implementation with the full class name to load.

Returns:RxJavaObservableExecutionHook

RxJavaObservableExecutionHook implementation to use

getPluginImplementationViaPropertyback to summary
pack-priv static Object getPluginImplementationViaProperty(Class<?> pluginClass, Properties propsIn)
getSchedulersHookback to summary
public RxJavaSchedulersHook getSchedulersHook()

Retrieves the instance of RxJavaSchedulersHook to use based on order of precedence as defined in the RxJavaPlugins class header.

Override the default by calling registerSchedulersHook(RxJavaSchedulersHook) or by setting the property rxjava.plugin.RxJavaSchedulersHook.implementation with the full class name to load.

Returns:RxJavaSchedulersHook

the RxJavaSchedulersHook implementation in use

getSingleExecutionHookback to summary
public RxJavaSingleExecutionHook getSingleExecutionHook()

Retrieves the instance of RxJavaSingleExecutionHook to use based on order of precedence as defined in RxJavaPlugins class header.

Override the default by calling registerSingleExecutionHook(RxJavaSingleExecutionHook) or by setting the property rxjava.plugin.RxJavaSingleExecutionHook.implementation with the full class name to load.

Returns:RxJavaSingleExecutionHook

RxJavaSingleExecutionHook implementation to use

getSystemPropertiesSafeback to summary
pack-priv static Properties getSystemPropertiesSafe()

A security manager may prevent accessing the System properties entirely, therefore, the SecurityException is turned into an empty properties.

Returns:Properties

the Properties to use for looking up settings

registerCompletableExecutionHookback to summary
public void registerCompletableExecutionHook(RxJavaCompletableExecutionHook impl)

Register an RxJavaCompletableExecutionHook implementation as a global override of any injected or default implementations.

Parameters
impl:RxJavaCompletableExecutionHook

RxJavaCompletableExecutionHook implementation

Exceptions
IllegalStateException:
if called more than once or after the default was initialized (if usage occurs before trying to register)
Since
1.3
registerErrorHandlerback to summary
public void registerErrorHandler(RxJavaErrorHandler impl)

Registers an RxJavaErrorHandler implementation as a global override of any injected or default implementations.

Parameters
impl:RxJavaErrorHandler

RxJavaErrorHandler implementation

Exceptions
IllegalStateException:
if called more than once or after the default was initialized (if usage occurs before trying to register)
registerObservableExecutionHookback to summary
public void registerObservableExecutionHook(RxJavaObservableExecutionHook impl)

Register an RxJavaObservableExecutionHook implementation as a global override of any injected or default implementations.

Parameters
impl:RxJavaObservableExecutionHook

RxJavaObservableExecutionHook implementation

Exceptions
IllegalStateException:
if called more than once or after the default was initialized (if usage occurs before trying to register)
registerSchedulersHookback to summary
public void registerSchedulersHook(RxJavaSchedulersHook impl)

Registers an RxJavaSchedulersHook implementation as a global override of any injected or default implementations.

Parameters
impl:RxJavaSchedulersHook

RxJavaSchedulersHook implementation

Exceptions
IllegalStateException:
if called more than once or after the default was initialized (if usage occurs before trying to register)
registerSingleExecutionHookback to summary
public void registerSingleExecutionHook(RxJavaSingleExecutionHook impl)

Register an RxJavaSingleExecutionHook implementation as a global override of any injected or default implementations.

Parameters
impl:RxJavaSingleExecutionHook

RxJavaSingleExecutionHook implementation

Exceptions
IllegalStateException:
if called more than once or after the default was initialized (if usage occurs before trying to register)
resetback to summary
public void reset()

Reset RxJavaPlugins instance

This API is experimental. Resetting the plugins is dangerous during application runtime and also bad code could invoke it in the middle of an application life-cycle and really break applications if not used cautiously. For more detailed discussions:

Since
1.3
See Also
Make RxJavaPlugins.reset() public