I am trying to have a function in my brand new bundle that is triggered once when the Apache Karaf container is started.
The main class in the Bundle looks like this:
@Component(service = BrandNewBundle.class)
public class BrandNewBundle {
....
@Activate
protected void activate(ComponentContext myComponentContext) {
LOG.info("Brand new bundle started.");
}
}
In the karaf console I see the bundle status as Active
. But in the logs, I don't see the message that I have tried to log.
Some information:
osgi.cmpn
and slf4j-api
are my dependencies in pom.xml
, and nothing else so far.bnd.bnd
file in this I have read the Apache Felix Service Component Runtime (SCR)
page. Unlike what it mentioned there, my OSGI-INF/....xml
is Autogenerated. I don't know how to debug further.
To sum up, the question is, how to actually trigger my activate
function?
The Component
annotation has to have an immediate=true
as well. I added that, and the activate()
function was triggered on the karaf start.
@Component(
immediate=tue,
service = BrandNewBundle.class
)