I am trying to implement simple scheduler for my project requirement, my project is using Adobe AEM
. As of now I gone through Adobe site and tried to implement the
You missed to set immediate = true
. This starts/activates an component/service automatically with the bundle-start. Otherwise the service is only started, if another (already started) service requests this service (or has a dependency).
In OSGi all services are lazy started, and stopped as soon as nobody needs them. I agree, it could be improved, if the scheduler service would automatically start all services that it would trigger. But that's the way it is.
This is a working example.
@Component(immediate = true, metatype = true)
@Service({ Runnable.class, AnotherServiceInterface.class})
@Properties({
// run every 5 seconds
@Property(name = "scheduler.period", longValue = 5),
// no concurrent execution
@Property(name = "scheduler.concurrent", propertyPrivate = true, boolValue = false)
})