0
votes

I know that @postconstruct annotation is used when we want a method to call at the time of creation of its object after constructor. But my question is can we use it inside OSGI service?

1
Could you add your Service? Is it a Bundle service? - Villat

1 Answers

3
votes

It depends on the dependency injection framework you use. If you use declarative services the equivalent would be @Activate. A good example is the enroute microservice example.

If you use Aries CDI then indeed @PostConstruct works. Unfortunately there are not yet good examples for this as it is still quite new but it works for the most part like normal CDI in Java EE.