Package org.springframework.context

Examples of org.springframework.context.Lifecycle


  }

  public boolean isRunning() {
    Iterator it = getLifecycleBeans().values().iterator();
    while (it.hasNext()) {
      Lifecycle lifecycle = (Lifecycle) it.next();
      if (!lifecycle.isRunning()) {
        return false;
      }
    }
    return true;
  }
View Full Code Here


   * making sure that any beans that it depends on are started first.
   * @param lifecycleBeans Map with bean name as key and Lifecycle instance as value
   * @param beanName the name of the bean to start
   */
  private void doStart(Map lifecycleBeans, String beanName) {
    Lifecycle bean = (Lifecycle) lifecycleBeans.get(beanName);
    if (bean != null) {
      String[] dependenciesForBean = getBeanFactory().getDependenciesForBean(beanName);
      for (int i = 0; i < dependenciesForBean.length; i++) {
        doStart(lifecycleBeans, dependenciesForBean[i]);
      }
      if (!bean.isRunning()) {
        bean.start();
      }
      lifecycleBeans.remove(beanName);
    }
  }
View Full Code Here

   * making sure that any beans that depends on it are stopped first.
   * @param lifecycleBeans Map with bean name as key and Lifecycle instance as value
   * @param beanName the name of the bean to stop
   */
  private void doStop(Map lifecycleBeans, String beanName) {
    Lifecycle bean = (Lifecycle) lifecycleBeans.get(beanName);
    if (bean != null) {
      String[] dependentBeans = getBeanFactory().getDependentBeans(beanName);
      for (int i = 0; i < dependentBeans.length; i++) {
        doStop(lifecycleBeans, dependentBeans[i]);
      }
      if (bean.isRunning()) {
        bean.stop();
      }
      lifecycleBeans.remove(beanName);
    }
  }
View Full Code Here

   * noops for the {@link Lifecycle} arg in {@link ExtendedSmppSessionAdaptingDelegate#ExtendedSmppSessionAdaptingDelegate(org.jsmpp.session.SMPPSession, org.springframework.context.Lifecycle)}
   *
   * @param session the session
   */
  public ExtendedSmppSessionAdaptingDelegate(SMPPSession session) {
    this(session, new Lifecycle() {
      public void start() {
      }

      public void stop() {
      }
View Full Code Here

   *
   * @param instance  the object to examine, not null
   */
  private void findAndRegisterLifeCycle(final Object instance) {
    if (ReflectionUtils.isCloseable(instance.getClass())) {
      registerLifecycle0(new Lifecycle() {
        @Override
        public void stop() {
          ReflectionUtils.close(instance);
        }
        @Override
View Full Code Here

    ArgumentChecker.notNull(obj, "object");
    ArgumentChecker.notNull(methodName, "methodName");
    checkStatus(Status.CREATING);

    initialize0(obj);
    registerLifecycle0(new Lifecycle() {
      @Override
      public void stop() {
        ReflectionUtils.invokeNoArgsNoException(obj, methodName);
      }
      @Override
View Full Code Here

    }

  }

  public void testStartStop_passThrough() {
    final Lifecycle lifecycle = Mockito.mock(Lifecycle.class);
    Mockito.when(lifecycle.isRunning()).thenReturn(true);
    final TempTargetRepository underlying = new LifecycleTempTargetRepository(lifecycle);
    final EHCachingTempTargetRepository cache = new EHCachingTempTargetRepository(underlying, _cacheManager);
    Mockito.verify(lifecycle, Mockito.times(0)).start();
    Mockito.verify(lifecycle, Mockito.times(0)).stop();
    Mockito.verify(lifecycle, Mockito.times(0)).isRunning();
View Full Code Here

TOP

Related Classes of org.springframework.context.Lifecycle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.