Injecting own client into internal node

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Injecting own client into internal node

Alexander Reelsen
Hi there,

While writing my plugin I came across the problem that I would like to
inject my custom self written client with a suggest method, whenever
node.client() is called - this would be especially useful for my
tests, as I am currently doing integration tests against the rest
controller.


--Alexander
Reply | Threaded
Open this post in threaded view
|

Re: Injecting own client into internal node

kimchy
Administrator
Hey,

  Sadly, there isn't really an option to do it. But, you could get the TransportXXAction one and use it (from the internal injector). Need to think more on custom APIs and how to add them to a statically typed language :)

-shay.banon

On Tue, Nov 29, 2011 at 5:18 PM, Alexander Reelsen <[hidden email]> wrote:
Hi there,

While writing my plugin I came across the problem that I would like to
inject my custom self written client with a suggest method, whenever
node.client() is called - this would be especially useful for my
tests, as I am currently doing integration tests against the rest
controller.


--Alexander

Reply | Threaded
Open this post in threaded view
|

Re: Injecting own client into internal node

Alexander Reelsen
Hey

On 29 Nov., 16:22, Shay Banon <[hidden email]> wrote:
>   Sadly, there isn't really an option to do it. But, you could get the
> TransportXXAction one and use it (from the internal injector). Need to
> think more on custom APIs and how to add them to a statically typed
> language :)
Hm, it feels a bit like maven downloading half the internet three
times when I try to resolve the dependencies of a
TransportBroadcastOperationAction manually, as it needs a
clusterservice, a transport service and a indicesservice - which in
turn needs all kinds of modules injected.

Does it make sense to resolve all these dependencies or is there some
trick I just dont see? Or some even better solution?

Thanks a lot for helping!


--Alexander
Reply | Threaded
Open this post in threaded view
|

Re: Injecting own client into internal node

kimchy
Administrator
What? You have your action implemented, no? You can get the guice injector and get its (singleton) instance.

On Thu, Dec 1, 2011 at 12:56 AM, Alexander Reelsen <[hidden email]> wrote:
Hey

On 29 Nov., 16:22, Shay Banon <[hidden email]> wrote:
>   Sadly, there isn't really an option to do it. But, you could get the
> TransportXXAction one and use it (from the internal injector). Need to
> think more on custom APIs and how to add them to a statically typed
> language :)
Hm, it feels a bit like maven downloading half the internet three
times when I try to resolve the dependencies of a
TransportBroadcastOperationAction manually, as it needs a
clusterservice, a transport service and a indicesservice - which in
turn needs all kinds of modules injected.

Does it make sense to resolve all these dependencies or is there some
trick I just dont see? Or some even better solution?

Thanks a lot for helping!


--Alexander

Reply | Threaded
Open this post in threaded view
|

Re: Injecting own client into internal node

Alexander Reelsen
Hi

On Dec 1, 3:08 pm, Shay Banon <[hidden email]> wrote:
> What? You have your action implemented, no? You can get the guice injector
> and get its (singleton) instance.
Works now, I did the same as in the HdfsGatewayTests:

TransportSuggestAction suggestAction = ((InternalNode)
node).injector().getInstance(TransportSuggestAction.class);

Thanks for helping, I shouldnt check/search/ask for such issues after
midnight during the week I guess.


--Alexander