higest = null;
}
EntityLinkingEngine engine = entityLinkingEngine;
ServiceTracker tracker = labelTokenizerTracker;
if(engine != null && tracker != null){
LabelTokenizer lt = (LabelTokenizer)
(reference.equals(higest) || higest == null ? service :
tracker.getService(higest));
if(!lt.equals(engine.getLabelTokenizer())){
log.info(" ... setting LabelTokenizer of Engine '{}' to {}",
engine.getName(),lt);
engine.setLabelTokenizer(lt);
}
}//if engine or tracker is null deactivate was already called
}
return service;
}
@Override
public void removedService(ServiceReference reference, Object service) {
synchronized (labelTokenizersRefs) {
labelTokenizersRefs.remove(reference); //override
EntityLinkingEngine engine = entityLinkingEngine;
ServiceTracker tracker = labelTokenizerTracker;
if(engine != null && tracker != null){
if(labelTokenizersRefs.isEmpty()){
log.info(" ... setting LabelTokenizer of Engine '{}' to null",
engine.getName());
engine.setLabelTokenizer(null);
} else {
LabelTokenizer lt = (LabelTokenizer)tracker.getService(
labelTokenizersRefs.last());
if(!lt.equals(engine.getLabelTokenizer())){
log.info(" ... setting LabelTokenizer of Engine '{}' to {}",
engine.getName(),lt);
engine.setLabelTokenizer(lt);
}
}
} //if engine or tracker is null deactivate was already called
}
bundleContext.ungetService(reference);
}
@Override
public void modifiedService(ServiceReference reference, Object service) {
synchronized (labelTokenizersRefs) {
labelTokenizersRefs.remove(reference); //override
labelTokenizersRefs.add(reference);
ServiceReference higest;
try {
higest = labelTokenizersRefs.last();
} catch (NoSuchElementException e) {
higest = null;
}
EntityLinkingEngine engine = entityLinkingEngine;
ServiceTracker tracker = labelTokenizerTracker;
if(engine != null && tracker != null){
LabelTokenizer lt = (LabelTokenizer)
(reference.equals(higest) || higest == null ? service :
tracker.getService(higest));
if(!lt.equals(engine.getLabelTokenizer())){
log.info(" ... setting LabelTokenizer of Engine '{}' to {}",
engine.getName(),lt);
engine.setLabelTokenizer(lt);
}
} //if engine or tracker is null deactivate was already called