Open ORESoftware opened 5 years ago
No it's not a "global".
Whenever verticles are deployed, the init
method is called, and sets vertx
attribute.
This allows you to instantiate stuff as you need to, especially if your verticle doesn't have a default constructor, hence Vert.x cannot instantiate it, then pass it to Vert.x so that it goes through "the verticle lifecycle" (init, start, ...).
ok i see, so i guess the fix i have works well enough?
I'd have moved the this.pool =
within init
, so that you can leave the constructor without Vertx
parameter.
I was getting an NPE when referring to a vertx instance in one of the 2 verticles, so I did this:
whereas the example in the project is like so:
using the second example, how does the vertx instance get shared? is it basically a global?
the Null Pointer Exception I was getting was here:
so I had to change it to:
kinda weird TBH