private void retainService()

in src/main/java/org/apache/sling/extensions/webconsolesecurityprovider/internal/ServicesListener.java [275:300]


        private void retainService(final ServiceReference<?> ref) {
            synchronized (lock) {
                boolean hadService = this.service != null;
                boolean getService = this.reference == null;
                if ( !getService ) {
                    final int result = this.reference.compareTo(ref);
                    if ( result < 0 ) {
                        bundleContext.ungetService(this.reference);
                        this.service = null;
                        getService = true;
                    }
                }
                if ( getService ) {
                    this.reference = ref;
                    this.service = bundleContext.getService(this.reference);
                    if ( this.service == null ) {
                        this.reference = null;
                    } else {
                        notifyChange();
                    }
                }
                if ( hadService && this.service == null ) {
                    notifyChange();
                }
            }
        }