@Override
    public ExecuteContext doBefore(ExecuteContext context) {
        checkState(context, null);
        if (arguments.length > 1 && arguments[1] instanceof TreeCacheEvent) {
            TreeCacheEvent event = (TreeCacheEvent) arguments[1];
            if (!isAvailable(event.getType())) {
                // The registry is disconnected
                RegisterContext.INSTANCE.compareAndSet(true, false);
            } else if (isAvailable(event.getType())) {
                // The registry is available
                RegisterContext.INSTANCE.compareAndSet(false, true);
            } else {
                return context;
            }
        }
        return context;
    }
@Test
    public void doBefore() throws Exception {
        final TreeCacheEvent event = new TreeCacheEvent(Type.CONNECTION_RECONNECTED, null);
        final ExecuteContext context = buildContext(this, new Object[]{null, event});
        RegisterContext.INSTANCE.setAvailable(false);
        interceptor.doBefore(context);
        Assert.assertTrue(RegisterContext.INSTANCE.isAvailable());

        final TreeCacheEvent loseEvent = new TreeCacheEvent(Type.CONNECTION_LOST, null);
        final ExecuteContext loseContext = buildContext(this, new Object[]{null, loseEvent});
        RegisterContext.INSTANCE.setAvailable(false);
        interceptor.doBefore(loseContext);
        Assert.assertFalse(RegisterContext.INSTANCE.isAvailable());
    }