try {
m_dependency.acquireWriteLockIfNotHeld();
m_filter = filter;
if (!m_trackingInterceptors.isEmpty()) {
ServiceTrackingInterceptor interceptor = m_trackingInterceptors.getLast();
if (interceptor != null && interceptor instanceof FilterBasedServiceTrackingInterceptor) {
// Remove it first.
m_trackingInterceptors.removeLast();
}
}
if (m_filter != null) {
// Add the new one.
ServiceTrackingInterceptor newInterceptor = new FilterBasedServiceTrackingInterceptor(m_filter);
m_trackingInterceptors.addLast(newInterceptor);
}
if (tracker == null) {
// Tracker closed, no problem