当前位置: 首页>>代码示例>>Java>>正文


Java Phased类代码示例

本文整理汇总了Java中org.springframework.context.Phased的典型用法代码示例。如果您正苦于以下问题:Java Phased类的具体用法?Java Phased怎么用?Java Phased使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Phased类属于org.springframework.context包,在下文中一共展示了Phased类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPhase

import org.springframework.context.Phased; //导入依赖的package包/类
private int getPhase(String containerBeanName) {
	Object container = this.context.getBean(containerBeanName);
	if (!(container instanceof Phased)) {
		throw new IllegalStateException("Container '" + containerBeanName + "' does not implement Phased.");
	}
	return ((Phased) container).getPhase();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:JmsNamespaceHandlerTests.java

示例2: findAndRegisterLifeCycle

import org.springframework.context.Phased; //导入依赖的package包/类
/**
 * Examines an object and sets up a {@code Lifecycle} instance if it can be closed.
 * If it implements {@code Phased} then the phase is used.
 *
 * @param instance  the object to examine, not null
 */
private void findAndRegisterLifeCycle(final Object instance) {
  if (ReflectionUtils.isCloseable(instance.getClass())) {
    registerLifecycle0(new PhasedLifecycle() {
      @Override
      public void stop() {
        ReflectionUtils.close(instance);
      }
      @Override
      public void start() {
      }
      @Override
      public boolean isRunning() {
        return false;
      }
      @Override
      public int getPhase() {
        if (instance instanceof Phased) {
          return ((Phased) instance).getPhase();
        }
        return 0;
      }
      @Override
      public String toString() {
        return instance.getClass().getSimpleName() + ":" + instance.toString();
      }
    });
  }
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:35,代码来源:ComponentRepository.java

示例3: registerLifecycleStop

import org.springframework.context.Phased; //导入依赖的package包/类
/**
 * Registers a non-component object that requires closing or shutdown when
 * the repository stops.
 * <p>
 * Certain interfaces are automatically detected.
 * If it implements {@code InitializingBean}, then it will be initialized
 * as though using {@link #initialize(InitializingBean)}.
 * If it implements {@code Phased} then the phase is used.
 *
 * @param obj  the object to close/shutdown, not null
 * @param methodName  the method name to call, not null
 */
public void registerLifecycleStop(final Object obj, final String methodName) {
  ArgumentChecker.notNull(obj, "object");
  ArgumentChecker.notNull(methodName, "methodName");
  checkStatus(Status.CREATING);

  initialize0(obj);
  registerLifecycle0(new PhasedLifecycle() {
    @Override
    public void stop() {
      ReflectionUtils.invokeNoArgsNoException(obj, methodName);
    }
    @Override
    public void start() {
    }
    @Override
    public boolean isRunning() {
      return false;
    }
    @Override
    public int getPhase() {
      if (obj instanceof Phased) {
        return ((Phased) obj).getPhase();
      }
      return 0;
    }
    @Override
    public String toString() {
      return obj.getClass().getSimpleName() + ":" + obj.toString();
    }
  });
  _logger.logDebug(" Registered lifecycle-stop: " + obj);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:45,代码来源:ComponentRepository.java

示例4: registerLifecycle0

import org.springframework.context.Phased; //导入依赖的package包/类
/**
 * Registers a {@code Lifecycle} instance.
 *
 * @param lifecycleObject  the object that has a lifecycle, not null
 */
private void registerLifecycle0(Lifecycle lifecycleObject) {
  Integer phase = 0;
  if (lifecycleObject instanceof Phased) {
    phase = ((Phased) lifecycleObject).getPhase();
  }
  List<Lifecycle> list = _lifecycles.get(phase);
  if (list == null) {
    list = new ArrayList<>();
    _lifecycles.put(phase, list);
  }
  list.add(lifecycleObject);
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:18,代码来源:ComponentRepository.java

示例5: getPhase

import org.springframework.context.Phased; //导入依赖的package包/类
public int getPhase(String containerBeanName) {
	Object container = this.context.getBean(containerBeanName);
	if (!(container instanceof Phased)) {
		throw new IllegalStateException("Container '" + containerBeanName + "' does not implement Phased.");
	}
	return ((Phased) container).getPhase();
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:8,代码来源:JmsNamespaceHandlerTests.java

示例6: getPhase

import org.springframework.context.Phased; //导入依赖的package包/类
/**
 * Determine the lifecycle phase of the given bean.
 * <p>The default implementation checks for the {@link Phased} interface.
 * Can be overridden to apply other/further policies.
 * @param bean the bean to introspect
 * @return the phase an an integer value. The suggested default is 0.
 * @see Phased
 * @see SmartLifecycle
 */
protected int getPhase(Lifecycle bean) {
	return (bean instanceof Phased ? ((Phased) bean).getPhase() : 0);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:DefaultLifecycleProcessor.java

示例7: getPhase

import org.springframework.context.Phased; //导入依赖的package包/类
/**
 * Determine the lifecycle phase of the given bean.
 * <p>The default implementation checks for the {@link Phased} interface.
 * Can be overridden to apply other/further policies.
 * @param bean the bean to introspect
 * @return the phase an integer value. The suggested default is 0.
 * @see Phased
 * @see SmartLifecycle
 */
protected int getPhase(Lifecycle bean) {
	return (bean instanceof Phased ? ((Phased) bean).getPhase() : 0);
}
 
开发者ID:txazo,项目名称:spring,代码行数:13,代码来源:DefaultLifecycleProcessor.java


注:本文中的org.springframework.context.Phased类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。