/** * Very advanced and tricky to handle: not designed for this. Intended for experiments only! */ public synchronized void resetParent(BootstrapServiceRegistry newParent) { if ( this.parent != null ) { this.parent.deRegisterChild( this ); } if ( newParent != null ) { if ( ! ServiceRegistryImplementor.class.isInstance( newParent ) ) { throw new IllegalArgumentException( "ServiceRegistry parent needs to implement ServiceRegistryImplementor" ); } this.parent = (ServiceRegistryImplementor) newParent; this.parent.registerChild( this ); } else { this.parent = null; } }
@Override @SuppressWarnings( {"unchecked"}) public synchronized void destroy() { if ( active.compareAndSet( true, false ) ) { try { //First thing, make sure that the fast path read is disabled so that //threads not owning the synchronization lock can't get an invalid Service: initializedServiceByRole.clear(); synchronized (serviceBindingList) { ListIterator<ServiceBinding> serviceBindingsIterator = serviceBindingList.listIterator( serviceBindingList.size() ); while ( serviceBindingsIterator.hasPrevious() ) { final ServiceBinding serviceBinding = serviceBindingsIterator.previous(); serviceBinding.getLifecycleOwner().stopService( serviceBinding ); } serviceBindingList.clear(); } serviceBindingMap.clear(); } finally { parent.deRegisterChild( this ); } } }
@Override @SuppressWarnings( {"unchecked"}) public synchronized void destroy() { if ( active.compareAndSet( true, false ) ) { try { //First thing, make sure that the fast path read is disabled so that //threads not owning the synchronization lock can't get an invalid Service: initializedServiceByRole.clear(); synchronized (serviceBindingList) { ListIterator<ServiceBinding> serviceBindingsIterator = serviceBindingList.listIterator( serviceBindingList.size() ); while ( serviceBindingsIterator.hasPrevious() ) { final ServiceBinding serviceBinding = serviceBindingsIterator.previous(); serviceBinding.getLifecycleOwner().stopService( serviceBinding ); } serviceBindingList.clear(); } serviceBindingMap.clear(); } finally { parent.deRegisterChild( this ); } } }