EDIT: you have to have it on some class marked as a @Component then the @Reference will inject the proper implementation right after initiation. If this is a true binding, usually your handler factory is a great place to have the event publisher injected and then you pass it to your handler.
Here you can find three different examples of how to injection a service into a bundle. The org.openhab.io.neeo - linked above - uses the “Method Injection”. Nowadays the “Constructor Injection” should be preferred.
@cweitkamp I hope you don’t mind, but notwithstanding your preference, I decided to go with the Method Injection, since I had followed @tmrobert8 suggestion to build this functionality onto the Thing Handler Factory component. And since the handler factory inherits from BaseHandlerFactory, and since BaseHandlerFactory already has its own constructor and @Activate and @Deactivate annotated methods, I did not want to get myself confused by overriding the constructor or multi- stacking @Override annotated methods on top of @Activate methods etc. ( or something like that )
Nope, I do not mind about that. I am just trying to help by giving hints for possible solutions. You have to figure out the best option for your use case.
I am afraid that is not true. The BaseHandlerFacrory does neither has a constructor nor annotated activate() / deactivate() methods. Even the JavaDoc states clearly that a sub class can overide them but must call super.... to initialize the BaseHandlerFactory properly.
I also think a constructor based injection is the cleaner way, just because we then don’t need a @Nullable which then needs to get checked on every access.