In web applications we have ServletContextListener interface which has method: contextInitialized and it is called on application start up. I would like to know is there something similar in the Apache Karaf when the OSGi bundle is starting that some method would be called by the container and when the bundle is stopping some stop method would be called by the container. Is there something like that in Apache Karaf?
I am also using Spring in my bundle so maybe somehow this is possible to do using Spring? I tried to search for the information how it might be done using OSGi and Apache Karaf but did not find any information.
I think you are looking for the BundleActivator.