Package jrpc.clightning.plugins
Class CLightningPlugin
- java.lang.Object
-
- jrpc.clightning.plugins.CLightningPlugin
-
- All Implemented Interfaces:
ICLightningPlugin
public abstract class CLightningPlugin extends java.lang.Object implements ICLightningPlugin
-
-
Field Summary
Fields Modifier and Type Field Description protected CLightingPluginConfig
configs
protected java.util.Map<java.lang.String,java.lang.Object>
parameters
-
Constructor Summary
Constructors Constructor Description CLightningPlugin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInterceptorAfterRPCMethod(Interceptor interceptor)
void
addInterceptorBeforeRPCMethod(Interceptor interceptor)
void
addNotification(java.lang.String methodName)
Method to help the user to register a custom notification for the pluginvoid
addParameter(java.lang.String key, java.lang.Object value)
void
addRPCMethod(AbstractRPCMethod method)
void
addSubscription(java.lang.String event)
boolean
containsNotification(java.lang.String methodName)
Helper method to check if a notification with the key (method name) exist in the plugin.CLightingPluginConfig
getConfigs()
java.util.List<java.lang.String>
getHooks()
<T> T
getParameter(java.lang.String key)
java.util.List<AbstractRPCMethod>
getRpcMethods()
java.util.List<java.lang.String>
getSubscriptions()
boolean
hasParameter(java.lang.String key)
boolean
hasParametersReady()
protected void
initPostHandlerInterceptor()
protected void
initPreHandlerInterceptor()
boolean
isDynamic()
void
log(PluginLog level, java.lang.Object json)
void
log(PluginLog level, java.lang.String logMessage)
This call should be enable also in RPC methods.void
log(PluginLog level, CLightningJsonObject json)
void
onInit(ICLightningPlugin plugin, CLightningJsonObject request, CLightningJsonObject response)
protected void
registerMethod()
void
sendNotification(java.lang.String methodName, CLightningJsonObject params)
Method to tell the plugin that the user want send a notificationvoid
setConfigs(CLightingPluginConfig configs)
void
setParametersReady(boolean parametersReady)
void
start()
java.lang.String
toString()
-
-
-
Field Detail
-
parameters
protected java.util.Map<java.lang.String,java.lang.Object> parameters
-
configs
protected CLightingPluginConfig configs
-
-
Method Detail
-
addRPCMethod
public void addRPCMethod(AbstractRPCMethod method)
- Specified by:
addRPCMethod
in interfaceICLightningPlugin
-
addInterceptorBeforeRPCMethod
public void addInterceptorBeforeRPCMethod(Interceptor interceptor)
- Specified by:
addInterceptorBeforeRPCMethod
in interfaceICLightningPlugin
-
addInterceptorAfterRPCMethod
public void addInterceptorAfterRPCMethod(Interceptor interceptor)
- Specified by:
addInterceptorAfterRPCMethod
in interfaceICLightningPlugin
-
onInit
public void onInit(ICLightningPlugin plugin, CLightningJsonObject request, CLightningJsonObject response)
- Specified by:
onInit
in interfaceICLightningPlugin
-
start
public void start()
- Specified by:
start
in interfaceICLightningPlugin
-
setConfigs
public void setConfigs(CLightingPluginConfig configs)
- Specified by:
setConfigs
in interfaceICLightningPlugin
-
getConfigs
public CLightingPluginConfig getConfigs()
- Specified by:
getConfigs
in interfaceICLightningPlugin
-
hasParametersReady
public boolean hasParametersReady()
- Specified by:
hasParametersReady
in interfaceICLightningPlugin
-
setParametersReady
public void setParametersReady(boolean parametersReady)
-
log
public void log(PluginLog level, CLightningJsonObject json)
- Specified by:
log
in interfaceICLightningPlugin
-
log
public void log(PluginLog level, java.lang.Object json)
- Specified by:
log
in interfaceICLightningPlugin
-
log
public void log(PluginLog level, java.lang.String logMessage)
This call should be enable also in RPC methods.- Specified by:
log
in interfaceICLightningPlugin
- Parameters:
level
- level log, this class should be an instance of enum CLightningLevelLoglogMessage
- log message should be the log message
-
addNotification
public void addNotification(java.lang.String methodName)
Method to help the user to register a custom notification for the plugin- Parameters:
methodName
- : A unique key to identify notification in the plugin
-
containsNotification
public boolean containsNotification(java.lang.String methodName)
Helper method to check if a notification with the key (method name) exist in the plugin.- Parameters:
methodName
- A unique key to identify notification in the plugin- Returns:
- true if the plugin contains a notification with the key (methodName), false otherwise.
-
sendNotification
public void sendNotification(java.lang.String methodName, CLightningJsonObject params)
Method to tell the plugin that the user want send a notification- Parameters:
methodName
- : A unique key to identify notification in the pluginparams
- : A json object (CLightningJsonObject) that contains all the parameters that the notification need to ship.
-
initPreHandlerInterceptor
protected void initPreHandlerInterceptor()
-
initPostHandlerInterceptor
protected void initPostHandlerInterceptor()
-
registerMethod
protected void registerMethod()
-
addSubscription
public void addSubscription(java.lang.String event)
-
addParameter
public void addParameter(java.lang.String key, java.lang.Object value)
- Specified by:
addParameter
in interfaceICLightningPlugin
-
getParameter
public <T> T getParameter(java.lang.String key)
- Specified by:
getParameter
in interfaceICLightningPlugin
-
hasParameter
public boolean hasParameter(java.lang.String key)
- Specified by:
hasParameter
in interfaceICLightningPlugin
-
getRpcMethods
public java.util.List<AbstractRPCMethod> getRpcMethods()
- Specified by:
getRpcMethods
in interfaceICLightningPlugin
-
getSubscriptions
public java.util.List<java.lang.String> getSubscriptions()
- Specified by:
getSubscriptions
in interfaceICLightningPlugin
-
getHooks
public java.util.List<java.lang.String> getHooks()
- Specified by:
getHooks
in interfaceICLightningPlugin
-
isDynamic
public boolean isDynamic()
- Specified by:
isDynamic
in interfaceICLightningPlugin
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-