Class RxJavaPlugins
- java.lang.Object
-
- rx.plugins.RxJavaPlugins
-
public class RxJavaPlugins extends java.lang.ObjectRegistry for plugin implementations that allows global override and handles the retrieval of correct implementation based on order of precedence:- plugin registered globally via
registermethods 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].implementationsystem properties, you can define two system property:
Where therxjava.plugin.[index].class} rxjava.plugin.[index].impl}.classproperty contains the simple classname from above and the.implcontains 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 customRxJavaErrorHandlervia 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 RxJavaErrorHandlerDEFAULT_ERROR_HANDLERprivate java.util.concurrent.atomic.AtomicReference<RxJavaErrorHandler>errorHandlerprivate static RxJavaPluginsINSTANCEprivate java.util.concurrent.atomic.AtomicReference<RxJavaObservableExecutionHook>observableExecutionHookprivate java.util.concurrent.atomic.AtomicReference<RxJavaSchedulersHook>schedulersHookprivate 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 RxJavaCompletableExecutionHookgetCompletableExecutionHook()Retrieves the instance ofRxJavaCompletableExecutionHookto use based on order of precedence as defined inRxJavaPluginsclass header.RxJavaErrorHandlergetErrorHandler()Retrieves an instance ofRxJavaErrorHandlerto use based on order of precedence as defined inRxJavaPluginsclass header.static RxJavaPluginsgetInstance()Deprecated.use the static methods ofRxJavaHooks.RxJavaObservableExecutionHookgetObservableExecutionHook()Retrieves the instance ofRxJavaObservableExecutionHookto use based on order of precedence as defined inRxJavaPluginsclass header.(package private) static java.lang.ObjectgetPluginImplementationViaProperty(java.lang.Class<?> pluginClass, java.util.Properties propsIn)RxJavaSchedulersHookgetSchedulersHook()Retrieves the instance ofRxJavaSchedulersHookto use based on order of precedence as defined in theRxJavaPluginsclass header.RxJavaSingleExecutionHookgetSingleExecutionHook()Retrieves the instance ofRxJavaSingleExecutionHookto use based on order of precedence as defined inRxJavaPluginsclass header.voidregisterCompletableExecutionHook(RxJavaCompletableExecutionHook impl)Register anRxJavaCompletableExecutionHookimplementation as a global override of any injected or default implementations.voidregisterErrorHandler(RxJavaErrorHandler impl)Registers anRxJavaErrorHandlerimplementation as a global override of any injected or default implementations.voidregisterObservableExecutionHook(RxJavaObservableExecutionHook impl)Register anRxJavaObservableExecutionHookimplementation as a global override of any injected or default implementations.voidregisterSchedulersHook(RxJavaSchedulersHook impl)Registers anRxJavaSchedulersHookimplementation as a global override of any injected or default implementations.voidregisterSingleExecutionHook(RxJavaSingleExecutionHook impl)Register anRxJavaSingleExecutionHookimplementation as a global override of any injected or default implementations.voidreset()ResetRxJavaPluginsinstance
-
-
-
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 singleRxJavaPluginsinstance.- Returns:
- the single
RxJavaPluginsinstance
-
reset
@Experimental public void reset()
ResetRxJavaPluginsinstanceThis 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 ofRxJavaErrorHandlerto use based on order of precedence as defined inRxJavaPluginsclass header.Override the default by calling
registerErrorHandler(RxJavaErrorHandler)or by setting the propertyrxjava.plugin.RxJavaErrorHandler.implementationwith the full classname to load.- Returns:
RxJavaErrorHandlerimplementation to use
-
registerErrorHandler
public void registerErrorHandler(RxJavaErrorHandler impl)
Registers anRxJavaErrorHandlerimplementation as a global override of any injected or default implementations.- Parameters:
impl-RxJavaErrorHandlerimplementation- 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 ofRxJavaObservableExecutionHookto use based on order of precedence as defined inRxJavaPluginsclass header.Override the default by calling
registerObservableExecutionHook(RxJavaObservableExecutionHook)or by setting the propertyrxjava.plugin.RxJavaObservableExecutionHook.implementationwith the full classname to load.- Returns:
RxJavaObservableExecutionHookimplementation to use
-
registerObservableExecutionHook
public void registerObservableExecutionHook(RxJavaObservableExecutionHook impl)
Register anRxJavaObservableExecutionHookimplementation as a global override of any injected or default implementations.- Parameters:
impl-RxJavaObservableExecutionHookimplementation- 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 ofRxJavaSingleExecutionHookto use based on order of precedence as defined inRxJavaPluginsclass header.Override the default by calling
registerSingleExecutionHook(RxJavaSingleExecutionHook)or by setting the propertyrxjava.plugin.RxJavaSingleExecutionHook.implementationwith the full classname to load.- Returns:
RxJavaSingleExecutionHookimplementation to use
-
registerSingleExecutionHook
public void registerSingleExecutionHook(RxJavaSingleExecutionHook impl)
Register anRxJavaSingleExecutionHookimplementation as a global override of any injected or default implementations.- Parameters:
impl-RxJavaSingleExecutionHookimplementation- 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 ofRxJavaCompletableExecutionHookto use based on order of precedence as defined inRxJavaPluginsclass header.Override the default by calling
registerCompletableExecutionHook(RxJavaCompletableExecutionHook)or by setting the propertyrxjava.plugin.RxJavaCompletableExecutionHook.implementationwith the full classname to load.- Returns:
RxJavaCompletableExecutionHookimplementation 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 anRxJavaCompletableExecutionHookimplementation as a global override of any injected or default implementations.- Parameters:
impl-RxJavaCompletableExecutionHookimplementation- 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 ofRxJavaSchedulersHookto use based on order of precedence as defined in theRxJavaPluginsclass header.Override the default by calling
registerSchedulersHook(RxJavaSchedulersHook)or by setting the propertyrxjava.plugin.RxJavaSchedulersHook.implementationwith the full classname to load.- Returns:
- the
RxJavaSchedulersHookimplementation in use
-
registerSchedulersHook
public void registerSchedulersHook(RxJavaSchedulersHook impl)
Registers anRxJavaSchedulersHookimplementation as a global override of any injected or default implementations.- Parameters:
impl-RxJavaSchedulersHookimplementation- Throws:
java.lang.IllegalStateException- if called more than once or after the default was initialized (if usage occurs before trying to register)
-
-