@Override
  public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
    try {
      // note: Spring will call close() on AutoCloseable beans.
      if (bean instanceof Startable startable) {
        startable.stop();
      }
    } catch (Exception e) {
      LoggerFactory.getLogger(StartableBeanPostProcessor.class)
        .warn("Dispose of component {} failed", bean.getClass().getCanonicalName(), e);
    }
  }
@Test
  public void stops_api_startable() {
    Startable startable = mock(Startable.class);
    underTest.postProcessBeforeDestruction(startable, "startable");
    verify(startable).stop();
    verifyNoMoreInteractions(startable);
  }