• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Phased类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TMXMapReader类代码示例发布时间:2022-05-22
下一篇:
Java SignallableActivityBehavior类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap