Class RxJavaPlugins
- java.lang.Object
-
- rx.plugins.RxJavaPlugins
-
public class RxJavaPlugins extends java.lang.Object
Registry for plugin implementations that allows global override and handles the retrieval of correct implementation based on order of precedence:- plugin registered globally via
register
methods in this class - plugin registered and retrieved using
System.getProperty(String)
(see get methods for property names) - default implementation
In addition to the
rxjava.plugin.[simple classname].implementation
system properties, you can define two system property:
Where therxjava.plugin.[index].class} rxjava.plugin.[index].impl}
.class
property contains the simple classname 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 customRxJavaErrorHandler
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.
- plugin registered globally via
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicReference<RxJavaCompletableExecutionHook>
completableExecutionHook
(package private) static RxJavaErrorHandler
DEFAULT_ERROR_HANDLER
private java.util.concurrent.atomic.AtomicReference<RxJavaErrorHandler>
errorHandler
private static RxJavaPlugins
INSTANCE
private java.util.concurrent.atomic.AtomicReference<RxJavaObservableExecutionHook>
observableExecutionHook
private java.util.concurrent.atomic.AtomicReference<RxJavaSchedulersHook>
schedulersHook
private java.util.concurrent.atomic.AtomicReference<RxJavaSingleExecutionHook>
singleExecutionHook
-
Constructor Summary
Constructors Constructor Description RxJavaPlugins()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description RxJavaCompletableExecutionHook
getCompletableExecutionHook()
Retrieves the instance ofRxJavaCompletableExecutionHook
to use based on order of precedence as defined inRxJavaPlugins
class header.RxJavaErrorHandler
getErrorHandler()
Retrieves an instance ofRxJavaErrorHandler
to use based on order of precedence as defined inRxJavaPlugins
class header.static RxJavaPlugins
getInstance()
Deprecated.use the static methods ofRxJavaHooks
.RxJavaObservableExecutionHook
getObservableExecutionHook()
Retrieves the instance ofRxJavaObservableExecutionHook
to use based on order of precedence as defined inRxJavaPlugins
class header.(package private) static java.lang.Object
getPluginImplementationViaProperty(java.lang.Class<?> pluginClass, java.util.Properties propsIn)
RxJavaSchedulersHook
getSchedulersHook()
Retrieves the instance ofRxJavaSchedulersHook
to use based on order of precedence as defined in theRxJavaPlugins
class header.RxJavaSingleExecutionHook
getSingleExecutionHook()
Retrieves the instance ofRxJavaSingleExecutionHook
to use based on order of precedence as defined inRxJavaPlugins
class header.void
registerCompletableExecutionHook(RxJavaCompletableExecutionHook impl)
Register anRxJavaCompletableExecutionHook
implementation as a global override of any injected or default implementations.void
registerErrorHandler(RxJavaErrorHandler impl)
Registers anRxJavaErrorHandler
implementation as a global override of any injected or default implementations.void
registerObservableExecutionHook(RxJavaObservableExecutionHook impl)
Register anRxJavaObservableExecutionHook
implementation as a global override of any injected or default implementations.void
registerSchedulersHook(RxJavaSchedulersHook impl)
Registers anRxJavaSchedulersHook
implementation as a global override of any injected or default implementations.void
registerSingleExecutionHook(RxJavaSingleExecutionHook impl)
Register anRxJavaSingleExecutionHook
implementation as a global override of any injected or default implementations.void
reset()
ResetRxJavaPlugins
instance
-
-
-
Field Detail
-
INSTANCE
private static final RxJavaPlugins INSTANCE
-
errorHandler
private final java.util.concurrent.atomic.AtomicReference<RxJavaErrorHandler> errorHandler
-
observableExecutionHook
private final java.util.concurrent.atomic.AtomicReference<RxJavaObservableExecutionHook> observableExecutionHook
-
singleExecutionHook
private final java.util.concurrent.atomic.AtomicReference<RxJavaSingleExecutionHook> singleExecutionHook
-
completableExecutionHook
private final java.util.concurrent.atomic.AtomicReference<RxJavaCompletableExecutionHook> completableExecutionHook
-
schedulersHook
private final java.util.concurrent.atomic.AtomicReference<RxJavaSchedulersHook> schedulersHook
-
DEFAULT_ERROR_HANDLER
static final RxJavaErrorHandler DEFAULT_ERROR_HANDLER
-
-
Method Detail
-
getInstance
@Deprecated public static RxJavaPlugins getInstance()
Deprecated.use the static methods ofRxJavaHooks
.Retrieves the singleRxJavaPlugins
instance.- Returns:
- the single
RxJavaPlugins
instance
-
reset
@Experimental public void reset()
ResetRxJavaPlugins
instanceThis 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: * @see Make RxJavaPlugins.reset() public
-
getErrorHandler
public RxJavaErrorHandler getErrorHandler()
Retrieves an instance ofRxJavaErrorHandler
to use based on order of precedence as defined inRxJavaPlugins
class header.Override the default by calling
registerErrorHandler(RxJavaErrorHandler)
or by setting the propertyrxjava.plugin.RxJavaErrorHandler.implementation
with the full classname to load.- Returns:
RxJavaErrorHandler
implementation to use
-
registerErrorHandler
public void registerErrorHandler(RxJavaErrorHandler impl)
Registers anRxJavaErrorHandler
implementation as a global override of any injected or default implementations.- Parameters:
impl
-RxJavaErrorHandler
implementation- Throws:
java.lang.IllegalStateException
- if called more than once or after the default was initialized (if usage occurs before trying to register)
-
getObservableExecutionHook
public RxJavaObservableExecutionHook getObservableExecutionHook()
Retrieves the instance ofRxJavaObservableExecutionHook
to use based on order of precedence as defined inRxJavaPlugins
class header.Override the default by calling
registerObservableExecutionHook(RxJavaObservableExecutionHook)
or by setting the propertyrxjava.plugin.RxJavaObservableExecutionHook.implementation
with the full classname to load.- Returns:
RxJavaObservableExecutionHook
implementation to use
-
registerObservableExecutionHook
public void registerObservableExecutionHook(RxJavaObservableExecutionHook impl)
Register anRxJavaObservableExecutionHook
implementation as a global override of any injected or default implementations.- Parameters:
impl
-RxJavaObservableExecutionHook
implementation- Throws:
java.lang.IllegalStateException
- if called more than once or after the default was initialized (if usage occurs before trying to register)
-
getSingleExecutionHook
public RxJavaSingleExecutionHook getSingleExecutionHook()
Retrieves the instance ofRxJavaSingleExecutionHook
to use based on order of precedence as defined inRxJavaPlugins
class header.Override the default by calling
registerSingleExecutionHook(RxJavaSingleExecutionHook)
or by setting the propertyrxjava.plugin.RxJavaSingleExecutionHook.implementation
with the full classname to load.- Returns:
RxJavaSingleExecutionHook
implementation to use
-
registerSingleExecutionHook
public void registerSingleExecutionHook(RxJavaSingleExecutionHook impl)
Register anRxJavaSingleExecutionHook
implementation as a global override of any injected or default implementations.- Parameters:
impl
-RxJavaSingleExecutionHook
implementation- Throws:
java.lang.IllegalStateException
- if called more than once or after the default was initialized (if usage occurs before trying to register)
-
getCompletableExecutionHook
@Experimental public RxJavaCompletableExecutionHook getCompletableExecutionHook()
Retrieves the instance ofRxJavaCompletableExecutionHook
to use based on order of precedence as defined inRxJavaPlugins
class header.Override the default by calling
registerCompletableExecutionHook(RxJavaCompletableExecutionHook)
or by setting the propertyrxjava.plugin.RxJavaCompletableExecutionHook.implementation
with the full classname to load.- Returns:
RxJavaCompletableExecutionHook
implementation to use- Since:
- (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-
registerCompletableExecutionHook
@Experimental public void registerCompletableExecutionHook(RxJavaCompletableExecutionHook impl)
Register anRxJavaCompletableExecutionHook
implementation as a global override of any injected or default implementations.- Parameters:
impl
-RxJavaCompletableExecutionHook
implementation- Throws:
java.lang.IllegalStateException
- if called more than once or after the default was initialized (if usage occurs before trying to register)- Since:
- (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
-
getPluginImplementationViaProperty
static java.lang.Object getPluginImplementationViaProperty(java.lang.Class<?> pluginClass, java.util.Properties propsIn)
-
getSchedulersHook
public RxJavaSchedulersHook getSchedulersHook()
Retrieves the instance ofRxJavaSchedulersHook
to use based on order of precedence as defined in theRxJavaPlugins
class header.Override the default by calling
registerSchedulersHook(RxJavaSchedulersHook)
or by setting the propertyrxjava.plugin.RxJavaSchedulersHook.implementation
with the full classname to load.- Returns:
- the
RxJavaSchedulersHook
implementation in use
-
registerSchedulersHook
public void registerSchedulersHook(RxJavaSchedulersHook impl)
Registers anRxJavaSchedulersHook
implementation as a global override of any injected or default implementations.- Parameters:
impl
-RxJavaSchedulersHook
implementation- Throws:
java.lang.IllegalStateException
- if called more than once or after the default was initialized (if usage occurs before trying to register)
-
-