I want to use Sling scheduler as a bundle in my Eclipse Equinox Environment and now trying to just run the examples, both whiteboard or via API without success. After lots of debugging I have now been able to make it work but I had to make a change in the scheduler bundle in QuartzScheduler and change the reference to MetricRegistry to add optional cardinality:
@Reference(cardinality=ReferenceCardinality.OPTIONAL)
MetricRegistry metricsRegistry;
which otherwise makes the service fail to start on Equinox.
Running tests in the bundle it seems that this is also never resolved even with Felix, but in that case the service still starts. I should also note that MetricRegistry doesn't appear to be a service and I can't understand why it would be instantiated via @Reference. Actually changing the line to:
MetricRegistry metricsRegistry = new MetricRegistry();
will correctly retrieve the metricsRegistry in all cases, Felix or Equinox.
Have I uncovered a bug or there is something I don't understand?
In Apache Sling a MetricRegistry
instance is registered from the org.apache.sling.commons.metrics
bundle, see MetricsServiceImpl#activate. You should deploy this bundle in your OSGi container.