use of org.osgi.service.indexer.osgi.AnalyzerTracker.TrackingStruct in project bnd by bndtools.
the class AnalyzerTracker method addingService.
@Override
public TrackingStruct addingService(ServiceReference<ResourceAnalyzer> reference) {
TrackingStruct struct = new TrackingStruct();
try {
String filterStr = (String) reference.getProperty(ResourceAnalyzer.FILTER);
Filter filter = (filterStr != null) ? FrameworkUtil.createFilter(filterStr) : null;
ResourceAnalyzer analyzer = context.getService(reference);
if (analyzer == null)
return null;
struct = new TrackingStruct();
struct.analyzer = analyzer;
struct.filter = filter;
struct.valid = true;
indexer.addAnalyzer(analyzer, filter);
} catch (InvalidSyntaxException e) {
struct.valid = false;
log.log(reference, LogService.LOG_ERROR, "Ignoring ResourceAnalyzer due to invalid filter expression", e);
}
return struct;
}
use of org.osgi.service.indexer.osgi.AnalyzerTracker.TrackingStruct in project bnd by bndtools.
the class AnalyzerTracker method modifiedService.
@Override
public void modifiedService(ServiceReference<ResourceAnalyzer> reference, TrackingStruct struct) {
if (struct.valid) {
indexer.removeAnalyzer(struct.analyzer, struct.filter);
}
try {
String filterStr = (String) reference.getProperty(ResourceAnalyzer.FILTER);
Filter filter = (filterStr != null) ? FrameworkUtil.createFilter(filterStr) : null;
struct = new TrackingStruct();
struct.filter = filter;
struct.valid = true;
indexer.addAnalyzer(struct.analyzer, filter);
} catch (InvalidSyntaxException e) {
struct.valid = false;
log.log(reference, LogService.LOG_ERROR, "Ignoring ResourceAnalyzer due to invalid filter expression", e);
}
}
Aggregations