@ Override public void unbind ( String name ) { if ( name == null || name . isEmpty ( ) ) { throw MessagingLogger . ROOT_LOGGER . cannotUnbindJndiName ( ) ; } final ContextNames . BindInfo bindInfo = ContextNames . bindInfoFor ( name ) ; ServiceController < ? > bindingService = container . getService ( bindInfo . getBinderServiceName ( ) ) ; if ( bindingService == null ) { ROOT_LOGGER . debugf ( "Cannot unbind %s since no binding exists with that name" , name ) ; return ; } // remove the binding service bindingService . setMode ( ServiceController . Mode . REMOVE ) ; final StabilityMonitor monitor = new StabilityMonitor ( ) ; monitor . addController ( bindingService ) ; try { monitor . awaitStability ( ) ; ROOT_LOGGER . unboundJndiName ( bindInfo . getAbsoluteJndiName ( ) ) ; } catch ( InterruptedException e ) { ROOT_LOGGER . failedToUnbindJndiName ( name , 5 , SECONDS . toString ( ) . toLowerCase ( Locale . US ) ) ; } finally { monitor . removeController ( bindingService ) ; } }
Unbind the resource and wait until the corresponding binding service is effectively removed .