- java.lang.Object
-
- com.ensarsarajcic.neovim.java.handler.NeovimHandlerManager
-
public final class NeovimHandlerManager extends java.lang.ObjectSimple class used to register and connectNeovimNotificationHandlerandNeovimRequestHandlerIt provides methods to register/unregister any kind of object as neovim handler, but only classes with methods annotated withNeovimNotificationHandlerorNeovimRequestHandlercan be useful, since this will find such methods and call them once notifications/requests arriveTo get notifications/requests it should first be attached to a
RpcStreamerusingattachToStream(RpcStreamer)Underneath,NeovimHandlerProxyis used to dispatch notifications/requests, which delegates thread management to itExamples:
NeovimHandlerManager neovimHandlerManager = new NeovimHandlerManager(); neovimHandlerManager.registerNeovimHandler(uiEventHandler); neovimHandlerManager.attachToStream(neovimStream);
-
-
Constructor Summary
Constructors Constructor Description NeovimHandlerManager()NeovimHandlerManager(NeovimHandlerProxy neovimHandlerProxy)Creates a newNeovimHandlerManagerwith givenNeovimHandlerProxy
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattachToStream(com.ensarsarajcic.neovim.java.corerpc.client.RpcStreamer rpcStreamer)Attaches to givenRpcStreamerRpcStreamerdoes not have to be attached to an actual connection at the time of this call, since this only sets up the notification/request callbacksvoidregisterNeovimHandler(java.lang.Object handler)Registers a new handler If this object is already registered, this is a no-op If this object has methods annotated withNeovimNotificationHandlerorNeovimRequestHandler, this method will have no effect, but it will still reflectively look for such methodsvoidunregisterNeovimHandler(java.lang.Object handler)Unregisters passed handler If it was not registered previously, this is a no-op It will no longer receive notifications/requests after this point, unless it is registered again
-
-
-
Constructor Detail
-
NeovimHandlerManager
public NeovimHandlerManager()
-
NeovimHandlerManager
public NeovimHandlerManager(NeovimHandlerProxy neovimHandlerProxy)
Creates a newNeovimHandlerManagerwith givenNeovimHandlerProxy- Parameters:
neovimHandlerProxy- proxy to use for dispatching notifications/messages- Throws:
java.lang.NullPointerException- if passedNeovimHandlerProxyis null
-
-
Method Detail
-
attachToStream
public void attachToStream(com.ensarsarajcic.neovim.java.corerpc.client.RpcStreamer rpcStreamer)
Attaches to givenRpcStreamerRpcStreamerdoes not have to be attached to an actual connection at the time of this call, since this only sets up the notification/request callbacks- Parameters:
rpcStreamer- streamer whose notifications/requests should be analysed- Throws:
java.lang.NullPointerException- ifRpcStreameris null
-
registerNeovimHandler
public void registerNeovimHandler(java.lang.Object handler)
Registers a new handler If this object is already registered, this is a no-op If this object has methods annotated withNeovimNotificationHandlerorNeovimRequestHandler, this method will have no effect, but it will still reflectively look for such methodsThis works for both static and instance methods
Passed objects methods are prepared to be called when new notifications/requests arrive from attached
RpcStreamerThis may be called prior to attaching, but no notifications/requests can arrive before attaching- Parameters:
handler- object to search for annotated methods
-
unregisterNeovimHandler
public void unregisterNeovimHandler(java.lang.Object handler)
Unregisters passed handler If it was not registered previously, this is a no-op It will no longer receive notifications/requests after this point, unless it is registered again- Parameters:
handler- object to unregister
-
-